Actions
Bug #22654
openparse.y should reject /o regexp literal as singleton method receiver
Bug #22654:
parse.y should reject /o regexp literal as singleton method receiver
Description
parse.y rejects literals in a singleton method receiver:
$ ruby --parser=parse.y -ve 'def (/a#{1}/).f; end'
ruby 4.1.0dev (2026-11-19T20:16:32Z master 5cefc5f906) [arm64-darwin23]
-e:1: can't define singleton method for literals
def (/a#{1}/).f; end
ruby: compile error (SyntaxError)
but if you wrap it in /o, it fails at runtime
$ ruby --parser=parse.y -ve 'def (/a#{1}/o).f; end'
ruby 4.1.0dev (2026-11-19T20:16:32Z master 5cefc5f906) [arm64-darwin23]
-e:1:in '<main>': can't modify frozen Regexp: /a1/ (FrozenError)
I think that should fail at parse time as well.
No data to display
Actions