diff options
author | Vladislav Zavialov <vlad.z.4096@gmail.com> | 2020-07-01 22:56:15 +0300 |
---|---|---|
committer | Vladislav Zavialov <vlad.z.4096@gmail.com> | 2020-07-26 07:34:51 -0400 |
commit | 9b78d4ce2d595d8d683b150ca4db21e16ee95035 (patch) | |
tree | 1ed034cde884bb87b07265cb123a66cfcb93c7c6 /docs/users_guide/8.12.1-notes.rst | |
parent | fc0f6fbcd95f2dc69a8efabbee2d8a485c34cc47 (diff) | |
download | haskell-wip/negative-literals.tar.gz |
Improve NegativeLiterals (#18022, GHC Proposal #344)wip/negative-literals
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.
Diffstat (limited to 'docs/users_guide/8.12.1-notes.rst')
-rw-r--r-- | docs/users_guide/8.12.1-notes.rst | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/docs/users_guide/8.12.1-notes.rst b/docs/users_guide/8.12.1-notes.rst index dd429c22d4..ea198f5167 100644 --- a/docs/users_guide/8.12.1-notes.rst +++ b/docs/users_guide/8.12.1-notes.rst @@ -224,6 +224,13 @@ Language f = (- x) -- operator section c = (-x) -- negation +* The behavior of :extension:`NegativeLiterals` changed, and now we require + that a negative literal must not be preceded by a closing token (see + `GHC Proposal #229 <https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0229-whitespace-bang-patterns.rst>`__ + for the definition of a closing token). In other words, we parse ``f -123`` + as ``f (-123)``, but ``x-123`` as ``(-) x 123``. Before this amendment, + :extension:`NegativeLiterals` caused ``x-123`` to be parsed as ``x(-123)``. + Compiler ~~~~~~~~ |