[commit: ghc] master: Add comment to Parser.y re extra API Annotation (638fde5)
git at git.haskell.org
git at git.haskell.org
Sun Nov 22 19:26:30 UTC 2015
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/638fde50365f29bc82fdf7058ab966a33d19e5ca/ghc
>---------------------------------------------------------------
commit 638fde50365f29bc82fdf7058ab966a33d19e5ca
Author: Alan Zimmerman <alan.zimm at gmail.com>
Date: Sun Nov 22 21:18:24 2015 +0200
Add comment to Parser.y re extra API Annotation
Document extra AnnRarrow annotation on a HsFunTy
>---------------------------------------------------------------
638fde50365f29bc82fdf7058ab966a33d19e5ca
compiler/parser/Parser.y | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/compiler/parser/Parser.y b/compiler/parser/Parser.y
index 7b40574..e761828 100644
--- a/compiler/parser/Parser.y
+++ b/compiler/parser/Parser.y
@@ -1607,12 +1607,28 @@ context :: { LHsContext RdrName }
else return ()
; ams ctx anns
} }
+{- Note [GADT decl discards annotations]
+~~~~~~~~~~~~~~~~~~~~~
+The type production for
+
+ btype `->` btype
+
+adds the AnnRarrow annotation twice, in different places.
+
+This is because if the type is processed as usual, it belongs on the annotations
+for the type as a whole.
+
+But if the type is passed to mkGadtDecl, it discards the top level SrcSpan, and
+the top-level annotation will be disconnected. Hence for this specific case it
+is connected to the first type too.
+-}
+
-- See Note [Parsing ~]
type :: { LHsType RdrName }
: btype { splitTilde $1 }
| btype qtyconop type { sLL $1 $> $ mkHsOpTy $1 $2 $3 }
| btype tyvarop type { sLL $1 $> $ mkHsOpTy $1 $2 $3 }
- | btype '->' ctype {% ams $1 [mu AnnRarrow $2]
+ | btype '->' ctype {% ams $1 [mu AnnRarrow $2] -- See note [GADT decl discards annotations]
>> ams (sLL $1 $> $ HsFunTy (splitTilde $1) $3)
[mu AnnRarrow $2] }
| btype SIMPLEQUOTE qconop type {% ams (sLL $1 $> $ mkHsOpTy $1 $3 $4)
More information about the ghc-commits
mailing list