fix: respect return value of constructors
This commit is contained in:
parent
285960bdd6
commit
c6dc031cfd
@ -6,7 +6,6 @@ import me.topchetoeu.jscript.core.engine.Context;
|
|||||||
|
|
||||||
public abstract class FunctionValue extends ObjectValue {
|
public abstract class FunctionValue extends ObjectValue {
|
||||||
public String name = "";
|
public String name = "";
|
||||||
public boolean special = false;
|
|
||||||
public int length;
|
public int length;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -411,7 +411,7 @@ public class Values {
|
|||||||
|
|
||||||
var ret = call(ctx, func, res, args);
|
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;
|
return res;
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException e) {
|
catch (IllegalArgumentException e) {
|
||||||
|
@ -247,8 +247,6 @@ public class NativeWrapperProvider implements WrapperProvider {
|
|||||||
new NativeFunction(getName(clazz), args -> { throw EngineException.ofError("This constructor is not invokable."); }) :
|
new NativeFunction(getName(clazz), args -> { throw EngineException.ofError("This constructor is not invokable."); }) :
|
||||||
create(getName(clazz), constr);
|
create(getName(clazz), constr);
|
||||||
|
|
||||||
res.special = true;
|
|
||||||
|
|
||||||
apply(res, ctx, ExposeTarget.CONSTRUCTOR, clazz);
|
apply(res, ctx, ExposeTarget.CONSTRUCTOR, clazz);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
Loading…
Reference in New Issue
Block a user