Repository navigation
runtime: coerce boxed Boolean, Number, and String objects in addition #3563
Copy link
Copy link
Closed
Description
Summary
Boxed primitive objects participate in addition through OrdinaryToPrimitive, yielding primitive boolean/number/string values before numeric or string addition.
Affected Test262 rows
- test(net): regression test for #91 sock.write via Map-retrieved socket #177 language/expressions/addition/S11.6.1_A3.1_T1.1.js (runtime-fail: Uncaught exception: linux compilation and README #2: new Boolean(true) + true === 2. Actual: NaN)
- Fix #137: for-loop continue skips update on --target web #178 language/expressions/addition/S11.6.1_A3.1_T1.2.js (runtime-fail: Uncaught exception: linux compilation and README #2: new Number(1) + 1 === 2. Actual: NaN)
- gc: block-persistence conservatism inflates peak RSS on tight allocation loops #179 language/expressions/addition/S11.6.1_A3.1_T2.1.js (runtime-fail: Uncaught exception: Using the fetch API #3: new Boolean(true) + 1 === 2. Actual: NaN)
- fix(runtime): #29 isWellFormed/toWellFormed lone-surrogate detection #180 language/expressions/addition/S11.6.1_A3.1_T2.2.js (runtime-fail: Uncaught exception: Using the fetch API #3: new Number(1) + null === 1. Actual: NaN)
- Compile native app tutor failed, Ubuntu 26.04 #181 language/expressions/addition/S11.6.1_A3.1_T2.5.js (runtime-fail: Uncaught exception: Using the fetch API #3: new Boolean(true) + null === 1. Actual: NaN)
- HarmonyOS #182 language/expressions/addition/S11.6.1_A3.2_T1.1.js (runtime-fail: Uncaught exception: linux compilation and README #2: new String("1") + "1" === "11". Actual: [object Object]1)
- Strict subset of typescript that allows even smaller/faster binaries #184 language/expressions/addition/S11.6.1_A3.2_T2.1.js (runtime-fail: Uncaught exception: Using the fetch API #3: new String("1") + 1 === "11". Actual: NaN)
- I hope it is easy and convenient to modify the component's style, similar to the
styleattribute in HTML. #185 language/expressions/addition/S11.6.1_A3.2_T2.2.js (runtime-fail: Uncaught exception: Using the fetch API #3: new Boolean(true) + "1" === "true1". Actual: [object Object]1) - AI told me this is a bug? #186 language/expressions/addition/S11.6.1_A3.2_T2.3.js (runtime-fail: Uncaught exception: Using the fetch API #3: new String("1") + undefined === "1undefined". Actual: NaN)
- Official commander docs example compiles successfully, but the generated binary ignores CLI arguments at runtime #187 language/expressions/addition/S11.6.1_A3.2_T2.4.js (runtime-fail: Uncaught exception: Using the fetch API #3: new String("1") + null === "1null". Actual: NaN)
Perry actual behavior from report
- 1 x runtime-fail: Uncaught exception: linux compilation and README #2: new Boolean(true) + true === 2. Actual: NaN
- 1 x runtime-fail: Uncaught exception: linux compilation and README #2: new Number(1) + 1 === 2. Actual: NaN
- 1 x runtime-fail: Uncaught exception: linux compilation and README #2: new String("1") + "1" === "11". Actual: [object Object]1
- 1 x runtime-fail: Uncaught exception: Using the fetch API #3: new Boolean(true) + "1" === "true1". Actual: [object Object]1
- 1 x runtime-fail: Uncaught exception: Using the fetch API #3: new Boolean(true) + 1 === 2. Actual: NaN
- 1 x runtime-fail: Uncaught exception: Using the fetch API #3: new Boolean(true) + null === 1. Actual: NaN
- 1 x runtime-fail: Uncaught exception: Using the fetch API #3: new Number(1) + null === 1. Actual: NaN
- 1 x runtime-fail: Uncaught exception: Using the fetch API #3: new String("1") + 1 === "11". Actual: NaN
- 1 x runtime-fail: Uncaught exception: Using the fetch API #3: new String("1") + null === "1null". Actual: NaN
- 1 x runtime-fail: Uncaught exception: Using the fetch API #3: new String("1") + undefined === "1undefined". Actual: NaN
Node / ECMAScript expected behavior
Boxed primitive objects participate in addition through OrdinaryToPrimitive, yielding primitive boolean/number/string values before numeric or string addition.
Likely subsystem
runtime object model / ToPrimitive for boxed primitives
Acceptance criteria
new Boolean(true) + 1,new Number(1) + null, andnew String("1") + undefinedmatch Node.- String concatenation vs numeric addition decisions follow the post-ToPrimitive operand types.
- Boxed primitive object identity behavior outside coercion does not regress.
Validation
Run the Test262 differential against the affected area and confirm these rows leave the gap report:
scripts/test262_subset.py --root vendor/test262 --dir language/expressions/addition --sample-cap 99999 --report /tmp/COERCION_BOXED_PRIMITIVES.jsonThis is Perry language/runtime semantics triage, not a Node core API compatibility issue.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity