Skip to content

Commit

Permalink
Re-imagine PR #4649
Browse files Browse the repository at this point in the history
Using jnthn's directions.  This code:

    $ raku -e 'role A { }; class B does A{ ... }'

Now throws:

    ===SORRY!=== Error while compiling -e
    Missing whitespace before '{'
    at -e:1
    ------> role A { }; class B does A⏏{ }; my $a = 42
  • Loading branch information
lizmat committed Jan 6, 2022
1 parent 36cee69 commit 535e015
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Perl6/Grammar.nqp
Expand Up @@ -3039,7 +3039,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
}
}
rule trait_mod:sym<hides> { <sym> [ <typename> || <.bad_trait_typename>] }
rule trait_mod:sym<does> { <sym> [ <typename> || <.bad_trait_typename>] }
rule trait_mod:sym<does> { <sym> [ <typename(:needs-whitespace)> || <.bad_trait_typename>] }
rule trait_mod:sym<will> { <sym> [ <identifier> || <.panic: 'Invalid name'>] <pblock($PBLOCK_OPTIONAL_TOPIC)> }
rule trait_mod:sym<of> { <sym> [ <typename> || <.bad_trait_typename>] }
rule trait_mod:sym<returns> { <sym> [ <typename> || <.bad_trait_typename>]
Expand Down Expand Up @@ -3357,7 +3357,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
token complex_number { '<' <bare_complex_number> '>' }
token bare_complex_number { <?before <.[-−+0..9<>:.eEboxdInfNa\\]>+? 'i'> <re=.signed-number> <?[-−+]> <im=.signed-number> \\? 'i' }
token typename {
token typename(:$needs-whitespace) {
:my %colonpairs;
[
| '::?'<identifier> <colonpair>* # parse ::?CLASS as special case
Expand All @@ -3376,7 +3376,14 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
'[' ~ ']' <arglist>
<.explain_mystery> <.cry_sorrows>
]?
<.unsp>? [ <?before '{'> <whence=.postcircumfix> <.NYI('Autovivifying object closures')> ]?
<.unsp>? [ <?before '{'> {
if $needs-whitespace {
$/.typed_panic('X::Syntax::Missing', what => "whitespace before '\{'");
}
else {
$/.typed_panic('X::NYI', feature => 'Autovivifying object closures');
}
} <whence=.postcircumfix> ]?
<.unsp>? [ <?[(]> '(' ~ ')' [<.ws> [<accept=.typename> || $<accept_any>=<?>] <.ws>] ]?
[<.ws> 'of' <.ws> <typename> ]?
[
Expand Down

0 comments on commit 535e015

Please sign in to comment.