summaryrefslogtreecommitdiff
path: root/src/Parser
diff options
context:
space:
mode:
Diffstat (limited to 'src/Parser')
-rw-r--r--src/Parser/Expr.hs9
-rw-r--r--src/Parser/Statement.hs4
2 files changed, 8 insertions, 5 deletions
diff --git a/src/Parser/Expr.hs b/src/Parser/Expr.hs
index c57aa97..53bd1a1 100644
--- a/src/Parser/Expr.hs
+++ b/src/Parser/Expr.hs
@@ -4,7 +4,7 @@ module Parser.Expr (
varName,
newVarName,
- addVarName,
+ addVarName, addVarNameType,
constrName,
someExpr,
@@ -78,12 +78,15 @@ newVarName = do
return name
addVarName :: forall a. ExprType a => Int -> TypedVarName a -> TestParser ()
-addVarName off (TypedVarName name) = do
+addVarName off tname = addVarNameType off tname (ExprTypePrim @a Proxy)
+
+addVarNameType :: forall a. ExprType a => Int -> TypedVarName a -> SomeExprType -> TestParser ()
+addVarNameType off (TypedVarName name) stype = do
gets (lookup name . testVars) >>= \case
Just _ -> registerParseError $ FancyError off $ S.singleton $ ErrorFail $ T.unpack $
T.pack "variable '" <> textVarName name <> T.pack "' already exists"
Nothing -> return ()
- modify $ \s -> s { testVars = ( name, ( LocalVarName name, ExprTypePrim @a Proxy )) : testVars s }
+ modify $ \s -> s { testVars = ( name, ( LocalVarName name, stype )) : testVars s }
constrName :: TestParser VarName
constrName = label "contructor name" $ do
diff --git a/src/Parser/Statement.hs b/src/Parser/Statement.hs
index 4548b63..96af2f3 100644
--- a/src/Parser/Statement.hs
+++ b/src/Parser/Statement.hs
@@ -37,11 +37,11 @@ letStatement = do
off <- stateOffset <$> getParserState
name <- varName
osymbol "="
- SomeExpr e <- someExpr
+ se@(SomeExpr e) <- someExpr
localState $ do
let tname = TypedVarName name
- addVarName off tname
+ addVarNameType off tname (someExprType se)
void $ eol
body <- testBlock indent
return $ Let line tname e (TestBlockStep EmptyTestBlock . Scope <$> body)