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: Do not consider global Path in def parameter restriction as free variable #11862

Merged
merged 2 commits into from
Mar 8, 2022

Conversation

HertzDevil
Copy link
Contributor

Given:

def foo(x : ::T) forall T
end

foo(1) # okay?

::T is a global path, so it should always refer to the type T from the top-level namespace, never the free variable. The above snippet now reports undefined constant ::T. If ::T were defined, then foo's argument must also be of type T.

Defs like these are now subject to #7737.

Also includes slight refactors outside restrictions.cr.

@HertzDevil HertzDevil added kind:bug A bug in the code. Does not apply to documentation, specs, etc. kind:refactor topic:compiler:semantic labels Mar 1, 2022
Copy link
Member

@beta-ziliani beta-ziliani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙇 for the refactor 🚀

@beta-ziliani beta-ziliani added this to the 1.4.0 milestone Mar 2, 2022
@straight-shoota straight-shoota changed the title Do not consider global Paths in def parameter restrictions as free variables Fix: Do not consider global Path in def parameter restriction as free variable Mar 8, 2022
@straight-shoota straight-shoota merged commit 3d928c7 into crystal-lang:master Mar 8, 2022
@HertzDevil HertzDevil deleted the bug/global-free-var branch March 9, 2022 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. kind:refactor topic:compiler:semantic
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants