@@ -28,6 +28,7 @@ import Data.Either.Combinators (fromLeft', fromRight, fromRight', isLeft, maybeT
28
28
import qualified Data.HashTable.IO as H
29
29
import Data.Maybe (fromJust , fromMaybe , isJust )
30
30
import Data.Text as T (Text , empty , pack , toLower , unpack )
31
+ import Debug.Trace (trace )
31
32
import Parser.Ast
32
33
( Expr (ArbitraryBlock , Array , Conditional , FunctionCall , FunctionDef , Nil , Root , VariableDef , VariableUsage ),
33
34
VDataType (Bool , Function , Inferred , NilType ),
@@ -80,7 +81,12 @@ analyseExprs acc' curr = do
80
81
-- cond :: Expr -> the condition to evaluate, must return bool
81
82
-- ift :: Expr -> the Expr to return if cond is **true**
82
83
-- iff :: Expr -> the Expr to return if cond is **false**
83
- Conditional cond ift iff -> analyseConditional acc cond ift iff
84
+ Conditional cond ift iff -> do
85
+ env <- get
86
+ v <- sequence . fst <$> liftIO (runStateT (foldl analyseExprs (pure [] ) [cond, ift, iff]) env)
87
+ case v of
88
+ Left err -> pure $ makeLeft err
89
+ Right _ -> analyseConditional acc cond ift iff
84
90
-- body :: [Expr] -> the set of exprs that the block is formed by
85
91
ArbitraryBlock body -> analyseArbitraryBlock acc body analyseExprs
86
92
-- name :: Text -> the name of the function
0 commit comments