From a39c804cda7d04b5b11c8dc5e97ccbd19c2a30d6 Mon Sep 17 00:00:00 2001 From: nykwono Date: Tue, 22 Sep 2026 00:52:34 -0400 Subject: [PATCH] Fix overriding constructors on native classes returning an error --- polymod/hscript/_internal/PolymodScriptClass.hx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/polymod/hscript/_internal/PolymodScriptClass.hx b/polymod/hscript/_internal/PolymodScriptClass.hx index 410bc6c7..8c73b9f6 100644 --- a/polymod/hscript/_internal/PolymodScriptClass.hx +++ b/polymod/hscript/_internal/PolymodScriptClass.hx @@ -1050,6 +1050,9 @@ class PolymodScriptClass #if POLYMOD_STRICT_SYNTAX if (f.access.contains(AOverride) && !superHasField(f.name)) { + // Native class constructors can not be retrieved at runtime so `superHasField` does not account for them so we ignore them. + if (f.name == 'new' && !Std.isOfType(superClass, PolymodScriptClass)) return; + // Throw an error if a function is declared overwritten but isn't overriding anything. throw 'Field ' + '"${f.name}"' + 'is declared "override"' + "but doesn't override any field."; } @@ -1226,7 +1229,7 @@ class PolymodScriptClass return false; } - + /** * Checks if the class has a script function with the given name, * which has been purged due to an uncaught exception when it was previously called.