Opened 3 years ago

Closed 3 years ago

#6145 closed bug (fixed)

DataCon do not have location info

Reported by: JeanPhilippeMoresmau Owned by:
Priority: normal Milestone:
Component: GHC API Version: 7.4.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect result at runtime Test Case: ghc-api/T6145
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description (last modified by simonpj)

A data constructor does not have a valid source location associated with it in the API. The sample code attached will print True in 7.0.4 and False in 7.4.1, because no valid srcspan is attached to the DataCon. This is a problem for several EclipseFP/BuildWrapper operations that rely on srcspan being right... I've notified the mailing list of the issue, and Simon Peyton Jones was kind enough to fix it without an issue, but I wanted to create it, hopefully I'll try the next nightly release:

commit cb705a38d677e2ab4cad37447c8180bd397d5576
Author: Simon Peyton Jones <[email protected]>
Date:   Tue Jun 5 13:35:07 2012 +0100

   Add sensible locations to record-selector bindings

 compiler/typecheck/TcTyClsDecls.lhs |   26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)

Attachments (1)

Main.hs (1.4 KB) - added by JeanPhilippeMoresmau 3 years ago.
File loading sample code and printing True if there is a valid SrcSpan attached to the DataCon, False otherwise

Download all attachments as: .zip

Change History (6)

Changed 3 years ago by JeanPhilippeMoresmau

File loading sample code and printing True if there is a valid SrcSpan attached to the DataCon, False otherwise

comment:1 Changed 3 years ago by simonpj

  • Description modified (diff)
  • difficulty set to Unknown

Thanks. But where is module GHC.Paths?

comment:2 Changed 3 years ago by JeanPhilippeMoresmau

Er, package ghc-paths I think. This is used to get libdir to start the API. I'm sorry, I don't know how you want such a test to be packaged. I've followed the code sample in http://www.haskell.org/haskellwiki/GHC/As_a_library, thinking that was the canonical way to call the GHC API... If there's a test harness you'd like code like this to fit in I'll be happy to oblige...

comment:3 Changed 3 years ago by simonpj

In our regression suite we try to avoid dependencies on packages that aren't in GHC's build tree, and I don't see package ghc-paths in the tree. I wonder whether it has now become filepath (which is in the tree)? Or maybe you don't need to depend on it at all?

S

comment:4 Changed 3 years ago by JeanPhilippeMoresmau

http://hackage.haskell.org/package/ghc-paths, to have an easy way to find out where GHC is installed, surely inside the test suite you know where the library directory should be... This is just for the first argument to runGhc (as the docs say: The first argument should point to the directory where GHC's library files reside. More precisely, this should be the output of ghc --print-libdir of the version of GHC the module using this API is compiled with. For portability, you should use the ghc-paths package, available at http://hackage.haskell.org/cgi-bin/hackage-scripts/package/ghc-paths.) So maybe using Nothing instead of Just libdir works inside the test suite.

comment:5 Changed 3 years ago by simonpj

  • Resolution set to fixed
  • Status changed from new to closed
  • Test Case set to ghc-api/T6145

OK, with a bit of fiddling I made the test work.

Note: See TracTickets for help on using tickets.