Skip to content

[TS] Stop unsupported accessor and method-value storage access - #595

Open
CaelmBleidd wants to merge 2 commits into
caelmbleidd/ts-computed-member-identityfrom
caelmbleidd/ts-declared-accessor-read-boundary
Open

CaelmBleidd wants to merge 2 commits into
caelmbleidd/ts-computed-member-identityfrom
caelmbleidd/ts-declared-accessor-read-boundary

Conversation

@CaelmBleidd

@CaelmBleidd CaelmBleidd commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Allocated class-instance reads can currently treat a declared getter as an ordinary storage field and return undefined without reporting a limitation. The frozen Matrix example reproduces this: new Matrix([[1,2],[3,4]]).get(1,0) reads the rows getter, producing symbolic undefined versus native 3.

EtsIR currently does not distinguish accessor declarations from ordinary prototype methods. A small shared boundary now rejects allocated instance property reads and writes when the runtime class/ancestor declares a same-name method-like member but no real data field. The existing unsupported-path mechanism retains the reason and does not report an engine failure. A previous write does not bypass this boundary: assigning a getter without a setter can throw or be ignored natively, so a modeled write must not fabricate an own property. Ordinary method calls, inherited calls, declared own data fields (including field shadowing), ordinary data-field writes, and callable data fields retain their behavior. Method-value reads and ambiguous method-overwriting assignments conservatively stop.

A narrow grammar proof preserves already supported method-overwriting calls: a TypeScript getter has zero parameters and a setter has one parameter with a void return. More than one parameter, or one parameter with an explicit Boolean/number/string return, proves an ordinary method. Only writes use that exception; unknown/ambiguous signatures remain guarded. The original CapturedMethodCalls source and assertions are unchanged.

Validation: full :usvm-ts:test passes with 1786 tests: 1647 passed, 139 skipped, zero failures/errors; detektMain, detektTest, and git diff --check pass. The 11 focused tests include the original method-capture controls and source/native accessor boundary tests. Before the guard, the new getter regression failed because analysis returned a state instead of an unsupported result. Native controls distinguish function-valued reads, own data, safe method-capture order, setter effects, and the TypeError from getter assignment inside a class method. Setter writes remain explicitly unsupported instead of discarding their effect.

Original frozen sources remain unchanged: Matrix retains 44 methods, stops explicitly on rows with zero terminal states and no engine failure; SegmentTree retains 21 methods and its constructor/query still returns one symbolic 3, matching native execution with no unsupported paths. This is a safety boundary, not getter execution. General accessor effects, setter execution, and complete method-value semantics remain in #577.

Refs #577. Depends on #578.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant