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

ast/tests: Delay resolution of features with args whose types are inferred #2316

Merged
merged 3 commits into from
Dec 7, 2023

Conversation

fridis
Copy link
Member

@fridis fridis commented Dec 6, 2023

This fixes #2290 by first resolving everything else before we are resolving a feature whose argument types are inferred from actual arguments.

Since type inference can results in some awful circles here, I had to add a check for such circles to avoid type inference in case of such a circle. For now, a circle is just ignored expecting this to occur only in case of recursion. Consequently, only types provided when entering this recursion will be considered for type inference for arguments.

This patch adds a number of tricky type inference tests that model the example from #2290 and indirect recursion.

Also, test scenarios were added where inference is used without any actual calls and the type ends up being void, which is wrong. This should be revisited within #2308.

I also added code to the parser to add a SourcePosition to each Impl which helps during debugging.

…erred

This fixes #2290 by first resolving everything else before we are resolving a
feature whose argument types are inferred from actual arguments.

Since type inference can results in some awful circles here, I had to add a
check for such circles to avoid type inference in case of such a circle.  For
now, a circle is just ignored expecting this to occur only in case of recursion.
Consequently, only types provided when entering this recursion will be
considered for type inference for arguments.

This patch adds a number of tricky type inference tests that model the example
from #2290 and indirect recursion.

Also, test scenarios were added where inference is used without any actual calls
and the type ends up being `void`, which is wrong.  This should be revisited
within #2308.
The check in Impl() was left over from my debugging, while the check in
Resolution.requiresCall() is wrong for recursive calls to this method, the
condition is already checked in Resolution.scheduleForDeclarations().
@michaellilltokiwa michaellilltokiwa merged commit 4bbd02d into main Dec 7, 2023
5 checks passed
@michaellilltokiwa michaellilltokiwa deleted the fix_2290 branch December 7, 2023 09:47
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.

Small example with inferred argument types fails to infer the argument types in time
2 participants