Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A script that gives different results when executed from a file and when pasted into REPL #3599

Open
p6rt opened this issue Dec 6, 2014 · 5 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Dec 6, 2014

Migrated from rt.perl.org#123380 (status was 'open')

Searchable as RT123380$

@p6rt
Copy link
Author

p6rt commented Dec 6, 2014

From djura@centrum.cz

$ ./perl6-m --version
This is perl6 version 2014.09 built on MoarVM version 2014.09

#############################xx

$ ./perl6-m

say 'a'.subst(/(.)/,{$0~$0});
aa
say "%20" ~~ /​:i \%(<[0..9A..F]>**2)/;
ï½¢%20ï½£
0 => ï½¢20ï½£

say 'a'.subst(/(.)/,{$0~$0});
2020

#############################xx

$ cat strangeregexp.pl
say 'a'.subst(/(.)/,{$0~$0}); # aa

say "%20" ~~ /​:i \%(<[0..9A..F]>**2)/; # ï½¢%20ï½£
  # 0 => ï½¢20ï½£

say 'a'.subst(/(.)/,{$0~$0});

#############################xx

./perl6-m strangeregexp.pl
aa
ï½¢%20ï½£
0 => ï½¢20ï½£

aa

#############################xx

@p6rt
Copy link
Author

p6rt commented Feb 7, 2015

From @usev6

This is another case where it makes a difference whether the command comes on a single line or on two separate lines​:

$ perl6-m -e 'say "a".subst(/(.)/,{$0~$0}); say "%20" ~~ /​:i \%(<[0..9A..F]>**2)/; say "a".subst(/(.)/,{$0~$0});'
aa
ï½¢%20ï½£
0 => ï½¢20ï½£
aa

But with a newline in the echo command​:

$ echo 'say "a".subst(/(.)/,{$0~$0}); say "%20" ~~ /​:i \%(<[0..9A..F]>**2)/;
say "a".subst(/(.)/,{$0~$0});' | perl6-m
aa
ï½¢%20ï½£
0 => ï½¢20ï½£
2020

The behaviour differs with rakudo.parrot and rakudo.jvm​:

$ echo 'say "a".subst(/(.)/,{$0~$0}); say "%20" ~~ /​:i \%(<[0..9A..F]>**2)/;
say "a".subst(/(.)/,{$0~$0});' | perl6-p

say "a".subst(/(.)/,{$0~$0}); say "%20" ~~ /​:i \%(<[0..9A..F]>**2)/;
aa
ï½¢%20ï½£
0 => ï½¢20ï½£
say "a".subst(/(.)/,{$0~$0});
aa

$ echo 'say "a".subst(/(.)/,{$0~$0}); say "%20" ~~ /​:i \%(<[0..9A..F]>**2)/;
say "a".subst(/(.)/,{$0~$0});' | perl6-j

say "a".subst(/(.)/,{$0~$0}); say "%20" ~~ /​:i \%(<[0..9A..F]>**2)/;
aa
ï½¢%20ï½£
0 => ï½¢20ï½£
True
say "a".subst(/(.)/,{$0~$0});
a
True

1 similar comment
@p6rt
Copy link
Author

p6rt commented Feb 7, 2015

From @usev6

This is another case where it makes a difference whether the command comes on a single line or on two separate lines​:

$ perl6-m -e 'say "a".subst(/(.)/,{$0~$0}); say "%20" ~~ /​:i \%(<[0..9A..F]>**2)/; say "a".subst(/(.)/,{$0~$0});'
aa
ï½¢%20ï½£
0 => ï½¢20ï½£
aa

But with a newline in the echo command​:

$ echo 'say "a".subst(/(.)/,{$0~$0}); say "%20" ~~ /​:i \%(<[0..9A..F]>**2)/;
say "a".subst(/(.)/,{$0~$0});' | perl6-m
aa
ï½¢%20ï½£
0 => ï½¢20ï½£
2020

The behaviour differs with rakudo.parrot and rakudo.jvm​:

$ echo 'say "a".subst(/(.)/,{$0~$0}); say "%20" ~~ /​:i \%(<[0..9A..F]>**2)/;
say "a".subst(/(.)/,{$0~$0});' | perl6-p

say "a".subst(/(.)/,{$0~$0}); say "%20" ~~ /​:i \%(<[0..9A..F]>**2)/;
aa
ï½¢%20ï½£
0 => ï½¢20ï½£
say "a".subst(/(.)/,{$0~$0});
aa

$ echo 'say "a".subst(/(.)/,{$0~$0}); say "%20" ~~ /​:i \%(<[0..9A..F]>**2)/;
say "a".subst(/(.)/,{$0~$0});' | perl6-j

say "a".subst(/(.)/,{$0~$0}); say "%20" ~~ /​:i \%(<[0..9A..F]>**2)/;
aa
ï½¢%20ï½£
0 => ï½¢20ï½£
True
say "a".subst(/(.)/,{$0~$0});
a
True

@p6rt
Copy link
Author

p6rt commented Feb 7, 2015

@usev6 - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented May 8, 2018

From @skids

Test PR for rakudo tree​: rakudo/rakudo#1806

If that is accepted, someone with a jvm build should check whether it needs to be fudged for rakudo-j
and if it is fine there as well, this ticket can be closed.

@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant