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

It should not be possible to use keywords as identifiers #217

Open
sebffischer opened this issue Oct 27, 2024 · 0 comments
Open

It should not be possible to use keywords as identifiers #217

sebffischer opened this issue Oct 27, 2024 · 0 comments
Labels
meta-good first issue Good for newcomers type-bug Something isn't working

Comments

@sebffischer
Copy link
Collaborator

sebffischer commented Oct 27, 2024

The following code runs, but should not.

function = 1
fn = 1
if = 1

I believe the best way to fix this is to just encode this in the grammar. I.e. exclude the keywords from being an identifier:

R/src/grammar/grammar.pest

Lines 189 to 192 in 5c13c49

symbol = _{ symbol_with_backticks | symbol_ident }
symbol_with_backticks = _{ "`" ~ symbol_backticked ~ "`" }
symbol_backticked = ${ ( !"`" ~ ANY )* }
symbol_ident = ${ ( LETTER | OTHER_SYMBOL | "_" | "." ) ~ ( ASCII_ALPHANUMERIC | "_" | "." )* }

We have to pay attention to the localizations.

@sebffischer sebffischer added type-bug Something isn't working meta-good first issue Good for newcomers labels Oct 27, 2024
@sebffischer sebffischer changed the title It should not be possible to assign to keywords It should not be possible to use keywords as identifiers Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
meta-good first issue Good for newcomers type-bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant