Skip to content

Commit

Permalink
Put an expensive assertion in CPP brackets
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikolaj committed Dec 31, 2024
1 parent e11538c commit efe4454
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/HordeAd/Core/AstInterpret.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# OPTIONS_GHC -fplugin GHC.TypeLits.KnownNat.Solver #-}
{-# OPTIONS_GHC -fplugin GHC.TypeLits.Normalise #-}
{-# OPTIONS_GHC -fmax-pmcheck-models=10000 #-}
Expand Down Expand Up @@ -171,12 +172,15 @@ interpretAst !env = \case
AstPair t1 t2 -> tpair (interpretAst env t1) (interpretAst env t2)
AstProject1 t -> tproject1 (interpretAst env t)
AstProject2 t -> tproject2 (interpretAst env t)
AstVar @y2 sh var ->
AstVar @y2 _sh var ->
let var2 = mkAstVarName @FullSpan @y2 (varNameToAstVarId var) -- TODO
in case DMap.lookup var2 env of
Just (AstEnvElemRep t) ->
assert (tftk (stensorKind @y2) t == sh
`blame` (sh, tftk (stensorKind @y2) t, var, t{-, env-})) t
#ifdef WITH_EXPENSIVE_ASSERTIONS
assert (tftk (stensorKind @y2) t == _sh
`blame` (_sh, tftk (stensorKind @y2) t, var, t))
#endif
t
_ -> error $ "interpretAst: unknown AstVar " ++ show var
-- TODO: ++ " in environment " ++ showsPrecAstEnv 0 env ""
AstPrimalPart a -> interpretAst env a
Expand Down

0 comments on commit efe4454

Please sign in to comment.