Skip Menu |
 
rt.cpan.org will be shut down on March 1st, 2021.

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Readonly CPAN distribution.

Report information
The Basics
Id: 86086
Status: resolved
Priority: 0/
Queue: Readonly

People
Owner: sanko [...] cpan.org
Requestors: hirose31 [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 2.01



Subject: Readonly @a = qw(foo bar) is not a syntax error with perl >= 5.16
Download (untitled) / with headers
text/plain 804b
I often mistake using Readonly. wrong : Readonly @a = qw(foo bar); correct: Readonly @a => qw(foo bar); Wrong code cause syntax error until Perl 5.14: $ ~/perlbrew/perls/perl-5.14.4/bin/perl -MReadonly -e 'Readonly my @a = qw(foo bar); warn "hey!"' Type of arg 1 to Readonly::Readonly must be one of [$@%] (not list assignment) at -e line 1, near "qw(foo bar);" Execution of -e aborted due to compilation errors. but no error from Perl 5.16: $ ~/perlbrew/perls/perl-5.16.3/bin/perl -MReadonly -e 'Readonly my @a = qw(foo bar); warn "hey!"' hey! at -e line 1. I suppose this cause is "The \$ prototype accepts any scalar lvalue" in perl 5.16. http://perldoc.perl.org/perl5160delta.html#Other-Changes I know wrong usage of Readonly is bad, but I hope it wll be syntax error with perl >= 5.16.
Download (untitled) / with headers
text/plain 1.1k
On Wed Jun 12 06:02:10 2013, HIROSE wrote: Show quoted text
> I often mistake using Readonly. > > wrong : Readonly @a = qw(foo bar); > correct: Readonly @a => qw(foo bar); > > Wrong code cause syntax error until Perl 5.14: > > $ ~/perlbrew/perls/perl-5.14.4/bin/perl -MReadonly -e 'Readonly my @a > = qw(foo bar); warn "hey!"' > Type of arg 1 to Readonly::Readonly must be one of [$@%] (not list > assignment) at -e line 1, near "qw(foo bar);" > Execution of -e aborted due to compilation errors. > > but no error from Perl 5.16: > > $ ~/perlbrew/perls/perl-5.16.3/bin/perl -MReadonly -e 'Readonly my @a > = qw(foo bar); warn "hey!"' > hey! at -e line 1. > > I suppose this cause is "The \$ prototype accepts any scalar lvalue" > in perl 5.16. > http://perldoc.perl.org/perl5160delta.html#Other-Changes > > I know wrong usage of Readonly is bad, but I hope it wll be syntax > error with perl >= 5.16.
I hadn’t realised it would have that effect. I wonder whether this should also be a syntax error: $ echo aosenuthaeosuhtse | perl -le 'read STDIN, @a=qw(foo bar), 10; print for @a' foo bar That is longstanding behaviour (tested with 5.12).
This cause is "The \$ prototype accepts any scalar lvalue" in perl 5.16. http://perldoc.perl.org/perl5160delta.html#Other-Changes Your code seems not using \$ prototype. Could you try a code below with Perl >= 5.16 and < 5.16: perl -MData::Dumper -e 'sub t(\[$@%]@) { warn Dumper(\@_) }; t(my @a = qw(foo bar));' $ ~/perlbrew/perls/perl-5.14.4/bin/perl -MData::Dumper -e 'sub t(\[$@%]@) { warn Dumper(\@_) }; t(my @a = qw(foo bar));' Type of arg 1 to main::t must be one of [$@%] (not list assignment) at -e line 1, near "qw(foo bar))" Execution of -e aborted due to compilation errors. # This is desirable behavior $ ~/perlbrew/perls/perl-5.16.3/bin/perl -MData::Dumper -e 'sub t(\[$@%]@) { warn Dumper(\@_) }; t(my @a = qw(foo bar));' $VAR1 = [ \2 ]; # No error... and check source code of Readonly. https://metacpan.org/source/ROODE/Readonly-1.03/Readonly.pm#L338 On 2013-6月-12 水 11:51:36, SPROUT wrote: Show quoted text
> On Wed Jun 12 06:02:10 2013, HIROSE wrote:
> > I often mistake using Readonly. > > > > wrong : Readonly @a = qw(foo bar); > > correct: Readonly @a => qw(foo bar); > > > > Wrong code cause syntax error until Perl 5.14: > > > > $ ~/perlbrew/perls/perl-5.14.4/bin/perl -MReadonly -e 'Readonly my
> @a
> > = qw(foo bar); warn "hey!"' > > Type of arg 1 to Readonly::Readonly must be one of [$@%] (not list > > assignment) at -e line 1, near "qw(foo bar);" > > Execution of -e aborted due to compilation errors. > > > > but no error from Perl 5.16: > > > > $ ~/perlbrew/perls/perl-5.16.3/bin/perl -MReadonly -e 'Readonly my
> @a
> > = qw(foo bar); warn "hey!"' > > hey! at -e line 1. > > > > I suppose this cause is "The \$ prototype accepts any scalar lvalue" > > in perl 5.16. > > http://perldoc.perl.org/perl5160delta.html#Other-Changes > > > > I know wrong usage of Readonly is bad, but I hope it wll be syntax > > error with perl >= 5.16.
> > I hadn’t realised it would have that effect. I wonder whether this > should also be a syntax error: > > $ echo aosenuthaeosuhtse | perl -le 'read STDIN, @a=qw(foo bar), 10; > print for @a' > foo > bar > > That is longstanding behaviour (tested with 5.12).
Download (untitled) / with headers
text/plain 222b
Apparently resolved months ago in v2.01. (Wish RT would let me resolve this without sending it to all of you... Sorry!) See also: - http://www.perlmonks.org/?node_id=1153664 - https://github.com/sanko/readonly/issues/18


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.