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

Disallow type declarations for local variables in scopes where it's impossible to call them #15223

Open
nobodywasishere opened this issue Nov 24, 2024 · 2 comments
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:parser

Comments

@nobodywasishere
Copy link
Contributor

This gives an error:

def hello(begin)
end

While this does not:

def hello(begin : String)
end

It should not be possible to declare a local variable within a scope that it's impossible to call within.

@nobodywasishere nobodywasishere added the kind:bug A bug in the code. Does not apply to documentation, specs, etc. label Nov 24, 2024
@Sija
Copy link
Contributor

Sija commented Nov 24, 2024

Another example:

raise : String = "foo"
begin : String = "foo"
end : String = "foo"
do : String = "foo"

# and possibly many other keywords (if not all)...

@nobodywasishere
Copy link
Contributor Author

type works, but that may be due to them only being used inside lib bodies.

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:parser
Projects
None yet
Development

No branches or pull requests

3 participants