Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion Jint.Tests/Runtime/EngineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,21 @@ public void EvalFunctionParseAndExecuteCode()
");
}

[Fact]
public void EvalFunctionWithTargetNewParse()
{
RunTest(@"
const code = `function MyClass() {
if (!new.target) throw new Error('Use MyClass as constructor!');
}`;
eval(code);
const code2 = `var x = function () {
if (!new.target) throw new Error('Use as constructor!');
}`;
eval(code2);
");
}

[Fact]
public void ForInStatement()
{
Expand Down Expand Up @@ -3098,4 +3113,4 @@ public bool TryConvert(object value, Type type, IFormatProvider formatProvider,
throw new NotImplementedException();
}
}
}
}
10 changes: 10 additions & 0 deletions Jint/Native/Function/EvalFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,5 +217,15 @@ protected override object VisitMetaProperty(MetaProperty metaProperty)
_containsSuperCall |= callExpression.Callee.Type == NodeType.Super;
return base.VisitCallExpression(callExpression);
}

protected override object? VisitFunctionDeclaration(FunctionDeclaration node)
{
return node;
}

protected override object? VisitFunctionExpression(FunctionExpression node)
{
return node;
}
}
}