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

ne is not identical to !eq in new infix subs, if statements #3100

Closed
p6rt opened this issue Apr 12, 2013 · 6 comments
Closed

ne is not identical to !eq in new infix subs, if statements #3100

p6rt opened this issue Apr 12, 2013 · 6 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Apr 12, 2013

Migrated from rt.perl.org#117579 (status was 'resolved')

Searchable as RT117579$

@p6rt
Copy link
Author

p6rt commented Apr 12, 2013

From @labster

multi infix​:<eq> (Int $a, Int $b) { $a * $b == 0 };
say 1 eq 0, 1 ne 0, 1 !eq 0;
TrueTrueFalse

1 ne 0 looks like it's calling .Str here, or otherwise it would follow my
strange definition of integer <eq>.

if 'a' ne 'a'|'b'|'c' { say True }
True
if 'a' !eq 'a'|'b'|'c' { say True }
Nil
'a' ne 'a'|'b'|'c'
False

I suspect these bugs are related.

@p6rt
Copy link
Author

p6rt commented Apr 13, 2013

From @moritz

On Fri Apr 12 01​:59​:19 2013, labster wrote​:

multi infix​:<eq> (Int $a, Int $b) { $a * $b == 0 };
say 1 eq 0, 1 ne 0, 1 !eq 0;
TrueTrueFalse

1 ne 0 looks like it's calling .Str here, or otherwise it would follow my
strange definition of integer <eq>.

Sure, you didn't define an infix​:<ne> for integers, which is why the
built-in one is used, which stringifies. As specified. (Afaict the specs
don't contain any wording about infix ne forwarding to infix eq ones,
which would make infix ne slower than necessary. So you must override
infix​:<ne> yourself).

if 'a' ne 'a'|'b'|'c' { say True }
True
if 'a' !eq 'a'|'b'|'c' { say True }
Nil
'a' ne 'a'|'b'|'c'
False

I'm pretty sure both should be the as as

!('a' eq 'a'|'b'|'c')

and thus return False.

@p6rt
Copy link
Author

p6rt commented Apr 13, 2013

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

@p6rt
Copy link
Author

p6rt commented Apr 13, 2013

From @moritz

It's an optimization bug​:

$ cat junc.pl
if 'a' ne 'a'|'b'|'c' { say True }
$ ./perl6 --optimize=0 junc.pl
$ ./perl6 junc.pl
True
$

@p6rt
Copy link
Author

p6rt commented Apr 14, 2013

From @timo

My optimization didn't check the arguments of the operator to see if they
accept Any or Mu. Thus it autothreaded the ne although it should have
passed the junction as an argument.

There now is a bit of test code in roast and the bug is fixed.

Thanks!

@p6rt
Copy link
Author

p6rt commented Apr 14, 2013

@timo - Status changed from 'open' to 'resolved'

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