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

Impoverished error reporting for TH-generated haskell #371

Open
kquick opened this issue Aug 12, 2024 · 0 comments
Open

Impoverished error reporting for TH-generated haskell #371

kquick opened this issue Aug 12, 2024 · 0 comments

Comments

@kquick
Copy link
Member

kquick commented Aug 12, 2024

Given a fairly simple parser for "key=value" style input names_params.txt and using the compileDDLWith TH-generated parser, there is not much error information provided on parse failures.

ghci> runDParser $ pMain $ newInput "test" $ encodeUtf8 " min-length = 5; max-length=8; min-longth=3"
Left (ParseError {peSource = FromSystem, peLoc = "", peInput = Stream { off  = 31, len  = 11, name = "test"}, peMsg = "", peStack = []})

Compare this to:

$ cabal run exe:daedalus run -- names_params.ddl -i <(echo " min-length = 5; max-length=8; min-longth=3")
--- Parse error:
[offset: 36]
  • expected 'e' while matching "min-length"
  • see grammar at: names_params.ddl:25:5--25:19
  • context:
      • names_params.ddl:4:10--4:28
      • names_params.ddl:13:69--13:80
      • names_params.ddl:13:76--13:80
      • minLength
      • names_params.ddl:20:17--20:47
  • input trace:
      /dev/fd/63
        0--36
File context:
Length: 40 (0x28) bytes
0000:                2d 6c 65 6e  67 74 68 20  3d 20 35 3b       -length = 5;
0010:   20 6d 61 78  2d 6c 65 6e  67 74 68 3d  38 3b 20 6d    max-length=8; m
0020:   69 6e 2d 6c  6f 6e 67 74  68 3d 33 0a     in-longth=3.

Notably:

  • peLoc always seems to be a null string for errorLevel=1 and is inscrutable for errorLevel greater than one (for the above: peLoc = "DETERMINIZE 1 Fully"). I had expected this to provide location information in the input; currently I'm extracting that from peInput.off, which may be the recommended method, but I'm unsure as peLoc has no documentation.
  • peStack always seems to be an empty list for errorLevel=1, but is not particularly helpful for errorLevel greater than one (for the above: peStack = [[":ManyBody_113"],[":Many_114",":Many_114","names_params.ddl:5:5--5:39:Many_114"]], where only the last entry is somewhat useful).
  • peMsg is sometimes a null string (as seen above), and seems unaffected by errorLevel values.
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

No branches or pull requests

1 participant