Skip to content

Commit ce18482

Browse files
committed
Normalize parameters names like _$N to _
TruffleRuby adds a "$N" suffix to parameter names to make them unique, but that is only possible if the parameter name is `_`. This internal implementation detail then leaks to the user when the user calls `parameters` on a method or proc that has multiple parameters defined with the name `_`. This commit matches parameter names that start with `_$` and normalizes them to be `_` as they are being assembled into the `parameters` array.
1 parent fbbc027 commit ce18482

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/main/java/org/truffleruby/language/arguments/ArgumentDescriptorUtils.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ private static RubyArray toArray(RubyLanguage language, RubyContext context, Arg
4747
if (argType.anonymous || name == null) {
4848
store = new Object[]{ language.getSymbol(argType.symbolicName) };
4949
} else {
50+
// make sure to normalize parameter names to "_" if they start with "_$"
51+
if (name.startsWith("_$")) {
52+
name = "_";
53+
}
54+
5055
store = new Object[]{ language.getSymbol(argType.symbolicName), language.getSymbol(name) };
5156
}
5257

0 commit comments

Comments
 (0)