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

Add restrictions on modifiers in local scope #40

Merged
merged 1 commit into from
Nov 6, 2021

Conversation

alex-pinkus
Copy link
Owner

Declarations for functions, classes, and variables are legal at various
different scopes (global, type-level, and local), but have different
sets of legal modifiers in each. While you might think that would be
fine and would simply improve our permissiveness, it actually ends up
restricting some valid code - in particular, code that uses those
would-be modifiers as identifiers. For instance, one file in Carthage
uses the innocent-looking variable name prefix, but we fail to parse
that because in other scopes, that would instead be a modifier.

To fix this, we split out declarations by scope: global, type-level, and
local. For now, we treat global and type-level as mostly the same except
that subscripts are legal in the latter and not the former. However, for
local declarations, we allow a much smaller list of operators.

Fixes #39

Declarations for functions, classes, and variables are legal at various
different scopes (global, type-level, and local), but have different
sets of legal modifiers in each. While you might think that would be
fine and would simply improve our permissiveness, it actually ends up
_restricting_ some valid code - in particular, code that uses those
would-be modifiers as identifiers. For instance, one file in Carthage
uses the innocent-looking variable name `prefix`, but we fail to parse
that because in other scopes, that would instead be a modifier.

To fix this, we split out declarations by scope: global, type-level, and
local. For now, we treat global and type-level as mostly the same except
that subscripts are legal in the latter and not the former. However, for
local declarations, we allow a much smaller list of operators.

Fixes #39
@alex-pinkus alex-pinkus merged commit c5e610a into main Nov 6, 2021
@alex-pinkus alex-pinkus deleted the restrict-local-modifiers branch November 6, 2021 20:06
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.

It's illegal to name a variable prefix (but should be legal)
1 participant