[ruby-core:114707] [Ruby master Bug#19876] Equality chaining

Issue #19876 has been reported by kddnewton (Kevin Newton). ---------------------------------------- Bug #19876: Equality chaining https://bugs.ruby-lang.org/issues/19876 * Author: kddnewton (Kevin Newton) * Status: Open * Priority: Normal * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- It appears that you cannot chain `==`, `!=`, `<=>`, `=~`, `!~`, `===`: ``` ruby foo == bar == baz ``` but you can chain all of the other operators: ``` ruby 1 << 2 << 3 ``` I'm not sure if I've missed some. I would just like to know if this is a bug. If it's not, then I need to know which operators cannot be chained. At the moment all of these can be chained in YARP, but if it's desired behavior that that is a syntax error, I need to explicitly disallow this. -- https://bugs.ruby-lang.org/

Issue #19876 has been updated by mame (Yusuke Endoh). I think it is by design. They are marked as `%nonassoc` in parse.y. https://github.com/ruby/ruby/blob/6e64d4370456190541705ec4c6cf3af6bf4ac647/p... ``` %nonassoc tCMP tEQ tEQQ tNEQ tMATCH tNMATCH ``` ---------------------------------------- Bug #19876: Equality chaining https://bugs.ruby-lang.org/issues/19876#change-104542 * Author: kddnewton (Kevin Newton) * Status: Open * Priority: Normal * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- It appears that you cannot chain `==`, `!=`, `<=>`, `=~`, `!~`, `===`: ``` ruby foo == bar == baz ``` but you can chain all of the other operators: ``` ruby 1 << 2 << 3 ``` I'm not sure if I've missed some. I would just like to know if this is a bug. If it's not, then I need to know which operators cannot be chained. At the moment all of these can be chained in YARP, but if it's desired behavior that that is a syntax error, I need to explicitly disallow this. -- https://bugs.ruby-lang.org/

Issue #19876 has been updated by kddnewton (Kevin Newton). Status changed from Open to Closed Okay. I will make this behavior match. ---------------------------------------- Bug #19876: Equality chaining https://bugs.ruby-lang.org/issues/19876#change-104543 * Author: kddnewton (Kevin Newton) * Status: Closed * Priority: Normal * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- It appears that you cannot chain `==`, `!=`, `<=>`, `=~`, `!~`, `===`: ``` ruby foo == bar == baz ``` but you can chain all of the other operators: ``` ruby 1 << 2 << 3 ``` I'm not sure if I've missed some. I would just like to know if this is a bug. If it's not, then I need to know which operators cannot be chained. At the moment all of these can be chained in YARP, but if it's desired behavior that that is a syntax error, I need to explicitly disallow this. -- https://bugs.ruby-lang.org/
participants (2)
-
kddnewton (Kevin Newton)
-
mame (Yusuke Endoh)