[GHC] #15279: CPP #includes may result in nonsensical SrcSpans

#15279: CPP #includes may result in nonsensical SrcSpans -------------------------------------+------------------------------------- Reporter: wz1000 | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.4.3 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Other Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Consider the following code in `compiler/prelude/PrimOp.hs` {{{#!hs primOpInfo :: PrimOp -> PrimOpInfo #include "primop-primop-info.hs-incl" primOpInfo _ = error "primOpInfo: unknown primop" -- line 175 in PrimOp.hs }}} The MatchGroup for primOpInfo includes the `SrcSpan` `compiler/stage2/build/primop-primop-info.hs-incl:(1,1)-(175,49)` Here is line 175 in `primop-primop-info.hs-incl` {{{#!hs primOpInfo IndexSmallArrayOp = mkGenPrimOp (fsLit "indexSmallArray#") [alphaTyVar] [mkSmallArrayPrimTy alphaTy, intPrimTy] ((mkTupleTy Unboxed [alphaTy])) }}} The `SrcSpan`s end is somewhere in the middle of that line. I guess this occurs because `combineSrcSpans` doesn't take the file into account. I can think of multiple ways to fix this: 1. Make `combineSrcSpans` output an `UnhelpfulSrcSpan` if the files don't match(quick and easy) 2. Extend SrcSpan to properly support things spanning multiple files 3. Don't fix: People who use CPP get what they deserve. Option 3 is not unreasonable as options 1 and 2 will incur some performance penalty. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15279 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15279: CPP #includes may result in nonsensical SrcSpans -------------------------------------+------------------------------------- Reporter: wz1000 | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.4.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by wz1000): * cc: bgamari, gbaz (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15279#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15279: CPP #includes may result in nonsensical SrcSpans -------------------------------------+------------------------------------- Reporter: wz1000 | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.4.3 Resolution: | Keywords: cpp Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: #14113 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * keywords: => cpp * related: => #14113 Comment: See #14113 for another example of CPP ruining `SrcSpan`s. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15279#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15279: CPP #includes may result in nonsensical SrcSpans -------------------------------------+------------------------------------- Reporter: wz1000 | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.4.3 Resolution: | Keywords: cpp Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: #14113 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): Indeed (2) seems like it might be a bit more complexity than warranted by the severity of the issue. (1) on the other hand seems a bit unfortunate since it may lose useful (albeit also slightly misleading) information. Nevertheless, I agree that (3) is also unfortunately so yes, let's just move ahead with (1). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15279#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15279: CPP #includes may result in nonsensical SrcSpans -------------------------------------+------------------------------------- Reporter: wz1000 | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.4.3 Resolution: | Keywords: cpp Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: #14113 | Differential Rev(s): Phab:D4866 Wiki Page: | -------------------------------------+------------------------------------- Changes (by wz1000): * differential: => Phab:D4866 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15279#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15279: CPP #includes may result in nonsensical SrcSpans
-------------------------------------+-------------------------------------
Reporter: wz1000 | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.4.3
Resolution: | Keywords: cpp
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: Other | Test Case:
Blocked By: | Blocking:
Related Tickets: #14113 | Differential Rev(s): Phab:D4866
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Krzysztof Gogolewski

#15279: CPP #includes may result in nonsensical SrcSpans -------------------------------------+------------------------------------- Reporter: wz1000 | Owner: (none) Type: bug | Status: merge Priority: normal | Milestone: Component: Compiler | Version: 8.4.3 Resolution: | Keywords: cpp Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: #14113 | Differential Rev(s): Phab:D4866 Wiki Page: | -------------------------------------+------------------------------------- Changes (by monoidal): * status: new => merge -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15279#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15279: CPP #includes may result in nonsensical SrcSpans -------------------------------------+------------------------------------- Reporter: wz1000 | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: fixed | Keywords: cpp Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: #14113 | Differential Rev(s): Phab:D4866 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed * milestone: => 8.6.1 Comment: Merged with 033d6ac775fad0aee9335169a41d19f54eee1486. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15279#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC