From 4cdb8a3c65d5f0e7df18be324a4ae05f4d9645ec Mon Sep 17 00:00:00 2001 From: Elizabeth Mattijsen Date: Tue, 26 Mar 2024 19:41:53 +0100 Subject: [PATCH] Fix DispatchMap module This basically reverts 99f52bc, but with using the new nqp::const values. --- src/Perl6/bootstrap.c/BOOTSTRAP.nqp | 72 ++++++++++++----------------- 1 file changed, 30 insertions(+), 42 deletions(-) diff --git a/src/Perl6/bootstrap.c/BOOTSTRAP.nqp b/src/Perl6/bootstrap.c/BOOTSTRAP.nqp index c73d358080..2c09bdabaf 100644 --- a/src/Perl6/bootstrap.c/BOOTSTRAP.nqp +++ b/src/Perl6/bootstrap.c/BOOTSTRAP.nqp @@ -3881,39 +3881,28 @@ BEGIN { # value, possibly in a container. #?if !jvm else { - - # Assume a native value unless proven otherwise - my int $primish := 1; - - # Set type to fall back to if no native involved - my $type := $arg.WHAT; - - # Adapt type to any native argument (whether in a - # container or not) - $got_prim == nqp::const::BIND_VAL_OBJ - ?? nqp::iscont_s($arg) - ?? ($type := Str) - !! nqp::iscont_i($arg) || nqp::iscont_u($arg) - ?? ($type := Int) - !! nqp::iscont_n($arg) - ?? ($type := Num) - !! ($primish := 0) # not a native container - !! $got_prim == nqp::const::BIND_VAL_STR - ?? ($type := Str) - !! ($got_prim == nqp::const::BIND_VAL_INT - || $got_prim == nqp::const::BIND_VAL_UINT) - ?? ($type := Int) - !! ($type := Num); # BIND_VAL_NUM - - # Type ok? - if nqp::eqaddr($type_obj, Mu) - ||nqp::istype($type, $type_obj) { # type ok - - # Not ok if exact invocant needed and not there - $no_mismatch := 0 - if $i == 0 - && nqp::existskey($candidate,'exact_invocant') - && nqp::not_i(nqp::eqaddr($type, $type_obj)); + my int $primish; + my $param := $arg; + if $got_prim == nqp::const::BIND_VAL_OBJ { + if nqp::iscont_i($param) { $param := Int; $primish := 1; } + elsif nqp::iscont_u($param) { $param := Int; $primish := 1; } + elsif nqp::iscont_n($param) { $param := Num; $primish := 1; } + elsif nqp::iscont_s($param) { $param := Str; $primish := 1; } + else { $param := nqp::hllizefor($param, 'Raku') } + } + else { + $param := $got_prim == nqp::const::BIND_VAL_INT ?? Int !! + $got_prim == nqp::const::BIND_VAL_UINT ?? Int !! + $got_prim == nqp::const::BIND_VAL_NUM ?? Num !! + Str; + $primish := 1; + } + if nqp::eqaddr($type_obj, Mu) || nqp::istype($param, $type_obj) { + if $i == 0 && nqp::existskey($candidate, 'exact_invocant') { + unless $param.WHAT =:= $type_obj { + $no_mismatch := 0; + } + } } # Positional param needs PositionalBindFailover @@ -3925,7 +3914,7 @@ BEGIN { ) ) { $no_mismatch := 0 unless nqp::istype( - $type, + $param, nqp::ifnull( $PositionalBindFailover, $PositionalBindFailover := @@ -3940,14 +3929,13 @@ BEGIN { } # Check for definedness if it still makes sense - if $no_mismatch { - $no_mismatch := 0 - if (my int $mask := - $flags +& nqp::const::DEFCON_MASK) - && ($primish || nqp::isconcrete($arg) - ?? nqp::const::DEFCON_DEFINED - !! nqp::const::DEFCON_UNDEFINED - ) != $mask + if $no_mismatch && $flags +& nqp::const::DEFCON_MASK { + my int $defined := $primish || nqp::isconcrete($param); + my int $desired := $flags +& nqp::const::DEFCON_MASK; + if ($defined && $desired == nqp::const::DEFCON_UNDEFINED) || + (!$defined && $desired == nqp::const::DEFCON_DEFINED) { + $no_mismatch := 0; + } } #?endif #?if jvm