Skip to content

Commit

Permalink
Remove __id__ from warning targets (#4924)
Browse files Browse the repository at this point in the history
* Fix a warning message

In MRI, this warning is

```
-e:1: warning: undefining `object_id' may cause serious problems
```

* Add `initialize` to warning targets

By this commit `TestModule#test_undef` will be passed.

* Remove `__id__` from warning targets

`__id__` is not listed on warning targets in MRI.


The MRI code is: 
```
  if (id == object_id || id == id__send__ || id == idInitialize) {
	rb_warn("undefining `%s' may cause serious problems", rb_id2name(id));
  }
```
yui-knk authored and kares committed Jan 2, 2018
1 parent ec3f91d commit 1534e7f
Showing 2 changed files with 2 additions and 3 deletions.
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/RubyModule.java
Original file line number Diff line number Diff line change
@@ -1129,8 +1129,8 @@ public void undef(ThreadContext context, String name) {
Ruby runtime = context.runtime;

testFrozen("module");
if (name.equals("__id__") || name.equals("__send__") || name.equals("object_id")) {
runtime.getWarnings().warn(ID.UNDEFINING_BAD, "undefining `"+ name +"' may cause serious problem");
if (name.equals("__send__") || name.equals("object_id") || name.equals("initialize")) {
runtime.getWarnings().warn(ID.UNDEFINING_BAD, "undefining `"+ name +"' may cause serious problems");
}

if (name.equals("method_missing")) {
1 change: 0 additions & 1 deletion test/mri/excludes/TestModule.rb
Original file line number Diff line number Diff line change
@@ -11,5 +11,4 @@
exclude :test_private_constant_reopen, "needs investigation"
exclude :test_private_constant_with_no_args, "needs investigation"
exclude :test_protected_singleton_method, "needs investigation"
exclude :test_undef, "needs investigation"
exclude :test_prepend_each_classes, "needs investigation - ancestors do not match"

0 comments on commit 1534e7f

Please sign in to comment.