ssadler / hawk

Awk for Hoodlums
BSD 3-Clause "New" or "Revised" License
35 stars 2 forks source link

use the LINE pragma #58

Closed gelisam closed 11 years ago

gelisam commented 11 years ago

Section 7.13.6 http://www.haskell.org/ghc/docs/7.2.1/html/users_guide/pragmas.html

This will allow prelude errors to be displayed as errors in prelude.hs instead of errors in "config20130821042820573056.hs" with slightly-different line numbers.

gelisam commented 11 years ago

Works for errors before the module declaration:

> head -n1 ~/.hawk/prelude.hs 
{-# OPTIONS -XOerloadedStrings #-}
> hawk [1..3]
Error detected while loading configuration file: /Users/gelisam/.hawk/cache/config20130821115847875939.hs

/Users/gelisam/.hawk/prelude.hs:1:12:
    unknown flag in  {-# OPTIONS_GHC #-} pragma: -XOerloadedStrings

Please check the file for errors.

As you can see, the ghc error message has changed, but hawk's message hasn't. Now that we correctly indicate that the source of the error is in the prelude and not in the cache file, maybe we don't need the custom error message at all?

melrief commented 11 years ago

Absolutely yes, that's a huge step forward for the usability of Hawk

gelisam commented 11 years ago

Now also works for errors after the module declaration:

> head -n5 ~/.hawk/prelude.hs 
{-# OPTIONS -XOverloadedStrings #-}

4

import           Prelude
> hawk [1..3]
Error detected while loading configuration file: /Users/gelisam/.hawk/cache/config20130821121704251373.hs

/Users/gelisam/.hawk/prelude.hs:5:1: parse error on input `import'

Please check the file for errors.
gelisam commented 11 years ago

I have also removed our wrapper around ghc's error message, I hope that's okay with you.

Also, the error is now printed on stderr.

> head -n1 ~/.hawk/prelude.hs
{-# LANGUAGE OerloadedStrings #-}
> hawk [1..3] 2> out
> echo $?
1
> cat out

/Users/gelisam/.hawk/prelude.hs:1:14:
    Unsupported extension: OerloadedStrings
    Perhaps you meant `OverloadedStrings' or `NoOverloadedStrings'