Skip Menu |
Report information
Id: 121108
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: cpan [at] zoffix.com
davidnmfarrell [at] gmail.com
peschwa [at] gmail.com
Cc:
AdminCc:

Severity: (no value)
Tag: Bug
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: [BUG] Inequality (!=) misparsed as assignment.
Download (untitled) / with headers
text/plain 1.1k
The following test in roast currently is skipped for Rakudo as a nom regression: { # Check a 3 != 3 vs 3 !=3 parsing issue that can cropped up in Rakudo. # Needs careful following of STD to get it right. :-) my $r; sub foo($x) { $r = $x } foo 3 != 3; is($r, False, 'sanity 3 != 3'); foo 3 !=3; is($r, False, 'ensure 3 !=3 gives same result as 3 != 3'); } STD parses the comparision successfully: <psch> std: 3 !=3 <camelia> std 09dda5b: OUTPUT«ok 00:01 122m␤» while Rakudo tries to assign and fails: <psch> r: say 3 !=3 <camelia> rakudo-parrot c884dc: OUTPUT«Cannot modify an immutable value␤ in sub infix:<=> at gen/parrot/CORE.setting:16361␤ in block at gen/parrot/CORE.setting:16706␤ in block at /tmp/tmpfile:1␤␤» 23:33 <camelia> ..rakudo-moar c884dc: OUTPUT«No such method 'STORE' for invocant of type 'Int'␤ in sub infix:<=> at src/gen/m-CORE.setting:16092␤ in block at src/gen/m-CORE.setting:16436␤ in block at /tmp/tmpfile:1␤␤» <camelia> ..rakudo-jvm c884dc: OUTPUT«Cannot modify an immutable value␤ in sub infix:<=> at gen/jvm/CORE.setting:16095␤ in block at gen/jvm/CORE.setting:16439␤ in block at /tmp/tmpfile:1␤␤»
Download (untitled) / with headers
text/plain 663b
that STD says it is okay does not mean much here, because: ./viv -e 'say 1 != 3' [...] └─VAST::SYM_infix__S_BangEqual, BEG: 6, END: 8, SYM: !=, TEXT: !=, WS: 1, _from: 8, _op: VAST::infix__S_BangEqual, _pos: 8, _specific: 1, assoc: chain, dba: chaining, diffy: 1, iffy: 1, prec: m=, pure: 1 [...] ./viv -e 'say 1 !=3' [...] └─VAST::SYM_infix__S_Equal, BEG: 7, END: 8, SYM: =, TEXT: =, _from: 8, _op: VAST::infix__S_Equal, _pos: 8, _specific: 1, assoc: right, dba: list assignment, fiddly: 1, prec: i=, pure: 0 [...] So already STD has a problem here and I will open a STD-issue in its github repo, see: https://github.com/perl6/std/issues/7
Subject: [BUG] Lack of space after != operator changes behaviour
Download (untitled) / with headers
text/plain 677b
If the programmer omits the space after the != (not equal, numeral) operator, the behavior of the operator changes to: [assign RHS to LHS, return !RHS], as can be seen from these examples: <ZoffixW> m: say 0 != 0 <camelia> rakudo-moar f05c77: OUTPUT«False␤» <ZoffixW> m: say 0 !=0 <camelia> rakudo-moar f05c77: OUTPUT«Cannot modify an immutable Int␤ in block <unit> at /tmp/7Z5OWfl3Go line 1␤␤» <ZoffixW> m: my $x = 42; say $x !=0; say $x <camelia> rakudo-moar f05c77: OUTPUT«True␤0␤» <ZoffixW> m: my $x = 0; say $x !=42; say $x <camelia> rakudo-moar f05c77: OUTPUT«False␤42␤» This behaviour is confusing and probably not wanted by most programmers.
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 872b
On Mon Apr 25 09:20:43 2016, cpan@zoffix.com wrote: Show quoted text
> > If the programmer omits the space after the != (not equal, numeral) > operator, the behavior of the operator changes to: [assign RHS to LHS, > return !RHS], as can be seen from these examples: > > <ZoffixW> m: say 0 != 0 > <camelia> rakudo-moar f05c77: OUTPUT«False␤» > <ZoffixW> m: say 0 !=0 > <camelia> rakudo-moar f05c77: OUTPUT«Cannot modify an immutable Int␤ > in block <unit> at /tmp/7Z5OWfl3Go line 1␤␤» > <ZoffixW> m: my $x = 42; say $x !=0; say $x > <camelia> rakudo-moar f05c77: OUTPUT«True␤0␤» > <ZoffixW> m: my $x = 0; say $x !=42; say $x > <camelia> rakudo-moar f05c77: OUTPUT«False␤42␤» > > This behaviour is confusing and probably not wanted by most > programmers.
This is a dupe of https://rt.perl.org/Ticket/Display.html?id=121108, which is wrongly titled at the moment.


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

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org