Skip to content

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

@sebffischer

Description

@sebffischer

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions