Skip to content
This repository was archived by the owner on Jan 9, 2026. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/Pact/Typechecker.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE LambdaCase #-}

-- |
-- Module : Pact.Typechecker
Expand All @@ -32,7 +33,6 @@
--

module Pact.Typechecker where

import Bound.Scope
import Control.Arrow hiding ((<+>))
import Control.Lens hiding (List,Fold)
Expand Down Expand Up @@ -1193,7 +1193,13 @@ singLens = iso pure head

-- | Typecheck a top-level production.
typecheck :: TopLevel Node -> TC (TopLevel Node)
typecheck f@(TopFun FDefun {} _) = typecheckBody f (tlFun . fBody)
typecheck f@(TopFun FDefun {} _) = typecheckBody f (tlFun . fBody) >>= \case
TopFun fd@FDefun{} i | x:_ <- reverse (_fBody fd) ->
let rt = view (aNode . aTy) x
fd' = set (fType . ftReturn) rt fd
in pure $ TopFun fd' i
a -> pure a

typecheck c@TopConst {..} = do
assocAstTy (_aNode _tlConstVal) _tlType
typecheckBody c (tlConstVal . singLens)
Expand Down