Last active
August 29, 2015 14:23
-
-
Save peschwa/f399cf10914f1d287a74 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/vm/moar/Perl6/Ops.nqp b/src/vm/moar/Perl6/Ops.nqp | |
index e18928e..0cafac9 100644 | |
--- a/src/vm/moar/Perl6/Ops.nqp | |
+++ b/src/vm/moar/Perl6/Ops.nqp | |
@@ -614,18 +614,27 @@ $ops.add_hll_op('perl6', 'p6typecheckrv', -> $qastcomp, $op { | |
} | |
else { | |
my @ops; | |
- my $value_res := $qastcomp.as_mast($op[0], :want($MVM_reg_obj)); | |
- my $type_res := $qastcomp.as_mast(QAST::WVal.new( :value($type) ), :want($MVM_reg_obj)); | |
- my $lbl_done := MAST::Label.new(); | |
+ my $value_res := $qastcomp.as_mast($op[0], :want($MVM_reg_obj)); | |
+ my $type_res := $qastcomp.as_mast(QAST::WVal.new( :value($type) ), :want($MVM_reg_obj)); | |
+ | |
+ my $lbl_done := MAST::Label.new(); | |
push_ilist(@ops, $value_res); | |
push_ilist(@ops, $type_res); | |
my $decont := $*REGALLOC.fresh_o(); | |
my $istype := $*REGALLOC.fresh_i(); | |
+ my $str_failure := $*REGALLOC.fresh_s(); | |
+ my $isfailure := $*REGALLOC.fresh_i(); | |
+ my $failure_o := $*REGALLOC.fresh_o(); | |
nqp::push(@ops, MAST::Op.new( :op('decont'), $decont, $value_res.result_reg )); | |
nqp::push(@ops, MAST::Op.new( :op('istype'), $istype, $decont, $type_res.result_reg )); | |
nqp::push(@ops, MAST::Op.new( :op('if_i'), $istype, $lbl_done )); | |
+ nqp::push(@ops, MAST::Op.new( :op('const_s'), $str_failure, MAST::SVal.new( :value('Failure') ) )); | |
+ nqp::push(@ops, MAST::Op.new( :op('getlexstatic_o'), $failure_o, $str_failure)); | |
+ nqp::push(@ops, MAST::Op.new( :op('istype'), $isfailure, $decont, $failure_o) ); | |
+ nqp::push(@ops, MAST::Op.new( :op('if_i'), $isfailure, $lbl_done )); | |
$*REGALLOC.release_register($decont, $MVM_reg_obj); | |
$*REGALLOC.release_register($istype, $MVM_reg_int64); | |
+ $*REGALLOC.release_register($str_failure, $MVM_reg_str); | |
# Error generation. | |
proto return_error($got, $wanted) { | |
@@ -648,6 +657,7 @@ $ops.add_hll_op('perl6', 'p6typecheckrv', -> $qastcomp, $op { | |
)); | |
nqp::push(@ops, $lbl_done); | |
$*REGALLOC.release_register($err_rep.result_reg, $MVM_reg_obj); | |
+ $*REGALLOC.release_register($isfailure, $MVM_reg_int64); | |
MAST::InstructionList.new(@ops, $value_res.result_reg, $MVM_reg_obj) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
]$ ./perl6 -e'sub f returns Int { fail 1 }; sub g (Int $) { say "uhh" }; g(f());' | |
Earlier failure: | |
1 | |
in block <unit> at -e:1 | |
Final error: | |
Type check failed in binding <anon>; expected 'Int' but got 'Failure' | |
in sub g at -e:1 | |
in block <unit> at -e:1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment