Skip to content

Commit

Permalink
Changes suggested by jnthn to make sure empty {} doesn't generate Nils
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Jul 6, 2013
1 parent 4e9635e commit 6319760
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/Perl6/Actions.nqp
Expand Up @@ -4180,15 +4180,17 @@ class Perl6::Actions is HLL::Actions does STDActions {
# element of which is either a hash or a pair, it's a hash constructor.
# Note that if it declares any symbols it is also not one.
my $Pair := $*W.find_symbol(['Pair']);
my int $is_hash := 0;
my int $is_hash := 0;
my int $has_stuff := 1;
my $stmts := +$<pblock><blockoid><statementlist><statement>;
my $bast := $<pblock><blockoid>.ast;
if $bast.symbol('$_')<used> || $bast<also_uses> && $bast<also_uses><$_> {
# Uses $_, so not a hash.
}
elsif $stmts == 0 {
# empty block, so a hash
$is_hash := 1;
$is_hash := 1;
$has_stuff := 0;
}
elsif $stmts == 1 {
my $elem := $past<past_block>[1][0][0];
Expand Down Expand Up @@ -4223,13 +4225,15 @@ class Perl6::Actions is HLL::Actions does STDActions {
:name('&circumfix:<{ }>'),
:node($/)
);
for @children {
if nqp::istype($_, QAST::Stmt) {
# Mustn't use QAST::Stmt here, as it will cause register
# re-use within a statemnet, which is a problem.
$_ := QAST::Stmts.new( |$_.list );
if $has_stuff {
for @children {
if nqp::istype($_, QAST::Stmt) {
# Mustn't use QAST::Stmt here, as it will cause register
# re-use within a statemnet, which is a problem.
$_ := QAST::Stmts.new( |$_.list );
}
$past.push($_);
}
$past.push($_);
}
}
else {
Expand Down

0 comments on commit 6319760

Please sign in to comment.