[GHC] #14113: Error message carets point at the wrong places in the presence of CPP macros

GHC ghc-devs at haskell.org
Mon Aug 14 13:13:44 UTC 2017


#14113: Error message carets point at the wrong places in the presence of CPP
macros
-------------------------------------+-------------------------------------
           Reporter:  RyanGlScott    |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.2.1
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  Poor/confusing
  Unknown/Multiple                   |  error message
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 Here's a program which doesn't typecheck:

 {{{#!hs
 {-# LANGUAGE CPP #-}
 module Bug where

 #define FOO putStrLn 4

 main :: IO ()
 main = FOO
 }}}

 The error message it gives looks kind of strange, however:

 {{{
 GHCi, version 8.2.1: http://www.haskell.org/ghc/  :? for help
 Loaded GHCi configuration from /home/ryanglscott/.ghci
 [1 of 1] Compiling Bug              ( Bug.hs, interpreted )

 Bug.hs:7:17: error:
     • No instance for (Num String) arising from the literal ‘4’
     • In the first argument of ‘putStrLn’, namely ‘4’
       In the expression: putStrLn 4
       In an equation for ‘main’: main = putStrLn 4
   |
 7 | main = FOO
   |                 ^
 }}}

 That caret seems to be pointing as if `FOO` had been replaced by `putStrLn
 4` in the diagnostic, but since it hadn't, it just points off into space.

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14113>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list