Lexer: Alternate Layout Rule injects actual not virtual braces

Authored by alanz on Feb 3 2019, 2:27 AM.

Description

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 Trac #16279

(cherry picked from commit c1cf2693d6efddeeeb813cd8995a1be136800d17)
(cherry picked from commit e0375ba980fd5639d23a29575efb00c30d97c743)

Details

Committed
bgamariFeb 26 2019, 11:58 AM
Parents
rGHCca5b476083e4: Revert "Lexer: Alternate Layout Rule injects actual not virtual braces"
Branches
Unknown
Tags
Unknown