logo       

Core, shadowing type variable names: msg#00065

lang.haskell.glasgow.bugs

Subject: Core, shadowing type variable names

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


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise