Repository navigation
A set accessor's untyped parameter takes its get accessor's type; a setter gets the value as the type it takes - #720
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
class C { f = 1; get prop() { return this.f; } set prop(v) { ... } }warned "type for parameter 'v' is any", andc.prop = 5then 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 takesany, with no conversion.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 andmlirGenClassMembersretries it. With no get accessor it isany, as before.Test:
00class_accessor_untyped_setter(getter first, setter first, typed getter, static pair,v: anysetter), AOT + JIT + rc/none corpus.Rebased onto #719. Full ctest (Release, Windows): 6127/6127 passed.
🤖 Generated with Claude Code