-
-
Save zoffixznet/6d0a2085bd343535b99f548d15547729 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/Perl6/Actions.nqp b/src/Perl6/Actions.nqp | |
index 6fe3df9ec..1bd07805a 100644 | |
--- a/src/Perl6/Actions.nqp | |
+++ b/src/Perl6/Actions.nqp | |
@@ -8653,24 +8653,30 @@ class Perl6::Actions is HLL::Actions does STDActions { | |
# Handle coercion. | |
my $coerce_to := nqp::getattr($param_obj, $Param, '$!coerce_type'); | |
unless nqp::isnull($coerce_to) { | |
- if $coerce_to.HOW.archetypes.generic { | |
- return 0; | |
- } | |
- $var.push(QAST::Op.new( | |
- :op('unless'), | |
- QAST::Op.new( | |
- :op('istype'), | |
- QAST::Var.new( :name($name), :scope('local') ), | |
- QAST::WVal.new( :value($coerce_to) ) | |
- ), | |
- QAST::Op.new( | |
- :op('bind'), | |
- QAST::Var.new( :name($name), :scope('local') ), | |
- QAST::Op.new( | |
- :op('callmethod'), | |
- :name(nqp::getattr_s($param_obj, $Param, '$!coerce_method')), | |
- QAST::Var.new( :name($name), :scope('local') ) | |
- )))); | |
+ return 0 if $coerce_to.HOW.archetypes.generic; | |
+ | |
+ # QAST: | |
+ # nqp::unless( | |
+ # nqp::istype($var, $to), | |
+ # nqp::unless( | |
+ # nqp::istype(($var := $var."$to"()), $to), | |
+ # die "Coercion failed")); | |
+ $var.push: | |
+ QAST::Op.new: :op<unless>, | |
+ QAST::Op.new(:op<istype>, | |
+ QAST::Var.new(:$name, :scope<local>), | |
+ QAST::WVal.new: :value($coerce_to)), | |
+ QAST::Op.new: :op<unless>, | |
+ QAST::Op.new(:op<istype>, | |
+ QAST::Op.new(:op<bind>, | |
+ QAST::Var.new(:$name, :scope<local>), | |
+ QAST::Op.new: :op<callmethod>, | |
+ :name(nqp::getattr_s($param_obj, $Param, | |
+ '$!coerce_method')), | |
+ QAST::Var.new: :$name, :scope<local>), | |
+ QAST::WVal.new: :value($coerce_to)), | |
+ QAST::Op.new: :op<call>, :name<&die>, | |
+ QAST::SVal.new: :value('Coercion failed') | |
} | |
# If it's optional, do any default handling. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment