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

dhall format produces unparseable file when Some is used #2601

Closed
winitzki opened this issue Aug 28, 2024 · 1 comment · Fixed by #2608
Closed

dhall format produces unparseable file when Some is used #2601

winitzki opened this issue Aug 28, 2024 · 1 comment · Fixed by #2608

Comments

@winitzki
Copy link
Collaborator

winitzki commented Aug 28, 2024

The command dhall format removes backquotes when it thinks backquotes are unnecessary. But when backquotes are used for builtin labels like Some and Type, sometimes removing the backquotes produces incorrect code.

Minimal example:

let T = < Some | Type >
let t : T = T.`Some`
let x : T = T.`Type`
in True

Save this file as test.dhall.

$ dhall --file test.dhall
True
$ dhall format test.dhall
$ dhall --file test.dhall
dhall:
Error: Invalid input

test_formatter.dhall:5:8:
  |
5 |     = T.Some
  |        ^^

The file after formatting looks like this:

let T = < Some | Type >

let t
    : T
    = T.Some

let x
    : T
    = T.Type

in  True

The backquotes in Some and Type have been removed. This produces incorrect code that does not parse.

Expected behavior: Quotes should not be removed with Some. (It's fine to remove them for Type though.)

Gabriella439 added a commit that referenced this issue Oct 5, 2024
Fixes #2601

According to the standard the `Some` needs to be escaped when used as
a field accessor because the `any-label` grammar rule kicks in, which
specifically does not permit `Some`.
@Gabriella439
Copy link
Collaborator

Fix up here: #2608

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