[#108552] [Ruby master Bug#18782] Race conditions in autoload when loading the same feature with multiple threads. — "ioquatix (Samuel Williams)" <noreply@...>
Issue #18782 has been reported by ioquatix (Samuel Williams).
11 messages
2022/05/14
[ruby-core:108620] [Ruby master Feature#18742] Introduce a way to tell if a method invokes the `super` keyword
From:
"matz (Yukihiro Matsumoto)" <noreply@...>
Date:
2022-05-19 08:09:16 UTC
List:
ruby-core #108620
Issue #18742 has been updated by matz (Yukihiro Matsumoto).
Status changed from Open to Rejected
First, I am afraid that no_clobber checks using `super` would not work well. People would override methods without using `super` more often that you may expect. Some may copy code from the parent methods, some may just reimplement methods. So the biggest use-case is not valid from my POV.
Second, by the core method naming convention we do not use third-person singular present form (e.g 'include?' instead of 'includes?'). Some (especially native English speaker) may feel unnatural, but we set the rule, and we are not going to change it for the foreseeable future.
For no_clobber, I propose the following instead:
```ruby
class A
def foo
end
def bar
end
end
class B<A
override def foo
end
def bar
end
no_clobber # checks overriding methods here
end
```
So we close this issue for now. If you think of a new real world use-case, please revisit.
Matz.
----------------------------------------
Feature #18742: Introduce a way to tell if a method invokes the `super` keyword
https://bugs.ruby-lang.org/issues/18742#change-97656
* Author: Dan0042 (Daniel DeLorme)
* Status: Rejected
* Priority: Normal
----------------------------------------
In order to implement a "no clobber" checker as in #18618, I would like to have a way to check if a method calls `super` or not.
So I'm thinking that something along the line of `Method#calls_super?` could return true/false if the method simply contains the `super` keyword. I'm not really interested in handling weird/artificial edge cases with eval and binding and whatnot.
```ruby
class X
def a
end; p instance_method(:a).calls_super? #=> false
def b
super
end; p instance_method(:b).calls_super? #=> true
def c
super if false
end; p instance_method(:c).calls_super? #=> true
def d
eval 'super'
end; p instance_method(:d).calls_super? #=> false (I doubt there's a reasonable way for this to return true)
end
```
With the above it would be possible to warn against a method that has a `super_method` but doesn't use the `super` keyword.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>