Ticket #1088 (new bug)

Opened 5 years ago

Last modified 5 years ago

Multidispatch 'concatenate_str' does not handle LHS undef

Reported by: Austin_Hastings Owned by:
Priority: normal Milestone:
Component: core Version: 1.6.0
Severity: medium Keywords: undef,multidispatch,concatenate_str
Cc: Language:
Patch status: Platform:

Description

This NQP code prints one line, then fails.

my $x;
my $z := '>' ~ $x;
say($z);
my $y := $x ~ '<';
say($y);

The error:

Multiple Dispatch: No suitable candidate found for 'concatenate_str', with signature 'PSP->P'
current instr.: '_block11' pc 50 (EVAL_3:27)
called from Sub 'parrot;PCT;HLLCompiler;eval' pc 982 (src/PCT/HLLCompiler.pir:548)

The generated PIR is concat $P0, $P1, $P2 for the constant-on-the-left case. But NQP generates concat $P0, $P1, '<' for the constant-on-the-right case. It is this case, with an undef first argument, that fails.

Changing the constant to a register does not affect the behavior. Storing an empty string in place of the left-hand undef does resolve the problem. I believe the multidispatch doesn't know what to do with undef.

Change History

Changed 5 years ago by Austin_Hastings

I was unclear in that when I wrote "undef first argument," about concat $P0, $P1, $P2 I meant $P1 -- first argument from the perspective of the '~' operator, not the PASM three-argument form. Sorry.

Note: See TracTickets for help on using tickets.