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

Associativity for list operators. WAS: Non-associativeness of infix:<|> and infix:<^> #3321

Closed
p6rt opened this issue Jan 28, 2014 · 5 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Jan 28, 2014

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

Searchable as RT121107$

@p6rt
Copy link
Author

p6rt commented Jan 28, 2014

From @peschwa

In roast currently skipping for rakudo is the following test​:

eval_dies_ok 'my Mu $a = (1 | 2 ^ 3)', '| and ^ may not associate.';

STD says the following​:

<psch> std​: my Mu $a = (1 | 2 ^ 3)
<camelia> std 09dda5b​: OUTPUT«===SORRY!===␤"|" and "^" are non-associative and require parens at /tmp/hzWmyyYWFa line 1​:␤------> my Mu $a = (1 | 2 ^ ⏏3)␤Check failed␤FAILED 00​:01 127m␤»

Rakudo currently parses successfully as right-associative​:

<psch> r​: my Mu $a = (1 | 2 ^ 3); $a.say
<camelia> rakudo-parrot c884dc, rakudo-jvm c884dc, rakudo-moar c884dc​: OUTPUT«any(1, one(2, 3))␤»

<psch> r​: my Mu $a = (1 | 2 ^ 3); $a.say
<camelia> rakudo-parrot c884dc, rakudo-jvm c884dc, rakudo-moar c884dc​: OUTPUT«any(1, one(2, 3))␤»

<psch> r​: $*PERL<compiler><ver>.say
<camelia> rakudo-parrot c884dc, rakudo-jvm c884dc, rakudo-moar c884dc​: OUTPUT«2014.01-42-gc884dc1␤»

@p6rt
Copy link
Author

p6rt commented Jan 28, 2014

From @peschwa

Am Di 28. Jan 2014, 14​:07​:59, peschwa@​gmail.com schrieb​:

In roast currently skipping for rakudo is the following test​:

eval_dies_ok 'my Mu $a = (1 | 2 ^ 3)', '| and ^ may not associate.';

STD says the following​:

<psch> std​: my Mu $a = (1 | 2 ^ 3)
<camelia> std 09dda5b​: OUTPUT«===SORRY!===␤"|" and "^" are non-
associative and require parens at /tmp/hzWmyyYWFa line 1​:␤------> my
Mu $a = (1 | 2 ^ ⏏3)␤Check failed␤FAILED 00​:01 127m␤»

Rakudo currently parses successfully as right-associative​:

<psch> r​: my Mu $a = (1 | 2 ^ 3); $a.say
<camelia> rakudo-parrot c884dc, rakudo-jvm c884dc, rakudo-moar c884dc​:
OUTPUT«any(1, one(2, 3))␤»

<psch> r​: my Mu $a = (1 | 2 ^ 3); $a.say
<camelia> rakudo-parrot c884dc, rakudo-jvm c884dc, rakudo-moar c884dc​:
OUTPUT«any(1, one(2, 3))␤»

<psch> r​: $*PERL<compiler><ver>.say
<camelia> rakudo-parrot c884dc, rakudo-jvm c884dc, rakudo-moar c884dc​:
OUTPUT«2014.01-42-gc884dc1␤»

Applies similarly for​:

eval_dies_ok '1, 2 Z 3, 4 X 5, 6'

which STD rejects with the same warning as above, but Rakudo currently parses as follows​:

<psch> r​: say 1, 2 Z 3, 4 X 5, 6
<camelia> rakudo-parrot c884dc, rakudo-jvm c884dc, rakudo-moar c884dc​: OUTPUT«1 3 2 5␤»

@p6rt
Copy link
Author

p6rt commented Nov 19, 2014

From @usev6

This now throws a typed exception X​::Syntax​::NonAssociative

$ perl6 -e '1, 2 Z 3, 4 X 5, 6'
===SORRY!=== Error while compiling -e
Operators 'Z' and 'X' are non-associative and require parentheses
at -e​:1
------> 1, 2 Z 3, 4 X⏏ 5, 6
  expecting any of​:
  postfix
  infix stopper
  infix or meta-infix

$ perl6 -e 'my Mu $a = (1 | 2 ^ 3)'
===SORRY!=== Error while compiling -e
Operators '|' and '^' are non-associative and require parentheses
at -e​:1
------> my Mu $a = (1 | 2 ⏏^ 3)
  expecting any of​:
  postfix
  infix stopper
  infix or meta-infix

The tests in S03-operators/precedence.t have been unfudged with commit Raku/roast@e8f7579421

I'm closing this ticket now.

1 similar comment
@p6rt
Copy link
Author

p6rt commented Nov 19, 2014

From @usev6

This now throws a typed exception X​::Syntax​::NonAssociative

$ perl6 -e '1, 2 Z 3, 4 X 5, 6'
===SORRY!=== Error while compiling -e
Operators 'Z' and 'X' are non-associative and require parentheses
at -e​:1
------> 1, 2 Z 3, 4 X⏏ 5, 6
  expecting any of​:
  postfix
  infix stopper
  infix or meta-infix

$ perl6 -e 'my Mu $a = (1 | 2 ^ 3)'
===SORRY!=== Error while compiling -e
Operators '|' and '^' are non-associative and require parentheses
at -e​:1
------> my Mu $a = (1 | 2 ⏏^ 3)
  expecting any of​:
  postfix
  infix stopper
  infix or meta-infix

The tests in S03-operators/precedence.t have been unfudged with commit Raku/roast@e8f7579421

I'm closing this ticket now.

@p6rt
Copy link
Author

p6rt commented Nov 19, 2014

@usev6 - Status changed from 'new' to 'resolved'

@p6rt p6rt closed this as completed Nov 19, 2014
@p6rt p6rt added the Bug label Jan 5, 2020
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