Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Yapsi] enabled call before declaration
  • Loading branch information
Carl Masak committed Mar 6, 2011
1 parent 73785d9 commit 745a83a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Yapsi.pm
Expand Up @@ -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];
Expand Down Expand Up @@ -277,7 +277,7 @@ class Yapsi::Perl6::Actions {
FUTURE::Var.new(:$name),
$<subdecl><block>.ast
);
make $bind;
@blockstack[*-1].children.push($bind);
}
}

Expand Down
2 changes: 2 additions & 0 deletions t/runtime.t
Expand Up @@ -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 {
Expand Down

0 comments on commit 745a83a

Please sign in to comment.