implicit-hie icon indicating copy to clipboard operation
implicit-hie copied to clipboard

Confusing parsing behaviour when a list is the last thing in the .cabal file

Open xal-0 opened this issue 4 years ago • 0 comments
trafficstars

I ran into some rather confusing behaviour when I used gen-hie with a cabal file that ended with an other-modules list. I loaded Hie.Cabal.Parser into GHCi to confirm this.

Test cabal file (to be parsed with/without a final newline):

name: foo
executable bar
  main-is: Main.hs
  other-modules: Hello
               , World

This file seems to miss World both with/without the final newline.

λ> parsePackage' "name: foo\nexecutable bar\n  main-is: Main.hs\n  other-modules: Hello\n               , World"
Right (Package "foo" [Comp Exe "bar" "./Main.hs",Comp Exe "bar" "./Hello.hs"])

λ> parsePackage' "name: foo\nexecutable bar\n  main-is: Main.hs\n  other-modules: Hello\n               , World\n"
Right (Package "foo" [Comp Exe "bar" "./Main.hs",Comp Exe "bar" "./Hello.hs"])

Test cabal file (to be parsed with/without a final newline):

name: foo
executable bar
  main-is: Main.hs
  other-modules: Hello,
                 World

This file is parsed different with/without a final newline:

λ> parsePackage' "name: foo\nexecutable bar\n  main-is: Main.hs\n  other-modules: Hello,\n                 World"
Right (Package "foo" [Comp Exe "bar" "./Main.hs"])

λ> parsePackage' "name: foo\nexecutable bar\n  main-is: Main.hs\n  other-modules: Hello,\n                 World\n"
Right (Package "foo" [Comp Exe "bar" "./Main.hs",Comp Exe "bar" "./Hello.hs",Comp Exe "bar" "./World.hs"])

xal-0 avatar Feb 14 '21 05:02 xal-0