Skip to content

Commit 1695965

Browse files
committed
[fix:Parser] don't require body for native defs
1 parent 9dfc07d commit 1695965

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Parser/Parser.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ nativeFunctionDef = parens func
7070
args <- squares $ many identifierWithType
7171
let len = length args
7272
-- check if only the last element is variadic
73-
fnTransformer (fst id) args
73+
fnTransformer True (fst id) args
7474

7575
-- (defun some-fn [(arg1: int, arg2: int, ...)] { ... })
7676
-- can also have variadic arguments, for example arg3 in
@@ -91,10 +91,10 @@ functionDef = parens func
9191
id <- optionallyTypedIdentifier
9292
args <- squares $ many identifierWithType
9393
-- check if only the last element is variadic
94-
fnTransformer id args
94+
fnTransformer False id args
9595

96-
fnTransformer :: (T.Text, VDataType) -> [((T.Text, VDataType), Bool)] -> Parser Expr
97-
fnTransformer id args = do
96+
fnTransformer :: Bool -> (T.Text, VDataType) -> [((T.Text, VDataType), Bool)] -> Parser Expr
97+
fnTransformer isNative id args = do
9898
let len = length args
9999
args' <- rFoldl
100100
(zip [(1 :: Int) ..] args)
@@ -111,7 +111,7 @@ fnTransformer id args = do
111111
else fail "Only the last argument of a function can be variadic!"
112112
else -- if not variadic, just add to accumulator
113113
pure (val, False)
114-
body <- braces exprs
114+
body <- if isNative then pure [] else braces exprs
115115
pure $ uncurry FunctionDef id args' body False
116116

117117
arbitraryBlock :: Parser Expr

0 commit comments

Comments
 (0)