You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Summary: The useful warning in Perl 5:
Found = in conditional, should be == at ...
is absent in Rakudo. Although its omission was originally intentional,
the warning can be added to Rakudo in a more restricted form,
catching most of the programmer errors that the Perl 5 warning caught,
while still allowing valid code without complaint.
$ perl6 --version
This is Rakudo version 2015.12-140-gf1dd491 built on MoarVM version 2015.12
implementing Perl 6.c.
$ perl6 -e 'my $foo = 3; if $foo = 4 { say "overwrote!" }; say $foo;'
overwrote!
4
$ perl -wE 'my $foo = 3; if ($foo = 4) { say "overwrote!" }; say $foo;'
Found = in conditional, should be == at -e line 1.
overwrote!
4
http://irclog.perlgeek.de/perl6/2016-01-07#i_11848637
< Util> m: my $foo = 3; if $foo = 4 { say 'overwrote!' }; say $foo;
<+camelia> rakudo-moar ed6ec7: OUTPUT«overwrote!4»
< Util> In Perl 5, with warnings enabled, I would have been warned:
< Util> Found = in conditional, should be == at ...
< Util> Rakudo does not give this warning. Is this just NYI, or deliberate?
< TimToady> deliberate
< diakopter> I would think it should warn if it's a constant being assigned, but not otherwise
< diakopter> non-True constant
< diakopter> *True constant
< TimToady> yes, we could warn if the RHS is constant
< Util> TimToady: The lack of warning surprised me.
< Util> I am following up for a member of Atlanta.pm, who was bitten by this change
< Util> during early Perl 6 experimenting.
* TimToady finds the spurious warning to be irritating on something like: while $this = getnextone() { ... }
< TimToady> though there's less excuse for that construct in Perl 6 than in Perl 5
< Util> TimToady: but you have given us: while getnextone() -> $this { ... }
< TimToady> since we can write: while getnextone() -> $this { ... }
< TimToady> otoh, what if you want the final $this after the loop?
< TimToady> and the failure mode of 'always true' is usually pretty obvious
< TimToady> so I tend to approach this one from the side of "don't rule out valid code"
< Util> 'always false' looks obvious too
< Util> +1 on "don't rule out valid code".
< Util> "warn if the RHS is constant" would catch many errors.
Migrated from rt.perl.org#127206 (status was 'new')
Searchable as RT127206$
The text was updated successfully, but these errors were encountered: