dhall-lang / dhall-haskell

Maintainable configuration files
https://dhall-lang.org/
BSD 3-Clause "New" or "Revised" License
918 stars 214 forks source link

record puns parsing error #1732

Closed amesgen closed 4 years ago

amesgen commented 4 years ago

I find this surprising:

$ dhall <<< "let x = 0 in { x, a = 0 }"
{ X = 1, Y = 2, a = 0 }
$ dhall <<< "let x = 0 in { x , a = 0 }"
dhall: 
Error: Invalid input

(stdin):1:18:
  |
1 | let x = 0 in { x , a = 0 }
  |                  ^
unexpected ','
expecting whitespace or }

dhall-rust accepts both inputs (clone https://github.com/amesgen/stuff and run cargo run in branch dhall-puns-repro).

amesgen commented 4 years ago

Maybe here

as <- Text.Megaparsec.sepBy1 keysValue (_comma *> whitespace)

to

as <- Text.Megaparsec.sepBy1 keysValue (whitespace *> _comma *> whitespace)

seems to fix it.

sjakobi commented 4 years ago

Many thanks for the report @amesgen. I've pushed a fix to #1733. Your solution might also work though – I'm not sure.

amesgen commented 4 years ago

Thanks for the very quick fix! I can't run the test suite as I am on 8.8.3 (--allow-newer worked) and I get errors like

     error: missing binary operator before token "("
       38 | #if MIN_VERSION_http_client(0,5,0)
          | 
   |
38 | #if MIN_VERSION_http_client(0,5,0)
   | ^

(but this is completely unrelate to this issue)

sjakobi commented 4 years ago

@amesgen Here's some info regarding the doctest issue: https://github.com/dhall-lang/dhall-haskell/pull/1700#issuecomment-599254595 (Actually we have a whole issue for that: https://github.com/dhall-lang/dhall-haskell/issues/1100)

Developing with 8.8 should be properly supported soon: https://github.com/dhall-lang/dhall-haskell/issues/1249

amesgen commented 4 years ago

Ah interesting, seems like a very annoying issue. Thanks!

Gabriella439 commented 4 years ago

@amesgen: Also, you can skip the doctests and selectively run the remaining tests using cabal test tasty

amesgen commented 4 years ago

Hmm, cabal test --allow-newer tasty results in

Running 1 test suites...
Test suite tasty: RUNNING...
tasty: ./dhall-lang/tests/normalization/success: getPermissions:getFileStatus: does not exist (No such file or directory)
Test suite tasty: FAIL

(feel free to ignore this)

sjakobi commented 4 years ago

@amesgen Did you git submodule update --init?

amesgen commented 4 years ago

Ah sry, that was it! My fix above does not work, good to know!

https://gist.github.com/amesgen/60ac5ab3884dc277de4da78fe1580637