[P2] Interpreter: structuredClone rejects BigInt primitives

Open Beginner friendly
#3,444 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
66/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
csharp, typescript
Domain
compilers

Research direction

The fix belongs in StructuredClone.IsPrimitive and the recursive primitive branch, which accept System.Numerics.BigInteger but not the interpreter's SharpTSBigInt type. Reproduce with structuredClone(3n) under --no-tsconfig --lib es2022,dom, which currently exits 1 with DataCloneError. Done when it prints 3, nested BigInt values clone, and functions and Symbols still throw.

Written by the indexing model from the issue text.

Description

bug priority: P2

The interpreter rejects its actual BigInt primitive carrier during structured clone.

console.log(String(structuredClone(3n)));

Expected: 3. On immutable PR head 1aa8ac0e72596b6daf9cf2280063c423716e9838, run --no-tsconfig --lib es2022,dom: SharpTS exits 1 with DataCloneError: Cannot clone value of type SharpTSBigInt.

StructuredClone.IsPrimitive and the recursive primitive branch accept System.Numerics.BigInteger but omit the interpreter's actual SharpTSBigInt representation. This affects direct and nested BigInt values. The emitted clone core accepts its BigInteger representation; this defect concerns interpretation.

Found while verifying #3443. The unchanged regression program structuredClone([undefined,null,true,"x",2,3n]) passes the Node v22.23.2 oracle but, after the undefined repair, the interpreter now reaches and rejects SharpTSBigInt. A separate reduced original was replayed on immutable head and fails before any repair; raw evidence is retained at artifacts/p2-work/structured-clone-callable-value-3439/bigint-baseline-original.json (source SHA-256 E0A2AA27BF28897962C8FC6A43EF42C51C3D4B6C40A071F944475E67CA09C755).

Expected: actual BigInt primitive values clone successfully at the top level and in nested containers, while functions and Symbols remain uncloneable. Keep the existing transfer and graph algorithms unchanged.

Dominant language
C#
Stars
156
Forks
4
Avg merge
13h 33m
Merged PRs (30d)
45

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nickna/SharpTS

All issues in nickna/SharpTS

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.