[P2] Compiler: boxed String own methods are bypassed by direct calls

Closed
#3,461 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

A pull request for this has already been merged.

  • #3329 by @nickna — merged

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
30/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
csharp, typescript
Domain
compilers

Research direction

The bug lives in the compiler's boxed-string method dispatch, where direct calls on a boxed String reach the intrinsic helper before ordinary own-property lookup. Start by reproducing the three-line TypeScript snippet with --no-tsconfig --lib es2022,dom and comparing interpreted output with saved compiled output. Done means the compiled run prints true, matching Node, and the related #3457 non-string receiver defect is not regressed.

Written by the indexing model from the issue text.

Description

bug priority: P2

A compiled direct method call on a boxed String bypasses its assigned own method.

const value: any = new String("abc");
value.includes = function (s: string) { return s === "q"; };
console.log(value.includes("q"));

Strict TypeScript accepts this program. Node and SharpTS interpretation print true; saved compiled execution prints false, matching the unmodified prototype method instead of the own function. Independent whole-assembly IL verification reports no findings.

Reproduced with --no-tsconfig --lib es2022,dom. No string assertion or annotated string parameter is involved. The compiler's boxed-string dispatch reaches the intrinsic helper before ordinary method lookup, so this is distinct from the asserted non-string receiver defect in #3457.

Dominant language
C#
Stars
156
Forks
4
Avg merge
14h 41m
Merged PRs (30d)
43

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.