Skip to content

A set accessor's untyped parameter takes its get accessor's type; a setter gets the value as the type it takes - #720

Merged
ASDAlexander77 merged 1 commit into
mainfrom
fix-untyped-setter-param
Oct 28, 2026
Merged

ASDAlexander77 merged 1 commit into
mainfrom
fix-untyped-setter-param

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

class C { f = 1; get prop() { return this.f; } set prop(v) { ... } } warned "type for parameter 'v' is any", and c.prop = 5 then crashed (0xC0000005) at run time. set prop(v: any) crashed the same way: an assignment through an accessor cast the value to the getter's type (i32) and passed it to a setter that takes any, with no conversion.

  • mlirGenParameters: a class set accessor's parameter with no type and no initializer takes what the get accessor of the same name returns (getPairedGetAccessorType): its written type, otherwise the type of the registered get accessor. When the get accessor comes after the set accessor and is not registered yet, the set accessor is left unresolved and mlirGenClassMembers retries it. With no get accessor it is any, as before.
  • mlirGenSaveLogic: an assignment through any accessor op casts the value to the set accessor's last parameter, not to the accessor's (getter's) type.

Test: 00class_accessor_untyped_setter (getter first, setter first, typed getter, static pair, v: any setter), AOT + JIT + rc/none corpus.

Rebased onto #719. Full ctest (Release, Windows): 6127/6127 passed.

🤖 Generated with Claude Code

…etter gets the value as the type it takes

`class C { f = 1; get prop() { return this.f; } set prop(v) { ... } }` warned
"type for parameter 'v' is any" and `c.prop = 5` then crashed (0xC0000005) at
run time. Even `set prop(v: any)` crashed the same way: an assignment through
an accessor cast the value to the getter's type (i32) and handed it to a setter
that takes `any`, with no conversion.

- mlirGenParameters: a class set accessor's parameter with no type and no
  initializer takes what the get accessor of the same name returns
  (getPairedGetAccessorType): its written type, else the type of the
  registered get accessor. When the get accessor comes after the set accessor
  and is not registered yet, the set accessor is left unresolved and
  mlirGenClassMembers retries it. With no get accessor it is `any`, as before.
- mlirGenSaveLogic: an assignment through any accessor op casts the value to
  the set accessor's last parameter, not to the accessor's (getter's) type.

Test: 00class_accessor_untyped_setter (getter first, setter first, typed
getter, static pair, `v: any` setter).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit 46f5335 into main Oct 28, 2026
2 checks passed
@ASDAlexander77
ASDAlexander77 deleted the fix-untyped-setter-param branch October 28, 2026 19:49
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