Ticket #1464 (closed bug: invalid)

Opened 5 years ago

Last modified 3 years ago

NQP-rx doesn't handle bare "return" from nested block correctly.

Reported by: Austin_Hastings Owned by: pmichaud
Priority: normal Milestone:
Component: nqp Version: 2.1.0
Severity: medium Keywords:
Cc: Language:
Patch status: Platform:

Description

In a nested loop with nested lexicals (requiring a block), a return with no argument does not escape the sub.

austin@andLinux:~/kakapo$ cat test.nqp
sub test1(@items) {
	for @items {
		my $temp := $_;

		if $temp == 2 {
			return 0;
		}
	}

	say("Test1 never finishes");
}

sub test2(@items) {

	for @items {
		my $temp := $_;

		if $temp == 2 {
			return;
		}
	}

	say("Test2 never finishes");
}

my @items := (1, 2, 3);
test1(@items);
test2(@items);
austin@andLinux:~/kakapo$ parrot-nqp test.nqp
Test2 never finishes

Change History

Changed 3 years ago by pmichaud

  • status changed from new to closed
  • resolution set to invalid

nqp-rx doesn't really support "bare return"; all functions are expected to return a value of some sort.

We might be able to flag bare return as a syntax error of some sort. If that's desirable, file it as a new ticket in nqp-rx's queue.

Pm

Note: See TracTickets for help on using tickets.