Skip to content

Commit

Permalink
Check types of refs right before passing to CCache
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisPenner committed Sep 13, 2024
1 parent 67f4597 commit 78532b0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ allow-newer-deps:

ghc-options:
# All packages
"$locals": -Wall -Werror -Wno-name-shadowing -Wno-missing-pattern-synonym-signatures -fprint-expanded-synonyms -fwrite-ide-info -Wunused-packages #-freverse-errors
"$locals": -Wall -Werror -Wno-name-shadowing -Wno-missing-pattern-synonym-signatures -fprint-expanded-synonyms -fwrite-ide-info -Wunused-packages -debug #-freverse-errors

# See https://github.com/haskell/haskell-language-server/issues/208
"$everything": -haddock
Expand Down
30 changes: 15 additions & 15 deletions unison-runtime/src/Unison/Runtime/Interface.hs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ import Unison.Codebase.Runtime (Error, Runtime (..))
import Unison.ConstructorReference (ConstructorReference, GConstructorReference (..))
import Unison.ConstructorReference qualified as RF
import Unison.DataDeclaration (Decl, declFields, declTypeDependencies)
import Unison.Debug qualified as Debug
import Unison.Hashing.V2.Convert qualified as Hashing
import Unison.LabeledDependency qualified as RF
import Unison.Parser.Ann (Ann (External))
Expand Down Expand Up @@ -200,17 +201,6 @@ resolveTermRef cl r@(RF.DerivedId i) =
Nothing -> die $ "Unknown term reference: " ++ show r
Just tm -> pure tm

resolveTermRefType ::
CodeLookup Symbol IO () ->
RF.Reference ->
IO (Type Symbol)
resolveTermRefType _ b@(RF.Builtin _) =
die $ "Unknown builtin term reference: " ++ show b
resolveTermRefType cl r@(RF.DerivedId i) =
getTypeOfTerm cl i >>= \case
Nothing -> die $ "Unknown term reference: " ++ show r
Just typ -> pure typ

allocType ::
EvalCtx ->
RF.Reference ->
Expand Down Expand Up @@ -467,10 +457,20 @@ loadDeps cl ppe ctx tyrs tmrs = do
where
checkCacheability :: (Reference, sprgrp) -> IO (Reference, sprgrp, Cacheability)
checkCacheability (r, sg) = do
typ <- resolveTermRefType cl r
if ABT.cata hasArrows typ
then pure (r, sg, Uncacheable)
else pure (r, sg, Cacheable)
getTermType r >>= \case
Just typ | not (ABT.cata hasArrows typ) -> pure (r, sg, Cacheable)
_ -> pure (r, sg, Uncacheable)
getTermType :: Reference -> IO (Maybe (Type Symbol))
getTermType = \case
ref@(RF.DerivedId i) ->
getTypeOfTerm cl i >>= \case
Just t -> do
Debug.debugM Debug.Temp "Found type for: " ref
pure $ Just t
Nothing -> do
Debug.debugM Debug.Temp "NO type for: " ref
pure Nothing
RF.Builtin {} -> pure $ Nothing
hasArrows :: a -> ABT.ABT Type.F v Bool -> Bool
hasArrows _ = \case
ABT.Tm f -> case f of
Expand Down

0 comments on commit 78532b0

Please sign in to comment.