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

stringification of regex with variables #6690

Closed
p6rt opened this issue Jan 16, 2019 · 2 comments
Closed

stringification of regex with variables #6690

p6rt opened this issue Jan 16, 2019 · 2 comments

Comments

@p6rt
Copy link

p6rt commented Jan 16, 2019

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

Searchable as RT133772$

@p6rt
Copy link
Author

p6rt commented Jan 16, 2019

From @daxim

rpm -qi rakudo | rg Version
Version : 2018.12

  my Str $s = 'abc';
  my @​l = $s.comb.map(-> $g { /$g/ });
  # time passes
  @​l.perl.say

Expect​:

  [/a/, /b/, /c/]

Got​:

  [/$g/, /$g/, /$g/]

The generated regexes do work, they just display wrong/useless. At the time I inspect the data structure, $g had been assigned multiple times with varying values and is long already out of scope.

@MasterDuke17
Copy link

21:27 | jnthn | Regexes  ain't strings, they're compiled code; I suspect it is getting the  closure semantics right, but you aren't going to see that reflected in  the stringification of the regex, since that's really just carrying  along its source
21:29 | MasterDuke | my Str $s = "abc"; my @l = $s.comb.map(-> $g { /$g/ }); say "a" ~~ @l[0]; say "a" ~~ @l[1]
21:29 | evalable6 | MasterDuke, rakudo-moar 99b67a4b6: OUTPUT: «「a」␤Nil␤»
21:29 | MasterDuke | jnthn++
21:30 | MasterDuke | jnthn: so you think https://github.com/Raku/old-issue-tracker/issues/6690 should be closed?
21:32 | jnthn | Yes, also the "$g has been assigned many times" thing is a bit confusing, given then it's a read-only parameter
21:32 | jnthn | But that issue seems to want things to work in a way that they fundementally do not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants