Open elebow opened 2 years ago
Just to be clear: This should be a syntax error when super
is used outside a def.
It might be more complicated when the proc literal is actually used in side a def. However, the following code actually works - which is a bit surprising to me (but probably fine?):
class Foo
def bar
"Foo#bar"
end
end
class Bar < Foo
def bar
-> { super }
end
end
Bar.new.bar.call # => "Foo#bar"
previous_def
is similar, but it has a nicer error message already:
->{ previous_def } # Error: there is no previous definition of '->'
Although it's a semantic error. It should already be a syntax error when previous_def
is used outside a def.
Bug Report
Minimal reproduction code
OS is Debian stable (11.2)