Opened 10 months ago

Last modified 9 months ago

#16279 merge bug

Lexer: Alternate Layout Rule injects actual not virtual braces

Reported by: alanz Owned by: alanz
Priority: normal Milestone: 8.8.1
Component: Compiler (Parser) Version: 8.6.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect API annotation Test Case:
Blocked By: Blocking:
Related Tickets: #13807 Differential Rev(s): https://gitlab.haskell.org/ghc/ghc/merge_requests/284
Wiki Page:

Description

When the alternate layout rule is activated via a pragma, it injects tokens for { and } to make sure that the source is parsed properly.

But it injects ITocurly and ITccurly, rather than their virtual counterparts ITvocurly and ITvccurly.

This causes problems for ghc-exactprint, which tries to print these.

Test case (the existing T13087.hs)

{-# LANGUAGE AlternativeLayoutRule #-}
{-# LANGUAGE LambdaCase            #-}

isOne :: Int -> Bool
isOne = \case 1 -> True
              _ -> False

main = return ()

Change History (4)

comment:1 Changed 10 months ago by alanz

Milestone: 8.8.1
Owner: set to alanz

comment:2 Changed 10 months ago by alanz

Status: newmerge

comment:3 Changed 10 months ago by bgamari

Differential Rev(s): https://gitlab.haskell.org/ghc/ghc/merge_requests/284

comment:4 Changed 9 months ago by Marge Bot <ben+marge-bot@…>

In c1cf2693/ghc:

Lexer: Alternate Layout Rule injects actual not virtual braces

When the alternate layout rule is activated via a pragma, it injects
tokens for { and } to make sure that the source is parsed properly.

But it injects ITocurly and ITccurly, rather than their virtual
counterparts ITvocurly and ITvccurly.

This causes problems for ghc-exactprint, which tries to print these.

Likewise, any injected ITsemi should have a zero-width SrcSpan.

Test case (the existing T13087.hs)

    {-# LANGUAGE AlternativeLayoutRule #-}
    {-# LANGUAGE LambdaCase            #-}

    isOne :: Int -> Bool
    isOne = \case 1 -> True
                  _ -> False

    main = return ()

Closes #16279
Note: See TracTickets for help on using tickets.