Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[Yapsi] enabled call before declaration

  • Loading branch information...
commit 745a83aeb043efa109593cf86e5e14ab9bb32e1f 1 parent 73785d9
@masak authored
Showing with 4 additions and 2 deletions.
  1. +2 −2 lib/Yapsi.pm
  2. +2 −0  t/runtime.t
View
4 lib/Yapsi.pm
@@ -184,7 +184,7 @@ class Yapsi::Perl6::Actions {
my $block = @blockstack.pop;
my $name = $block.name;
$block.vars = @vars.list;
- $block.children = $<statementlist><statement>».ast;
+ $block.children.push($<statementlist><statement>».ast.grep(*.defined));
make $block;
if @blockstack {
%block-parents{$name} = @blockstack[*-1];
@@ -277,7 +277,7 @@ class Yapsi::Perl6::Actions {
FUTURE::Var.new(:$name),
$<subdecl><block>.ast
);
- make $bind;
+ @blockstack[*-1].children.push($bind);
}
}
View
2  t/runtime.t
@@ -51,6 +51,8 @@ my @tests =
'my $a = { say 42 }; say 1; $a()', "1\n42\n", 'non-immediate block',
'my $a := { say 2 }; say 1; $a()', "1\n2\n", 'bind block and call',
'{ say 42 }()', "42\n", 'call a block',
+ 'sub foo { say 42 }; foo()', "42\n", 'call a named sub',
+ 'foo(); sub foo { say 5 }', "5\n", 'call before declaration',
;
for @tests -> $program, $expected, $message {
Please sign in to comment.
Something went wrong with that request. Please try again.