Skip to content

Commit 24a762b

Browse files
committed
src: set function names in SetFastMethod helpers
SetMethod() and SetMethodNoSideEffect() with a context and a target object call SetName() on the new function, but the SetFastMethod() and SetFastMethodNoSideEffect() overloads with the same parameters did not. Functions registered through them had an empty name, which is visible in util.types since its predicates became fast API calls. Fixes: #67826 Signed-off-by: Yohannes Desta <yohannesdestagebru10@gmail.com>
1 parent d2812af commit 24a762b

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

‎src/util.cc‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ void SetFastMethod(Local<v8::Context> context,
385385
v8::String::NewFromUtf8(isolate, name.data(), type, name.size())
386386
.ToLocalChecked();
387387
that->Set(context, name_string, function).Check();
388+
function->SetName(name_string);
388389
}
389390

390391
void SetFastMethodNoSideEffect(Local<v8::Context> context,
@@ -407,6 +408,7 @@ void SetFastMethodNoSideEffect(Local<v8::Context> context,
407408
v8::String::NewFromUtf8(isolate, name.data(), type, name.size())
408409
.ToLocalChecked();
409410
that->Set(context, name_string, function).Check();
411+
function->SetName(name_string);
410412
}
411413

412414
void SetFastMethodNoSideEffect(Isolate* isolate,
@@ -499,6 +501,7 @@ void SetFastMethodNoSideEffect(
499501
v8::String::NewFromUtf8(isolate, name.data(), type, name.size())
500502
.ToLocalChecked();
501503
that->Set(context, name_string, function).Check();
504+
function->SetName(name_string);
502505
}
503506

504507
void SetMethodNoSideEffect(Local<v8::Context> context,
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
3+
// The functions in util.types should be named after the property that
4+
// exposes them, including the ones implemented in C++.
5+
// Refs: https://github.com/nodejs/node/issues/67826
6+
7+
require('../common');
8+
const assert = require('assert');
9+
const { types } = require('util');
10+
11+
for (const [key, fn] of Object.entries(types)) {
12+
// isArrayBufferView is ArrayBuffer.isView.
13+
if (key === 'isArrayBufferView') continue;
14+
assert.strictEqual(fn.name, key);
15+
}

0 commit comments

Comments
 (0)