petdance/scratch — Issue #138: Multidispatch 'concatenate_str' does not handle LHS undef
Author: petdance
Created: 2011-11-01 05:41:20+00:00
State: open
Labels: bug, core, Pri-normal, Sev-medium

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.

Originally http://trac.parrot.org/parrot/ticket/1088