Wiki

Ticket #242 (closed defect: wontfix)

Opened 8 years ago

Last modified 8 years ago

'and' not getting precedence over 'or'

Reported by: nevdelap Owned by: nevdelap
Priority: major Milestone:
Component: Cobra Compiler Version: 0.8.0
Keywords: Cc:

Description

class P

	def main is shared
		assert true or (false and false) # Ok
		assert true or false and false   # Barf!

Change History

follow-up: ↓ 2   Changed 8 years ago by hopscc

'and' and 'or' actually have the same precedence and as binary ops they bind to their immediate left and right ( of-less-or-equal precedence) operands so the above is same as

assert (true or false) and false

in reply to: ↑ 1   Changed 8 years ago by nevdelap

Replying to hopscc:

'and' and 'or' actually have the same precedence and as binary ops they bind to their immediate left and right ( of-less-or-equal precedence) operands so the above is same as
{{{
assert (true or false) and false
}}}

Yes indeed. I misworded.

I should have said and doesn't have precedence over or, which of course it should.

The same is the bug and

assert true or false and false

should be evaluated the same as

assert true or (false and false)

  Changed 8 years ago by nevdelap

  • summary changed from 'or' getting precedence over 'and' to 'and' not getting precedence over 'or'

  Changed 8 years ago by Chuck

  • status changed from new to assigned
  • owner set to nevdelap

This was intentional rather than accidental. I don't see that adding another operator precedence level is advantageous, or that you wouldn't want the parens for added clarity. I'll close this ticket unless I'm convinced otherwise.

  Changed 8 years ago by nevdelap

  • status changed from assigned to accepted

It's not going to matter, but for posterity, 'implies' should have a lower precedence than 'or'.

  Changed 8 years ago by nevdelap

  • status changed from accepted to closed
  • resolution set to wontfix
Note: See TracTickets for help on using tickets.