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

Be more strict about ProcNotation variable declarations #11372

Merged

Conversation

HertzDevil
Copy link
Contributor

@HertzDevil HertzDevil commented Oct 27, 2021

The following is an error:

x : -> Int32.class = ->{ Int32 } # Error: type must be Proc(Int32), not Proc(Int32.class)

Here the Int32.class is already read as a type expression. This PR removes an incorrect conversion to Int32.class's instance type.

This PR also now disallows the following ProcNotations, because they would have been rejected if they were rewritten into their equivalent Proc instances:

x : -> Reference # ditto for similar base types like Object and Number
x : Array ->     # uninstantiated generics
x : -> ARGV      # constants

No Procs with these argument types could possibly be constructed, so this shouldn't be a breaking change. Resolves part of #11371.

@HertzDevil HertzDevil added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:semantic labels Oct 27, 2021
Copy link
Member

@sdogruyol sdogruyol left a comment

Choose a reason for hiding this comment

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

Thank you @HertzDevil 🙏

@straight-shoota straight-shoota added this to the 1.3.0 milestone Nov 26, 2021
@straight-shoota straight-shoota merged commit 1afc69e into crystal-lang:master Nov 29, 2021
@HertzDevil HertzDevil deleted the bug/procnotation-var-decl branch November 29, 2021 15:10
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. topic:compiler:semantic
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants