# New Ticket Created by  "Carl Mäsak" 
# Please include the string:  [perl #113904]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=113904 >


<tadzik> r: for Range.new(0, 1) -> $p { when $p { say $_.perl; say $_.path } }
<p6eval> rakudo 39087a: OUTPUT«use of uninitialized variable $a of
type Any in numeric context  in block <anon> at
/tmp/bhcZACNkRT:1␤␤Null PMC access in find_method('perl') [...]
<tadzik> there we are
* masak submits rakudobug
<pmichaud> ...why is that a bug, ooc?
<masak> pmichaud: Null PMC access
<tadzik> NPA
<pmichaud> oh, I see.
<masak> r: for ^1 -> $p { when $p { .foo } }
<p6eval> rakudo 39087a: OUTPUT«use of uninitialized variable $a of
type Any in numeric context  in block <anon> at
/tmp/HzMxDYTCaC:1␤␤Null PMC access in find_method('foo') [...]
<pmichaud> oh, it's the .ACCEPTS bug
<masak> oh?
<pmichaud> sure, it's the   when $p    that is attempting to convert
Any into a number
<pmichaud> in order to smart match it against $p
<masak> the interesting thing is that the Range, the 'when' and the
$_.foo call are all irreducible parts of triggering the bug.
<masak> remove any of them, and the Null PMC Access disappears.
<pmichaud> r: for (0,1) -> $p { when $p { .foo } }
<p6eval> rakudo 39087a: OUTPUT«use of uninitialized variable $a of
type Any in numeric context  in block <anon> at
/tmp/VgCIK_kuoP:1␤␤Null PMC access in find_method('foo') [...]
<masak> maybe not. :)
<pmichaud> r: for 0 -> $p { when $p { .foo } }
<masak> ok, the Range is not essential, then.
<p6eval> rakudo 39087a: OUTPUT«use of uninitialized variable $a of
type Any in numeric context  in block <anon> at
/tmp/2BcvX6lmnC:1␤␤Null PMC access in find_method('foo') [...]
<masak> huh.
<masak> tadzik: I'm pretty sure we tested that.
<tadzik> masak: yeah, same. Odd
<pmichaud> given 0 -> $p { when $p { .foo } }
<pmichaud> r: given 0 -> $p { when $p { .foo } }
<p6eval> rakudo 39087a: OUTPUT«use of uninitialized variable $a of
type Any in numeric context  in block <anon> at
/tmp/SJ1JbHQSej:1␤␤Null PMC access in find_method('foo') [...]
<pmichaud> r: (-> $p { when $p { .foo } }).(0)
<p6eval> rakudo 39087a: OUTPUT«use of uninitialized variable $a of
type Any in numeric context  in block <anon> at /tmp/5zdWF1O_Fa:1␤␤No
such method 'foo' for invocant of type 'Any' [...]
<masak> there. it disappeared.
<masak> I think iteration is involved somehow, anyway.
<pmichaud> well, not with 'given'
<pmichaud> there's no iteration with the .given
<masak> hm, troo.
<masak> so, why does it trigger with 'for' and 'given', but not with
that last one, with a block?
<pmichaud> r: my $ps = -> $p { when $p { .foo } };  $ps(0);
<p6eval> rakudo 39087a: OUTPUT«use of uninitialized variable $a of
type Any in numeric context  in block <anon> at
/tmp/Ap9xU9dVVo:1NLNLNo such method 'foo' for invocant of type 'Any'
[...]
<pmichaud> r: 0.map( -> $p { when $p { .foo } }).eager
<p6eval> rakudo 39087a: OUTPUT<<use of uninitialized variable $a of
type Any in numeric context  in block <anon> at
/tmp/JRkifpk737:1NLNLNo such method 'foo' for invocant of type 'Any'
[...]
<pmichaud> the NPA has to be something in the way the closures are
being built when part of 'for' or 'given'
<pmichaud> which means it's a bug in <xblock>
<pmichaud> (in Actions.pm)
<pmichaud> here's another, then
<pmichaud> r: if 1 -> $p { when $p { .foo } }
<p6eval> rakudo 39087a: OUTPUT<<use of uninitialized variable $a of
type Any in numeric context  in block <anon> at
/tmp/C8Mba0rmGT:1NLNL>>
<pmichaud> hmm.
<pmichaud> okay, so, the "unintialized variable $a..." is coming from
an ACCEPTS call
<pmichaud> I'm guessing it's this one:
<pmichaud> src/core/Numeric.pm:4:    multi method ACCEPTS(Numeric:D: $a) {
<pmichaud> The NPA is because the pointy block is somehow getting the
wrong outer $_
<masak> ah.
<pmichaud> but only when being used as part of 'for' or 'given' (so
far... could be other structures)
<pmichaud> r: $_ = Bool; if 1 -> $p { when $p { .say } }
<p6eval> rakudo 39087a: OUTPUT<<use of uninitialized variable $a of
type Bool in numeric context  in block <anon> at
/tmp/amepJyEJYf:1NLNL>>
<pmichaud> r:  Bool.say
<p6eval> rakudo 39087a: OUTPUT<<Bool()NL>>
<pmichaud> *there*
<masak> \o/
<pmichaud> the .say got a $_ that isn't the one with the Bool
<pmichaud> even though the one with the Bool is the one that was used
for the smartmatching 'when'
<masak> I'm lost, but I'm including this in the report anyway :P
<pmichaud> please do, it's pretty well golfed.
<masak> pmichaud++

Reply via email to