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

try all call kinds in generic type node handling #23411

Draft
wants to merge 5 commits into
base: devel
Choose a base branch
from

Conversation

metagn
Copy link
Collaborator

@metagn metagn commented Mar 15, 2024

fixes #23406

Apparently it was intentional that this only checked nkCall but maybe things have changed since, we can see what CI says.

Also n.kind in nkCallKinds is implied already, probably just c.inGenericContext > 0 is enough.

@metagn
Copy link
Collaborator Author

metagn commented Mar 15, 2024

The problem is only encountered in CI with -> so whitelisting nkCommand will probably not break anything. Someone could depend on the difference outside of CI though and checking the node type is still weird. Basically semGenericStmt doesn't capture generic parameter symbols? I think this is the minimal case for tclosure:

template foo(x: untyped): untyped = x

type Foo[A] = foo(A) # `foo A` or just `A` works

proc bar[A](x: Foo[A]) = discard

bar(123) # undeclared identifier: A

Doesn't matter if foo is entirely untyped or not.

Normally in seminst each generic parameter is added manually to scope so the generic parameters not being captured in semGenericStmt doesn't matter. In semtypinst however when typing tyFromExpr nodes the generic parameters are not in scope. I don't know if semtypinst is even aware of generic parameter symbols outside of the binding map, I don't know how generic parameter symbols even enter the scope for regular semtypes behavior.

@metagn
Copy link
Collaborator Author

metagn commented Mar 21, 2024

We should probably remove this if branch altogether and use only the else branch, then fix #23406 for semTypeExpr.

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.

Different symbol resolution in generic types depending on f(x) vs f x call syntax
1 participant