Bug #20111
closed
`defined?` returns `expression` for assignment operators combined with fully qualified constants
Added by andrykonchin (Andrew Konchin) 11 months ago.
Updated 9 months ago.
Description
defined?
doesn't consider &&=, ||= and other ...= operators as assignment
:
defined?(A::B += 1) # => "expression"
defined?(A::B &&= true) # => "expression"
defined?(A::B ||= true) # => "expression"
But considers as assignment
ordinal assignment:
defined?(A::B = 1) # => "assignment"
Wondering if it's expected behaviour.
At least it seems inconsistent with defined?(A += 1)
and defined?(a += 1)
which are both "assignment"
- Description updated (diff)
- Status changed from Open to Closed
Applied in changeset git|ef751252711ca7ecabb3e4ad9214fa0d1d63608a.
Make defined? for op asgn expressions to constants use "assignment"
Previously, it used "expression", as that was the default. However,
op asgn expressions to constants use the NODE_OP_CDECL, so recognize
that node type as assignement.
Fixes [Bug #20111]
Just curious, who cares the difference?
@ko1 (Koichi Sasada) Just inconsistency discovered while implementing defined?
for these various constructs.
Also available in: Atom
PDF
Like0
Like0Like0Like0Like1Like0Like1