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

fix error messages for wrongly typed generic param default values #24006

Merged
merged 2 commits into from
Aug 23, 2024

Conversation

metagn
Copy link
Collaborator

@metagn metagn commented Aug 23, 2024

fixes #21258

When a generic proc is instantiated, if one of the default values doesn't match the type of the parameter, seminst sets the default parameter node to an nkEmpty node with tyError type. sigmatch checks for this to give an error message if the default param is actually used, but only while actively matching the proc signature, before the proc is even instantiated. The error message also gives very little information.

Now, we check for this in updateDefaultParams at the end of semResolvedCall, after the proc has been instantiated. The nkEmpty node also is given the original mismatching type instead rather than tyError, only setting tyError after erroring to prevent cascading errors. The error message is changed to the standard type mismatch error also giving the instantiation info of the routine.

@Araq Araq merged commit 446501b into nim-lang:devel Aug 23, 2024
19 checks passed
Copy link
Contributor

Thanks for your hard work on this PR!
The lines below are statistics of the Nim compiler built from 446501b

Hint: mm: orc; opt: speed; options: -d:release
173635 lines; 8.060s; 654.516MiB peakmem

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.

Default valued generic proc parameter causes missing parameter in generated C code.
2 participants