summaryrefslogtreecommitdiff
path: root/compiler/parser
Commit message (Collapse)AuthorAgeFilesLines
...
* Lexer: support consecutive references to Haddock chunks (#10398)Thomas Miedema2015-07-231-1/+1
| | | | | | | | | | | | Reviewers: austin, bgamari, Fuuzetsu Reviewed By: bgamari Subscribers: thomie, bgamari Differential Revision: https://phabricator.haskell.org/D1025 GHC Trac Issues: #10398
* Fix word repetitions in commentsGabor Greif2015-07-071-1/+1
|
* Add Note [Warnings in code generated by Alex]Thomas Miedema2015-07-071-7/+35
| | | | Differential Revision: https://phabricator.haskell.org/D1044
* Remove warnings for -fwarn-incomplete-patternswip/lexer-warningsAlan Zimmerman2015-07-061-3/+3
| | | | | | | | And remove one unused bind. See https://phabricator.haskell.org/rGHCc0ad5bc03e02ce0d7d545599e4b1a68a6f727f2b for concerns raised prompting this change.
* Lexer.x and Parser.y: delete dead codeThomas Miedema2015-07-052-17/+1
|
* Use -fno-warn-unused-imports instead of hiding `ord`Thomas Miedema2015-07-051-1/+2
| | | | | This is more future proof. Maybe later versions of Alex won't `import Data.Char (ord)` anymore.
* Remove dead code / overlapping pattern (#9723)Thomas Miedema2015-07-041-2/+0
|
* Replace usages of `-w` by `-fno-warn`sThomas Miedema2015-07-042-20/+11
| | | | | | | | | | | And remove unused imports and language pragmas. I checked that the minimum Happy and Alex version requirements, as listed in aclocal.m4, don't have to change. Before building ghc, I ran: - cabal install happy==1.19.4 --with-ghc=ghc-7.8.4 - cabal install alex==3.1.0 --with-ghc=ghc-7.6.3 Differential Revision: https://phabricator.haskell.org/D1032
* parser: Allow Lm (MODIFIER LETTER) category in identifiersThomas Miedema2015-07-031-2/+6
| | | | | | | | | | | | | | | | | | | Easy fix in the parser to stop regressions, due to Unicode 7.0 changing the classification of some prior code points. Signed-off-by: Austin Seipp <austin@well-typed.com> Test Plan: `tests/parser/should_compile/T10196.hs` Reviewers: hvr, austin, bgamari Reviewed By: austin, bgamari Subscribers: thomie, bgamari Differential Revision: https://phabricator.haskell.org/D969 GHC Trac Issues: #10196
* Remove redundant parser entry pointMatthew Pickering2015-07-031-2/+1
| | | | | | | | | | | | | `parseFullStmt` and `parseStatement` exposed the same parser entry point. Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: gibiansky, alanz, thomie, bgamari Differential Revision: https://phabricator.haskell.org/D1014
* Remove unnecessary OrdList from decl parser.Matthew Pickering2015-07-031-73/+112
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Each production produced a singleton list. Similar treatment is applied to the decl_cls parser. This changes the type of the parseDeclaration entry point to `parseDeclaration :: P (LHsDecl RdrName)` and `parseTypeSignature :: P (LHsDecl RdrName)` which is in line with the other parser entry points. This patch also updates the conflict commentary. There were 4 reduce/reduce conflicts introduced by `ffc21506894c7887d3620423aaf86bc6113a1071` which refactored tuple constraints. Reviewers: austin Reviewed By: austin Subscribers: thomie, bgamari Differential Revision: https://phabricator.haskell.org/D1007
* Correct BangPat SrcSpan calculationMatthew Pickering2015-06-291-2/+3
| | | | | | | | | | | | | | | | | Summary: Previously when the split was performed in splitBang, `BangPat` was given the same SrcSpan as the whole of the LHS of the declaration. This patch correctly calculates the value. Reviewers: alanz, austin Reviewed By: alanz, austin Subscribers: thomie, bgamari Differential Revision: https://phabricator.haskell.org/D1020 GHC Trac Issues: #10588
* Add parsePattern parser entry pointAlan Zimmerman2015-06-211-1/+3
| | | | | | | | | | | | Reviewers: austin, thomie, alanz Reviewed By: thomie, alanz Subscribers: thomie, bgamari Differential Revision: https://phabricator.haskell.org/D1005 GHC Trac Issues: #10556
* Parser: commas_tup_tail duplicate SrcSpan on "Missing" valueAlan Zimmerman2015-06-181-10/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Parsing {-# LANGUAGE TupleSections #-} baz = (1, "hello", 6.5,,) 'a' (Just ()) Results in the following AST fragment (L tests/examples/Tuple.hs:3:7-25 (ExplicitTuple [ L tests/examples/Tuple.hs:3:8 (Present (L tests/examples/Tuple.hs:3:8 (HsOverLit (OverLit (HsIntegral [ '1' ] 1) PlaceHolder (HsLit (HsString [] {abstract:FastString})) PlaceHolder)))) , L tests/examples/Tuple.hs:3:11-17 (Present (L tests/examples/Tuple.hs:3:11-17 (HsLit (HsString [ '"' , 'h' , 'e' , 'l' , 'l' , 'o' , '"' ] {abstract:FastString})))) , L tests/examples/Tuple.hs:3:20-22 (Present (L tests/examples/Tuple.hs:3:20-22 (HsOverLit (OverLit (HsFractional (FL [ '6' , '.' , '5' ] (:% 13 2))) PlaceHolder (HsLit (HsString [] {abstract:FastString})) PlaceHolder)))) , L tests/examples/Tuple.hs:3:24 (Missing PlaceHolder) , L tests/examples/Tuple.hs:3:24 (Missing PlaceHolder) ] The final `Missing PlaceHolder` has a duplicated `SrcSpan` Test Plan: ./validate Reviewers: austin, hvr, bgamari Reviewed By: bgamari Subscribers: thomie, bgamari, mpickering Differential Revision: https://phabricator.haskell.org/D995 GHC Trac Issues: #10537
* Lexer: Suggest adding 'let' on unexpected '=' tokenBen Gamari2015-06-161-0/+3
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: I've heard numerous fledgling Haskeller's complain about the behavior of ghci regarding bindings. While most REPLs accept bindings of the form `x = 42`, GHCi is implicitly a `do` block, meaning that the user must know to use a `let` to introduce a binding. Here we suggest to the user that they may need a `let` and give them a small example in the event that we find an unexpected `=` token. Reviewers: austin Reviewed By: austin Subscribers: thomie, bgamari Differential Revision: https://phabricator.haskell.org/D980
| * Lexer: Suggest adding 'let' on unexpected '=' tokenBen Gamari2015-06-161-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: I've heard numerous fledgling Haskeller's complain about the behavior of ghci regarding bindings. While most REPLs accept bindings of the form `x = 42`, GHCi is implicitly a `do` block, meaning that the user must know to use a `let` to introduce a binding. Here we suggest to the user that they may need a `let` and give them a small example in the event that we find an unexpected `=` token. Reviewers: austin Reviewed By: austin Subscribers: thomie, bgamari Differential Revision: https://phabricator.haskell.org/D980
* | add type annotations to SrcLoc functionsÖmer Sinan Ağacan2015-06-141-0/+3
| | | | | | | | | | | | | | | | Because sometimes types make more sense than docs. Reviewed By: austin Differential Revision: https://phabricator.haskell.org/D983
* | Refactor wild card renamingThomas Winant2015-06-092-297/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Refactor wild card error reporting * Merge `HsWildcardTy` and `HsNamedWildcardTy` into one constructor `HsWildCardTy` with as field the new type `HsWildCardInfo`, which has two constructors: `AnonWildCard` and `NamedWildCard`. * All partial type checks are removed from `RdrHsSyn.hs` and are now done during renaming in order to report better error messages. When wild cards are allowed in a type, the new function `rnLHsTypeWithWildCards` (or `rnHsSigTypeWithWildCards`) should be used. This will bring the named wild cards into scope before renaming them. When this is not done, renaming will trigger "Unexpected wild card..." errors. Unfortunately, this has to be done separately for anonymous wild cards because they are given a fresh name during renaming, so they will not cause an out-of-scope error. They are handled in `tc_hs_type`, as a special case of a lookup that fails. The previous opt-out approach is replaced with an opt-in approach. No more panics because of forgotten checks! * `[t| _ |]` isn't caught by the above two checks, so it is currently handled by a special case. The error message (generated in the `DsM` monad) doesn't provide as much context information as the other cases. * Instead of three (!) functions that walk `HsType`, there is now only one pure function called `collectWildCards`. * Alternative approach: catch all unwanted wild cards in `rnHsTyKi` by looking at the `HsDocContext`. This will reduce the number of places to catch unwanted wild cards form three to one, and make the error messages more uniform, albeit less informative, as the error context for renaming is not as informative as the one for type checking. A new constructor of `HsDocContext` will be required for pattern synonyms signatures. Small problem: currently type-class type signatures can't be distinguished from type signatures using the `HsDocContext`. This requires an update to the Haddock submodule. Test Plan: validate Reviewers: goldfire, simonpj, austin Reviewed By: simonpj Subscribers: bgamari, thomie, goldfire Differential Revision: https://phabricator.haskell.org/D613 GHC Trac Issues: #10098
* | ApiAnnotations : strings in warnings do not return SourceTextAlan Zimmerman2015-06-012-29/+30
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The strings used in a WARNING pragma are captured via strings :: { Located ([AddAnn],[Located FastString]) } : STRING { sL1 $1 ([],[L (gl $1) (getSTRING $1)]) } .. The STRING token has a method getSTRINGs that returns the original source text for a string. A warning of the form {-# WARNING Logic , mkSolver , mkSimpleSolver , mkSolverForLogic , solverSetParams , solverPush , solverPop , solverReset , solverGetNumScopes , solverAssertCnstr , solverAssertAndTrack , solverCheck , solverCheckAndGetModel , solverGetReasonUnknown "New Z3 API support is still incomplete and fragile: \ \you may experience segmentation faults!" #-} returns the concatenated warning string rather than the original source. This patch now deals with all remaining instances of getSTRING to bring in a SourceText for each. This updates the haddock submodule as well, for the AST change. Test Plan: ./validate Reviewers: hvr, austin, goldfire Reviewed By: austin Subscribers: bgamari, thomie, mpickering Differential Revision: https://phabricator.haskell.org/D907 GHC Trac Issues: #10313
* ApiAnnotations tweaksAlan Zimmerman2015-05-273-16/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: A collection of minor updates for the API Annotations. 1. The annotations for the implicity parameter is disconnected in the following type MPI = ?mpi_secret :: MPISecret 2. In the following, the annotation for one of the commas is disconeected. mkPoli = mkBila . map ((,,(),,()) <$> P.base <*> P.pos <*> P.form) 3. In the following, the annotation for the parens becomes disconnected data MaybeDefault v where SetTo :: forall v . ( Eq v, Show v ) => !v -> MaybeDefault v SetTo4 :: forall v a. (( Eq v, Show v ) => v -> MaybeDefault v -> a -> MaybeDefault [a]) Test Plan: ./validate Reviewers: hvr, austin Reviewed By: austin Subscribers: bgamari, thomie, mpickering Differential Revision: https://phabricator.haskell.org/D901 GHC Trac Issues: #10399
* ApiAnnotatons : AnnDcolon in wrong place for PatBindAlan Zimmerman2015-05-211-2/+3
| | | | | | | | | | | | | | | | | | | | | | Summary: In the following code fragment let ls :: Int = undefined the `::` is attached to the ls function as a whole, rather than to the pattern on the LHS. Test Plan: ./validate Reviewers: hvr, austin Reviewed By: austin Subscribers: bgamari, thomie, mpickering Differential Revision: https://phabricator.haskell.org/D883 GHC Trac Issues: #10396
* ApiAnnotations : parens around a context with wildcard loses annotationsAlan Zimmerman2015-05-212-13/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: In the following code, the extra set of parens around the context end up with detached annotations. {-# LANGUAGE PartialTypeSignatures #-} module ParensAroundContext where f :: ((Eq a, _)) => a -> a -> Bool f x y = x == y Trac ticket #10354 It turns out it was the TupleTy that was the culprit. This may also solve #10315 Test Plan: ./validate Reviewers: hvr, austin, goldfire Reviewed By: austin Subscribers: goldfire, bgamari, thomie, mpickering Differential Revision: https://phabricator.haskell.org/D868 GHC Trac Issues: #10354, #10315
* ApiAnnotations : AST version of nested forall loses forall annotationAlan Zimmerman2015-05-212-5/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: When parsing {-# LANGUAGE ScopedTypeVariables #-} extremumNewton :: forall tag. forall tag1. tag -> tag1 -> Int extremumNewton = undefined the parser creates nested HsForAllTy's for the two forall statements. These get flattened into a single one in `HsTypes.mk_forall_ty` This patch removes the flattening, so that API Annotations are not lost in the process. Test Plan: ./validate Reviewers: goldfire, austin, simonpj Reviewed By: simonpj Subscribers: bgamari, mpickering, thomie, goldfire Differential Revision: https://phabricator.haskell.org/D836 GHC Trac Issues: #10278, #10315, #10354, #10363
* Refactor tuple constraintsSimon Peyton Jones2015-05-182-46/+138
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make tuple constraints be handled by a perfectly ordinary type class, with the component constraints being the superclasses: class (c1, c2) => (c2, c2) This change was provoked by #10359 inability to re-use a given tuple constraint as a whole #9858 confusion between term tuples and constraint tuples but it's generally a very nice simplification. We get rid of - In Type, the TuplePred constructor of PredTree, and all the code that dealt with TuplePreds - In TcEvidence, the constructors EvTupleMk, EvTupleSel See Note [How tuples work] in TysWiredIn. Of course, nothing is ever entirely simple. This one proved quite fiddly. - I did quite a bit of renaming, which makes this patch touch a lot of modules. In partiuclar tupleCon -> tupleDataCon. - I made constraint tuples known-key rather than wired-in. This is different to boxed/unboxed tuples, but it proved awkward to have all the superclass selectors wired-in. Easier just to use the standard mechanims. - While I was fiddling with known-key names, I split the TH Name definitions out of DsMeta into a new module THNames. That meant that the known-key names can all be gathered in PrelInfo, without causing module loops. - I found that the parser was parsing an import item like T( .. ) as a *data constructor* T, and then using setRdrNameSpace to fix it. Stupid! So I changed the parser to parse a *type constructor* T, which means less use of setRdrNameSpace. I also improved setRdrNameSpace to behave better on Exact Names. Largely on priciple; I don't think it matters a lot. - When compiling a data type declaration for a wired-in thing like tuples (,), or lists, we don't really need to look at the declaration. We have the wired-in thing! And not doing so avoids having to line up the uniques for data constructor workers etc. See Note [Declarations for wired-in things] - I found that FunDeps.oclose wasn't taking superclasses into account; easily fixed. - Some error message refactoring for invalid constraints in TcValidity - Haddock needs to absorb the change too; so there is a submodule update
* Revert multiple commitsAustin Seipp2015-05-142-138/+46
| | | | | | | | | | | | | | | | | | | | This reverts multiple commits from Simon: - 04a484eafc9eb9f8774b4bdd41a5dc6c9f640daf Test Trac #10359 - a9ccd37add8315e061c02e5bf26c08f05fad9ac9 Test Trac #10403 - c0aae6f699cbd222d826d0b8d78d6cb3f682079e Test Trac #10248 - eb6ca851f553262efe0824b8dcbe64952de4963d Make the "matchable-given" check happen first - ca173aa30467a0b1023682d573fcd94244d85c50 Add a case to checkValidTyCon - 51cbad15f86fca1d1b0e777199eb1079a1b64d74 Update haddock submodule - 6e1174da5b8e0b296f5bfc8b39904300d04eb5b7 Separate transCloVarSet from fixVarSet - a8493e03b89f3b3bfcdb6005795de050501f5c29 Fix imports in HscMain (stage2) - a154944bf07b2e13175519bafebd5a03926bf105 Two wibbles to fix the build - 5910a1bc8142b4e56a19abea104263d7bb5c5d3f Change in capitalisation of error msg - 130e93aab220bdf14d08028771f83df210da340b Refactor tuple constraints - 8da785d59f5989b9a9df06386d5bd13f65435bc0 Delete commented-out line These break the build by causing Haddock to fail mysteriously when trying to examine GHC.Prim it seems.
* Refactor tuple constraintsSimon Peyton Jones2015-05-132-46/+138
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make tuple constraints be handled by a perfectly ordinary type class, with the component constraints being the superclasses: class (c1, c2) => (c2, c2) This change was provoked by #10359 inability to re-use a given tuple constraint as a whole #9858 confusion between term tuples and constraint tuples but it's generally a very nice simplification. We get rid of - In Type, the TuplePred constructor of PredTree, and all the code that dealt with TuplePreds - In TcEvidence, the constructors EvTupleMk, EvTupleSel See Note [How tuples work] in TysWiredIn. Of course, nothing is ever entirely simple. This one proved quite fiddly. - I did quite a bit of renaming, which makes this patch touch a lot of modules. In partiuclar tupleCon -> tupleDataCon. - I made constraint tuples known-key rather than wired-in. This is different to boxed/unboxed tuples, but it proved awkward to have all the superclass selectors wired-in. Easier just to use the standard mechanims. - While I was fiddling with known-key names, I split the TH Name definitions out of DsMeta into a new module THNames. That meant that the known-key names can all be gathered in PrelInfo, without causing module loops. - I found that the parser was parsing an import item like T( .. ) as a *data constructor* T, and then using setRdrNameSpace to fix it. Stupid! So I changed the parser to parse a *type constructor* T, which means less use of setRdrNameSpace. I also improved setRdrNameSpace to behave better on Exact Names. Largely on priciple; I don't think it matters a lot. - When compiling a data type declaration for a wired-in thing like tuples (,), or lists, we don't really need to look at the declaration. We have the wired-in thing! And not doing so avoids having to line up the uniques for data constructor workers etc. See Note [Declarations for wired-in things] - I found that FunDeps.oclose wasn't taking superclasses into account; easily fixed. - Some error message refactoring for invalid constraints in TcValidity
* ApiAnnotations : PatBind gives wrong SrcSpan for the pattern.Alan Zimmerman2015-05-111-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The production for decl_no_th starts decl_no_th :: { Located (OrdList (LHsDecl RdrName)) } : sigdecl { $1 } | '!' aexp rhs {% do { let { e = sLL $1 $> (SectionR (sL1 $1 (HsVar bang_RDR)) $2) }; pat <- checkPattern empty e; ... The e value should be just the pattern, excluding the rhs, but the span created includes the rhs. Test Plan: ./validate Reviewers: hvr, austin Reviewed By: austin Subscribers: bgamari, thomie, mpickering Differential Revision: https://phabricator.haskell.org/D873 GHC Trac Issues: #10358
* ApiAnnotations : pquals production adds AnnVbar in the wrong placeAlan Zimmerman2015-05-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The Parser.y production for pquals is pquals :: { Located [[LStmt RdrName (LHsExpr RdrName)]] } : squals '|' pquals {% addAnnotation (gl $ last $ unLoc $1) AnnVbar (gl $2) >> return (sLL $1 $> (reverse (unLoc $1) : unLoc $3)) } | squals { L (getLoc $1) [reverse (unLoc $1)] } The squals are returned in reverse order, so the AnnVbar should be attached to the head of the list, not the last. Test Plan: ./validate Reviewers: hvr, austin Reviewed By: austin Subscribers: thomie, mpickering Differential Revision: https://phabricator.haskell.org/D869 GHC Trac Issues: #10357
* ApiAnnotations : BooleanFormula construction discards originalAlan Zimmerman2015-05-111-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The MINIMAL pragma is captured in the parser using a BooleanFormula. The constructors (mkBool,mkAnd,mkOr) are smart and try to minimise the boolean formula as it is constructed. This discards the original information, making round tripping impossible. Note: there is another version which provides a more API Annotations friendly version of the MINIMAL pragma, but this requires changes to haddock, which will cause problems for 7.10.2. See https://github.com/alanz/ghc/tree/wip/10287 Test Plan: ./validate Reviewers: hvr, austin Reviewed By: austin Subscribers: bgamari, Fuuzetsu, thomie, mpickering Differential Revision: https://phabricator.haskell.org/D837 GHC Trac Issues: #10287
* ApiAnnotations : mkGadtDecl discards annotations for HsFunTyAlan Zimmerman2015-05-111-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: When mkGadtDecl is presented wih a HsFunTy it discards the SrcSpan, thus disconnecting any annotations on the HsFunTy. ``` mkGadtDecl names (L ls (HsForAllTy imp Nothing qvars cxt tau)) = return $ mk_gadt_con names where (details, res_ty) -- See Note [Sorting out the result type] = case tau of L _ (HsFunTy (L l (HsRecTy flds)) res_ty) -> (RecCon (L l flds), res_ty) _other -> (PrefixCon [], tau) ... ``` This can be triggered by the following ``` {-# LANGUAGE GADTs #-} module GADTRecords2 (H1(..)) where -- | h1 data H1 a b where C3 :: (Num a) => { field :: a -- ^ hello docs } -> H1 Int Int ``` Test Plan: ./validate Reviewers: hvr, austin Reviewed By: austin Subscribers: bgamari, thomie, mpickering Differential Revision: https://phabricator.haskell.org/D848 GHC Trac Issues: #10309
* Api Annotations: RdrHsSyn.mkAtDefault causes annotations to be disconnected.Alan Zimmerman2015-05-111-13/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The code for mkAtDefault is as follows. mkATDefault (L loc (TyFamInstDecl { tfid_eqn = L _ e })) | TyFamEqn { tfe_tycon = tc, tfe_pats = pats, tfe_rhs = rhs } <- e = do { tvs <- checkTyVars (ptext (sLit "default")) equalsDots tc (hswb_cts pats) ; return (L loc (TyFamEqn { tfe_tycon = tc , tfe_pats = tvs , tfe_rhs = rhs })) } An associated type in a class of the form type FoldableConstraint t x = () has an AnnEqual attached to the location in tfid_eqn. Since the location is discarded, this annotation is then disconnected from the AST. Test Plan: ./validate Reviewers: hvr, austin Reviewed By: austin Subscribers: bgamari, thomie, mpickering Differential Revision: https://phabricator.haskell.org/D842 GHC Trac Issues: #10307
* ApiAnnotations: misplaced AnnComma for squals productionAlan Zimmerman2015-05-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: The parser production for squals has : squals ',' transformqual {% addAnnotation (gl $ last $ unLoc $1) AnnComma (gl $2) >> ams (sLL $1 $> ()) (fst $ unLoc $3) >> return (sLL $1 $> [sLL $1 $> ((snd $ unLoc $3) (reverse (unLoc $1)))]) } This attaches the comma to the wrong part of the squals, as it is generated in reverse order. Test Plan: ./validate Reviewers: hvr, austin Reviewed By: austin Subscribers: bgamari, thomie, mpickering Differential Revision: https://phabricator.haskell.org/D846 GHC Trac Issues: #10312
* ApiAnnotations : AnnComma missing in TupleSectionAlan Zimmerman2015-05-081-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | Summary: For the following code {-# LANGUAGE TupleSections #-} foo = do liftIO $ atomicModifyIORef ciTokens ((,()) . f) the annotation is missing for the comma. Test Plan: ./validate Reviewers: hvr, austin Reviewed By: austin Subscribers: bgamari, thomie Differential Revision: https://phabricator.haskell.org/D834 GHC Trac Issues: #10280
* ApiAnnotations : RdrHsSyn.isFunLhs discards parenthesesAlan Zimmerman2015-05-072-23/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The RdrHsSyn.isFunLhs function has the following isFunLhs e = go e [] where go (L loc (HsVar f)) es | not (isRdrDataCon f) = return (Just (L loc f, False, es)) go (L _ (HsApp f e)) es = go f (e:es) go (L _ (HsPar e)) es@(_:_) = go e es The treatment of HsPar means that any parentheses around an infix function will be discarded. e.g. (f =*= g) sa i = f (toF sa i) =^= g (toG sa i) will lose the ( before f and the closing one after g Test Plan: ./validate Reviewers: hvr, austin Reviewed By: austin Subscribers: bgamari, thomie Differential Revision: https://phabricator.haskell.org/D832 GHC Trac Issues: #10269
* Revert "API Annotations : add Locations in hsSyn were layout occurs"Austin Seipp2015-05-062-18/+16
| | | | | | | This reverts commit fb54b2c11cc7f2cfbafa35b6a1819d7443aa5494. As Alan pointed out, this will make cherry picking a lot harder until 7.10.2, so lets back it out until after the release.
* Revert "ApiAnnotations : Nested forall loses forall annotation"Austin Seipp2015-05-061-46/+37
| | | | | | This reverts commit 81030ede73c4e3783219b2a8d7463524e847cfce. Alan is abandoning this approach in favor of D836.
* ApiAnnotations : Nested forall loses forall annotationAlan Zimmerman2015-05-061-37/+46
| | | | | | | | | | | | | | | | | | | | | | | When parsing {-# LANGUAGE ScopedTypeVariables #-} extremumNewton :: forall tag. forall tag1. tag -> tag1 -> Int extremumNewton = undefined The parser attaches an AnnForall to the second forall, which appears as a nested HsForAllTy. Somewhere this nesting is flattened, and the tyvarbndrs are collapsed into a single HsForAllTy. In this process the second AnnForAll loses its anchor in the AST. Reviewed By: austin Differential Revision: https://phabricator.haskell.org/D833 GHC Trac Issues: #10278
* ApiAnnotations : quoted type variables missing leading quoteAlan Zimmerman2015-05-062-16/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The HsOpTy can be constructed for a promoted type operator, in which case it has the following form | btype SIMPLEQUOTE qconop type { sLL $1 $> $ mkHsOpTy $1 $3 $4 } | btype SIMPLEQUOTE varop type { sLL $1 $> $ mkHsOpTy $1 $3 $4 } The SIMPLEQUOTE does not get an annotation, so cannot be reproduced via the API Annotations. Also, in splice_exp :: { LHsExpr RdrName } : TH_ID_SPLICE { sL1 $1 $ mkHsSpliceE (sL1 $1 $ HsVar (mkUnqual varName (getTH_ID_SPLICE $1))) } | '$(' exp ')' {% ams (sLL $1 $> $ mkHsSpliceE $2) [mo $1,mc $3] } | TH_ID_TY_SPLICE { sL1 $1 $ mkHsSpliceTE (sL1 $1 $ HsVar (mkUnqual varName (getTH_ID_TY_SPLICE $1))) } | '$$(' exp ')' {% ams (sLL $1 $> $ mkHsSpliceTE $2) [mo $1,mc $3] } the TH_ID_SPLICE and TH_ID_TY_SPLICE positions are lost. Reviewed By: austin Differential Revision: https://phabricator.haskell.org/D825 GHC Trac Issues: #10268
* Correct parsing of lifted empty list constructorMatthew Pickering2015-05-061-17/+21
| | | | | | | | | | | | See #10299 Previously `'[]` was parsed to a `HsTyVar` rather than a `HsExplicitListTy`. This patch fixes the shift-reduce conflict which caused this problem. Reviewed By: alanz, austin Differential Revision: https://phabricator.haskell.org/D840
* API Annotations : add Locations in hsSyn were layout occursAlan Zimmerman2015-05-062-16/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At the moment ghc-exactprint, which uses the GHC API Annotations to provide a framework for roundtripping Haskell source code with optional AST edits, has to implement a horrible workaround to manage the points where layout needs to be captured. These are MatchGroup HsDo HsCmdDo HsLet LetStmt HsCmdLet GRHSs To provide a more natural representation, the contents subject to layout rules need to be wrapped in a SrcSpan. This commit does this. Trac ticket #10250 Reviewed By: austin Differential Revision: https://phabricator.haskell.org/D815 GHC Trac Issues: #10250
* Permit empty closed type familiesAdam Gundry2015-05-041-6/+7
| | | | | | | | | | | | | | | | | | | Fixes #9840 and #10306, and includes an alternative resolution to #8028. This permits empty closed type families, and documents them in the user guide. It updates the Haddock submodule to support the API change. Test Plan: Added `indexed-types/should_compile/T9840` and updated `indexed-types/should_fail/ClosedFam4` and `th/T8028`. Reviewers: austin, simonpj, goldfire Reviewed By: goldfire Subscribers: bgamari, jstolarek, thomie, goldfire Differential Revision: https://phabricator.haskell.org/D841 GHC Trac Issues: #9840, #10306
* ApiAnnotations : lexer discards comment close in nested commentAlan Zimmerman2015-04-141-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | When parsing a nested comment, such as {- {- nested comment -} {-# nested pragma #-} -} The lexer returns the comment annotation as {- {- nested comment {-# nested pragma # -} Restore the missing comment end markers in the annotation. Reviewed By: austin Differential Revision: https://phabricator.haskell.org/D829 GHC Trac Issues: #10277
* API Annotations : ExprWithTySig processing discards annotated spansAlan Zimmerman2015-04-141-1/+2
| | | | | | | | | | | | | | | | | | | | | | | In RdrHsSyn.checkAPat the processing for ExprWithTySig is defined as ExprWithTySig e t _ -> do e <- checkLPat msg e -- Pattern signatures are parsed as sigtypes, -- but they aren't explicit forall points. Hence -- we have to remove the implicit forall here. let t' = case t of L _ (HsForAllTy Implicit _ _ (L _ []) ty) -> ty other -> other return (SigPatIn e (mkHsWithBndrs t')) The t' variable ends up losing its original SrcSpan in the first case branch. This results in annotations becoming detached from the AST. Reviewed By: austin Differential Revision: https://phabricator.haskell.org/D823 GHC Trac Issues: #10255
* parser : the API annotation on opt_sig is being discardedAlan Zimmerman2015-04-141-3/+3
| | | | | | | | | | | | | | | | | | | The opt_sig production is defined as opt_sig :: { ([AddAnn],Maybe (LHsType RdrName)) } : {- empty -} { ([],Nothing) } | '::' sigtype { ([mj AnnDcolon $1],Just $2) } It is used in the alt and decl_no_th productions, but neither of them add the returned annotations. This commit captures the annotations in the calling productions. Reviewed By: austin Differential Revision: https://phabricator.haskell.org/D822 GHC Trac Issues: #10254
* parser: API Annotations : guardquals1 does not annotate commas properlyAlan Zimmerman2015-04-141-1/+1
| | | | | | | | | | | | | | | | | The `guardquals1` production includes : guardquals1 ',' qual {% addAnnotation (gl $ last $ unLoc $1) AnnComma (gl $2) >> return (sLL $1 $> ($3 : unLoc $1)) } The AnnComma should be attached to `(gl $ head $ unLoc $1)`, rather than `last`. Reviewed By: austin Differential Revision: https://phabricator.haskell.org/D818 GHC Trac Issues: #10256
* parser: opt_kind_sig has incorrect SrcSpanAlan Zimmerman2015-04-141-19/+19
| | | | | | | | | | | | | | | | | | | | The production for opt_kind_sig is opt_kind_sig :: { Located (Maybe (LHsKind RdrName)) } : { noLoc Nothing } | '::' kind {% ajl (sLL $1 $> (Just $2)) AnnDcolon (gl $1) } The outer Location is used only to get the full span for the enclosing declration, and is then stripped. The inner LHsKind then has a SrcSpan that does not include the '::' Extend the SrcSpan on $2 to include $1 Reviewed By: austin Differential Revision: https://phabricator.haskell.org/D813 GHC Trac Issues: #10209
* Typos in error messages and in commentsGabor Greif2015-04-101-1/+1
|
* The production for squals is incorrect; see D806 for specifics.Alan Zimmerman2015-04-071-11/+9
| | | | | | | | | | This diff depends on D803. Reviewed By: austin Differential Revision: https://phabricator.haskell.org/D806 GHC Trac Issues: #10214
* The production for `pquals` is incorrect; the specifics are in D803.Alan Zimmerman2015-04-071-1/+1
| | | | | | | | Reviewed By: austin Differential Revision: https://phabricator.haskell.org/D803 GHC Trac Issues: #10207
* parser: allow type-level cons in prefix positionKinokkory2015-04-031-18/+30
| | | | | | | | Reviewed By: austin Differential Revision: https://phabricator.haskell.org/D768 GHC Trac Issues: #10188