Opened 4 years ago

Closed 4 years ago

#10537 closed bug (fixed)

Parser: commas_tup_tail duplicate SrcSpan on "Missing" value

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

Description (last modified by alanz)

Parsing

{-# LANGUAGE TupleSections #-}

baz = (1, "hello", 6.5,,) 'a' (Just ())

Results in the following AST fragment

(L tests/examples/Tuple.hs:3:7-25
   (ExplicitTuple
      [ L tests/examples/Tuple.hs:3:8
          (Present
             (L tests/examples/Tuple.hs:3:8
                (HsOverLit
                   (OverLit
                      (HsIntegral [ '1' ] 1)
                      PlaceHolder
                      (HsLit
                         (HsString
                            []
                            {abstract:FastString}))
                      PlaceHolder))))
      , L tests/examples/Tuple.hs:3:11-17
          (Present
             (L tests/examples/Tuple.hs:3:11-17
                (HsLit
                   (HsString
                      [ '"'
                      , 'h'
                      , 'e'
                      , 'l'
                      , 'l'
                      , 'o'
                      , '"'
                      ]
                      {abstract:FastString}))))
      , L tests/examples/Tuple.hs:3:20-22
          (Present
             (L tests/examples/Tuple.hs:3:20-22
                (HsOverLit
                   (OverLit
                      (HsFractional
                         (FL
                            [ '6' , '.' , '5' ]
                            (:% 13 2)))
                      PlaceHolder
                      (HsLit
                         (HsString
                            []
                            {abstract:FastString}))
                      PlaceHolder))))
      , L tests/examples/Tuple.hs:3:24
          (Missing PlaceHolder)
      , L tests/examples/Tuple.hs:3:24
          (Missing PlaceHolder)
      ]

The final Missing PlaceHolder has a duplicated SrcSpan

Change History (8)

comment:1 Changed 4 years ago by simonpj

It doesn't look duplicated to me. There are indeed two missing elements in the tuple.

Do you have a program that goes wrong?

comment:2 Changed 4 years ago by mpickering

I think you're right Simon. There is something wrong with the annotations though, firstly both the Missing elements have the same SrcSpan L tests/examples/Tuple.hs:3:24.

 ((tests/examples/Tuple.hs:3:8, AnnComma),
   [tests/examples/Tuple.hs:3:9]),
  ((tests/examples/Tuple.hs:3:11-17, AnnComma),
   [tests/examples/Tuple.hs:3:18]),
  ((tests/examples/Tuple.hs:3:20-22, AnnComma),
   [tests/examples/Tuple.hs:3:23]),
  ((tests/examples/Tuple.hs:3:24, AnnComma),
   [tests/examples/Tuple.hs:3:24]),

Here are the relevant annotations. Notice how the first three commas are associated with the preceding item (much like they are for lists) but the last one is associated directly with the Missing. As both Missings have the same SrcSpan then this is causing duplicated output in ghc-exactprint.

comment:3 Changed 4 years ago by alanz

Description: modified (diff)
Summary: Parser: commas_tup_tail returns spurious "Missing" valueParser: commas_tup_tail duplicate SrcSpan on "Missing" value

comment:4 Changed 4 years ago by alanz

Status: newpatch

comment:5 Changed 4 years ago by alanz

Differential Rev(s): Phab:D995

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

In 72b21c393831b49867a296f19a2d039e48bb8dcd/ghc:

Parser: commas_tup_tail duplicate SrcSpan on "Missing" value

Summary:
Parsing

    {-# LANGUAGE TupleSections #-}

    baz = (1, "hello", 6.5,,) 'a' (Just ())

Results in the following AST fragment

    (L tests/examples/Tuple.hs:3:7-25
       (ExplicitTuple
          [ L tests/examples/Tuple.hs:3:8
              (Present
                 (L tests/examples/Tuple.hs:3:8
                    (HsOverLit
                       (OverLit
                          (HsIntegral [ '1' ] 1)
                          PlaceHolder
                          (HsLit
                             (HsString
                                []
                                {abstract:FastString}))
                          PlaceHolder))))
          , L tests/examples/Tuple.hs:3:11-17
              (Present
                 (L tests/examples/Tuple.hs:3:11-17
                    (HsLit
                       (HsString
                          [ '"'
                          , 'h'
                          , 'e'
                          , 'l'
                          , 'l'
                          , 'o'
                          , '"'
                          ]
                          {abstract:FastString}))))
          , L tests/examples/Tuple.hs:3:20-22
              (Present
                 (L tests/examples/Tuple.hs:3:20-22
                    (HsOverLit
                       (OverLit
                          (HsFractional
                             (FL
                                [ '6' , '.' , '5' ]
                                (:% 13 2)))
                          PlaceHolder
                          (HsLit
                             (HsString
                                []
                                {abstract:FastString}))
                          PlaceHolder))))
          , L tests/examples/Tuple.hs:3:24
              (Missing PlaceHolder)
          , L tests/examples/Tuple.hs:3:24
              (Missing PlaceHolder)
          ]

The final `Missing PlaceHolder` has a duplicated `SrcSpan`

Test Plan: ./validate

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: thomie, bgamari, mpickering

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

GHC Trac Issues: #10537

comment:7 Changed 4 years ago by alanz

Status: patchmerge

comment:8 Changed 4 years ago by thoughtpolice

Resolution: fixed
Status: mergeclosed

Merged to ghc-7.10.

Note: See TracTickets for help on using tickets.