Commit 0c7db226 authored by Ryan Scott's avatar Ryan Scott Committed by Ben Gamari

Fix #15073 by suggesting UnboxedTuples in an error message

Under certain circumstances, `GeneralizedNewtypeDeriving`
can emit code which uses unboxed tuple types, but if `UnboxedTuples`
wasn't enabled, the error message that GHC gave didn't make it very
clear that it could be worked around by explicitly enabling the
extension. Easily fixed.

Test Plan: make test TEST=T15073

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: simonpj, thomie, carter

GHC Trac Issues: #15073

Differential Revision: https://phabricator.haskell.org/D4620
parent 4ffaf4b6
......@@ -621,7 +621,10 @@ forAllEscapeErr env ty tau_kind
, text "of kind:" <+> ppr_tidy env tau_kind ]) )
ubxArgTyErr :: TidyEnv -> Type -> (TidyEnv, SDoc)
ubxArgTyErr env ty = (env, sep [text "Illegal unboxed tuple type as function argument:", ppr_tidy env ty])
ubxArgTyErr env ty
= ( env, vcat [ sep [ text "Illegal unboxed tuple type as function argument:"
, ppr_tidy env ty ]
, text "Perhaps you intended to use UnboxedTuples" ] )
{-
Note [Liberal type synonyms]
......
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE TypeInType #-}
module T15073 where
import T15073a
newtype Foo a = MkFoo a
deriving P
T15073.hs:8:12: error:
• Illegal unboxed tuple type as function argument: (# a #)
Perhaps you intended to use UnboxedTuples
• In the expression:
GHC.Prim.coerce
@(a
-> (Unit# a :: TYPE (GHC.Types.TupleRep ((:) GHC.Types.LiftedRep ([] :: [] GHC.Types.RuntimeRep) :: [] GHC.Types.RuntimeRep))))
@(Foo a
-> (Unit# (Foo a) :: TYPE (GHC.Types.TupleRep ((:) GHC.Types.LiftedRep ([] :: [] GHC.Types.RuntimeRep) :: [] GHC.Types.RuntimeRep))))
p
In an equation for ‘p’:
p = GHC.Prim.coerce
@(a
-> (Unit# a :: TYPE (GHC.Types.TupleRep ((:) GHC.Types.LiftedRep ([] :: [] GHC.Types.RuntimeRep) :: [] GHC.Types.RuntimeRep))))
@(Foo a
-> (Unit# (Foo a) :: TYPE (GHC.Types.TupleRep ((:) GHC.Types.LiftedRep ([] :: [] GHC.Types.RuntimeRep) :: [] GHC.Types.RuntimeRep))))
p
When typechecking the code for ‘p’
in a derived instance for ‘P (Foo a)’:
To see the code I am typechecking, use -ddump-deriv
In the instance declaration for ‘P (Foo a)’
{-# LANGUAGE UnboxedTuples #-}
module T15073a where
class P a where
p :: a -> (# a #)
......@@ -72,3 +72,5 @@ test('T14365', [extra_files(['T14365B.hs','T14365B.hs-boot'])],
test('T14728a', normal, compile_fail, [''])
test('T14728b', normal, compile_fail, [''])
test('T14916', normal, compile_fail, [''])
test('T15073', [extra_files(['T15073a.hs'])], multimod_compile_fail,
['T15073', '-v0'])
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment