[GHC] #13012: ApiAnnotations comments are not machine checked

#13012: ApiAnnotations comments are not machine checked -------------------------------------+------------------------------------- Reporter: ezyang | Owner: alanz Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.1 (Parser) | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Sprinkled throughout the codebase are comments like this: {{{ -- | let(rec) -- -- - 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnLet', -- 'ApiAnnotation.AnnOpen' @'{'@, -- 'ApiAnnotation.AnnClose' @'}'@,'ApiAnnotation.AnnIn' }}} The comments are intended to describe the set of annotations that might be possibly associated with an AST node of this constructor. However, the source of truth about these comments is the Parser itself. It's not difficult to imagine that these comments might get out of date if changes are made to the Parser. Nor does the comment in `ApiAnnotations` nor the wiki page (https://ghc.haskell.org/trac/ghc/wiki/ApiAnnotations) explain what the comments are for, and I only recently figured out what they actually mean. (I'm working on a doc patch to improve this.) Ideally, the set of permissible annotations would be encoded in *machine- readable* form, as a contract that we can use to check that the parser upholds the contract. Here is my suggestion: we create a function to recursively traverse a parsed module, and verify that the only annotations associated with any given SrcSpan are the "valid" ones for that AST element. We can enable this extra pass as an "annotation lint" and turn it on for all tests in the test suite. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13012 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13012: ApiAnnotations comments are not machine checked -------------------------------------+------------------------------------- Reporter: ezyang | Owner: alanz Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.1 (Parser) | Resolution: | Keywords: easy Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by ezyang): * keywords: => easy -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13012#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13012: ApiAnnotations comments are not machine checked -------------------------------------+------------------------------------- Reporter: ezyang | Owner: alanz Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.1 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by mpickering): * keywords: easy => Comment: This exact information already exists in ghc-exactprint - https://github.com/alanz/ghc- exactprint/blob/master/src/Language/Haskell/GHC/ExactPrint/Annotate.hs - and we tested it by running it on the whole of hackage. I agree that the comments are useless, any consumers should just use `ghc- exactprint` as it performs a lot of utility with the annotations. There haven't been many people who have used it though as the API is not great and balancing everything is quite complicated. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13012#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC