Skip to content

Instantly share code, notes, and snippets.

@bduggan
Last active July 9, 2018 18:22
Show Gist options
  • Select an option

  • Save bduggan/cd2da7ac41da9bdadca4ee80d5e61ce1 to your computer and use it in GitHub Desktop.

Select an option

Save bduggan/cd2da7ac41da9bdadca4ee80d5e61ce1 to your computer and use it in GitHub Desktop.
use nqp;
# see https://rt.perl.org/Public/Bug/Display.html?id=131530
# search for add_categorical in src/Perl6/Grammar.nqp
my $compiler = nqp::getcomp("perl6");
my $outer_ctx;
my $*MAIN_CTX;
sub reval($code) {
my $*CTXSAVE = class {
method ctxsave(--> Nil) {
$*MAIN_CTX := nqp::ctxcaller(nqp::ctx());
$*CTXSAVE := 0;
}
};
$compiler.eval($code, :$outer_ctx);
$outer_ctx := $*MAIN_CTX;
}
reval('my $y = 1; say $y');
reval('$y++; say $y');
reval('$y++; say $y');
reval('sub infix:<→>($x,$y) { ( $x * $y - $y + 3 ) ÷ $y }; say 1 → 3;');
reval('sub foo($x,$y) { ( $x * $y - $y + 3 ) ÷ $y }; say foo(1,2)');
reval('say foo(1,2)');
reval('say infix:<→>(1,3)');
reval('say 1 → 3');
$ perl6 bug.p6
1
2
3
1
1.5
1.5
1
===SORRY!=== Error while compiling /Users/bduggan/rakudo/bug.p6
Confused
at /Users/bduggan/rakudo/bug.p6:1
------> say 1⏏ → 3
expecting any of:
infix
infix stopper
postfix
statement end
statement modifier
statement modifier loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment