cannot use `OUTER` as label name for loop control in Raku

72 Views Asked by At

If I use OUTA as a label name it works, but OUTER doesn't:

OUTA:  say OUTA.^name;  # Label
OUTER: say OUTER.^name; # OUTER

Thus:

OUTA:  loop { last OUTA  } # works
OUTER: loop { last OUTER } # fails (see below)

It is strange that OUTER cannot be used as a label name for loop control in Raku. For example,

OUTER:
loop {
    loop { state $c = 0; say $c++; last OUTER if $c > 2 }

}

The output and the error message is as follow:

0
1
2
Cannot resolve caller last(OUTER:U); none of these signatures matches:
    ( --> Nil)
    (Label:D $x --> Nil)
  in block  at <unknown file> line 1
  in block <unit> at <unknown file> line 1
  in any <main> at /opt/homebrew/Cellar/rakudo-star/2024.03/bin/../share/perl6/runtime/perl6.moarvm line 1
  in any <entry> at /opt/homebrew/Cellar/rakudo-star/2024.03/bin/../share/perl6/runtime/perl6.moarvm line 1

Changing OUTER to OUT, OUTE, OUTA, etc. will work just fine. Is OUTER a type name which cannot be used as a label name? I have searched for it but cannot find any mention of OUTER in docs.raku.org.

0

There are 0 best solutions below