Skip to content
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

consider instantiation errors in overload resolution as type mismatch #24098

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from

Conversation

metagn
Copy link
Collaborator

@metagn metagn commented Sep 12, 2024

refs #24086

Instantiation errors encountered during overload resolution (such as when instantiating array range expressions based on existing generic parameters) are now saved for the current overload until overload resolution is finished and no overloads match, instead of immediately erroring globally. Encountering such errors also now treats the overload as non-matching. This allows other overloads that would instantiate normally to match even when no generic parameters are given.

Unfortunately I couldn't think of any tests that would encounter the errors created in semtypinst as the handling of tyFromExpr already doesn't create any errors. This doesn't give a great error message either, but going out of our way to error in semtypinst might make things worse.

Note: Covers #10220 but not #22964, which errors when calling generateTypeInstance in getInstantiatedType, which could also be handled. If we ever fix param constraints with instantiations, we should also handle this, which currently crashes the compiler:

proc foo[I](): array[I, int] = discard

let x = foo[int]()

In general this paves the way for generic instantiations to fail on constraint mismatches.

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