From: "rits (First Last)" Date: 2013-12-18T03:57:36+09:00 Subject: [ruby-core:59161] [ruby-trunk - Bug #9251] ! operator has lower precedence than = in an assignment expression Issue #9251 has been updated by rits (First Last). > Studying this simple grammar with some examples shows that LALR is capable of figuring out that the restriction on LHS is more 'important' than the priority of operations with higher priority than '='. You say it almost with admiration as if this is a great feature, but as I pointed out it's worse than worthless. being able to write "while ! a = b" is hardly a desirable feature, it's a poor way to communicate intent (this "feature" isn't documented and not intuitive, as it goes against the precedence table that is well documented, so many/most would be surprised by it) Close to 100% would write "while !(a = b)" or at least "while not a = b" (not is documented having lower precedence than =) and there clear benefits in a * -b = -c / d producing an error, rather than silently evaluating an almost certainly unintended expression. ---------------------------------------- Bug #9251: ! operator has lower precedence than = in an assignment expression https://bugs.ruby-lang.org/issues/9251#change-43725 Author: rits (First Last) Status: Third Party's Issue Priority: Low Assignee: pragdave (Dave Thomas) Category: doc Target version: ruby -v: ruby 2.0.0p353 (2013-11-22 revision 43784) [i686-linux] Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN irb(main):001:0> !a = 1 (irb):1: warning: found = in conditional, should be == => false irb(main):002:0> a => 1 ! is supposed to have higher precedence than =, so !a = 1 should be (!a) = 1, and thus an error, not !(a = 1) -- http://bugs.ruby-lang.org/