-
-
Save MasterDuke17/a731e2dc7a8b2f5c82ff581f535ad0f9 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 src/Perl6/Actions.nqp src/Perl6/Actions.nqp | |
index ca2f9277a..c4b1263df 100644 | |
--- src/Perl6/Actions.nqp | |
+++ src/Perl6/Actions.nqp | |
@@ -2341,14 +2341,21 @@ class Perl6::Actions is HLL::Actions does STDActions { | |
# Make sure we're not comparing against a type object, since those could | |
# coerce to the value | |
+ my $method_call := | |
+ QAST::Op.new( :op('callmethod'), :name($method), | |
+ QAST::Var.new( :name('$_'), :scope('lexical') ) ); | |
+ if $method eq 'Numeric' { | |
+ my $fail-or-bool := QAST::Op.new( :op('hllbool'), QAST::IVal.new( :value(1) ) ); | |
+ $fail-or-bool.named('fail-or-nil'); | |
+ $method_call.push($fail-or-bool); | |
+ } | |
my $is_eq := | |
QAST::Op.new( :op('if'), | |
QAST::Op.new( :op('isconcrete' ), | |
QAST::Var.new( :name('$_'), :scope('lexical') ) ), | |
QAST::Op.new( :op("iseq_$op_type" ), | |
$sm_exp[2], | |
- WANTED(QAST::Op.new( :op('callmethod'), :name($method), | |
- QAST::Var.new( :name('$_'), :scope('lexical') ) ),'when') ) ); | |
+ WANTED($method_call,'when') ) ); | |
# Needed so we can `handle` the code below | |
fatalize($is_eq); | |
diff --git src/core.c/Str.pm6 src/core.c/Str.pm6 | |
index 4e18364f9..266674d0d 100644 | |
--- src/core.c/Str.pm6 | |
+++ src/core.c/Str.pm6 | |
@@ -772,7 +772,7 @@ method !combiners() | |
) | |
) | |
} | |
- multi method Numeric(Str:D: --> Numeric:D) { | |
+ multi method Numeric(Str:D: :$fail-or-nil --> Numeric:D) { | |
#?if !jvm | |
# check for any combining characters | |
nqp::isne_i(nqp::chars(self),nqp::codes(self)) | |
@@ -800,7 +800,7 @@ multi method Numeric(Str:D: --> Numeric:D) | |
self,0,nqp::chars(self) | |
) == nqp::chars(self) | |
?? 0 # just spaces | |
- !! val(self, :val-or-fail) # take the slow route | |
+ !! val(self, :val-or-fail, :$fail-or-nil) # take the slow route | |
} | |
multi method gist(Str:D:) { self } | |
diff --git src/core.c/allomorphs.pm6 src/core.c/allomorphs.pm6 | |
index ee493d958..645c84402 100644 | |
--- src/core.c/allomorphs.pm6 | |
+++ src/core.c/allomorphs.pm6 | |
@@ -193,7 +193,7 @@ multi sub val(\one-thing) is raw | |
one-thing | |
} | |
-multi sub val(Str:D $MAYBEVAL, :$val-or-fail) { | |
+multi sub val(Str:D $MAYBEVAL, :$val-or-fail, :$fail-or-nil) { | |
# TODO: | |
# * Additional numeric styles: | |
# + fractions in [] radix notation: :100[10,'.',53] | |
@@ -217,7 +217,9 @@ multi sub val(Str:D $MAYBEVAL, :$val-or-fail) | |
# string, or a failure if we're Str.Numeric | |
my &parse_fail := -> \msg { | |
$val-or-fail | |
- ?? fail X::Str::Numeric.new(:source($MAYBEVAL),:reason(msg),:$pos) | |
+ ?? $fail-or-nil | |
+ ?? return Nil | |
+ !! fail X::Str::Numeric.new(:source($MAYBEVAL),:reason(msg),:$pos) | |
!! return $MAYBEVAL | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment