[P2] Interpreter: async numeric bitwise operations use saturating casts instead of ToInt32
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- csharp, typescript
- Domain
- compilers
Research direction
Start with Interpreter.Async.cs::EvaluateBinaryAsync and compare its numeric bitwise conversions with Interpreter.Calls.cs::EvaluateBinary, which already uses JsToInt32 and JsToUint32. Run the supplied async reproduction against the interpreter and Node. Done when the async results match Node while preserving the stated evaluation order, shift masking, and unsigned-result behavior.
Written by the indexing model from the issue text.
Description
The async interpreter's primitive-Number binary fast path casts operands directly to int, producing saturating conversions instead of ECMAScript ToInt32 wrapping. The same synchronous operations already match Node.
const large = 4294967297, zero = 0, infinite = Infinity, negative = -4294967297.75;
console.log("sync", large | zero, infinite | zero, negative | zero);
async function main() {
await Promise.resolve(0);
console.log("async", large | zero, infinite | zero, negative | zero);
}
main();
Node v22.23.2, exit0:
sync 1 0 -1
async 1 0 -1
Immutable interpreter baseline, exit0:
sync 1 0 -1
async 2147483647 2147483647 -2147483648
The await ensures the async evaluator is exercised. All operands are primitive Numbers; there are no objects, conversion hooks, BigInts, Symbols, computed keys, assignment, typed arrays or CLR interop involved. ToInt32 wraps 4294967297 to1, maps Infinity to0, and truncates then wraps -4294967297.75 to-1. The synchronous line is a positive control on the same values and same runtime.
Source lead: Interpreter.Async.cs::EvaluateBinaryAsync handles Bitwise/BitwiseShift with EvaluateBitwise(..., (int)l, (int)r) and unsigned right shift with (uint)(int)l. Interpreter.Calls.cs::EvaluateBinary already uses JsToInt32/JsToUint32. Reuse the JavaScript conversion rules in the async numeric fast path while retaining left-to-right evaluation, five-bit shift masking and unsigned Number results.
Found during #2514's binary ToNumeric review. That issue concerns object conversion yielding BigInt on the shared slow path; this reduction has primitive Number operands and returns entirely within the async fast path. Fresh all-state async/bitwise, exact4294967297, interpreter/ToInt32, bitwise/Infinity, async/ToInt32, interpreter/bitwise/overflow and async/bitwise/operands searches found no focused owner. Closed #1421 was read in full and concerns compiled unboxed numeric bitwise optimization, not the interpreter's async evaluator.
Evidence: ignored artifacts/p2-interpreter/2514-async-number-bitwise-truncation.ts, .node.log, .baseline.log, 2514-async-number-bitwise-truncation-results.json, 2514-async-number-bitwise-{focused-,}dedup.json, and saved #1421 body. Immutable baseline artifacts/p2-interpreter/baseline/SharpTS.dll SHA256 checked before invocation: B5FA2CADDEA116B83166442205B825130A663B682EDAABAA1312A26FB7909E85 (source fec823522). Commands use Node type stripping or dotnet BASELINE --no-tsconfig --noLib SOURCE.ts. No compiled failure, project build, tracked edit or introducing-commit claim is made.
- Dominant language
- C#
- Stars
- 156
- Forks
- 4
- Avg merge
- 5h 24m
- Merged PRs (30d)
- 68
Getting set up
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nickna/SharpTS
-
bug priority: P2
Difficulty 1/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
bug priority: P2
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
bug priority: P2
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
bug priority: P2
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day
-
[Docs] README/PRIVACY still name AppCenter although v1.5.6.0+ uses the Microsoft Store Services SDKOpen
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Azure/azure-sdk-tools#17317 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
swisstopo/swissgeol-boreholes-suite#3086 ·
Maintainers usually reply within 1 day
-
[Bug]: wiki jump bugOpenbug
Difficulty 1/5 Under an hour Newbie friendliness 65/100
Maintainers usually reply within 1 day