Skip to content

Commit

Permalink
Fix constant initializers that include a block.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Apr 21, 2012
1 parent b1f5835 commit 501e401
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Perl6/Actions.pm
Expand Up @@ -2361,13 +2361,15 @@ class Perl6::Actions is HLL::Actions {

method type_declarator:sym<constant>($/) {
# Get constant value.
my $con_block := $*W.pop_lexpad();
my $value_ast := $<initializer>.ast;
my $value;
if $value_ast<has_compile_time_value> {
$value := $value_ast<compile_time_value>;
}
else {
my $value_thunk := make_thunk($value_ast, $/);
$con_block.push($value_ast);
my $value_thunk := make_simple_code_object($con_block, 'Block');
$value := $value_thunk();
$*W.add_constant_folded_result($value);
}
Expand Down
1 change: 1 addition & 0 deletions src/Perl6/Grammar.pm
Expand Up @@ -1861,6 +1861,7 @@ grammar Perl6::Grammar is HLL::Grammar {

<trait>*

{ $*W.push_lexpad($/) }
[
|| <initializer>
|| <.missing: "initializer on constant declaration">
Expand Down

0 comments on commit 501e401

Please sign in to comment.