Core, shadowing type variable names

Tobias Gedell d99getob at dtek.chalmers.se
Sat Jan 25 09:14:51 EST 2003


There is a problem with unique type variables in some bindings when 
generating Core.

I found the error in Text/ParserCombinators/ReadP.hcr (generated with 
the -O0 flag).


The error occurs at line 825 in ReadP.hcr:

-----
		    %case ds %of (wild::GHCziBase.ZMZN GHCziBase.Char)
		      {GHCziBase.ZC
		       (c::GHCziBase.Char) (cs::GHCziBase.ZMZN GHCziBase.Char) ->
			 zddmzgzg @ GHCziBase.Char @ (GHCziBase.ZMZN GHCziBase.Char)
			 (TextziParserCombinatorsziReadP.char c) (scan cs);
-----



If we look at the definition of zddmzgzg, line 732, we see what the 
problem is:

-----
    zddmzgzg :: %forall a b . (%forall b . (a ->
					   TextziParserCombinatorsziReadP.P b)
					  -> TextziParserCombinatorsziReadP.P b)
			     ->
			     (%forall b . (b -> TextziParserCombinatorsziReadP.P b) ->
					  TextziParserCombinatorsziReadP.P b)
			     ->
			     %forall b . (b -> TextziParserCombinatorsziReadP.P b) ->
					 TextziParserCombinatorsziReadP.P b = ...
-----


The second time b is bound it shadows the first binding. Maybe there is 
a missing tidyType on the binding types?


If we at line 54 in ReadP.hs change
  newtype ReadP a = R (forall b . (a -> P b) -> P b)
to
  newtype ReadP a = R (forall z . (a -> P z) -> P z)
we get the correct type definition in the generated Core code:

-----
    zddmzgzg :: %forall a b . (%forall zz . (a ->
					    TextziParserCombinatorsziReadP.P zz)
					   -> TextziParserCombinatorsziReadP.P zz)
			     ->
			     (%forall zz . (b -> TextziParserCombinatorsziReadP.P zz) ->
					   TextziParserCombinatorsziReadP.P zz)
			     ->
			     %forall zz . (b -> TextziParserCombinatorsziReadP.P zz) ->
					  TextziParserCombinatorsziReadP.P zz = ...
-----


This problem can also be found in Lex.hcr at line 1479.



Sincerely,
  Tobias




More information about the Glasgow-haskell-bugs mailing list