Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make 'use variable :D' work
  • Loading branch information
lizmat committed Oct 8, 2015
1 parent c1e9ede commit 94d4570
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
16 changes: 2 additions & 14 deletions src/Perl6/Grammar.nqp
Expand Up @@ -2314,22 +2314,10 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
|| <?{ $*SCOPE eq 'has' }> <.newpad>
[
|| <.ws> <initializer>
|| { my $colonpairs := $*OFTYPE<colonpairs>;
if $colonpairs<D> {
self.typed_panic: "X::Syntax::Variable::MissingInitializer", type => ~$*OFTYPE;
}
elsif $colonpairs<U> || $colonpairs<_> {
}
elsif %*PRAGMAS<attributes> -> $default {
if $default eq 'D' {
self.typed_panic: "X::Syntax::Variable::MissingInitializer", type => ~$*OFTYPE ~ ' (with implicit :D)';
}
}
1;
}
|| <?{ $*W.handle_OFTYPE_for_pragma($/,'attributes') }>
]? { $*ATTR_INIT_BLOCK := $*W.pop_lexpad() }
|| <.ws> <initializer>
|| <?{ $*OFTYPE<colonpairs><D> }> { self.typed_panic: "X::Syntax::Variable::MissingInitializer", type => ~$*OFTYPE }
|| <?{ $*W.handle_OFTYPE_for_pragma($/,'variables') }>
|| <?>
]
| '(' ~ ')' <signature('variable')> [ <.ws> <trait>+ ]? [ <.ws> <initializer> ]?
Expand Down
21 changes: 21 additions & 0 deletions src/Perl6/World.nqp
Expand Up @@ -810,6 +810,27 @@ class Perl6::World is HLL::World {
}
}

method handle_OFTYPE_for_pragma($/, $pragma) {
my $colonpairs := $*OFTYPE<colonpairs>;
if $colonpairs<D> {
self.throw($/, 'X::Syntax::Variable::MissingInitializer',
type => ~$*OFTYPE,
);
}
elsif $colonpairs<U> || $colonpairs<_> {
}

# no specific smiley found, check for default
elsif %*PRAGMAS{$pragma} -> $default {
if $default eq 'D' {
self.throw($/, 'X::Syntax::Variable::MissingInitializer',
type => $*OFTYPE ~ ' (with implicit :D)',
);
}
}
1
}

method current_file() {
my $file := nqp::getlexdyn('$?FILES');
if nqp::isnull($file) {
Expand Down

0 comments on commit 94d4570

Please sign in to comment.