Skip to content

Commit

Permalink
Bring pblock signature building before body parse.
Browse files Browse the repository at this point in the history
Means that -> int $x { $x = 42 } is now also a compile-time error, and
native lexical access code-gen is better for pointy block args also.
  • Loading branch information
jnthn committed Feb 24, 2015
1 parent 304300f commit 9276140
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/Perl6/Actions.nqp
Expand Up @@ -830,7 +830,7 @@ class Perl6::Actions is HLL::Actions does STDActions {
}
}
elsif $<signature> {
%sig_info := $<signature>.ast;
%sig_info := %*SIG_INFO;
@params := %sig_info<parameters>;
if $*IMPLICIT {
my int $declares_topic := 0;
Expand Down Expand Up @@ -867,9 +867,9 @@ class Perl6::Actions is HLL::Actions does STDActions {
%sig_info<parameters> := @params;
}

# Create signature object and set up binding.
my $signature := $*W.create_signature_and_params($<signature>, %sig_info,
$block, 'Mu', :rw($<lambda> eq '<->'));
# Create signature object if we didn't already, and set up binding.
my $signature := $*SIG_OBJ // $*W.create_signature_and_params(
$<signature>, %sig_info, $block, 'Mu');
add_signature_binding_code($block, $signature, @params);

# We'll install PAST in current block so it gets capture_lex'd.
Expand Down
8 changes: 7 additions & 1 deletion src/Perl6/Grammar.nqp
Expand Up @@ -1358,13 +1358,19 @@ grammar Perl6::Grammar is HLL::Grammar does STD {

token pblock($*IMPLICIT = 0) {
:my $*DECLARAND := $*W.stub_code_object('Block');
:my $*SIG_OBJ;
:my %*SIG_INFO;
:dba('parameterized block')
[
| <lambda>
<.newpad>
:my $*SCOPE := 'my';
:my $*GOAL := '{';
<signature>
<signature> {
%*SIG_INFO := $<signature>.ast;
$*SIG_OBJ := $*W.create_signature_and_params($<signature>,
%*SIG_INFO, $*W.cur_lexpad(), 'Mu', :rw($<lambda> eq '<->'));
}
<blockoid>
| <?[{]>
<.newpad>
Expand Down

0 comments on commit 9276140

Please sign in to comment.