diff options
Diffstat (limited to 'docs')
-rw-r--r-- | docs/users_guide/8.12.1-notes.rst | 7 | ||||
-rw-r--r-- | docs/users_guide/exts/negative_literals.rst | 14 |
2 files changed, 15 insertions, 6 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 ~~~~~~~~ diff --git a/docs/users_guide/exts/negative_literals.rst b/docs/users_guide/exts/negative_literals.rst index 237fabf044..c2dbc1eff4 100644 --- a/docs/users_guide/exts/negative_literals.rst +++ b/docs/users_guide/exts/negative_literals.rst @@ -24,9 +24,11 @@ will elicit an unexpected integer-literal-overflow message. Whitespace can be inserted, as in ``- 123``, to force interpretation as two tokens. -One pitfall is that with :extension:`NegativeLiterals`, ``x-1`` will -be parsed as ``x`` applied to the argument ``-1``, which is usually -not what you want. ``x - 1`` or even ``x- 1`` can be used instead -for subtraction. To avoid this, consider using :extension:`LexicalNegation` -instead. - +In 8.12, the behavior of this extension 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)``. + +:extension:`NegativeLiterals` is a subset of :extension:`LexicalNegation`. That +is, enabling both of those extensions has the same effect as enabling +:extension:`LexicalNegation` alone. |