1. 29 Mar, 2017 9 commits
    • Sergei Trofimovich's avatar
      unique: fix UNIQUE_BITS crosscompilation (Trac #13491) · 01b062ec
      Sergei Trofimovich authored
      The #13491 manifests best when we try to crosscompile
      from 32-bit (i386-linux) to 64-bit (powerpc64-linux)
          ./configure --target=powerpc64-unknown-linux-gnu
      The build fails at assembly time:
        "inplace/bin/ghc-stage1" ...  -c rts/StgStartup.cmm
          /tmp/ghc19687_0/ghc_4.s: Assembler messages:
          /tmp/ghc19687_0/ghc_4.s:11:0: error:
               Error: unknown pseudo-op: `.l'
          11 | .L<\x00>4:
             | ^
      That happens because UNIQUE_BITS is defined in terms
      of WORD_SIZE_IN_BITS macro:
          #define UNIQUE_BITS (WORD_SIZE_IN_BITS - 8)
      WORD_SIZE_IN_BITS is 64 bits (equals to target value)
      while ghc-stage1 is still running on i386-linux
      The fix is to stop relying on target macros and use
      host's 'sizeof (HsInt)' and 'finiteBitSize' way to
      determine unique layout.
      Signed-off-by: default avatarSergei Trofimovich <slyfox@gentoo.org>
      Test Plan: build i386-to-powerpc64 crosscompiler
      Reviewers: rwbarton, austin, bgamari
      Reviewed By: bgamari
    • Matthías Páll Gissurarson's avatar
      Show valid substitutions for typed holes · 26c95f46
      Matthías Páll Gissurarson authored
      The idea is to implement a mechanism similar to PureScript, where they
      suggest which identifiers in scope would fit the given hole. In
      PureScript, they use subsumption (which is what we would like here as
      well). For subsumption, we would have to check each type in scope
      whether the hole is a subtype of the given type, but that would require
      `tcSubType` and constraint satisfiability checking. Currently,
      `TcSimplify` uses a lot of functions from `TcErrors`, so that would
      require more of a rewrite, I will hold on with that for now, and submit
      the more simpler type equality version.
      As an example, consider
      ps :: String -> IO ()
      ps = putStrLn
      ps2 :: a -> IO ()
      ps2 _ = putStrLn "hello, world"
      main :: IO ()
      main = _ "hello, world"
      The results would be something like
          • Found hole: _ :: [Char] -> IO ()
          • In the expression: _
            In a stmt of a 'do' block: _ "hello, world"
            In the expression:
              do _ "hello, world"
          • Relevant bindings include
              main :: IO () (bound at test.hs:13:1)
              ps :: String -> IO () (bound at test.hs:7:1)
              ps2 :: forall a. a  -> IO () (bound at test.hs:10:1)
            Valid substitutions include
              putStrLn :: String
                          -> IO () (imported from ‘Prelude’ at
                                    (and originally defined in
              putStr :: String
                        -> IO () (imported from ‘Prelude’ at
                                  (and originally defined in ‘System.IO’))
      We'd like here for ps2 to be suggested as well, but for that we require
      Reviewers: austin, bgamari, dfeuer, mpickering
      Reviewed By: dfeuer, mpickering
      Subscribers: mpickering, Wizek, dfeuer, rwbarton, thomie
      Differential Revision: https://phabricator.haskell.org/D3361
    • Moritz Angermann's avatar
      Various patches to support android cross compilation · 924a65fc
      Moritz Angermann authored
      - Better test for SHT_INIT_ARRAY than openbsd_HOST_OS
        This is actually bens patch:
      - linux-android defines.
      - No need for -lpthread on OSAndroid
        However, I’m confused why we do not use the AC NEED_PTHREAD_LIB
        value here?
      - Use mmap on android
      - Support `none` vendor.
      Reviewers: austin, hvr, bgamari, erikd, simonmar
      Reviewed By: bgamari
      Subscribers: rwbarton, thomie, erikd
      Differential Revision: https://phabricator.haskell.org/D3356
    • Matthew Pickering's avatar
      Allow operators as record pattern synonym fields · 154d224a
      Matthew Pickering authored
      Fixes #13454
      Reviewers: austin, bgamari, dfeuer
      Reviewed By: dfeuer
      Subscribers: RyanGlScott, rwbarton, thomie
      Differential Revision: https://phabricator.haskell.org/D3379
    • Matthew Pickering's avatar
      Print module when dumping rules · 04ea4c3f
      Matthew Pickering authored
      It is sometimes hard to find where a rule is defined. Printing the
      module where it comes from will make it much easier to find.
      Reviewers: austin, bgamari
      Reviewed By: bgamari
      Subscribers: rwbarton, thomie
      Differential Revision: https://phabricator.haskell.org/D3378
    • ruperthorlick's avatar
      Fixed error messages for RecursiveDo (#8501) · 5856c564
      ruperthorlick authored
      Changes in a few different places to catch several different
      types of error related to RecursiveDo
      Signed-off-by: ruperthorlick's avatarRupert Horlick <ruperthorlick@gmail.com>
      Test Plan: Three test cases, with further tests in comments
      Reviewers: austin, bgamari
      Reviewed By: bgamari
      Subscribers: thomie
      Differential Revision: https://phabricator.haskell.org/D3271
    • Simon Peyton Jones's avatar
      Fix ASSERT failure in TcErrors · f88ac374
      Simon Peyton Jones authored
      This fixes Trac #13494, by improving
         commit e0ad55f8
         Author: Simon Peyton Jones <simonpj@microsoft.com>
         Date:   Mon Mar 27 10:32:08 2017 +0100
         Fix error-message suppress on given equalities
      which in turn was a fix to #13446
    • Simon Peyton Jones's avatar
      Add a couple of HasDebugCallStack contexts · 60d338f5
      Simon Peyton Jones authored
      Just for future (and past) debugging...
    • Simon Peyton Jones's avatar
      Allow unbound Refl binders in a RULE · 8674883c
      Simon Peyton Jones authored
      Trac #13410 was failing because we had a RULE with a binder
         (c :: t~t)
      and the /occurrences/ of c on the LHS were being optimised to Refl,
      leaving a binder that would not be filled in by matching the LHS
      of the rule.
      I flirted with trying to ensure that occurrences (c :: t~t) are
      not optimised to Relf, but that turned out to be fragile; it was
      being done, for good reasons, in multiple places, including
        - TyCoRep.substCoVarBndr
        - Simplify.simplCast
        - Corecion.mkCoVarCo
      So I fixed it in one place by making Rules.matchN deal happily
      with an unbound binder (c :: t~t).  Quite easy.  See "Coercion
      variables" in Note [Unbound RULE binders] in Rules.
      In addition, I needed to make CoreLint be happy with an bound
      RULE binder that is a Relf coercion variable
      In debugging this, I was perplexed that occurrences of a variable
      (c :: t~t) mysteriously turned into Refl.  I found out how it
      was happening, and decided to move it:
      * In TyCoRep.substCoVarBndr, do not substitute Refl for a
        binder (c :: t~t).
      * In mkCoVarCo do not optimise (c :: t~t) to Refl.
      Instead, we do this optimisation in optCoercion (specifically
      opt_co4) where, surprisingly, the optimisation was /not/
      being done.  This has no effect on what programs compile;
      it just moves a relatively-expensive optimisation to optCoercion,
      where it seems more properly to belong.  It's actually not clear
      to me which is really "better", but this way round is less
      One small simplifying refactoring
      * Eliminate TyCoRep.substCoVarBndrCallback, which was only
        called locally.
  2. 28 Mar, 2017 3 commits
    • Joachim Breitner's avatar
      Zap Call Arity info in the simplifier · e07211f7
      Joachim Breitner authored
      As #13479 shows, there are corner cases where the simplifier decides to
      not eta-expand a function as much as its call arity would suggest, but
      instead transforms the code that the call arity annotation becomes a
      As the call arity information is only meant to be used by the
      immediatelly following simplifier run, it makes sense to simply zap the
      information there.
      Differential Revision: https://phabricator.haskell.org/D3390
    • Gabor Greif's avatar
      Spelling in comments only [ci skip] · 08a6fc69
      Gabor Greif authored
    • Simon Peyton Jones's avatar
      Complete the fix for #13441 (pattern synonyms) · b5c81203
      Simon Peyton Jones authored
      Do not attempt to typecheck both directions of an
      implicitly-bidirectional pattern synonym simultanously,
      as we were before.  Instead, the builder is typechecked
      when we typecheck the code for the builder, which was
      of course happening already, even in both bidirectional
      See Note [Checking against a pattern signature], under
      "Existential type variables".
  3. 27 Mar, 2017 9 commits
    • Richard Eisenberg's avatar
      Fix #13458 · cea71418
      Richard Eisenberg authored
      Core Lint shouldn't check representations of types that don't
      have representations.
      test case: typecheck/should_compile/T13458
    • Simon Peyton Jones's avatar
      Remove utterly bogus code · de4723fd
      Simon Peyton Jones authored
      The commit 67465497
          Author: Richard Eisenberg <eir@cis.upenn.edu>
          Date:   Fri Dec 11 18:19:53 2015 -0500
          Add kind equalities to GHC.
      added this entirely bogus code to Simplify.simplLam:
          env' | Coercion co <- arg
               = extendCvSubst env bndr co
               | otherwise
               = env
      It's bogus because 'co' is an 'InCoercion', but a CvSubst should have
      only OutCoercions in it.  Moreover, completeBind does the job nicely.
      This led to an ASSERT failure in an experimental branch; but I have
      not got a repro case that works on HEAD.  But still, the patch deletes
      code and fixes a bug, so it must be good.
      The only mystery is why Richard added it in the first place :-).
      I hope I'm not missing anything.  But it validates fine.
    • Simon Peyton Jones's avatar
      Fix 'unsolved constraints' in GHCi · feca929b
      Simon Peyton Jones authored
      In initTc, if the computation fails with an exception, we
      should not complain about unsolved constraints.
      Fixes Trac #13466.
    • Simon Peyton Jones's avatar
      Fix error-message suppress on given equalities · e0ad55f8
      Simon Peyton Jones authored
      I'd got the logic slightly wrong when reporting type errors
      for insoluble 'given' equalities.  We suppress insoluble givens
      under some circumstances (see Note [Given errors]), but we then
      suppressed subsequent 'wanted' errors because the (suppressed)
      'given' error "won".  Result: no errors at all :-(.
      This patch fixes it and
       - Renames TcType.isTyVarUnderDatatype to the more
         perspicuous TcType.isInsolubleOccursCheck
      In doing this I realise that I don't understand why we need
      to keep the insolubles partitioned out separately at all...
      but that is for another day.
    • Simon Peyton Jones's avatar
      Fix explicitly-bidirectional pattern synonyms · 7c7479d0
      Simon Peyton Jones authored
      This partly fixes Trac #13441, at least for the explicitly
      bidirectional case.
      See Note [Checking against a pattern signature], the part about
      "Existential type variables".
      Alas, the implicitly-bidirectional case is still not quite right, but
      at least there is a workaround by making it explicitly bidirectional.
    • Simon Peyton Jones's avatar
    • Simon Peyton Jones's avatar
      Simplify the logic for tc_hs_sig_type · 1e06d8b8
      Simon Peyton Jones authored
      In fixing Trac #13337, and introducing solveSomeEqualities,
      Richard introduce the higher-order function tc_hs_sig_type_x,
      with a solver as its argument.
      It turned out that there was a much simpler way to do the
      same thing, which this patch implements.  Less code, easier
      to grok.  No change in behaviour though.
    • Matthew Pickering's avatar
      Only use locally bound variables in pattern synonym declarations · d819e416
      Matthew Pickering authored
      We were using the unconstrainted `lookupOccRn` function which looked up
      any variable in scope. Instead we only want to consider variables brought into
      scope by renaming the pattern on the RHS.
      A few more changes to make reporting of unbound names suggest the correct
      Fixes #13470
      Reviewers: simonpj, austin, bgamari
      Reviewed By: simonpj
      Subscribers: rwbarton, thomie
      Differential Revision: https://phabricator.haskell.org/D3377
    • Matthew Pickering's avatar
      Remove unused argument from importSuggestions · a6ce7f33
      Matthew Pickering authored
      Reviewers: austin, bgamari
      Subscribers: rwbarton, thomie
      Differential Revision: https://phabricator.haskell.org/D3376
  4. 26 Mar, 2017 2 commits
  5. 24 Mar, 2017 6 commits
  6. 22 Mar, 2017 1 commit
    • David Feuer's avatar
      Make unsafeInterleaveST less unsafe · 30d68d63
      David Feuer authored
      * Make `unsafeInterleaveST` use `noDuplicate#` like
      `unsafeInterleaveIO` does to prevent the suspended action from
      being run in two threads.
      * In order to accomplish this without `unsafeCoerce#`, generalize
      the type of `noDuplicate#`.
      * Add `unsafeDupableInterleaveST` to get the old behavior.
      * Document unsafe `ST` functions and clean up some related
      Fixes #13457
      Reviewers: austin, hvr, bgamari, ekmett
      Reviewed By: bgamari
      Subscribers: rwbarton, thomie
      Differential Revision: https://phabricator.haskell.org/D3370
  7. 21 Mar, 2017 1 commit
    • David Feuer's avatar
      Let GHC know MutVar# ops can't fail · 2ac13c13
      David Feuer authored
      The only way `readMutVar#` or `writeMutVar#` can fail is if its
      argument is not a valid pointer. I believe we ensure this by
      construction, and never test for pointer validity. So I think it
      should be safe to say that it can't fail.
      Fixes #13424
      Reviewers: austin, bgamari
      Reviewed By: bgamari
      Subscribers: rwbarton, thomie
      Differential Revision: https://phabricator.haskell.org/D3340
  8. 20 Mar, 2017 3 commits
  9. 19 Mar, 2017 2 commits
  10. 18 Mar, 2017 1 commit
  11. 17 Mar, 2017 3 commits
    • Simon Peyton Jones's avatar
      No join-point from an INLINE function with wrong arity · a7dbafe9
      Simon Peyton Jones authored
      The main payload of this patch is NOT to make a join-point
      from a function with an INLINE pragma and the wrong arity;
      see Note [Join points and INLINE pragmas] in CoreOpt.
      This is what caused Trac #13413.
      But we must do the exact same thing in simpleOptExpr,
      which drove me to the following refactoring:
      * Move simpleOptExpr and simpleOptPgm from CoreSubst to a new
        module CoreOpt along with a few others (exprIsConApp_maybe,
        pushCoArg, etc)
        This eliminates a module loop altogether (delete
        CoreArity.hs-boot), and stops CoreSubst getting too huge.
      * Rename Simplify.matchOrConvertToJoinPoint
           to joinPointBinding_maybe
        Move it to the new CoreOpt
        Use it in simpleOptExpr as well as in Simplify
      * Define CoreArity.joinRhsArity and use it
    • Simon Peyton Jones's avatar
      Improve Lint a little · 567bc6bd
      Simon Peyton Jones authored
      Better location info if the error is in an unfolding
    • Richard Eisenberg's avatar
      Remove solveSomeEqualities · 3cfee57a
      Richard Eisenberg authored
      I had thought that it was necessary to solve kind-level equalities
      before validity-checking a type, but I was wrong. This patch simply
      deletes code. Hooray!