@@ -94,5 +94,12 @@ assertEqual(booleanCount, 1);
.SetValue("assertEqual", new Action<object, object>((a, b) => Assert.Equal(b, a)))
.Execute(script);
}
+
+ [Fact]
+ public void AnonymousLambdaShouldHaveNameDefined()
+ {
+ var engine = new Engine();
+ Assert.True(engine.Evaluate("(()=>{}).hasOwnProperty('name')").AsBoolean());
+ }
@@ -213,7 +213,7 @@ namespace Jint.Native.Function
internal void SetFunctionName(JsValue name, string prefix = null, bool force = false)
{
- if (!force && _nameDescriptor != null && !UnwrapJsValue(_nameDescriptor).IsUndefined())
+ if (!force && _nameDescriptor != null && UnwrapJsValue(_nameDescriptor) != JsString.Empty)
return;
@@ -1,4 +1,5 @@
using Esprima.Ast;
+using Jint.Native;
using Jint.Native.Function;
namespace Jint.Runtime.Interpreter.Expressions
@@ -25,6 +26,11 @@ namespace Jint.Runtime.Interpreter.Expressions
FunctionThisMode.Lexical,
proto: engine.Realm.Intrinsics.Function.PrototypeObject);
+ if (_function.Name is null)
+ closure.SetFunctionName(JsString.Empty);
return NormalCompletion(closure);