[GHC] #13509: Perplexing type error
#13509: Perplexing type error -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: GHC rejects Unknown/Multiple | valid program Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- The `fast-digits` package fails to build with 8.2.0-rc1, {{{ [1 of 2] Compiling Data.FastDigits.Internal ( src/Data/FastDigits/Internal.hs, dist/build/Data/FastDigits/Internal.o ) src/Data/FastDigits/Internal.hs:42:34: error: • Couldn't match a lifted type with an unlifted type Expected type: Word# -> (# Word#, Word# #) Actual type: Word# -> (# Word#, Word# #) • In the expression: go pw2 In a pattern binding: (# n, pw2n #) = go pw2 In the expression: let (# n, pw2n #) = go pw2 in case timesWord2# pw pw2n of (# 0##, pw2n1 #) -> (# n `timesWord#` 2## `plusWord#` 1##, pw2n1 #) _ -> (# n `timesWord#` 2##, pw2n #) | 42 | -> let (# n, pw2n #) = go pw2 in | ^^^^^^ src/Data/FastDigits/Internal.hs:43:33: error: • Couldn't match a lifted type with an unlifted type When matching the kind of ‘Word#’ • In the second argument of ‘timesWord2#’, namely ‘pw2n’ In the expression: timesWord2# pw pw2n In the expression: case timesWord2# pw pw2n of (# 0##, pw2n1 #) -> (# n `timesWord#` 2## `plusWord#` 1##, pw2n1 #) _ -> (# n `timesWord#` 2##, pw2n #) | 43 | case timesWord2# pw pw2n of | ^^^^ src/Data/FastDigits/Internal.hs:44:37: error: • Couldn't match a lifted type with an unlifted type When matching the kind of ‘Word#’ • In the first argument of ‘timesWord#’, namely ‘n’ In the first argument of ‘plusWord#’, namely ‘n `timesWord#` 2##’ In the expression: n `timesWord#` 2## `plusWord#` 1## | 44 | (# 0##, pw2n1 #) -> (#n `timesWord#` 2## `plusWord#` 1##, pw2n1 #) | ^ }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13509> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13509: Perplexing type error -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): The function in question is, {{{#!hs selectPower :: Word# -> (# Word#, Word# #) selectPower 2## = (# 63##, 9223372036854775808## #) selectPower base = go base where go :: Word# -> (# Word#, Word# #) go pw = case timesWord2# pw pw of (# 0##, pw2 #) -> let (# n, pw2n #) = go pw2 in case timesWord2# pw pw2n of (# 0##, pw2n1 #) -> (#n `timesWord#` 2## `plusWord#` 1##, pw2n1 #) _ -> (# n `timesWord#` 2##, pw2n #) _ -> (# 1##, pw #) }}} Adding a type signature, `go :: Word# -> (# Word#, Word# #)`, appears to allow compilation to proceed. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13509#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13509: Perplexing type error -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * cc: goldfire (added) Comment: The commit e7985ed23ddc68b6a2e4af753578dc1d9e8ab4c9 (Update levity polymorphism) introduced this regression. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13509#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13509: Perplexing type error -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: | LevityPolymorphism Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * keywords: => LevityPolymorphism -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13509#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13509: Perplexing type error -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: | LevityPolymorphism Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Even shorter repro case {{{ {-# LANGUAGE UnboxedTuples, MagicHash #-} module T13509 where import GHC.Exts import Data.Word selectPower :: Word# -> (# Word#, Word# #) selectPower base = go base where go :: Word# -> (# Word#, Word# #) go pw = let (# n, pw2n #) = go pw in (# n `timesWord#` 2##, pw2n #) }}} This compiles. Commenting out the signature for `go` makes it fail. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13509#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13509: Perplexing type error with unboxed tuples -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: | LevityPolymorphism Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13509#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13509: Perplexing type error with unboxed tuples -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: | LevityPolymorphism Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Interestingly, comment:4 fails with GHC 7.10 and 8.0 as well. But comment:1 succeeds (I don't know why yet). -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13509#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13509: Perplexing type error with unboxed tuples -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: | LevityPolymorphism Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Simon Peyton Jones <simonpj@…>): In [changeset:"bac95f9de5bd8d0a647a3a1e4492497603c2fda2/ghc" bac95f9d/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="bac95f9de5bd8d0a647a3a1e4492497603c2fda2" Yet another attempt at inferring the right quantification TcSimplify.decideQuantification is truly a tricky function! Trac #13509 showed that we were being over-eager with defaulting of runtime-rep variables (levity polymorphism), which meant that a program was wrongly rejected, and with a very odd error message (c.f. Trac #13530) I spent an unreasonably long time figuring out how to fix this in a decent way, and ended up with a major refactoring of decideQuantification, with a kock-on effect in simplifyInfer. It is at least a bit more comprehensible now; but I still can't say I like it. }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13509#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13509: Perplexing type error with unboxed tuples -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: merge Priority: high | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: | LevityPolymorphism Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: new => merge Comment: I think I've fixed this. Things are better. It's a fairly big patch, so I suppose that I could have introduced some new bug (although it validates fine). I'm open-minded about whether to merge it to 8.2. Simon -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13509#comment:8> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13509: Perplexing type error with unboxed tuples -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: merge Priority: high | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: | LevityPolymorphism Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): PS: this does NOT fix #11530 and #11198. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13509#comment:9> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13509: Perplexing type error with unboxed tuples -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: closed Priority: high | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 Resolution: fixed | Keywords: | LevityPolymorphism Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed Comment: Merged as 859dc65369e8a9722514046246dd32b683c8b4a9. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13509#comment:10> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC