Skip to content

implement setter fallback for subscripts #24872

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: devel
Choose a base branch
from

Conversation

metagn
Copy link
Collaborator

@metagn metagn commented Apr 13, 2025

follows up #24871

For subscript assignments, if an overload of []=/{}= is not found, the LHS checks for overloads of []/{} as a fallback, similar to what field setters do since #24871. This is accomplished by just compiling the LHS if the assignment overloads fail. This has the side effect that the error messages are different now, instead of displaying the overloads of []=/{}= that did not match, it will display the ones for []/{} instead. This could be fixed by checking for efLValue when giving the error messages for []/{} but this is not done here.

The code for [] subscripts is a little different because of the mArrGet/mArrPut overloads that always match. If the mArrPut overload matches without a builtin subscript behavior for the LHS then it calls semAsgn again with mode = noOverloadedSubscript. Before this meant "fail to compile" but now it means "try to compile the LHS as normal", in both cases the overloads of []= are not considered again.

@metagn metagn marked this pull request as ready for review April 14, 2025 15:12
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