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 (cherry picked from commit c1cf2693) (cherry picked from commit e0375ba9)
Showing
- compiler/parser/Lexer.x 17 additions, 15 deletionscompiler/parser/Lexer.x
- testsuite/tests/ghc-api/annotations/Makefile 20 additions, 0 deletionstestsuite/tests/ghc-api/annotations/Makefile
- testsuite/tests/ghc-api/annotations/T16279.stdout 30 additions, 0 deletionstestsuite/tests/ghc-api/annotations/T16279.stdout
- testsuite/tests/ghc-api/annotations/Test16279.hs 10 additions, 0 deletionstestsuite/tests/ghc-api/annotations/Test16279.hs
- testsuite/tests/ghc-api/annotations/all.T 2 additions, 0 deletionstestsuite/tests/ghc-api/annotations/all.T
Please register or sign in to comment