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

Disallow labels that match builtins or keywords #299

Merged
merged 1 commit into from Nov 26, 2018

Conversation

Gabriella439
Copy link
Contributor

Fixes dhall-lang/dhall-haskell#683

Before this change the grammar allowed variables to be named after
builtins or keywords, such as:

let if = 1 in if

However, permitting this deteriorates error messages since an expression
like this:

if a then b else

... becomes a type error ("Unbound variable: if") instead of a parse
error due to an incomplete if expression.

The solution is to disallow these sorts of variable names. Given that
we don't have a good way to do that in the grammar, we just specify it
as a comment for now.

Fixes dhall-lang/dhall-haskell#683

Before this change the grammar allowed variables to be named after
builtins or keywords, such as:

```haskell
let if = 1 in if
```

However, permitting this deteriorates error messages since an expression
like this:

```haskell
if a then b else
```

... becomes a type error ("Unbound variable: if") instead of a parse
error due to an incomplete `if` expression.

The solution is to disallow these sorts of variable names.  Given that
we don't have a good way to do that in the grammar, we just specify it
as a comment for now.
f-f added a commit to f-f/dhall-clj that referenced this pull request Nov 25, 2018
Implements dhall-lang/dhall-lang#299

We add a negative lookahead in the simple-label rule, so that
if a label starts with a keyword we backtrack.
(Note: there's a space added, to avoid refusing partial matches,
e.g. if a keyword is "in" we should still accept "index" as a label.
@Gabriella439 Gabriella439 merged commit 3aa37b3 into master Nov 26, 2018
@Gabriella439 Gabriella439 deleted the gabriel/disallowed_labels branch November 26, 2018 02:10
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.

None yet

2 participants