Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Support Str() coercion from Any, fix Str( Any ).
  • Loading branch information
jnthn committed Jan 24, 2015
1 parent 8ec84b6 commit 994dd52
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/Perl6/Actions.nqp
Expand Up @@ -5861,11 +5861,12 @@ class Perl6::Actions is HLL::Actions does STDActions {
if $<arglist> {
$type := $*W.parameterize_type($type, $<arglist>.ast, $/);
}
if $<accept> {
if $<accept> || $<accept_any> {
if $<typename> {
$/.CURSOR.panic("Cannot put 'of' constraint on a coercion type");
}
$type := %*HOW<coercion>.new_type($type, $<accept>.ast);
$type := %*HOW<coercion>.new_type($type,
$<accept> ?? $<accept>.ast !! $*W.find_symbol(['Any']));
}
elsif $<typename> {
$type := $*W.parameterize_type_with_args($type,
Expand All @@ -5877,7 +5878,7 @@ class Perl6::Actions is HLL::Actions does STDActions {
if $<arglist> || $<typename> {
$/.CURSOR.panic("Cannot put type parameters on a type capture");
}
if $<accepts> {
if $<accepts> || $<accepts_any> {
$/.CURSOR.panic("Cannot base a coercion type on a type capture");
}
if $str_longname eq '::' {
Expand Down
2 changes: 1 addition & 1 deletion src/Perl6/Grammar.nqp
Expand Up @@ -3345,7 +3345,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
]
# parametric/coercion type?
<.unsp>? [ <?[[]> '[' ~ ']' <arglist> ]?
<.unsp>? [ <?[(]> '(' ~ ')' <accept=.typename>]?
<.unsp>? [ <?[(]> '(' ~ ')' [<.ws> [<accept=.typename> || $<accept_any>=<?>] <.ws>] ]?
[<.ws> 'of' <.ws> <typename> ]?
}

Expand Down

0 comments on commit 994dd52

Please sign in to comment.