Opened 4 years ago

Closed 4 years ago

#10588 closed bug (fixed)

BangPat gets wrong SrcSpan.

Reported by: mpickering Owned by:
Priority: normal Milestone: 7.10.2
Component: Compiler Version: 7.10.1
Keywords: Cc: alanz
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D1020
Wiki Page:

Description

In this simple file

{-# LANGUAGE BangPatterns #-}
 
baz !"a" = bang

It can be seen that on line 28 the BangPat has the wrong SrcSpan.

({ typetest.hs:1:1 }
 Just (Ann (DP (0,0)) (ColDelta 1) DP (0,0) [] [((G AnnEofPos),DP (1,0))])
 (HsModule 
  (Nothing) 
  (Nothing) 
  [] 
  [
   ({ typetest.hs:3:1-15 }
    Just (Ann (DP (2,1)) (ColDelta 1) DP (2,1) [(Comment {commentPos = DP (0,29), commentContents = "{-# LANGUAGE BangPatterns #-}", commentIdentifier = RealSrcSpan SrcSpanOneLine "typetest.hs" 1 1 30, commentOrigin = Nothing},DP (0,0))] [])
    (ValD 
     (FunBind 
      ({ typetest.hs:3:1-3 }
       Just (Ann (DP (0,0)) (ColDelta 1) DP (0,0) [] [((G AnnVal),DP (0,0))])
       (Unqual {OccName: baz})) 
      (False) 
      (MG 
       [
        ({ typetest.hs:3:1-15 }
         Just (Ann (DP (0,0)) (ColDelta 1) DP (0,0) [] [((G AnnEqual),DP (0,1)),((AnnList <no location info> NotNeeded),DP (0,0))])
         (Match 
          (Just 
           ((,) 
            ({ typetest.hs:3:1-3 }
             Just (Ann (DP (0,0)) (ColDelta 1) DP (0,0) [] [((G AnnVal),DP (0,0))])
             (Unqual {OccName: baz})) 
            (False))) 
          [
           ({ typetest.hs:3:1-8 }
            Just (Ann (DP (0,-3)) (ColDelta 1) DP (0,-3) [] [((G AnnBang),DP (0,1))])
            (BangPat 
             ({ typetest.hs:3:6-8 }
              Just (Ann (DP (0,0)) (ColDelta 6) DP (0,0) [] [((G AnnVal),DP (0,0))])
              (LitPat 
               (HsString "\"a\"" {FastString: "a"})))))] 
          (Nothing) 
          (GRHSs 
           [
            ({ typetest.hs:3:10-15 }
             Just (Ann (DP (0,-1)) (ColDelta 10) DP (0,-1) [] [])
             (GRHS 
              [] 
              ({ typetest.hs:3:12-15 }
               Just (Ann (DP (0,1)) (ColDelta 12) DP (0,1) [] [((G AnnVal),DP (0,0))])
               (HsVar 
                (Unqual {OccName: bang})))))] 
           (EmptyLocalBinds))))] 
       [] 
       (PlaceHolder) 
       (FromSource)) 
      (WpHole) 
      (PlaceHolder) 
      [])))] 
  (Nothing) 
  (Nothing)))

Change History (7)

comment:1 Changed 4 years ago by mpickering

Differential Rev(s): Phab: D1020
Status: newpatch

comment:2 Changed 4 years ago by mpickering

Differential Rev(s): Phab: D1020Phab:D1020

comment:3 Changed 4 years ago by mpickering

Milestone: 7.10.2

comment:4 Changed 4 years ago by mpickering

Cc: alanz added

comment:5 Changed 4 years ago by Alan Zimmerman <alan.zimm@…>

In c6bb2fc50716a2fc540d55ecddbc5c14e94979f7/ghc:

Correct BangPat SrcSpan calculation

Summary:
Previously when the split was performed in splitBang, `BangPat` was given the
same SrcSpan as the whole of the LHS of the declaration. This patch
correctly calculates the value.

Reviewers: alanz, austin

Reviewed By: alanz, austin

Subscribers: thomie, bgamari

Differential Revision: https://phabricator.haskell.org/D1020

GHC Trac Issues: #10588

comment:6 Changed 4 years ago by mpickering

Status: patchmerge

comment:7 Changed 4 years ago by thoughtpolice

Resolution: fixed
Status: mergeclosed
Note: See TracTickets for help on using tickets.