From feb0496d713bfe81d5598437a0387880340fc1a6 Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Mon, 7 Apr 2008 23:36:30 +0000 Subject: [PATCH] Handle DATA TYPE FOO IS (some record). --- frontends/OccamTypes.hs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/frontends/OccamTypes.hs b/frontends/OccamTypes.hs index 55e55e2..47372cc 100644 --- a/frontends/OccamTypes.hs +++ b/frontends/OccamTypes.hs @@ -877,10 +877,14 @@ inferTypes = applyExplicitM10 doExpression doDimension doSubscript -- | Resolve the @v[s]@ ambiguity: this takes the type that @v@ is, and -- returns the correct 'Subscript'. fixSubscript :: A.Type -> A.Subscript -> PassM A.Subscript - fixSubscript (A.Record _) (A.Subscript m _ (A.ExprVariable _ (A.Variable _ wrong))) - = do n <- nameToUnscoped wrong - return $ A.SubscriptField m n - fixSubscript t s = return s + fixSubscript t s@(A.Subscript m _ (A.ExprVariable _ (A.Variable _ wrong))) + = do underT <- resolveUserType m t + case underT of + A.Record _ -> + do n <- nameToUnscoped wrong + return $ A.SubscriptField m n + _ -> return s + fixSubscript _ s = return s -- | Given a name that should really have been a tag, make it one. nameToUnscoped :: A.Name -> PassM A.Name