summaryrefslogtreecommitdiff
path: root/compiler
Commit message (Collapse)AuthorAgeFilesLines
* Fix warnings and fatal parsing errorswip/parse-errorsVladislav Zavialov2019-02-1612-128/+116
|
* Don't wrap the entry map for LiveInfo in Maybe.klebinger.andreas@gmx.at2019-02-156-26/+27
| | | | | | | | | | | | | It never really encoded a invariant. * The linear register allocator just did partial pattern matches * The graph allocator just set it to (Just mapEmpty) for Nothing So I changed LiveInfo to directly contain the map. Further natCmmTopToLive which filled in Nothing is no longer exported. Instead we know call cmmTopLiveness which changes the type AND fills in the map.
* Properly escape character literals in HaddocksAlec Theriault2019-02-152-5/+5
| | | | | | | | Character literals in Haddock should not be written as plain `'\n'` since single quotes are for linking identifiers. Besides, since we want the character literal to be monospaced, we really should use `@\'\\n\'@`. [skip ci]
* 'forall' always a keyword, plus the dot type operatorVladislav Zavialov2019-02-156-64/+41
|
* Fail fast in solveLocalEqualitiesSimon Peyton Jones2019-02-142-1/+22
| | | | | | | | | | | | | | | | | | This patch makes us fail fast in TcSimplify.solveLocalEqualities, and in TcHsType.tc_hs_sig_type, if there are insoluble constraints. Previously we ploughed on even if there were insoluble constraints, leading to a cascade of hard-to-understand type errors. Failing eagerly is much better; hence a lot of testsuite error message changes. Eg if we have f :: [Maybe] -> blah f xs = e then trying typecheck 'f x = e' with an utterly bogus type is just asking for trouble. I can't quite remember what provoked me to make this change, but I think the error messages are notably improved, by removing confusing clutter and focusing on the real error.
* Make a smart mkAppTyMSimon Peyton Jones2019-02-1424-756/+830
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch finally delivers on Trac #15952. Specifically * Completely remove Note [The tcType invariant], along with its complicated consequences (IT1-IT6). * Replace Note [The well-kinded type invariant] with: Note [The Purely Kinded Type Invariant (PKTI)] * Instead, establish the (PKTI) in TcHsType.tcInferApps, by using a new function mkAppTyM when building a type application. See Note [mkAppTyM]. * As a result we can remove the delicate mkNakedXX functions entirely. Specifically, mkNakedCastTy retained lots of extremly delicate Refl coercions which just cluttered everything up, and(worse) were very vulnerable to being silently eliminated by (say) substTy. This led to a succession of bug reports. The result is noticeably simpler to explain, simpler to code, and Richard and I are much more confident that it is correct. It does not actually fix any bugs, but it brings us closer. E.g. I hoped it'd fix #15918 and #15799, but it doesn't quite do so. However, it makes it much easier to fix. I also did a raft of other minor refactorings: * Use tcTypeKind consistently in the type checker * Rename tcInstTyBinders to tcInvisibleTyBinders, and refactor it a bit * Refactor tcEqType, pickyEqType, tcEqTypeVis Simpler, probably more efficient. * Make zonkTcType zonk TcTyCons, at least if they have any free unification variables -- see zonk_tc_tycon in TcMType.zonkTcTypeMapper. Not zonking these TcTyCons was actually a bug before. * Simplify try_to_reduce_no_cache in TcFlatten (a lot) * Combine checkExpectedKind and checkExpectedKindX. And then combine the invisible-binder instantation code Much simpler now. * Fix a little bug in TcMType.skolemiseQuantifiedTyVar. I'm not sure how I came across this originally. * Fix a little bug in TyCoRep.isUnliftedRuntimeRep (the ASSERT was over-zealous). Again I'm not certain how I encountered this. * Add a missing solveLocalEqualities in TcHsType.tcHsPartialSigType. I came across this when trying to get level numbers right.
* Implement -Wredundant-record-wildcards and -Wunused-record-wildcardsMatthew Pickering2019-02-1410-54/+175
| | | | | | | | | -Wredundant-record-wildcards warns when a .. pattern binds no variables. -Wunused-record-wildcards warns when none of the variables bound by a .. pattern are used. These flags are enabled by `-Wall`.
* NCG: fast compilation of very large strings (#16190)Sylvain Henry2019-02-145-12/+57
| | | | | | | | | | This patch adds an optimization into the NCG: for large strings (threshold configurable via -fbinary-blob-threshold=NNN flag), instead of printing `.asciz "..."` in the generated ASM source, we print `.incbin "tmpXXX.dat"` and we dump the contents of the string into a temporary "tmpXXX.dat" file. See the note for more details.
* Fix #15849 by checking whether there's a do blocknineonine2019-02-121-1/+2
|
* Fix #16299 by deleting incorrect code from IfaceSynRyan Scott2019-02-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | GHCi's `:info` command was pretty-printing Haskell98-style data types with explicit return kinds if the return kind wasn't `Type`. This leads to bizarre output like this: ``` λ> :i (##) data (##) :: TYPE ('GHC.Types.TupleRep '[]) = (##) -- Defined in ‘GHC.Prim’ ``` Or, with unlifted newtypes: ``` λ> newtype T = MkT Int# λ> :i T newtype T :: TYPE 'IntRep = MkT Int# -- Defined at <interactive>:5:1 ``` The solution is simple: just delete one part from `IfaceSyn` where GHC mistakenly pretty-prints the return kinds for non-GADTs.
* Fix #16188Richard Eisenberg2019-02-122-14/+29
| | | | | | | | | | | | | | There was an awful lot of zipping going on in canDecomposableTyConAppOK, and one of the lists being zipped was too short, causing the result to be too short. Easily fixed. Also fixes #16204 and #16225 test case: typecheck/should_compile/T16188 typecheck/should_compile/T16204[ab] typecheck/should_fail/T16204c typecheck/should_compile/T16225
* Fix #16293 by cleaning up Proxy# infelicitiesRyan Scott2019-02-124-19/+30
| | | | | | | | | | | | | | | | | | | | This bug fixes three problems related to `Proxy#`/`proxy#`: 1. Reifying it with TH claims that the `Proxy#` type constructor has two arguments, but that ought to be one for consistency with TH's treatment for other primitive type constructors like `(->)`. This was fixed by just returning the number of `tyConVisibleTyVars` instead of using `tyConArity` (which includes invisible arguments). 2. The role of `Proxy#`'s visible argument was hard-coded as nominal. Easily fixed by changing it to phantom. 3. The visibility of `proxy#`'s kind argument was specified, which is different from the `Proxy` constructor (which treats it as inferred). Some minor refactoring in `proxyHashId` fixed ths up. Along the way, I had to introduce a `mkSpecForAllTy` function, so I did some related Haddock cleanup in `Type`, where that function lives.
* Fix Int overflow on 32 bit platformPeter Trommler2019-02-101-1/+1
|
* Capture and simplify constraints arising from running typed splicesMatthew Pickering2019-02-101-3/+8
| | | | | | | | | | | | | | | This fixes a regression caused by #15471 where splicing in a trivial program such as `[|| return () ||]` would fail as the dictionary for `return` would never get bound in the module containing the splice. Arguably this is symptomatic of a major problem affecting TTH where we serialise renamed asts and then retype check them. The reference to the dictionary should be fully determined at the quote site so that splicing doesn't have to solve any implicits at all. It's a coincidence this works due to coherence but see #15863 and #15865 for examples where things do go very wrong. Fixes #16195
* Remove ghctags (#16274)Sylvain Henry2019-02-101-3/+0
|
* Fix inverted position pragma flag in parser APIAlec Theriault2019-02-101-1/+1
| | | | | | | | The behviour of `lexTokenStream` around position pragma was accidentally inverted in 469fe6133646df5568c9486de2202124cb734242. This fixes that bug. This also unbreaks #16239.
* Improve snocView implementation.klebinger.andreas@gmx.at2019-02-091-12/+17
| | | | | | | | | | | | The new implementation isn't tailrecursive and instead builds up the initial part of the list as it goes. This improves allocation numbers as we don't build up an intermediate list just to reverse it later. This is slightly slower for lists of size <= 3. But in benchmarks significantly faster for any list above 5 elements, assuming the majority of the resulting list will be evaluated.
* Replace a few uses of snocView with last/lastMaybe.klebinger.andreas@gmx.at2019-02-093-4/+13
| | | | | | These never used the first part of the result from snocView. Hence replacing them with last[Maybe] is both clearer and gives better performance.
* Stack: fix name mangling.Tamar Christina2019-02-091-1/+1
|
* Minor refactor of CUSK handlingSimon Peyton Jones2019-02-082-23/+34
| | | | | | | | | Previously, in getFamDeclInitialKind, we were figuring out whether the enclosing class decl had a CUSK very indirectly, via tcTyConIsPoly. This patch just makes the computation much more direct and easy to grok. No change in behaviour.
* Comments only about the binder-swap in OccurAnalSimon Peyton Jones2019-02-081-12/+41
|
* Comments onlySimon Peyton Jones2019-02-083-6/+11
|
* Remove a few undefined prel namesÖmer Sinan Ağacan2019-02-081-29/+3
| | | | | | | | | | - breakpointAuto - breakpointJump - breakpointCondJump - breakpointAutoJump These Ids are never defined, but there were definitions about those in PrelNames. Those are now removed.
* Fix optSemi type in Parser.yVladislav Zavialov2019-02-081-2/+1
| | | | | | | | | | | | | | | | | | | | | The definition of 'optSemi' claimed it had type ([Located a],Bool) Note that its production actually returns ([Located Token],Bool): : ';' { ([$1],True) } -- $1 :: Located Token Due to an infelicity in the implementation of 'happy -c', it effectively resulted in 'unsafeCoerce :: Token -> a'. See https://github.com/simonmar/happy/pull/134 If any consumer of 'optSemi' tried to instantiate 'a' to something not representationally equal to 'Token', they would experience a segfault. In addition to that, this definition made it impossible to compile Parser.y without the -c flag (as it's reliant on this bug to cast 'Token' to 'forall a. a').
* Cleanup in parser/Ctype.hsSylvain Henry2019-02-081-138/+135
| | | | | | | | | | | | | | | * GHC now performs constant folding on bit operations like (.|.) so we use them and we remove the misleading comment * we use Word8 instead of Int and we remove the useless conversion to Int32. Hopefully future releases of GHC could transform the big case in `charType` into a value table indexing instead of a jump table. Word8 would make the table smaller. * we use INLINABLE pragma instead of INLINE on `is_ctype`: in my test, the latter *prevents* `is_ctype` to be inlined because `charType` is inlined into `is_ctype` (to call charType`s worker on the unboxed Char directly).
* Lexer: Alternate Layout Rule injects actual not virtual bracesAlan Zimmerman2019-02-081-15/+17
| | | | | | | | | | | | | | | | | | | | | | | | | When the alternate layout rule is activated via a pragma, it injects tokens for { and } to make sure that the source is parsed properly. But it injects ITocurly and ITccurly, rather than their virtual counterparts ITvocurly and ITvccurly. This causes problems for ghc-exactprint, which tries to print these. Likewise, any injected ITsemi should have a zero-width SrcSpan. Test case (the existing T13087.hs) {-# LANGUAGE AlternativeLayoutRule #-} {-# LANGUAGE LambdaCase #-} isOne :: Int -> Bool isOne = \case 1 -> True _ -> False main = return () Closes #16279
* API Annotations: parens anns discarded for `(*)` operatorAlan Zimmerman2019-02-082-3/+4
| | | | | | | | | | | | | | | The patch from https://phabricator.haskell.org/D4865 introduces go _ (HsParTy _ (dL->L l (HsStarTy _ isUni))) acc ann fix = do { warnStarBndr l ; let name = mkOccName tcClsName (if isUni then "★" else "*") ; return (cL l (Unqual name), acc, fix, ann) } which discards the parens annotations belonging to the HsParTy. Updates haddock submodule Closes #16265
* API Annotations: AnnAt disconnected for TYPEAPPAlan Zimmerman2019-02-089-68/+84
| | | | | | | | | | | | For the code type family F1 (a :: k) (f :: k -> Type) :: Type where F1 @Peano a f = T @Peano f a the API annotation for the first @ is not attached to a SourceSpan in the ParsedSource Closes #16236
* API Annotations: more explicit foralls fixupAlan Zimmerman2019-02-082-24/+25
| | | | | | | The AnnForall annotations introduced via Phab:D4894 are not always attached to the correct SourceSpan. Closes #16230
* Allow resizing the stack for the graph allocator.klebinger.andreas@gmx.at2019-02-086-36/+105
| | | | | | | | | | The graph allocator now dynamically resizes the number of stack slots when running into the limit. This fixes #8657. Also loop membership of basic blocks is now available in the register allocator for cost heuristics.
* Fix #14729 by making the normaliser homogeneousRichard Eisenberg2019-02-085-371/+545
| | | | | | | | | | | | | | | | This ports the fix to #12919 to the normaliser. (#12919 was about the flattener.) Because the fix is involved, this is done by moving the critical piece of code to Coercion, and then calling this from both the flattener and the normaliser. The key bit is: simplifying type families in a type is always a *homogeneous* operation. See #12919 for a discussion of why this is the Right Way to simplify type families. Also fixes #15549. test case: dependent/should_compile/T14729{,kind} typecheck/should_compile/T15549[ab]
* Fix #16287 by checking for more unsaturated synonym argumentsRyan Scott2019-02-061-24/+23
| | | | | | | | | | | | | Trac #16287 shows that we were checking for unsaturated type synonym arguments (in `:kind`) when the argument was to a type synonym, but _not_ when the argument was to some other form of type constructor, such as a data type. The solution is to use the machinery that rejects unsaturated type synonym arguments (previously confined to `check_syn_tc_app`) to `check_arg_type`, which checks these other forms of arguments. While I was in town, I cleaned up `check_syn_tc_app` a bit to only invoke `check_arg_type` so as to minimize the number of different code paths that that function could go down.
* Fix #14579 by defining tyConAppNeedsKindSig, and using itRyan Scott2019-02-053-170/+342
|
* Refactor splice_exp in Parser.yVladislav Zavialov2019-02-053-22/+22
|
* Add `-fplugin-trustworthy` to avoid marking modules as unsafeZejun Wu2019-02-043-4/+10
| | | | | | | | By default, when a module is compiled with plugins, it will be marked as unsafe. With this flag passed, all plugins are treated as trustworthy and the safety inference will no longer be affected. This fixes Trac #16260.
* Report multiple errorsVladislav Zavialov2019-02-032-21/+28
|
* Fix missing space in ppr_cmd for HsCmdArrFormVladislav Zavialov2019-02-031-2/+2
|
* Remove unused importsSebastian Graf2019-02-021-3/+0
|
* Polished Note [Exceptions and strictness]Sebastian Graf2019-02-021-15/+27
| | | | [ci skip]
* Reject oversaturated VKAs in type family equationsRyan Scott2019-02-012-1/+70
|
* Remove ExnStr and ThrowsExn businessSebastian Graf2019-02-016-234/+126
|
* Fix #16219: TemplateHaskell causes indefinite package build errorEdward Z. Yang2019-01-312-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | It should work to write an indefinite package using TemplateHaskell, so long as all of the actual TH code lives outside of the package. However, cleverness we had to build TH code even when building with -fno-code meant that we attempted to build object code for modules in an indefinite package, even when the signatures were not instantiated. This patch disables said logic in the event that an indefinite package is being typechecked. Signed-off-by: Edward Z. Yang <ezyang@fb.com> Test Plan: validate Reviewers: simonpj, bgamari Reviewed By: bgamari Subscribers: rwbarton, carter GHC Trac Issues: #16219 Differential Revision: https://phabricator.haskell.org/D5475
* PPC NCG: Promote integers to word size in C callsPeter Trommler2019-01-312-15/+29
| | | | Fixes #16222
* Small optimizations to BlockLayout.klebinger.andreas@gmx.at2019-01-311-39/+31
| | | | | | | | | | * Remove `takeL/R 1` occurences by lastOL/headOL. * Make BlockChain a OrdList newtype by removing the set of blocks. Initially BlockChain contained both, a set for membership test and a ordered list of blocks. The set is not used for any performance sensitive lookups so we get rid of it.
* Replace BlockSequence with OrdList in BlockLayout.hsklebinger.andreas@gmx.at2019-01-312-77/+45
| | | | | OrdList does the same thing and more so there is no reason to have both.
* Add -fdefer-diagnostics to defer and group diagnostic messages in make-modeZejun Wu2019-01-312-2/+39
| | | | | | | | | | | | | When loading many modules in parallel there can a lot of warnings and errors get mixed up with regular output. When the compilation fails, the relevant error message can be thousands of lines backward and is hard to find. When the compilation successes, warning message is likely to be ignored as it is not seen. We can address this by deferring the warning and error message after the compilation. We also put errors after warnings so it is more visible. This idea was originally proposed by Bartosz Nitka in https://phabricator.haskell.org/D4219.
* Optimize pprASCIISylvain Henry2019-01-311-12/+23
| | | | | | | | | * Use `ByteString.foldr` instead of `(List.foldr . BS.unpack)` * Avoid calling `chr` and its test that checks for invalid Unicode codepoints: we stay in the ASCII range so we know we're ok * Avoid calling `isPrint` (unsafe FFI call): we can check the ASCII printable range directly * Use bit operations (`unsafeShiftR`, `.&.`) instead of `div` and `mod`
* Use ByteString to represent Cmm string literals (#16198)Sylvain Henry2019-01-3129-91/+86
| | | | Also used ByteString in some other relevant places
* API Annotations: Parens not attached correctly for ClassDeclAlan Zimmerman2019-01-301-19/+22
| | | | | | | | | | | The parens around the kinded tyvars should be attached to the class declaration as a whole, they are attached to the tyvar instead, outside the span. An annotation must always be within or after the span it is contained in. Closes #16212
* Include type info for only some exprs in HIE filesAlec Theriault2019-01-301-8/+63
| | | | | | | | | | | | | | | | This commit relinquishes some some type information in `.hie` files in exchange for better performance. See #16233 for more on this. Using `.hie` files to generate hyperlinked sources is a crucial milestone towards Hi Haddock (the initiative to move Haddock to work over `.hi` files and embed docstrings in those). Unfortunately, even after much optimization on the Haddock side, the `.hie` based solution is still considerably slower and more memory hungry than the existing implementation - and the @.hie@ code is to blame. This changes `.hie` file generation to track type information for only a limited subset of expressions (specifically, those that might eventually turn into hyperlinks in the Haddock's hyperlinker backend).