summaryrefslogtreecommitdiff
path: root/compiler
Commit message (Collapse)AuthorAgeFilesLines
...
* Handle unset HOME environment variable more gracefullyBen Gamari2016-03-113-8/+17
| | | | | | | | | | | | | | | Test Plan: * Validate * try `env -i ghc` * try `env -i runghc HelloWorld.hs` Reviewers: austin Subscribers: thomie, ezyang Differential Revision: https://phabricator.haskell.org/D1971 GHC Trac Issues: #11678
* Add MonadUnique instance for LlvmMBen Gamari2016-03-112-9/+16
| | | | | | | | | | Reviewers: erikd, austin Reviewed By: erikd Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1994
* Add Note [Running splices in the Renamer]Owen Stephens2016-03-111-1/+43
| | | | | | | | | | Reviewers: austin, goldfire, bgamari Reviewed By: goldfire, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1985
* Fix #11624, cannot declare hs-boot if already one in scope.Edward Z. Yang2016-03-113-18/+16
| | | | | | | | | | | | | | | | | | | | | I'm not sure if this fix is the "right way" to do it, but it solves the proximal problem, which is that lookupBindGroupOcc was picking out the wrong renaming for hs-boot signatures, which then lead to an interface file error. Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu> Test Plan: validate Reviewers: simonpj, hvr, austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1963 GHC Trac Issues: #11624
* fix Float/Double unreg cross-compilationSergei Trofimovich2016-03-101-30/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Looking at more failures on m68k (Trac #11395) I've noticed the arith001 and arith012 test failures. (--host=x86_64-linux --target=m68k-linux). The following example was enough to reproduce a problem: v :: Float v = 43 main = print v m68k binaries printed '0.0' instead of '43.0'. The bug here is how we encode Floats and Double as Words with the same binary representation. Floats: Before the patch we just coerced Float to Int. That breaks when we cross-compile from 64-bit LE to 32-bit BE. The patch fixes conversion by accounting for padding. when we extend 32-bit value to 64-bit value (LE and BE do it slightly differently). Doubles: Before the patch Doubles were coerced to a pair of Ints (not correct as x86_64 can hold Double in one Int) and then trucated this pair of Ints to pair of Word32. The patch fixes conversion by always decomposing in Word32 and accounting for host endianness (newly introduced hostBE) and target endianness (wORDS_BIGENDIAN). I've tested this patch on Double and Float conversion on --host=x86_64-linux --target=m68k-linux crosscompiler. It fixes 10 tests related to printing Floats and Doubles. Thanks to Bertram Felgenhauer who poined out this probem. Signed-off-by: Sergei Trofimovich <siarheit@google.com> Test Plan: checked some examples manually, fixed 10 tests in test suite Reviewers: int-e, austin, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1990 GHC Trac Issues: #11395
* Refactoring around TcPatSyn.tcPatToExprSimon Peyton Jones2016-03-091-71/+102
| | | | | Just comments, a bit of refactoring, and a better error-reporting infrastructure
* Fix the implementation of lazyIdSimon Peyton Jones2016-03-092-37/+68
| | | | | | | | | | | | | | | 'lazy' was doing part of its job, but not all! In particular, an application f (lazy e) where f is strict, was still being compiled using call-by-value in CorePrep. This defeated the purpose of defining catch as catch a b = catch# (lazy a) b See Trac #11555, and Neil Mitchell's test case in comment:14 This patch makes 'lazy' behave properly. I updated Note [lazyId magic] in MkId, but all the action is in CorePrep. I can't say I really like this, but it does the job.
* Split external symbol prototypes (EF_) (Trac #11395)Sergei Trofimovich2016-03-082-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before the patch both Cmm and C symbols were declared with 'EF_' macro: #define EF_(f) extern StgFunPtr f() but for Cmm symbols we know exact prototypes. The patch splits there prototypes in to: #define EFF_(f) void f() /* See Note [External function prototypes] */ #define EF_(f) StgFunPtr f(void) Cmm functions are 'EF_' (External Functions), C functions are 'EFF_' (External Foreign Functions). While at it changed external C function prototype to return 'void' to workaround ghc bug on m68k. Described in detail in Trac #11395. This makes simple tests work on m68k-linux target! Thanks to Michael Karcher for awesome analysis happening in Trac #11395. Signed-off-by: Sergei Trofimovich <siarheit@google.com> Test Plan: ran "hello world" on m68k successfully Reviewers: simonmar, austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1975 GHC Trac Issues: #11395
* GhcMake: Clang/ASSERT fixErik de Castro Lopo2016-03-071-2/+4
| | | | | | | | | | Test Plan: Build with clang Reviewers: thomie, rwbarton, austin, bgamari Reviewed By: bgamari Differential Revision: https://phabricator.haskell.org/D1977
* Fix minimum alignment for StgClosure (Trac #11395)Sergei Trofimovich2016-03-061-1/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The bug is observed on m68k-linux target as crash in RTS: -- a.hs: main = print 43 $ inplace/bin/ghc-stage1 --make -debug a.hs $ ./a Program terminated with signal SIGSEGV, Segmentation fault. #0 0x80463b0a in LOOKS_LIKE_INFO_PTR_NOT_NULL (p=32858) at includes/rts/storage/ClosureMacros.h:248 (gdb) bt #0 0x80463b0a in LOOKS_LIKE_INFO_PTR_NOT_NULL (p=32858) at includes/rts/storage/ClosureMacros.h:248 #1 0x80463b46 in LOOKS_LIKE_INFO_PTR (p=32858) at includes/rts/storage/ClosureMacros.h:253 #2 0x80463b6c in LOOKS_LIKE_CLOSURE_PTR ( p=0x805aac6e <stg_dummy_ret_closure>) at includes/rts/storage/ClosureMacros.h:258 #3 0x80463e4c in initStorage () at rts/sm/Storage.c:121 #4 0x8043ffb4 in hs_init_ghc (...) at rts/RtsStartup.c:181 #5 0x80455982 in hs_main (...) at rts/RtsMain.c:51 #6 0x80003c1c in main () GHC assumes last 2 pointer bits are tags on 32-bit targets. But here 'stg_dummy_ret_closure' address violates the assumption: LOOKS_LIKE_CLOSURE_PTR (p=0x805aac6e <stg_dummy_ret_closure>) I've added compiler hint for static StgClosure objects to align closures at least by their natural alignment (what GHC assumes). See Note [StgWord alignment]. Signed-off-by: Sergei Trofimovich <siarheit@google.com> Test Plan: ran basic test on m68k qemu, it got past ASSERTs Reviewers: simonmar, austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1974 GHC Trac Issues: #11395
* Drop module qualifier from punned record fields (#11662)Adam Gundry2016-03-051-2/+6
| | | | | | | | | | | | | | | | | | A record pattern match, construction or update like `Rec { Mod.f }` should expand to `Rec { Mod.f = f }` rather than `Rec { Mod.f = Mod.f }`. Test Plan: New test rename/should_compile/T11662 Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: hesselink, thomie Differential Revision: https://phabricator.haskell.org/D1965 GHC Trac Issues: #11662
* Fix printing of an `IfacePatSyn`Rik Steenkamp2016-03-053-31/+20
| | | | | | | | | | | | | | | | | Now the existentially quantified type variables are printed at the correct location when printing a pattern synonym type from an `IfacePatSyn`. The function `pprIfaceContextMaybe` has been removed as it is no longer needed. Fixes #11524. Reviewers: austin, goldfire, thomie, bgamari, mpickering Reviewed By: bgamari Differential Revision: https://phabricator.haskell.org/D1958 GHC Trac Issues: #11524
* GHCi: Fix load/reload space leaks (#4029)Jason Eisenberg2016-03-053-13/+22
| | | | | | | | | | | | | | | | | This patch addresses GHCi load/reload space leaks which could be fixed without adversely affecting performance. Test Plan: make test "TEST=T4029" Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: mpickering, thomie Differential Revision: https://phabricator.haskell.org/D1950 GHC Trac Issues: #4029
* SimplEnv: Add Haddock headings to export listBen Gamari2016-03-051-4/+8
|
* Add Monoid instance for FastStringBen Gamari2016-03-051-0/+4
|
* Use tyConArity rather than (length tvs)Simon Peyton Jones2016-03-021-4/+3
| | | | A bit more efficient
* Fix an outright bug in expandTypeSynonymsSimon Peyton Jones2016-03-021-5/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The bug was in this code: go subst (TyConApp tc tys) | Just (tenv, rhs, tys') <- expandSynTyCon_maybe tc tys = let subst' = unionTCvSubst subst (mkTvSubstPrs tenv) in go subst' (mkAppTys rhs tys') This is wrong in two ways. * It is wrong to apply the expanded substitution to tys', * The unionTCvSubst is utterly wrong; after all, rhs is completely separate, and the union makes a non-idempotent substitution. It was the non-idempotency that gave the Lint failure in Trac #11665, when there was a type synonym whose RHS mentioned another type synonym, something like type T a b = a -> b type S x y = T y x It only affects SpecConstr because that's about the only place where expandTypeSyonym is called. I tried to trigger the failure with a simple test case, but failed, so I have not added a regression test. Fortunately the solution is very simple and solid. FWIW, the culprit was 674654, "Add kind equalities to GHC".
* Don't complain about unused Rule bindersSimon Peyton Jones2016-03-011-4/+17
| | | | | This fixes Trac #11643. It's a corner case, now documented in Note [Linting rules] in CoreLint
* Remove unnecessary isTyVar tests in TcTypeSimon Peyton Jones2016-03-011-12/+0
| | | | | | | | | These extra tests were added by Richard when he had CoVars floating around in places where previously only TyVars had been. But fortunately those days are gone, so these tests are unnecessary, and are slowing GHC down. Let's remove them.
* A bit more tracing in TcHsType.tcTyVarSimon Peyton Jones2016-03-011-2/+6
|
* Comments onlySimon Peyton Jones2016-03-011-2/+3
|
* Do not check synonym RHS for ambiguitySimon Peyton Jones2016-03-011-10/+25
| | | | | | | | | | | | | With this patch we no longer check the RHS of a type synonym declaration for ambiguity. It only affects type synonyms with foralls on the RHS (which are rare in the first place), and it's arguably over-aggressive to check them for ambiguity. See TcValidity Note [When we don't check for ambiguity] This fixes the ASSERT failures in th T3100 typecheck/should_compile T3692 typecheck/should_fail T3592
* DynFlags: Add -Wredundant-constraints to -WallBen Gamari2016-02-291-1/+2
| | | | | | | | | | | | Test Plan: It works, I promise. Reviewers: austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1956 GHC Trac Issues: #11370
* Refactor `warnMissingSignatures` in `RnNames.hs`Rik Steenkamp2016-02-291-69/+32
| | | | | | | | Reviewers: austin, thomie, bgamari Reviewed By: thomie, bgamari Differential Revision: https://phabricator.haskell.org/D1955
* Default to -fno-show-warning-groups (re #10752)Herbert Valerio Riedel2016-02-271-2/+1
| | | | | | | | | | | | | | | | | | As `-fno-show-warning-groups` shows associated warning groups regardless of whether the respective warning group flag as been passed on the CLI, the warning-group information may be confusing to users. At this point, `-fshow-warning-groups` is useful mostly to GHC developers and possibly GHC users who want to see which warning groups an emitted warning is part of. (Btw, this is particularly interesting in combination with `-Weverything` which enables *every* warning flag known to GHC.) Consequently, starting with this commit, one has to opt-in via `-fshow-warning-groups` for GHC to show warning groups. In order to reduce the testsuite delta in this commit, the `-fshow-warning-groups` flag has been added to TEST_HC_OPTS.
* Annotate `[-Wdeferred-type-errors]` in warnings (re #10752)Herbert Valerio Riedel2016-02-271-1/+1
| | | | This was missed in bb5afd3c274011c5ea302210b4c290ec1f83209c
* Print which flag controls emitted SafeHaskell warningsHerbert Valerio Riedel2016-02-271-5/+9
| | | | | | | This is extends bb5afd3c274011c5ea302210b4c290ec1f83209c to cover SafeHaskell warnings. This implements yet another part of #10752
* Annotate `[-Wredundant-constraints]` in warnings (re #10752)Herbert Valerio Riedel2016-02-271-2/+2
| | | | This was missed in bb5afd3c274011c5ea302210b4c290ec1f83209c
* Print which flag controls emitted lexer warningsHerbert Valerio Riedel2016-02-271-2/+4
| | | | | | | This is extends bb5afd3c274011c5ea302210b4c290ec1f83209c to cover warnings emitted during lexing. This implements another part of #10752
* Print which flag controls emitted desugaring warningsHerbert Valerio Riedel2016-02-277-42/+58
| | | | | | | | | | | This is extends bb5afd3c274011c5ea302210b4c290ec1f83209c to cover warnings emitted during the desugaring phase. This implements another part of #10752 Reviewed-by: quchen, bgamari Differential Revision: https://phabricator.haskell.org/D1954
* Filter out BuiltinRules in occurrence analysisSimon Peyton Jones2016-02-261-0/+14
| | | | Fixes Trac #11651. Merge to 8.0.
* Fix kind generalisation for pattern synonymsSimon Peyton Jones2016-02-261-13/+22
| | | | | | | | We were failing to zonk, after quantifyTyVars, and that left un-zonked type variables in the final PatSyn. This fixes the patsyn/ problems in Trac #11648, but not the polykinds/ ones.
* Comments and white space onlySimon Peyton Jones2016-02-261-8/+10
|
* Exclude TyVars from the constraint solverSimon Peyton Jones2016-02-263-34/+81
| | | | | | | | | | | | | | There is a general invariant that the constraint solver doesn't see TyVars, only TcTyVars. But when checking the generic-default signature of a class, we called checkValidType on the generic-default type, which had the class TyVar free. That in turn meant that it wasn't considered during flattening, which led to the error reported in Trac #11608. The fix is simple: call checkValidType on the /closed/ type. Easy. While I was at it, I added a bunch of ASSERTs about the TcTyVar invariant.
* Get the right in-scope set in specUnfoldingSimon Peyton Jones2016-02-262-5/+20
| | | | This fixes Trac #11600
* Special case for desugaring AbsBindsSimon Peyton Jones2016-02-261-0/+20
| | | | | | | | When AbsBinds has no tyvars and no dicts, a rather simpler desugaring is possible. This patch implements it. I don't think the optimised code changes, but there is less clutter generated.
* Fix and refactor strict pattern bindingsSimon Peyton Jones2016-02-266-202/+335
| | | | | | | | | | | | | | | | | | | | | | This patch was triggered by Trac #11601, where I discovered that -XStrict was really not doing the right thing. In particular, f y = let !(Just x) = blah[y] in body[y,x] This was evaluating 'blah' but not pattern matching it against Just until x was demanded. This is wrong. The patch implements a new semantics which ensures that strict patterns (i.e. ones with an explicit bang, or with -XStrict) are evaluated fully when bound. * There are extensive notes in DsUtils: Note [mkSelectorBinds] * To do this I found I need one-tuples; see Note [One-tuples] in TysWiredIn I updated the user manual to give the new semantics
* Typos in comments, etc.Gabor Greif2016-02-263-3/+3
|
* Unconditionally handle TH known key names.Edward Z. Yang2016-02-261-3/+1
| | | | | | | | | | | | | | | | | | | | | | Previously, we didn't add Template Haskell key names to the list of known uniques when building a stage 1 compiler. But with f16ddcee0c64a92ab911a7841a8cf64e3ac671fd we may refer to TH names even in stage 1, and this was causing uniques to not be setup properly. Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu> Test Plan: validate and run stage1 test suite Reviewers: osa1, austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1520 GHC Trac Issues: #10382
* Print which warning-flag controls an emitted warningMichael Walker2016-02-2540-182/+371
| | | | | | | | | | | | | | | | | Both gcc and clang tell which warning flag a reported warning can be controlled with, this patch makes ghc do the same. More generally, this allows for annotated compiler output, where an optional annotation is displayed in brackets after the severity. This also adds a new flag `-f(no-)show-warning-groups` to control whether to show which warning-group (such as `-Wall` or `-Wcompat`) a warning belongs to. This flag is on by default. This implements #10752 Reviewed By: quchen, bgamari, hvr Differential Revision: https://phabricator.haskell.org/D1943
* Improve pattern synonym error messages (add `PatSynOrigin`)Rik Steenkamp2016-02-253-10/+40
| | | | | | | | | | | | | | | | | | Adds a new data constructor `PatSynOrigin Bool Name` to the `CtOrigin` data type. This allows for better error messages when the origin of a wanted constraint is a pattern synonym declaration. Fixes T10873. Reviewers: mpickering, simonpj, austin, thomie, bgamari Reviewed By: simonpj, thomie, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1866 GHC Trac Issues: #10873
* Improve accuracy of suggestion to use TypeApplicationsMatthew Pickering2016-02-251-6/+7
| | | | | | | | | | | | | | | | The suggestion only makes sense when we try to use an as pattern in an expression context. It is misleading in the case of a lazy pattern and view pattern. Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1948
* Handle multiline named haddock comments properlyThomas Miedema2016-02-251-15/+28
| | | | | | | | | | | | | Fixes #10398 in a different way, thereby also fixing #11579. I inverted the logic of the Bool argument to "worker", to hopefully make it more self-explanatory. Reviewers: austin, hvr, bgamari Reviewed By: bgamari Differential Revision: https://phabricator.haskell.org/D1935
* (Alternative way to) address #8710George Karachalias2016-02-251-19/+26
| | | | | | | | | | | | | | | | | | | | | | | | Issue a separate warning per redundant (or inaccessible) clause. This way each warning can have more precice location information (the location of the clause under consideration and not the whole match). I thought that this could be too much but actually the number of such warnings is bound by the number of cases matched against (in contrast to the non-exhaustive warnings which may be exponentially more). Test Plan: validate Reviewers: simonpj, austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1920 GHC Trac Issues: #8710
* cmpTypeX: Avoid kind comparison when possibleBen Gamari2016-02-251-25/+60
| | | | | | | | | | | | | | | | | | This comparison is only necessary when the types being compared contain casts. Otherwise the structural equality of the types implies that their kinds are equal. Test Plan: Validate Reviewers: goldfire, austin, simonpj Reviewed By: simonpj Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1944 GHC Trac Issues: #11597
* Reconstruct record expression in bidir pattern synonymMatthew Pickering2016-02-252-8/+26
| | | | | | | | | | Reviewers: austin, rdragon, bgamari Reviewed By: bgamari Subscribers: rdragon, thomie Differential Revision: https://phabricator.haskell.org/D1949
* Make warning names more consistentManav Rathi2016-02-254-24/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - Replace "Sigs" with "Signatures" in WarningFlag data constructors. - Replace "PatSyn" with "PatternSynonym" in WarningFlag data constructors. - Deprecate "missing-local-sigs" in favor of "missing-local-signatures". - Deprecate "missing-exported-sigs" in favor of "missing-exported-signatures". - Deprecate "missing-pat-syn-signatures" in favor of "missing-pattern-synonym-signatures". - Replace "ddump-strsigs" with "ddump-str-signatures" These complete the tasks that were explicitly mentioned in #11583 Test Plan: Executed `ghc --show-options` and verified that the flags were changed as expected. Reviewers: svenpanne, austin, bgamari Reviewed By: austin, bgamari Subscribers: mpickering, thomie Differential Revision: https://phabricator.haskell.org/D1939 GHC Trac Issues: #11583
* HscMain: Delete some unused codeÖmer Sinan Ağacan2016-02-251-68/+0
| | | | | | | | | | Reviewers: bgamari, austin Reviewed By: austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1936
* ApplicativeDo: Handle terminal `pure` statementsBen Gamari2016-02-251-1/+1
| | | | | | | | | | | | | | | | | ApplicativeDo handled terminal `return` statements properly, but not `pure`. Test Plan: Validate with included testcase Reviewers: austin, simonmar Reviewed By: austin, simonmar Subscribers: simonpj, thomie Differential Revision: https://phabricator.haskell.org/D1931 GHC Trac Issues: #11607
* Overload the static form to reduce verbosity.Facundo Domínguez2016-02-252-5/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Static pointers are rarely used naked: most often they are defined at the base of a Closure, as defined in e.g. the distributed-closure and distributed-static packages. So a typical usage pattern is: distributeMap (closure (static (\x -> x * 2))) which is more verbose than it needs to be. Ideally we'd just have to write distributeMap (static (\x -> x * 2)) and let the static pointer be lifted to a Closure implicitly. i.e. what we want is to overload static literals, just like we already overload list literals and string literals. This is achieved by introducing the IsStatic type class and changing the typing rule for static forms slightly: static (e :: t) :: IsStatic p => p t Test Plan: ./validate Reviewers: austin, hvr, bgamari Reviewed By: bgamari Subscribers: simonpj, mboes, thomie Differential Revision: https://phabricator.haskell.org/D1923 GHC Trac Issues: #11585