dhall-haskell icon indicating copy to clipboard operation
dhall-haskell copied to clipboard

dhall format produces unparseable file when `Some` is used

Open winitzki opened this issue 1 year ago • 0 comments

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.)

winitzki avatar Aug 28 '24 13:08 winitzki