V8 JavaScript:为什么C ++构造函数过滤代理?

看来,V8的C + +代码(testing人员)不把代理作为一个对象,从而返回默认的目标。 纯JavaScript(其他)中的相同场景按预期工作。

C ++中实现的pass through函数

static void tester(const FunctionCallbackInfo<Value>& info) { if (info.Length() > 0) { info.GetReturnValue().Set(info[0]); } } 

安装代码(从应用程序周围收集)

 Local<String> testerString = String::NewFromUtf8(isolate, "tester", NewStringType::kNormal).ToLocalChecked(); Local<ObjectTemplate> globalTemplate = ObjectTemplate::New(isolate); globalTemplate->Set(testerString, FunctionTemplate::New(isolate, tester), DontEnum); Local<Context> context = Context::New(isolate, nullptr, globalTemplate, Local<Value>()); 

JavaScripttesting,与C ++和JavaScript交互,对象和代理,函数和构造函数。

 function other(x) { return x; } { let a = tester({x: 10}); let b = new tester({x: 10}); let c = tester(new Proxy({}, {get: function(target, name) { return name; }})); let d = new tester(new Proxy({}, {get: function(target, name) { return name; }})); print(ax); print(bx); print(cx); print(dx); } { let a = other({x: 10}); let b = new other({x: 10}); let c = other(new Proxy({}, {get: function(target, name) { return name; }})); let d = new other(new Proxy({}, {get: function(target, name) { return name; }})); print(ax); print(bx); print(cx); print(dx); } 

输出:

 10 10 x undefined 10 10 x x 

V8 dev在这里。 这确实看起来像一个错误。 你能否提交一份错误报告?