duktape
duktape copied to clipboard
An issue about Error.prototype.toString
Version
Overview
According to the ES 5.1 or 6, when the parameter in Error.prototype.toString.call() is a function, if the function name is not empty but the message is empty, the function name will be returned. However, duktape returned empty. So I think there may be a problem here.
Testcase
var NISLFuzzingFunc = function (e) {
return Error.prototype.toString.call(e);
};
var NISLParameter0 = function(){};
var NISLCallingResult = NISLFuzzingFunc(NISLParameter0);
print(NISLCallingResult);
Actual Results
Expected Results
NISLParameter0
The function in the test is actually anonymous (empty name):
var NISLParameter0 = function(){};
Duktape doesn't automatically default the name of the function based on the assignment (i.e. name = NISLParameter0) which is post-ES5.1 behavior. So the function is anonymous:
duk> var NISLParameter0 = function(){};
= undefined
duk> NISLParameter0.name
= ""
If you give it a name explicitly:
var NISLFuzzingFunc = function (e) {
return Error.prototype.toString.call(e);
};
var NISLParameter0 = function NISLParameter0(){};
var NISLCallingResult = NISLFuzzingFunc(NISLParameter0);
print(NISLCallingResult);
The test prints:
NISLParameter0
@svaarala Thank you for your reply. In addition, I would like to ask whether Duktape will support this feature in next versions?