fix: respect return value of constructors

This commit is contained in:
TopchetoEU 2024-02-21 11:01:33 +02:00
parent 285960bdd6
commit c6dc031cfd
Signed by: topchetoeu
GPG Key ID: 6531B8583E5F6ED4
3 changed files with 1 additions and 4 deletions

View File

@ -6,7 +6,6 @@ import me.topchetoeu.jscript.core.engine.Context;
public abstract class FunctionValue extends ObjectValue {
public String name = "";
public boolean special = false;
public int length;
@Override

View File

@ -411,7 +411,7 @@ public class Values {
var ret = call(ctx, func, res, args);
if (ret != null && func instanceof FunctionValue && ((FunctionValue)func).special) return ret;
if (!isPrimitive(ret)) return ret;
return res;
}
catch (IllegalArgumentException e) {

View File

@ -247,8 +247,6 @@ public class NativeWrapperProvider implements WrapperProvider {
new NativeFunction(getName(clazz), args -> { throw EngineException.ofError("This constructor is not invokable."); }) :
create(getName(clazz), constr);
res.special = true;
apply(res, ctx, ExposeTarget.CONSTRUCTOR, clazz);
return res;