diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2025-02-13 21:03:00 +0100 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2025-02-13 21:03:00 +0100 |
commit | 14efffc66cb60465c18c984311bde5a5502803db (patch) | |
tree | 72ce535da6c6f7c7851b49547030bc15de6620c6 /src/Parser/Expr.hs | |
parent | d67825ea3f441523e2814b831d397d95c0dc46a4 (diff) |
Evaluate functions in parameters via unifyExpr
Diffstat (limited to 'src/Parser/Expr.hs')
-rw-r--r-- | src/Parser/Expr.hs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/Parser/Expr.hs b/src/Parser/Expr.hs index d59e0b2..bc16149 100644 --- a/src/Parser/Expr.hs +++ b/src/Parser/Expr.hs @@ -391,18 +391,17 @@ recordSelector (SomeExpr expr) = do checkFunctionArguments :: FunctionArguments SomeArgumentType -> Int -> Maybe ArgumentKeyword -> SomeExpr -> TestParser SomeExpr -checkFunctionArguments (FunctionArguments argTypes) poff kw expr = do +checkFunctionArguments (FunctionArguments argTypes) poff kw sexpr@(SomeExpr expr) = do case M.lookup kw argTypes of Just (SomeArgumentType (_ :: ArgumentType expected)) -> do - withRecovery registerParseError $ do - void $ unify poff (ExprTypePrim (Proxy @expected)) (someExprType expr) - return expr + withRecovery (\e -> registerParseError e >> return sexpr) $ do + SomeExpr <$> unifyExpr poff (Proxy @expected) expr Nothing -> do registerParseError $ FancyError poff $ S.singleton $ ErrorFail $ T.unpack $ case kw of Just (ArgumentKeyword tkw) -> "unexpected parameter with keyword `" <> tkw <> "'" Nothing -> "unexpected parameter" - return expr + return sexpr functionArguments :: (Int -> Maybe ArgumentKeyword -> a -> TestParser b) -> TestParser a -> TestParser a -> (Int -> Text -> TestParser a) -> TestParser (FunctionArguments b) |