Skip to content

Commit c9f55c4

Browse files
committed
Extra "" around singleton in {Name|No}MethodError
This was weirdly hard to see in reading MRI's logic where it adds a break to jump past reinspecting the String it makes only for singletons (other cases still are module/classes to be inspected). This fixes a single spec failure in ruby/language.
1 parent 0113a90 commit c9f55c4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

core/src/main/java/org/jruby/RubyNameError.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,17 +150,20 @@ public IRubyObject to_str(ThreadContext context) {
150150
if (klass.isSingleton()) {
151151
separator = newString(context, "");
152152
if (object == runtime.getTopSelf()) {
153-
classTmp = newString(context, "main");
153+
className = newString(context, "main");
154154
} else {
155-
classTmp = object.anyToString();
155+
className = (RubyString) object.anyToString();
156156
}
157157
} else {
158158
separator = newString(context, "an instance of ");
159159
classTmp = klass.getRealClass();
160+
className = getNameOrInspect(context, classTmp);
160161
}
162+
} else {
163+
className = getNameOrInspect(context, classTmp);
161164
}
162165

163-
className = getNameOrInspect(context, classTmp);
166+
164167
}
165168

166169
RubyArray arr = RubyArray.newArray(runtime, this.name, description, separator, className);

0 commit comments

Comments
 (0)