-
Notifications
You must be signed in to change notification settings - Fork 540
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
Make list assignment to sub :lvalue{keys} an error #15339
Comments
From @cpansproutWith the %hash{'key'} syntax, which is not an lvalue, we have an error if it is the last statement in an lvalue sub and the lvalue sub is assigned to. However, if the lvalue sub call is in foreach(...) or referenced by \ we have no error. So, given sub foo :lvalue { %hash{'key'} } the first line is permitted, but the second one dies: \foo; even though these are both variants of lvalue context. I propose extending that to keys() returned from an lvalue sub in a list assignement. Currently, this works: sub foo :lvalue { keys %h } But this does not die, yet does nothing useful, and is probably a mistake wherever it occurs: sub foo :lvalue { keys %h } whereas the plain form of list assignment to keys *does* die at compile time: (keys %h) = 1024; # Can't modify keys in list assignment The reason I bring this up is that, with the demise of autoderef, the one thing standing in the way of making &CORE::keys() work is gone, and I am trying to implement it now. It will be much easier to make this behave the same way as a bare keys()-- &CORE::keys(\%h) = 1024; # ok; scalar assignment --if I can disallow keys in the circumstance described above. After all, &CORE::keys will be an lvalue sub with ‘keys’ (or the next best thing) as the last op. I intend to go ahead and make this change soon (whatever soon means), but you still have until next year’s code freeze to object. :-) -- Father Chrysostomos |
From @cpansproutOn Thu May 19 11:30:35 2016, sprout wrote:
I have made this change in commits a061ab0 and 738155d. -- Father Chrysostomos |
The RT System itself - Status changed from 'new' to 'open' |
@cpansprout - Status changed from 'open' to 'resolved' |
From @demerphqI think long term we should deprecate assignment to keys. It is a
|
Migrated from rt.perl.org#128187 (status was 'resolved')
Searchable as RT128187$
The text was updated successfully, but these errors were encountered: