Lexer: Alternate Layout Rule injects actual not virtual braces
authorAlan Zimmerman <alan.zimm@gmail.com>
Sun, 3 Feb 2019 08:27:42 +0000 (10:27 +0200)
committerBen Gamari <ben@smart-cactus.org>
Tue, 5 Feb 2019 03:23:10 +0000 (22:23 -0500)
commit9e94a14986c8397c219c4fa17069680775019bc6
treef3407263870a5cd455d897147adfe4018f37dec4
parent11723122d13e295509aa3ba89f6fb5a8f27ab778
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
compiler/parser/Lexer.x
testsuite/tests/ghc-api/annotations/Makefile
testsuite/tests/ghc-api/annotations/T16279.stdout [new file with mode: 0644]
testsuite/tests/ghc-api/annotations/Test16279.hs [new file with mode: 0644]
testsuite/tests/ghc-api/annotations/all.T