dgkf / dgkf/R

It should not be possible to use keywords as identifiers

Open
#217 0 comments 0 reactions 0 assignees View on GitHub
meta-good first issue type-bug
Dominant language
Rust
Stars
145
Forks
5
PR merge metrics
No merged PRs in 30d

Description

The following code runs, but should not.

```r
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: https://github.com/dgkf/R/blob/5c13c4950991c821aa5fd2255751d3eabc3316a1/src/grammar/grammar.pest#L189-L192

We have to pay attention to the localizations.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in src/grammar/grammar.pest around lines 189–192, where identifiers and keywords are defined. Check how keyword localization is represented before adjusting the grammar. The examples using function, fn, and if should no longer run as assignments, including under the relevant localizations.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.