Commit 0f495083 authored by niteria's avatar niteria Committed by Ben Gamari

Put kind variables before type variables when specializing

When you reverse the order of uniques you get the core lint
error from the testcase. The testcase is copied from
tests/simplCore/should_compile/T10689a.hs.

The problem is that we would put type and kind variables ordered by
unique order, which happened to be the right order for this testcase to
pass under normal conditions.

I think it's enough to sort them with `sortQuantVars`, but I'm not
really sure if some more sophisticated dependency analysis isn't needed.

Test Plan: added a new testcase

Reviewers: simonpj, goldfire, simonmar, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D1457
parent fa61edde
......@@ -37,7 +37,7 @@ import Type hiding ( substTy )
import TyCon ( isRecursiveTyCon, tyConName )
import Id
import PprCore ( pprParendExpr )
import MkCore ( mkImpossibleExpr )
import MkCore ( mkImpossibleExpr, sortQuantVars )
import Var
import VarEnv
import VarSet
......@@ -1843,10 +1843,11 @@ callToPats env bndr_occs (Call _ args con_env)
-- See Note [Free type variables of the qvar types]
-- See Note [Shadowing] at the top
(tvs, ids) = partition isTyVar qvars
qvars' = tvs ++ map sanitise ids
-- Put the type variables first; the type of a term
-- variable may mention a type variable
(ktvs, ids) = partition isTyVar qvars
qvars' = sortQuantVars ktvs ++ map sanitise ids
-- Order into kind variables, type variables, term variables
-- The kind of a type variable may mention a kind variable
-- and the type of a term variable may mention a type variable
sanitise id = id `setIdType` expandTypeSynonyms (idType id)
-- See Note [Free type variables of the qvar types]
......
TOP=../../..
include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/test.mk
test('determ004', normal, compile, ['-dinitial-unique=8388608 -dunique-increment=-1'])
This diff is collapsed.
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