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

perl6 rakudo 2016.11 match tries to assign to read-only variable, why not in 2016.07? #5862

Closed
p6rt opened this issue Dec 6, 2016 · 4 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Dec 6, 2016

Migrated from rt.perl.org#130274 (status was 'rejected')

Searchable as RT130274$

@p6rt
Copy link
Author

p6rt commented Dec 6, 2016

From rongshenmd@gmail.com

perl6 rakudo 2016.11 match tries to assign to read-only variable, why not
in 2016.07?
<http://stackoverflow.com/questions/40970080/perl6-rakudo-2016-11-match-tries-to-assign-to-read-only-variable-why-not-in-201>
<http://engine.adzerk.net/r?e=eyJhdiI6NDE0LCJhdCI6NCwiYnQiOjAsImNtIjo0NzE0OTMsImNoIjoxMTc4LCJjayI6e30sImNyIjoxNjM4OTkwLCJkaSI6IjA0NzRhMWUwOTc0NDQzYTE5Mjk4NDZlZDQxMDM0Nzg1IiwiZG0iOjEsImZjIjoxOTQzNDQ0LCJmbCI6MjE0MjMxMiwiaXAiOiI2Ny4xNjkuNzQuMTk0Iiwia3ciOiJtYXRjaCxyZWFkb25seSxhc3NpZ24scGVybDYscmFrdWRvLHgtdXNlci1yZWdpc3RlcmVkIiwibnciOjIyLCJwYyI6MCwiZWMiOjAsInByIjoxNjA0LCJydCI6MSwicmYiOiJodHRwOi8vc3RhY2tvdmVyZmxvdy5jb20vIiwic3QiOjgyNzcsInVrIjoidWUxLWZiMGQzNDJmZjA1YTRjY2RhOTczYzI0MDM0N2EzMWEzIiwiem4iOjQzLCJ0cyI6MTQ4MTAwNzA1NjY0MywiYmYiOnRydWUsInBuIjoiYWR6ZXJrMTQzMDQ2MDc2OSIsInVyIjoiaHR0cDovL3N0YWNrb3ZlcmZsb3cuY29tL2pvYnM_dXRtX3NvdXJjZT13ZWJzaXRlJnV0bV9tZWRpdW09YmFubmVyJnV0bV9jb250ZW50PWxlYWRlcmJvYXJkXzkmdXRtX2NhbXBhaWduPWhvdXNlX2Fkc19ob3VzZV9hZHNfUk9TX1NPIn0&s=t-73aTTxrewxtSYg-5ctk4Ty30Q>
up vote 2 down vote favorite
<http://stackoverflow.com/questions/40970080/perl6-rakudo-2016-11-match-tries-to-assign-to-read-only-variable-why-not-in-201?noredirect=1#>

I have the following method in an action class that worked well in Rakudo
2016.07, but I just installed 2016.11 and now the new Rakudo says my method
tries to assign to read-only varible, and I just don't see the problem​:

method ptName ($/) {
  my $nameStr = $/.Str, my $lastName, my $firstName;
  my $newMatch # this is line 182;
  # Cannot assign to a readonly variable or a value
  = $nameStr.match(/ \" (<alpha>+) .*? \, \s* (<alpha>+) .*? \" /);
  $lastName = $newMatch[0];
  $firstName = $newMatch[1];
  make "$lastName $firstName";
}

The whole error message is

Cannot assign to a readonly variable or a value
  in method ptName at /home/lisprog/Binary/grammar.pl line 182
  in regex ptName at /home/lisprog/Binary/grammar.pl line 151
  in regex TOP at /home/lisprog/Binary/grammar.pl line 137
  in block <unit> at /home/lisprog/Binary/grammar.pl line 217

What language spec has changed? Please help. Thanks.
match <http://stackoverflow.com/questions/tagged/match> readonly
<http://stackoverflow.com/questions/tagged/readonly> assign
<http://stackoverflow.com/questions/tagged/assign> perl6
<http://stackoverflow.com/questions/tagged/perl6> rakudo
<http://stackoverflow.com/questions/tagged/rakudo>
share <http://stackoverflow.com/q/40970080/4400590>edit
<http://stackoverflow.com/posts/40970080/edit>delete
<http://stackoverflow.com/questions/40970080/perl6-rakudo-2016-11-match-tries-to-assign-to-read-only-variable-why-not-in-201?noredirect=1#>
flag
<http://stackoverflow.com/questions/40970080/perl6-rakudo-2016-11-match-tries-to-assign-to-read-only-variable-why-not-in-201?noredirect=1#>
asked 22 hours ago
<http://stackoverflow.com/users/4400590/lisprogtor>
lisprogtor <http://stackoverflow.com/users/4400590/lisprogtor>
1615

I vaguely recall something about this. What happens when you write method
ptName ($/ is copy) {? What about method ptName ($/ is rw) {? – raiph
<http://stackoverflow.com/users/1077672/raiph> 7 hours ago
<http://stackoverflow.com/questions/40970080/perl6-rakudo-2016-11-match-tries-to-assign-to-read-only-variable-why-not-in-201?noredirect=1#comment69180396_40970080>

Thank you raiph ! When I use ($/ is copy) on any $a=$someString.match(),
then the program runs, but fails to give meaningful $a[0] or $a[1]; when I
use ($/ is rw), then new error occurs and it says "Parameter '$/' expected
a writable container, but got Match value". I did not have this problem in
Rakudo 2016.07. I think something broke in 2016.11. Last time I tried to
report a bug, the email bounced back as undeliverable. Thanks. – lisprogtor
<http://stackoverflow.com/users/4400590/lisprogtor> 41 mins ago
<http://stackoverflow.com/questions/40970080/perl6-rakudo-2016-11-match-tries-to-assign-to-read-only-variable-why-not-in-201?noredirect=1#comment69186754_40970080>

add a comment
<http://stackoverflow.com/questions/40970080/perl6-rakudo-2016-11-match-tries-to-assign-to-read-only-variable-why-not-in-201?noredirect=1#>
question eligible for bounty tomorrow <http://stackoverflow.com/help/bounty>
1 Answer
active
<http://stackoverflow.com/questions/40970080/perl6-rakudo-2016-11-match-tries-to-assign-to-read-only-variable-why-not-in-201?answertab=active#tab-top>
oldest
<http://stackoverflow.com/questions/40970080/perl6-rakudo-2016-11-match-tries-to-assign-to-read-only-variable-why-not-in-201?answertab=oldest#tab-top>
votes
<http://stackoverflow.com/questions/40970080/perl6-rakudo-2016-11-match-tries-to-assign-to-read-only-variable-why-not-in-201?answertab=votes#tab-top>
up vote 1 down vote accept

According to git blame src/core/Str.pm, lizmat worked on this in October.
Str.match will now fiddle with the lexical $/ of the calling block when it
apparently did not do so before.

As Str.match also returns a match object, there is no need to do so and
this might just be a bug. Either report it as such or ask in #perl6 on
Freenode about it.
share <http://stackoverflow.com/a/40970413/4400590>edit
<http://stackoverflow.com/posts/40970413/edit>flag
<http://stackoverflow.com/questions/40970080/perl6-rakudo-2016-11-match-tries-to-assign-to-read-only-variable-why-not-in-201?noredirect=1#>
answered 22 hours ago
<http://stackoverflow.com/users/48015/christoph>
Christoph <http://stackoverflow.com/users/48015/christoph>
102k24123186

Thanks Christoph ! I am not sure what you mean by "no need to do so." –
lisprogtor <http://stackoverflow.com/users/4400590/lisprogtor> 35 mins ago
<http://stackoverflow.com/questions/40970080/perl6-rakudo-2016-11-match-tries-to-assign-to-read-only-variable-why-not-in-201?noredirect=1#comment69186901_40970413>

@p6rt
Copy link
Author

p6rt commented Dec 6, 2016

From @zoffixznet

Thank you for the report.

The current behaviour is correct. I wrote a more detailed answer on StackOverflow​:
http://stackoverflow.com/questions/40970080/perl6-rakudo-2016-11-match-tries-to-assign-to-read-only-variable-why-not-in-201/40998615#&#8203;40998615

P.S.​: in the future, please email bugs to rakudobug@​perl.org. I think the address you've used belongs to the Perl 5 queue.

Cheers,
ZZ

@p6rt
Copy link
Author

p6rt commented Dec 6, 2016

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Dec 6, 2016

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

@p6rt p6rt closed this as completed Dec 6, 2016
@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