[Git][ghc/ghc][master] Parser.y: clarify treatment of @{-# UNPACK #-}

Marge Bot gitlab at gitlab.haskell.org
Thu Sep 17 12:52:25 UTC 2020



 Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
4f461e1a by Vladislav Zavialov at 2020-09-17T08:52:19-04:00
Parser.y: clarify treatment of @{-# UNPACK #-}

Before this patch, we had this parser production:

	ftype : ...
	      | ftype PREFIX_AT tyarg  { ... }

And 'tyarg' is defined as follows:

	tyarg : atype              { ... }
	      | unpackedness atype { ... }

So one might get the (false) impression that that parser production is
intended to parse things like:

	F @{-# UNPACK #-} X

However, the lexer wouldn't produce PREFIX_AT followed by 'unpackedness',
as the '@' operator followed by '{-' is not considered prefix.

Thus there's no point using 'tyarg' after PREFIX_AT,
and a simple 'atype' will suffice:

	ftype : ...
	      | ftype PREFIX_AT atype  { ... }

This change has no user-facing consequences. It just makes the grammar a
bit more clear.

- - - - -


1 changed file:

- compiler/GHC/Parser.y


Changes:

=====================================
compiler/GHC/Parser.y
=====================================
@@ -1981,7 +1981,7 @@ ftype :: { forall b. DisambTD b => PV (Located b) }
         | tyop                          { failOpFewArgs $1 }
         | ftype tyarg                   { $1 >>= \ $1 ->
                                           mkHsAppTyPV $1 $2 }
-        | ftype PREFIX_AT tyarg         { $1 >>= \ $1 ->
+        | ftype PREFIX_AT atype         { $1 >>= \ $1 ->
                                           mkHsAppKindTyPV $1 (getLoc $2) $3 }
 
 tyarg :: { LHsType GhcPs }



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4f461e1a31263f052effd03738b11ea123512cb0

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4f461e1a31263f052effd03738b11ea123512cb0
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20200917/8ec950e9/attachment-0001.html>


More information about the ghc-commits mailing list