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

.subst does not work inside BEGIN block ($/ is set too late) #3515

Closed
p6rt opened this issue Sep 16, 2014 · 6 comments
Closed

.subst does not work inside BEGIN block ($/ is set too late) #3515

p6rt opened this issue Sep 16, 2014 · 6 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Sep 16, 2014

Migrated from rt.perl.org#122789 (status was 'resolved')

Searchable as RT122789$

@p6rt
Copy link
Author

p6rt commented Sep 16, 2014

From anteusz@freemail.hu

Hi all,

I found this

12​:55​:39] [jaffa4] m​: BEGIN {my $p =
'D​:\m\p6\guiultimate\lib\\GUI\Upp.pm6'; say $p.subst(/(.+)\\.+$/,{$0});}
[12​:55​:40] [+camelia] rakudo-moar 3fae8d​: OUTPUT«␤»
[12​:55​:47] [jaffa4] m​: {my $p = 'D​:\m\p6\guiultimate\lib\\GUI\Upp.pm6';
say $p.subst(/(.+)\\.+$/,{$0});}
[12​:55​:48] [+camelia] rakudo-moar 3fae8d​:
OUTPUT«D​:\m\p6\guiultimate\lib\GUI␤»
[12​:56​:03] [jaffa4] bug!!!!!!!!!!!!!!!

Jaffa4

@p6rt
Copy link
Author

p6rt commented May 7, 2016

From @smls

Comfirmed on current Rakudo. Now it additionally throws a weird exception...

Simpler demo example​:

  ➜ say "a".subst(/a/, "b");
  b

  ➜ BEGIN { say "a".subst(/a/, "b"); }
  ===SORRY!=== Error while compiling -e
  An exception occurred while evaluating a BEGIN
  at -e​:1
  Exception details​:
  Type check failed in binding cds; expected Any but got Mu (Mu)
  in block at -e line 1

@p6rt
Copy link
Author

p6rt commented May 12, 2016

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

@p6rt
Copy link
Author

p6rt commented Jun 23, 2016

From @smls

IRC comments​:

  psch​: m​: BEGIN { my $/ := Any; note "foo".subst("foo","bar") }
  camelia​: rakudo-moar 78d2ce​: OUTPUT«bar␤»
  psch​: it's really just that we set $/ too late
  psch​: might be rather easy to patch, or might not :)

@p6rt
Copy link
Author

p6rt commented Oct 21, 2017

From @zoffixznet

Fix​: rakudo/rakudo@a62b221
Test​: Raku/roast@9585230c26

@p6rt
Copy link
Author

p6rt commented Oct 21, 2017

@zoffixznet - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Oct 21, 2017
@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