Raku / old-issue-tracker

Tickets from RT
https://github.com/Raku/old-issue-tracker/issues
2 stars 1 forks source link

Some parsing glitch with `\term` in a string #6286

Open p6rt opened 7 years ago

p6rt commented 7 years ago

Migrated from rt.perl.org#131389 (status was 'new')

Searchable as RT131389$

p6rt commented 7 years ago

From @zoffixznet

IRC​: https://irclog.perlgeek.de/perl6-dev/2017-05-28#i_14648548

The first eval uses emoji cat in a string and it works; The second one tries to do the same in a bit more elaborate eval and it crashes with bogus term error; The third one executes the same code, except swapping \term​:\<😹> to \x, and it works fine; The fourth one executes the same code, except swapping \term​:\<😹> to \term​:\, and now it crashes with "undeclared routine x"; The last one uses \term​:\, except it works fine.

Seems in the problematic cases, the defined \term is not seen by the block inside the string.

09​:07 Zoffix m​: my \term​:\<😹> = -42; say 😹; say 😹.abs; say "{😹}"; my $foo = ''; say "{😹.abs}​:$foo" for 😹.abs 09​:07 camelia rakudo-moar 87d0e0​: OUTPUT​: «-42␤42␤-42␤42​:␤» 09​:07 Zoffix m​: '/tmp/file1'.IO.spurt​: "a\nb\nc"; '/tmp/file2'.IO.spurt​: "d\ne\n"; '/tmp/file3'.IO.spurt​: "f\ng\nh\ni"; my $line; my \term​:\<😹> = IO​::CatHandle.new('/tmp/file1', '/tmp/file2'.IO, '/tmp/file3'.IO.open, :on-switch{ $line = 1 }); say "{😹.path}​:$line $_" for 😹.lines 09​:07 camelia rakudo-moar 87d0e0​: OUTPUT​: «5===SORRY!5=== Error while compiling \␤Bogus statement␤at \​:1␤------> 3 :on-switch{ $line = 1 }); say "{7⏏5😹.path}​:$line $_" for 😹.lines␤ expecting any of​:␤ prefix␤ term␤» 09​:07 Zoffix m​: '/tmp/file1'.IO.spurt​: "a\nb\nc"; '/tmp/file2'.IO.spurt​: "d\ne\n"; '/tmp/file3'.IO.spurt​: "f\ng\nh\ni"; my $line; my \x = IO​::CatHandle.new('/tmp/file1', '/tmp/file2'.IO, '/tmp/file3'.IO.open, :on-switch{ $line = 1 }); say "{x.path}​:$line $_" for x.lines 09​:07 camelia rakudo-moar 87d0e0​: OUTPUT​: «/tmp/file1​:1 a␤/tmp/file1​:1 b␤/tmp/file1​:1 c␤/tmp/file2​:1 d␤/tmp/file2​:1 e␤/tmp/file3​:1 f␤/tmp/file3​:1 g␤/tmp/file3​:1 h␤/tmp/file3​:1 i␤» 09​:12 m​: '/tmp/file1'.IO.spurt​: "a\nb\nc"; '/tmp/file2'.IO.spurt​: "d\ne\n"; '/tmp/file3'.IO.spurt​: "f\ng\nh\ni"; my $line; my \term​:\ = IO​::CatHandle.new('/tmp/file1', '/tmp/file2'.IO, '/tmp/file3'.IO.open, :on-switch{ $line = 1 }); say "{x.path}​:$line $_" for x.lines 09​:12 camelia rakudo-moar 87d0e0​: OUTPUT​: «5===SORRY!5=== Error while compiling \␤Undeclared routine​:␤ x used at line 1␤␤» 09​:12 Zoffix m​: my \term​:\ = 42; say x.path 09​:12 camelia rakudo-moar 87d0e0​: OUTPUT​: «"42".IO␤»