Skip to content

Commit b80b6bb

Browse files
authored
Make Symbol() comply with the spec
* Add test of `Symbol()` with multiple arguments. * Make `Symbol()` comply with the spec. Specifically, it's handling of the second argument to the constructor.
1 parent c43851a commit b80b6bb

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

rhino/src/main/java/org/mozilla/javascript/NativeSymbol.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,12 @@ private static NativeSymbol getSelf(Scriptable thisObj) {
9090

9191
private static SymbolKey js_constructorCall(
9292
Context cx, Scriptable scope, Scriptable thisObj, Object[] args) {
93-
String desc = null;
93+
String desc;
9494
if (args.length > 0 && !Undefined.isUndefined(args[0])) {
9595
desc = ScriptRuntime.toString(args[0]);
96+
} else {
97+
desc = null;
9698
}
97-
98-
if (args.length > 1) {
99-
return (SymbolKey) args[1];
100-
}
101-
10299
return new SymbolKey(desc, Symbol.Kind.REGULAR);
103100
}
104101

tests/testsrc/jstests/es6/symbols.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ function TestNew() {
5050
symbols.push(Symbol())
5151
symbols.push(Symbol(undefined))
5252
symbols.push(Symbol("66"))
53+
symbols.push(Symbol(undefined, "ignored"))
5354
symbols.push(Symbol(66))
5455
symbols.push(Symbol().valueOf())
5556
symbols.push(indirect())

0 commit comments

Comments
 (0)