Opened 3 years ago

Last modified 4 months ago

#7430 new bug

GHC API reports CPP errors in confusing ways

Reported by: MikolajKonarski Owned by:
Priority: normal Milestone: 7.12.1
Component: GHC API Version: 7.6.1
Keywords: Cc:
Operating System: Linux Architecture: Unknown/Multiple
Type of failure: Other Test Case:
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description

When there is a CPP error, the GHC API provides a normal error message (such as in case of type errors), e.g.,

error: missing binary operator before token "("

but it does not say it's a CPP error. In addition (and unlike for type errors), GHC API throws an exception, e.g.,

phase `C pre-processor' failed (exitcode = 1)

which states the error comes from CPP, but is otherwise uninformative and not tied in any way to the normal error message.

Ideally, all the information would be in the error message and the exception that disrupts the normal control flow would not be thrown.

Here's how to reproduce this: in the following repo (uh, just realised it's a rather large repo)

https://github.com/Mikolaj/ghc/tree/CPPrunGhc

run

ghc --make GhcRun.hs -package ghc-7.6.1

and then

./GhcRun

You should get

Normal error message:
Severity: SevError  SrcSpan: RealSrcSpan (SrcSpanPoint {srcSpanFile = "Ticks.hs", srcSpanLine = 1, srcSpanCol = 0})  MsgDoc:  error: missing binary operator before token "("

Exception:
GhcRun: phase `C pre-processor' failed (exitcode = 1)

Attachments (2)

GhcRun.hs (2.3 KB) - added by MikolajKonarski 3 years ago.
Ticks.hs (42 bytes) - added by MikolajKonarski 3 years ago.

Download all attachments as: .zip

Change History (8)

Changed 3 years ago by MikolajKonarski

Changed 3 years ago by MikolajKonarski

comment:1 Changed 3 years ago by MikolajKonarski

Attached the source files. Just make sure you run GhcRun in the same directory that Ticks.hs resides.

comment:2 Changed 2 years ago by igloo

  • difficulty set to Unknown
  • Milestone set to 7.8.1

Thanks for the report.

comment:3 Changed 16 months ago by thoughtpolice

  • Milestone changed from 7.8.3 to 7.10.1

Moving to 7.10.1

comment:4 Changed 9 months ago by thomie

Confirmed with 7.8.3. Unfortunately the example doesn't compile with ghc-7.9.20141121.

comment:5 Changed 8 months ago by thoughtpolice

  • Milestone changed from 7.10.1 to 7.12.1

Moving to 7.12.1 milestone; if you feel this is an error and should be addressed sooner, please move it back to the 7.10.1 milestone.

comment:6 Changed 4 months ago by ezyang

Should be possible to construct a small example?

Note: See TracTickets for help on using tickets.