Version/platform/runtime used
.NET 8.0, Jint 4.x
Describe the bug
var engine = new Engine();
var obj = new JsObject(engine);
var getterFunction = (IFunction)new Parser().ParseExpression(
"function() { return 'test'.match(/[a-z]/)?.[0]; }" // Fails
// "function() { return 'test'.match(new RegExp('[a-z]'))?.[0]; }" // RegExp will work
);
var getter = new ScriptFunction(engine, getterFunction, true);
obj.FastSetProperty("name", new GetSetPropertyDescriptor(getter, null, true, false));
engine.SetValue("customObj", obj);
engine.Execute(string.Empty);
var result = engine.GetValue("customObj").AsObject();
var name = result.Get("name").ToString();
Console.WriteLine("Property [name]: {0}", name);
Additional context
In 3.x it worked as expected
If getters are defined via code - it works fine in 4.x too.