Skip to content
This repository was archived by the owner on Nov 12, 2017. It is now read-only.
This repository was archived by the owner on Nov 12, 2017. It is now read-only.

Transformed source has incorrect LINE pragmas #2

@Deewiant

Description

@Deewiant

After interpol preprocessing, there's a single LINE 1 pragma at the top of the file, but no others, even though comments are stripped and whitespace is changed. This leads to GHC's error messages pointing at wrong lines. Consider for example:

-- Hello!

{-# OPTIONS_GHC -F -pgmF interpol #-}

-- Hey there!

module Bug where


-- Greetings!


foo :: Int
foo = "wrong type"

-- Bye!

After ghc -E, we're left with:

{-# LINE 1 "asdf.hs" #-}
{-# OPTIONS_GHC -F -pgmF interpol  #-}
module Bug where

foo :: Int
foo = "wrong type"

And the error message points to asdf.hs:5:7 instead of asdf.hs:14:7. If foo here were to contain a string interpolation, it'd point to line 6 instead of 5, as the import of Text.Interpol would be added.

The Test/NoWarn.hs file in the repository is another example of a file that would suffer from this, if it were to contain any type errors. (For example, try removing putStrLn from the definition of foo there.)

I'm not sure what can be done about this as I'm not at all familiar with haskell-src-exts. In my mind, the simplest solution would be to not modify the original source in any way except to perform the string interpolation (duh), add the import, and immediately after the import add a LINE pragma for the appropriate line number. If that's not an option, you need a LINE pragma after every removed comment and blank line...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions