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

Do not allow the hyphen character in identifiers #164

Closed
yannham opened this issue Oct 12, 2020 · 1 comment · Fixed by #165
Closed

Do not allow the hyphen character in identifiers #164

yannham opened this issue Oct 12, 2020 · 1 comment · Fixed by #165
Assignees

Comments

@yannham
Copy link
Member

yannham commented Oct 12, 2020

Describe the bug
Currently, the lexer allows to use hyphens - in identifiers. This clashes with the use of, say, the dynamic field removing operator -$, or any binary operator starting with an hyphen.

To Reproduce
Using the field removing operator without spaces after an identifier causes an error:

nickel <<< 'let field = "a" in let rec = {a=1} in rec-$field'
error: Unexpected token
  ┌─ <stdin>:1:43
  │
1 │ let field = "a" in let rec = {a=1} in rec-$field
  │                                           ^

while adding a space makes parsing succeed:

nickel <<< 'let field = "a" in let rec = {a=1} in rec -$ field'
[...]

Expected behavior
Do not consider the hyphen - character as valid identifier character. This is not standard and clashes with potentially any binary operator starting with a -. Parsing exp binop exp should not be whitespace sensitive.

@yannham yannham added the bug label Oct 12, 2020
@yannham yannham self-assigned this Oct 12, 2020
@aspiwack
Copy link
Member

For the record, identifiers with a hyphen are standard in lisp languages. But they can only pull it off reasonably because of the very constrained syntax that they have. It is the most beautiful part of lisp in my eyes 🙂

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 a pull request may close this issue.

2 participants