From 98e5299f9c633695a741b1b3f82e063f15c1efca Mon Sep 17 00:00:00 2001 From: TopchetoEU <36534413+TopchetoEU@users.noreply.github.com> Date: Sat, 21 Sep 2024 18:43:32 +0300 Subject: [PATCH] fix: derived classes use the scope API incorrectly --- .../java/me/topchetoeu/jscript/compilation/ClassNode.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/topchetoeu/jscript/compilation/ClassNode.java b/src/main/java/me/topchetoeu/jscript/compilation/ClassNode.java index af9585a..3efad3b 100644 --- a/src/main/java/me/topchetoeu/jscript/compilation/ClassNode.java +++ b/src/main/java/me/topchetoeu/jscript/compilation/ClassNode.java @@ -99,7 +99,9 @@ public abstract class ClassNode extends FunctionNode { compilePrototype(target); } else { - var subtarget = target.rootEnvironment(JavaScript.COMPILE_ROOT).subtarget(); + var subtarget = target.subtarget().rootEnvironment(JavaScript.COMPILE_ROOT); + subtarget.scope.singleEntry = true; + subtarget.beginScope(); var protoVar = target.scope.defineTemp(); var constrVar = target.scope.defineTemp(); @@ -138,6 +140,7 @@ public abstract class ClassNode extends FunctionNode { compileStatic(staticTarget); compilePrototype(protoTarget); + subtarget.endScope(); } } @@ -228,7 +231,7 @@ public abstract class ClassNode extends FunctionNode { n++; break; } - else ParseRes.error(src.loc(i + n), "Expected a comma or a closing brace."); + // else return ParseRes.error(src.loc(i + n), "Expected a comma or a closing brace."); } return ParseRes.res(new ClassBody(statics, fields, members, params, body, superExpr.result, hasConstr), n);