Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,260
    • Issues 4,260
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 398
    • Merge Requests 398
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #14113

Closed
Open
Opened Aug 14, 2017 by Ryan Scott@RyanGlScottMaintainer

Error message carets point at the wrong places in the presence of CPP macros

Here's a program which doesn't typecheck:

{-# 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.

Trac metadata
Trac field Value
Version 8.2.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC Rufflewind
Operating system
Architecture
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#14113