From 0aa8f116365c97478fc16ffa7ed4f6cd5985e6dd Mon Sep 17 00:00:00 2001 From: Lura Skye Date: Wed, 5 Apr 2023 05:34:24 +0100 Subject: [PATCH 1/2] remove super.findPrototypeId() calls in various objects this seemingly only serves to be annoying and was likely accidental during code cleanup. --- .../java/dev/latvian/mods/rhino/BaseFunction.java | 2 +- .../main/java/dev/latvian/mods/rhino/NativeDate.java | 2 +- .../main/java/dev/latvian/mods/rhino/NativeJSON.java | 2 +- .../java/dev/latvian/mods/rhino/NativeNumber.java | 2 +- .../java/dev/latvian/mods/rhino/NativeString.java | 2 +- .../java/dev/latvian/mods/rhino/NativeWeakMap.java | 2 +- .../java/dev/latvian/mods/rhino/NativeWeakSet.java | 2 +- .../java/dev/latvian/mods/rhino/test/MiscTests.java | 12 +++++++++++- 8 files changed, 18 insertions(+), 8 deletions(-) diff --git a/common/src/main/java/dev/latvian/mods/rhino/BaseFunction.java b/common/src/main/java/dev/latvian/mods/rhino/BaseFunction.java index d4bf23a2..e65ddabe 100644 --- a/common/src/main/java/dev/latvian/mods/rhino/BaseFunction.java +++ b/common/src/main/java/dev/latvian/mods/rhino/BaseFunction.java @@ -537,7 +537,7 @@ protected int findPrototypeId(String s) { case "apply" -> Id_apply; case "call" -> Id_call; case "bind" -> Id_bind; - default -> super.findPrototypeId(s); + default -> 0; }; } } diff --git a/common/src/main/java/dev/latvian/mods/rhino/NativeDate.java b/common/src/main/java/dev/latvian/mods/rhino/NativeDate.java index 7e056c2c..7f0208fa 100644 --- a/common/src/main/java/dev/latvian/mods/rhino/NativeDate.java +++ b/common/src/main/java/dev/latvian/mods/rhino/NativeDate.java @@ -1851,7 +1851,7 @@ protected int findPrototypeId(String s) { case "setYear" -> Id_setYear; case "toISOString" -> Id_toISOString; case "toJSON" -> Id_toJSON; - default -> super.findPrototypeId(s); + default -> 0; }; } } diff --git a/common/src/main/java/dev/latvian/mods/rhino/NativeJSON.java b/common/src/main/java/dev/latvian/mods/rhino/NativeJSON.java index 7f34dc7d..ba7d0cd4 100644 --- a/common/src/main/java/dev/latvian/mods/rhino/NativeJSON.java +++ b/common/src/main/java/dev/latvian/mods/rhino/NativeJSON.java @@ -438,7 +438,7 @@ protected int findPrototypeId(String s) { case "toSource" -> Id_toSource; case "parse" -> Id_parse; case "stringify" -> Id_stringify; - default -> super.findPrototypeId(s); + default -> 0; }; } } diff --git a/common/src/main/java/dev/latvian/mods/rhino/NativeNumber.java b/common/src/main/java/dev/latvian/mods/rhino/NativeNumber.java index 58361ca5..854a9f1a 100644 --- a/common/src/main/java/dev/latvian/mods/rhino/NativeNumber.java +++ b/common/src/main/java/dev/latvian/mods/rhino/NativeNumber.java @@ -339,7 +339,7 @@ protected int findPrototypeId(String s) { case "toFixed" -> Id_toFixed; case "toExponential" -> Id_toExponential; case "toPrecision" -> Id_toPrecision; - default -> super.findPrototypeId(s); + default -> 0; }; } } diff --git a/common/src/main/java/dev/latvian/mods/rhino/NativeString.java b/common/src/main/java/dev/latvian/mods/rhino/NativeString.java index 7b48ebfe..81fd4b1d 100644 --- a/common/src/main/java/dev/latvian/mods/rhino/NativeString.java +++ b/common/src/main/java/dev/latvian/mods/rhino/NativeString.java @@ -1245,7 +1245,7 @@ protected int findPrototypeId(String s) { case "padEnd" -> Id_padEnd; case "trimStart" -> Id_trimStart; case "trimEnd" -> Id_trimEnd; - default -> super.findPrototypeId(s); + default -> 0; }; } } diff --git a/common/src/main/java/dev/latvian/mods/rhino/NativeWeakMap.java b/common/src/main/java/dev/latvian/mods/rhino/NativeWeakMap.java index 900019e6..51a80c4b 100644 --- a/common/src/main/java/dev/latvian/mods/rhino/NativeWeakMap.java +++ b/common/src/main/java/dev/latvian/mods/rhino/NativeWeakMap.java @@ -179,7 +179,7 @@ protected int findPrototypeId(String s) { case "get" -> Id_get; case "has" -> Id_has; case "set" -> Id_set; - default -> super.findPrototypeId(s); + default -> 0; }; } } diff --git a/common/src/main/java/dev/latvian/mods/rhino/NativeWeakSet.java b/common/src/main/java/dev/latvian/mods/rhino/NativeWeakSet.java index f22215a5..2b7dfc2c 100644 --- a/common/src/main/java/dev/latvian/mods/rhino/NativeWeakSet.java +++ b/common/src/main/java/dev/latvian/mods/rhino/NativeWeakSet.java @@ -157,7 +157,7 @@ protected int findPrototypeId(String s) { case "add" -> Id_add; case "delete" -> Id_delete; case "has" -> Id_has; - default -> super.findPrototypeId(s); + default -> 0; }; } diff --git a/common/src/test/java/dev/latvian/mods/rhino/test/MiscTests.java b/common/src/test/java/dev/latvian/mods/rhino/test/MiscTests.java index e8748a8b..0ebab2d4 100644 --- a/common/src/test/java/dev/latvian/mods/rhino/test/MiscTests.java +++ b/common/src/test/java/dev/latvian/mods/rhino/test/MiscTests.java @@ -10,7 +10,17 @@ public class MiscTests { public static final RhinoTest TEST = new RhinoTest("misc").shareScope(); - @Test + public void testFunctionAssignment() { + TEST.test("functionAssignment", + """ + let x = () => {}; + x.abc = 1; + console.info(x.abc); + """, + "1.0" + ); + } + @Order(1) public void init() { TEST.test("init", """ From fd579370715e5f68a10367b0544fbd77fa19f9bb Mon Sep 17 00:00:00 2001 From: Lura Skye Date: Wed, 5 Apr 2023 06:38:47 +0100 Subject: [PATCH 2/2] missed nativeerror --- common/src/main/java/dev/latvian/mods/rhino/NativeError.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/java/dev/latvian/mods/rhino/NativeError.java b/common/src/main/java/dev/latvian/mods/rhino/NativeError.java index 09137951..ba600c97 100644 --- a/common/src/main/java/dev/latvian/mods/rhino/NativeError.java +++ b/common/src/main/java/dev/latvian/mods/rhino/NativeError.java @@ -322,7 +322,7 @@ protected int findPrototypeId(String s) { case "constructor" -> Id_constructor; case "toString" -> Id_toString; case "toSource" -> Id_toSource; - default -> super.findPrototypeId(s); + default -> 0; }; } }