[ruby-core:115991] [Ruby master Bug#20111] `defined?` returns `expression` for assignment operators combined with fully qualified constants

Issue #20111 has been reported by andrykonchin (Andrew Konchin). ---------------------------------------- Bug #20111: `defined?` returns `expression` for assignment operators combined with fully qualified constants https://bugs.ruby-lang.org/issues/20111 * Author: andrykonchin (Andrew Konchin) * Status: Open * Priority: Normal * ruby -v: 3.2.2 * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- `defined?` doesn't consider &&=, ||= and other ...= operators as `assignment`: ```ruby defined?(A::B += 1) # => "expression" defined?(A::B &&= true) # => "expression" defined?(A::B ||= true) # => "expression" ``` But consider as `assignment` ordinal assignment: ```ruby defined?(A::B = 1) # => "assignment" ``` Wondering if it's expected behaviour. -- https://bugs.ruby-lang.org/

Issue #20111 has been updated by Eregon (Benoit Daloze). At least it seems inconsistent with `defined?(A += 1)` and `defined?(a += 1)` which are both `"assignment"` ---------------------------------------- Bug #20111: `defined?` returns `expression` for assignment operators combined with fully qualified constants https://bugs.ruby-lang.org/issues/20111#change-105956 * Author: andrykonchin (Andrew Konchin) * Status: Open * Priority: Normal * ruby -v: 3.2.2 * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- `defined?` doesn't consider &&=, ||= and other ...= operators as `assignment`: ```ruby defined?(A::B += 1) # => "expression" defined?(A::B &&= true) # => "expression" defined?(A::B ||= true) # => "expression" ``` But consider as `assignment` ordinal assignment: ```ruby defined?(A::B = 1) # => "assignment" ``` Wondering if it's expected behaviour. -- https://bugs.ruby-lang.org/

Issue #20111 has been updated by jeremyevans0 (Jeremy Evans). I submitted a pull request to fix this: https://github.com/ruby/ruby/pull/9476 ---------------------------------------- Bug #20111: `defined?` returns `expression` for assignment operators combined with fully qualified constants https://bugs.ruby-lang.org/issues/20111#change-106166 * Author: andrykonchin (Andrew Konchin) * Status: Open * Priority: Normal * ruby -v: 3.2.2 * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- `defined?` doesn't consider &&=, ||= and other ...= operators as `assignment`: ```ruby defined?(A::B += 1) # => "expression" defined?(A::B &&= true) # => "expression" defined?(A::B ||= true) # => "expression" ``` But considers as `assignment` ordinal assignment: ```ruby defined?(A::B = 1) # => "assignment" ``` Wondering if it's expected behaviour. -- https://bugs.ruby-lang.org/

Issue #20111 has been updated by ko1 (Koichi Sasada). Just curious, who cares the difference? ---------------------------------------- Bug #20111: `defined?` returns `expression` for assignment operators combined with fully qualified constants https://bugs.ruby-lang.org/issues/20111#change-106733 * Author: andrykonchin (Andrew Konchin) * Status: Closed * Priority: Normal * ruby -v: 3.2.2 * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- `defined?` doesn't consider &&=, ||= and other ...= operators as `assignment`: ```ruby defined?(A::B += 1) # => "expression" defined?(A::B &&= true) # => "expression" defined?(A::B ||= true) # => "expression" ``` But considers as `assignment` ordinal assignment: ```ruby defined?(A::B = 1) # => "assignment" ``` Wondering if it's expected behaviour. -- https://bugs.ruby-lang.org/

Issue #20111 has been updated by Eregon (Benoit Daloze). @ko1 Just inconsistency discovered while implementing `defined?` for these various constructs. ---------------------------------------- Bug #20111: `defined?` returns `expression` for assignment operators combined with fully qualified constants https://bugs.ruby-lang.org/issues/20111#change-106759 * Author: andrykonchin (Andrew Konchin) * Status: Closed * Priority: Normal * ruby -v: 3.2.2 * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- `defined?` doesn't consider &&=, ||= and other ...= operators as `assignment`: ```ruby defined?(A::B += 1) # => "expression" defined?(A::B &&= true) # => "expression" defined?(A::B ||= true) # => "expression" ``` But considers as `assignment` ordinal assignment: ```ruby defined?(A::B = 1) # => "assignment" ``` Wondering if it's expected behaviour. -- https://bugs.ruby-lang.org/
participants (4)
-
andrykonchin (Andrew Konchin)
-
Eregon (Benoit Daloze)
-
jeremyevans0 (Jeremy Evans)
-
ko1 (Koichi Sasada)