From 20b24c190e70cf57819c9b67aae1338d20248784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sat, 7 Dec 2024 19:46:34 +0100 Subject: Use void context for user-defined functions --- src/Parser.hs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Parser.hs b/src/Parser.hs index 1339ec8..e23b277 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -14,6 +14,7 @@ import Data.Set qualified as S import Data.Text qualified as T import Data.Text.Lazy qualified as TL import Data.Text.Lazy.IO qualified as TL +import Data.Void import Text.Megaparsec hiding (State) import Text.Megaparsec.Char @@ -32,10 +33,15 @@ import Test.Builtins parseTestDefinition :: TestParser Toplevel parseTestDefinition = label "test definition" $ toplevel ToplevelTest $ do - block (\name steps -> return $ Test name $ mconcat steps) header testStep - where header = do - wsymbol "test" - lexeme $ TL.toStrict <$> takeWhileP (Just "test name") (/=':') + localState $ do + modify $ \s -> s + { testContext = SomeExpr $ varExpr SourceLineBuiltin rootNetworkVar + } + block (\name steps -> return $ Test name $ mconcat steps) header testStep + where + header = do + wsymbol "test" + lexeme $ TL.toStrict <$> takeWhileP (Just "test name") (/=':') parseDefinition :: TestParser Toplevel parseDefinition = label "symbol definition" $ toplevel ToplevelDefinition $ do @@ -121,7 +127,7 @@ parseTestFile path = do { testVars = concat [ map (fmap someVarValueType) builtins ] - , testContext = SomeExpr $ varExpr SourceLineBuiltin rootNetworkVar + , testContext = SomeExpr (Undefined "void" :: Expr Void) , testNextTypeVar = 0 , testTypeUnif = M.empty } -- cgit v1.2.3