let/app invariant violated by code generated with mkCoreApp
Simon Peyton Jones
simonpj at microsoft.com
Tue Nov 11 14:13:03 UTC 2014
Oh bother, that is _so_ tiresome. The desugarer establishes the let/app invariant, so we get
I# x_help
but if x_help has a compulsory unfolding to (x void), returning an Int#, that violates the let/app invariant. Sigh. This is a ridiculous amount of work for a tiny corner (pattern synonyms for unboxed constants).
Harump. Let's see. We are talking only of things like this
pattern P = 4#
correct? Perhaps it may be simpler to make the psWrapper in PatSyn be
psWrapper :: Either Id Literal
and treat such patterns specially from the moment we first see them? That would eliminate all this void stuff entirely.
Pursuing the current line, though, I suppose that the desugarer could inline compulsory unfoldings during desugaring itself. In this line, add a case for when var has a compulsory unfolding.
dsExpr (HsVar var) = return (varToCoreExpr var) -- See Note [Desugaring vars]
That would, I suppose, be the quickest pathc.
Simon
| -----Original Message-----
| From: ghc-devs [mailto:ghc-devs-bounces at haskell.org] On Behalf Of Dr.
| ERDI Gergo
| Sent: 08 November 2014 14:03
| To: GHC Devs
| Subject: let/app invariant violated by code generated with mkCoreApp
|
| Hi,
|
| I'm trying to attach (f Void#) as a compulsory unfolding to an Id.
| Here's what I tried originally:
|
| let unfolding = mkCoreApp (Var worker_id) (Var voidPrimId)
| wrapper_id' = setIdUnfolding wrapper_id $
| mkCompulsoryUnfolding unfolding
|
| However, when I try to use wrapper_id' in the desugarer, the Core
| linter looks at me strange. This is the original Core:
|
| f :: Int
| [LclIdX, Str=DmdType]
| f = break<1>() GHC.Types.I# Main.$WPAT
|
| and this is the error message ($WPAT is the wrapper_id', PAT is the
| worker_id in this example)
|
| <no location info>: Warning:
| In the expression: I# (PAT void#)
| This argument does not satisfy the let/app invariant: PAT void#
|
| Now, I thought I'd make sure mkCoreApp generated correct Core by
| writing it out by hand:
|
| let unfolding = Case (Var voidPrimId) voidArgId pat_ty
| [(DEFAULT,[],App (Var worker_id) (Var voidArgId))]
|
| however, bizarrely, this *still* results in *the same* error message,
| as if something was transforming it back to a straight App.
|
| Anyone have any hints what I'm doing wrong here?
|
| Bye,
| Gergo
|
| --
|
| .--= ULLA! =-----------------.
| \ http://gergo.erdi.hu \
| `---= gergo at erdi.hu =-------'
| You are in a twisty maze of little install diskettes.
| _______________________________________________
| ghc-devs mailing list
| ghc-devs at haskell.org
| http://www.haskell.org/mailman/listinfo/ghc-devs
More information about the ghc-devs
mailing list