The optimizer can lower lexical variables into local variables.
When it does so, it keeps track of this so that it can give you this error
message.
The `given` block and the `when` blocks are optimized away.
If you move the first `$a` declaration to inside the `given` block the
error goes away.
I think what is happening is that somehow both `$a` variables are
coalescing into the same local variable.
This is definitely an optimizer bug.
This is not really a LTA error message bug, because the runtime doesn't
have any more information to give you.
On Tue, Oct 22, 2019 at 5:37 PM Kevin Pye wrote:
> Yesterday I created a new when clause in an existing working program,
> which worked fine, but today when I came to exercise another previously
> working when clause it was broken.
>
> The golfed version...
>
> my $a = 41;
>
> given 6 {
> when 5 {
> my $a;
> }
> when 6 {
> say $a + 1;
> }
> }
>
> When run with various version of rakudo (at least on 2019.07.1 and current
> HEAD) this produces
>
> Use of uninitialized value of type Rakudo::Internals::LoweredAwayLexical
> in numeric context
>
> Is this expected? If nothing else, the error message is decidedly LTA.
>
> I fixed it in my case by removing the unnecessary redeclaration of $a in
> the when clause, but there might be times when that is incorrect.
>
> (And on a side note, are there plans to move this mailing list to
> raku-users@somewhere? There's nothing about it in the path to raku
> document.)
>
> Kevin.
>