Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
better error messages for hash shapes.
  • Loading branch information
timo committed Jun 15, 2013
1 parent 5705c3d commit cdda38e
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/Perl6/Actions.nqp
Expand Up @@ -153,10 +153,25 @@ class Perl6::Actions is HLL::Actions does STDActions {
if $shape {
@value_type[0] := $*W.find_symbol(['Any']) unless +@value_type;
my $shape_ast := $shape[0].ast;
if $shape_ast.isa(QAST::Stmts) && +@($shape_ast) == 1 && $shape_ast[0].has_compile_time_value {
@value_type[1] := $shape_ast[0].compile_time_value;
}
else {
if $shape_ast.isa(QAST::Stmts) {
if +@($shape_ast) == 1 {
if $shape_ast[0].has_compile_time_value {
@value_type[1] := $shape_ast[0].compile_time_value;
} elsif (my $op_ast := $shape_ast[0]).isa(QAST::Op) {
if $op_ast.op eq "call" && +@($op_ast) == 2 {
if !nqp::isconcrete($op_ast[0].value) && !nqp::isconcrete($op_ast[1].value) {
$*W.throw($/, 'X::Comp::NYI',
feature => "coercive type declarations");
}
}
} else {
nqp::die("Invalid hash shape; type expected");
}
} elsif +@($shape_ast) > 1 {
$*W.throw($/, 'X::Comp::NYI',
feature => "multidimensional shaped hashes");
}
} else {
nqp::die("Invalid hash shape; type expected");
}
}
Expand Down

0 comments on commit cdda38e

Please sign in to comment.