abau / co4

COmplexity COncerned COnstraint COmpiler
GNU General Public License v3.0
2 stars 3 forks source link

line numbers in error messages #67

Open jwaldmann opened 10 years ago

jwaldmann commented 10 years ago

if I have an incomplete pattern match (missing a case), I get

tc/CO4/Test/TermComp2014/Main.hs:1:1:
    Exception when trying to run compile-time code:
      Algorithms.Eitherize.matchFromConstructor: no match for constructor 'LinearInterpretation'
    Code: compileFile
            [CO4.Config.Cache, CO4.Config.Dump "/tmp/tc",
             CO4.Config.ImportPrelude]
            "tc/CO4/Test/TermComp2014/Standalone.hs"

while cabal build but it does not show the location of the case. Is srcloc info available in TH at all?

abau commented 10 years ago

The ADT of the syntax tree in TH does not contain any source locations that I am aware of.

abau commented 10 years ago
Algorithms.Eitherize.matchFromConstructor: no match for constructor 'LinearInterpretation'

is a CO4 error. It complains about an incomplete pattern match.

jwaldmann commented 10 years ago

but "LinearInterpretation" is from my source file

abau commented 10 years ago

Yes, I assume there is a ADT

data TerminationOrder = FilterAndPrec ... | LinearInterpretation ...

and a pattern match

case (e :: TerminationOrder) of FilterAndPrec {} -> foo

without a branch for the LinearInterpretation constructor

jwaldmann commented 10 years ago

The input comes from haskell-src-exts (not TH), the doc says

All nodes in the syntax tree are annotated with something of a user-definable data type. 
When parsing, this annotation will contain information about the source location 
that the particular node comes from. 

http://hackage.haskell.org/package/haskell-src-exts-1.14.0.1/docs/Language-Haskell-Exts-Annotated-Syntax.html

so perhaps something could be made to work. but it's not urgent

still keeping the issue open as a reminder.

abau commented 10 years ago

CO4 uses haskell-src-meta to map the syntax tree to TH. I assume that erases all location information. I will investigate...