Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

better error messages for hash shapes.

  • Loading branch information...
commit cdda38e9922b7881071ef668454848399060d353 1 parent 5705c3d
@timo timo authored
Showing with 19 additions and 4 deletions.
  1. +19 −4 src/Perl6/Actions.nqp
View
23 src/Perl6/Actions.nqp
@@ -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");
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.