Skip to content

Commit

Permalink
Stash partial fix for R#1723
Browse files Browse the repository at this point in the history
  • Loading branch information
zoffixznet committed Apr 11, 2018
1 parent d393b82 commit fb7d5de
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 12 deletions.
6 changes: 5 additions & 1 deletion src/Perl6/Grammar.nqp
Expand Up @@ -3714,7 +3714,11 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
<.explain_mystery> <.cry_sorrows>
]?
<.unsp>? [ <?before '{'> <whence=.postcircumfix> <.NYI('Autovivifying object closures')> ]?
<.unsp>? [ <?[(]> '(' ~ ')' [<.ws> [<accept=.typename> || $<accept_any>=<?>] <.ws>] ]?
<.unsp>? [
<?[(]> '(' ~ ')' [
<.ws> [ <accept=.typename> || <typo_typename(1)> || $<accept_any>=<?> ]
<.ws> ]
]?
[<.ws> 'of' <.ws> <typename> ]?
[
<?{
Expand Down
50 changes: 39 additions & 11 deletions src/Perl6/World.nqp
Expand Up @@ -4223,17 +4223,45 @@ class Perl6::World is HLL::World {
}
elsif $<colonpairs> && ($<colonpairs>.ast<D> || $<colonpairs>.ast<U>) {
my $val := $<longname><colonpair>[0].ast[2];
nqp::istype($val, QAST::Op)
# XXX TODO: the circumfix:<[ ]> path is a misparse of parameterization,
# e.g. List:D[Int]. When parse is fixed, the circumfix branch likely can be removed
?? $val.op eq 'p6bool' || $val.op eq 'call' && $val.name eq '&circumfix:<[ ]>'
?? nqp::null # not a coercer, but just got a regular DefiniteHOW
!! $val.name eq '&infix:<,>' && @($val) == 0
?? self.find_symbol: ['Any'], :setting-only # empty coercer source type
!! self.throw: $/, ['X', 'Syntax', 'Coercer', 'TooComplex']
!! nqp::istype($val, QAST::WVal)
?? $val.value
!! self.throw: $/, ['X', 'Syntax', 'Coercer', 'TooComplex']
nqp::atkey(nqp::getenvhash(),'ZZ') && nqp::say("ZZ1:\n" ~ $val.dump);
nqp::atkey(nqp::getenvhash(),'ZZ2') && nqp::say("ZZ2:\n" ~ $<longname><colonpair>[0].dump);
nqp::atkey(nqp::getenvhash(),'ZZ3') && nqp::say("ZZ3:\n" ~ $<longname><colonpair>[0].ast.dump);

if nqp::istype($val, QAST::Op) {
if $val.op eq 'call' {
if $val.name && $val.name eq '&circumfix:<[ ]>' {
# XXX TODO: the circumfix:<[ ]> path is a misparse of
# parameterization, e.g. List:D[Int]. When parse is fixed,
# the circumfix branch likely can be removed
nqp::null
}
elsif $val.name && $val.name eq '&infix:<,>' && @($val) == 0 {
# empty coercer source type
self.find_symbol: ['Any'], :setting-only
}
elsif (my $long := # possibly mistyped typename
$<longname><colonpair>[0]<coloncircumfix><circumfix><semilist><statement><EXPR>[1]<longname>) {
my $longname := $*W.dissect_longname: $long;
try {$*W.find_symbol: $longname; 1}
?? self.throw: $/, ['X', 'Syntax', 'Coercer', 'TooComplex']
!! self.throw: $/, ['X', 'Undeclared'],
:what<Type>, :symbol($longname.name),
:suggestions(self.suggest_typename: $longname.name)
}
else {
self.throw: $/, ['X', 'Syntax', 'Coercer', 'TooComplex']
}
}
elsif $val.op eq 'p6bool' {
nqp::null # not a coercer, but just got a regular DefiniteHOW
}
}
elsif nqp::istype($val, QAST::WVal) {
$val.value
}
else {
self.throw: $/, ['X', 'Syntax', 'Coercer', 'TooComplex']
}
}
else {
nqp::null # we didn't find any coercers
Expand Down

0 comments on commit fb7d5de

Please sign in to comment.