-
Notifications
You must be signed in to change notification settings - Fork 105
Description
BUG Description
Suspected bug in MuJS: When converting an Error object to a string using toString(), MuJS incorrectly appends the stack trace to the resulting string by default. According to the ECMAScript 5.1 specification, the default behavior of Error.prototype.toString should only return a formatted string containing the error’s name and message. Automatically appending the stack trace is a deviation from this standard behavior and may lead to inconsistencies or unexpected results in applications that rely on strict error formatting.
Version
MuJS 1.3.7
Command
/home/engines/mujs-1.3.7/mujs-1.3.7/build/debug/mujsTestcase
print("Error: test" === String.prototype.trim.call(new Error("test")));
print("Error: test");
print(String.prototype.trim.call(new Error("test")));Actual Output
false
Error: test
Error: test
at abug.js:3
Expected Output
true
Error: test
Error: test
Specification Reference
According to ECMAScript 5.1, Section 15.11.4.4, Error.prototype.toString should return a string in the form:
"<error name>: <error message>"
https://262.ecma-international.org/5.1/#sec-15.11.4.4
The specification makes no mention of including stack trace information in the toString() output. Therefore, MuJS’s behavior appears to be non-compliant.