Skip to content
  • Alan Zimmerman's avatar
    f6abc30d
    Lexer: Alternate Layout Rule injects actual not virtual braces · f6abc30d
    Alan Zimmerman authored and Ben Gamari's avatar Ben Gamari committed
    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)
    f6abc30d
    Lexer: Alternate Layout Rule injects actual not virtual braces
    Alan Zimmerman authored and Ben Gamari's avatar Ben Gamari committed
    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)
Loading