Skip to content

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

Open
@xal-0

Description

@xal-0

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"])

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions