[GHC] #13388: Caret diagnostics interact badly with hsc2hs

#13388: Caret diagnostics interact badly with hsc2hs -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Incorrect Unknown/Multiple | error/warning at compile-time Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- I saw this recently, {{{ libraries\Win32\Graphics\Win32\Window.hsc:188:46: error: Not in scope: type constructor or class `Int32' | 188 | cW_USEDEFAULT = fromIntegral (#{const CW_USEDEFAULT} :: Int32) | ^^^^^ }}} Clearly the caret is pointing to the wrong place in the line. Note that the file in question is a `hsc2hs` file. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13388 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13388: Caret diagnostics interact badly with hsc2hs -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): Here's an easier way to reproduce this: {{{#!hs module Bug where #define LONG_CONSTANT_NAME 42 lONG_CONSTANT_NAME = #{const LONG_CONSTANT_NAME} :: Int32 }}} {{{ $ hsc2hs Bug.hsc $ ~/Software/ghc5/inplace/bin/ghc-stage2 --interactive -Wall Bug.hs GHCi, version 8.1.20170303: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/rgscott/.ghci [1 of 1] Compiling Bug ( Bug.hs, interpreted ) Bug.hsc:5:28: error: Not in scope: type constructor or class ‘Int32’ | 5 | lONG_CONSTANT_NAME = #{const LONG_CONSTANT_NAME} :: Int32 | ^^^^^ Failed, modules loaded: none. }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13388#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13388: Caret diagnostics interact badly with hsc2hs -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Rufflewind): Hm, it seems hsc2hs does not propagate column numbers from the original source file. One could add spaces as necessary to push tokens to the correct location: {{{ lONG_CONSTANT_NAME = 42 :: Int32 }}} If the replaced token is longer then it could be worked around as: {{{ lONG_CONSTANT_NAME = someVeryVeryVeryVeryVeryLongConstant {-# LINE 5 "Bug.hsc" #-} :: Int32 }}} But this might be risky because Haskell is indentation sensitive, so perhaps the simpler approach is to teach GHC a more precise `LINE` pragma: {{{ {-# LINE 5 "Bug.hsc" 57 49 #-} lONG_CONSTANT_NAME = someVeryVeryVeryVeryVeryLongConstant :: Int32 }}} The syntax of this new pragma could be something like: {{{ {-# LINE <line> <name> <oldCol1> <newCol1> <oldCol2> <newCol2> ... #-} }}} This can be used to adjust column numbers. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13388#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13388: Caret diagnostics interact badly with hsc2hs -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Rufflewind): WIP differentials: - https://phabricator.haskell.org/D3313 (ghc) - https://phabricator.haskell.org/D3314 (hsc2hs) Note: the new pragma will be just `{-# COLUMN 12345 #-}`, because it’s simpler for both ghc and hsc2hs. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13388#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13388: Caret diagnostics interact badly with hsc2hs -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: merge Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => merge Comment: Merged to `master` in e61b4a4169da17cd7b77f9dc09e3627eff1ff559. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13388#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13388: Caret diagnostics interact badly with hsc2hs -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed Comment: GHC change merged to `ghc-8.2` in 2bd87cd498a6dc3b7c37362f8645b00ba5262410. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13388#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13388: Caret diagnostics interact badly with hsc2hs
-------------------------------------+-------------------------------------
Reporter: bgamari | Owner: (none)
Type: bug | Status: closed
Priority: normal | Milestone: 8.2.1
Component: Compiler | Version: 8.0.1
Resolution: fixed | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Incorrect | Unknown/Multiple
error/warning at compile-time | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari
participants (1)
-
GHC