Skip to content
  • Vladislav Zavialov's avatar
    Improve NegativeLiterals (#18022, GHC Proposal #344) · aee45d9e
    Vladislav Zavialov authored and Marge Bot's avatar Marge Bot committed
    Before this patch, NegativeLiterals used to parse x-1 as x (-1).
    
    This may not be what the user expects, and now it is fixed:
    x-1 is parsed as (-) x 1.
    
    We achieve this by the following requirement:
    
      * When lexing a negative literal,
        it must not be preceded by a 'closing token'.
    
    This also applies to unboxed literals, e.g. -1#.
    
    See GHC Proposal #229 for the definition of a closing token.
    
    A nice consequence of this change is that -XNegativeLiterals becomes a
    subset of -XLexicalNegation. In other words, enabling both of those
    extensions has the same effect as enabling -XLexicalNegation alone.
    aee45d9e