diff --git a/src/Act/Type.hs b/src/Act/Type.hs index 6f39bf4b..d2f1df6b 100644 --- a/src/Act/Type.hs +++ b/src/Act/Type.hs @@ -535,7 +535,10 @@ checkContractType env SInteger (ITE p _ a b) = (Just c1, Just c2) -> Just c1 <$ assert (p, "Type of if-then-else branches does not match") (c1 == c2) (_, _ )-> pure Nothing checkContractType _ SInteger (Create _ c _) = pure $ Just c -checkContractType env SInteger var@(Var _ _ _ _) = error "TODO" -- varContractType env var +checkContractType Env{pointers} SInteger (Var _ _ _ x) = + case Map.lookup x pointers of + Just c -> pure $ Just c + Nothing -> pure Nothing checkContractType _ _ (TEntry _ _ (Item _ (ContractType c) _)) = pure $ Just c checkContractType _ SInteger _ = pure Nothing diff --git a/tests/frontend/pass/case/case.act.typed.json b/tests/frontend/pass/case/case.act.typed.json index bc357e7d..c87eee6e 100644 --- a/tests/frontend/pass/case/case.act.typed.json +++ b/tests/frontend/pass/case/case.act.typed.json @@ -40,6 +40,7 @@ }, "kind": "Behaviour", "name": "bar", + "pointers": [], "postConditions": [], "preConditions": [ { @@ -241,6 +242,7 @@ }, "kind": "Behaviour", "name": "bar", + "pointers": [], "postConditions": [], "preConditions": [ { @@ -452,6 +454,7 @@ }, "kind": "Behaviour", "name": "bar", + "pointers": [], "postConditions": [], "preConditions": [ { @@ -651,6 +654,7 @@ }, "invariants": [], "kind": "Constructor", + "pointers": [], "postConditions": [], "preConditions": [] }, diff --git a/tests/frontend/pass/creation/create.act.typed.json b/tests/frontend/pass/creation/create.act.typed.json index 77affbc7..081dbe5a 100644 --- a/tests/frontend/pass/creation/create.act.typed.json +++ b/tests/frontend/pass/creation/create.act.typed.json @@ -41,6 +41,7 @@ }, "invariants": [], "kind": "Constructor", + "pointers": [], "postConditions": [], "preConditions": [ { diff --git a/tests/frontend/pass/multi/multi.act.typed.json b/tests/frontend/pass/multi/multi.act.typed.json index eb8e1ae8..9c4400d1 100644 --- a/tests/frontend/pass/multi/multi.act.typed.json +++ b/tests/frontend/pass/multi/multi.act.typed.json @@ -27,6 +27,7 @@ }, "invariants": [], "kind": "Constructor", + "pointers": [], "postConditions": [], "preConditions": [] }, @@ -58,6 +59,7 @@ }, "kind": "Behaviour", "name": "remote", + "pointers": [], "postConditions": [], "preConditions": [ { @@ -260,6 +262,7 @@ }, "kind": "Behaviour", "name": "multi", + "pointers": [], "postConditions": [], "preConditions": [ { @@ -525,7 +528,7 @@ "kind": "SVar", "svar": "a" }, - "type": "contract" + "type": "int" }, "value": { "args": [ @@ -546,6 +549,7 @@ }, "invariants": [], "kind": "Constructor", + "pointers": [], "postConditions": [], "preConditions": [] }, diff --git a/tests/frontend/pass/safemath/safemathraw.act.typed.json b/tests/frontend/pass/safemath/safemathraw.act.typed.json index 63b65ed6..82d32fbf 100644 --- a/tests/frontend/pass/safemath/safemathraw.act.typed.json +++ b/tests/frontend/pass/safemath/safemathraw.act.typed.json @@ -34,6 +34,7 @@ }, "kind": "Behaviour", "name": "add", + "pointers": [], "postConditions": [], "preConditions": [ { @@ -276,6 +277,7 @@ }, "invariants": [], "kind": "Constructor", + "pointers": [], "postConditions": [], "preConditions": [] }, diff --git a/tests/frontend/pass/smoke/smoke.act.typed.json b/tests/frontend/pass/smoke/smoke.act.typed.json index 2bc7f9c5..31eedc4c 100644 --- a/tests/frontend/pass/smoke/smoke.act.typed.json +++ b/tests/frontend/pass/smoke/smoke.act.typed.json @@ -26,6 +26,7 @@ }, "kind": "Behaviour", "name": "f", + "pointers": [], "postConditions": [], "preConditions": [ { @@ -92,6 +93,7 @@ }, "invariants": [], "kind": "Constructor", + "pointers": [], "postConditions": [], "preConditions": [] }, diff --git a/tests/frontend/pass/token/transfer.act.typed.json b/tests/frontend/pass/token/transfer.act.typed.json index d9f3ff76..5055da5d 100644 --- a/tests/frontend/pass/token/transfer.act.typed.json +++ b/tests/frontend/pass/token/transfer.act.typed.json @@ -46,6 +46,7 @@ }, "kind": "Behaviour", "name": "transfer", + "pointers": [], "postConditions": [], "preConditions": [ { @@ -826,6 +827,7 @@ }, "kind": "Behaviour", "name": "transfer", + "pointers": [], "postConditions": [], "preConditions": [ { @@ -1356,6 +1358,7 @@ }, "kind": "Behaviour", "name": "transferFrom", + "pointers": [], "postConditions": [], "preConditions": [ { @@ -2473,6 +2476,7 @@ }, "kind": "Behaviour", "name": "transferFrom", + "pointers": [], "postConditions": [], "preConditions": [ { @@ -3686,6 +3690,7 @@ }, "kind": "Behaviour", "name": "transferFrom", + "pointers": [], "postConditions": [], "preConditions": [ { @@ -4984,6 +4989,7 @@ }, "kind": "Behaviour", "name": "transferFrom", + "pointers": [], "postConditions": [], "preConditions": [ { @@ -6132,6 +6138,7 @@ } ], "kind": "Constructor", + "pointers": [], "postConditions": [], "preConditions": [ {