Skip to content
This repository was archived by the owner on Mar 29, 2019. It is now read-only.

Commit 252ab54

Browse files
committed
added parameter count check for function call
1 parent f30a0dc commit 252ab54

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

mamba/ast.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ def __init__(self, children=None):
1111
children = []
1212
self.children = children
1313

14+
def __len__(self):
15+
return len(self.children)
16+
1417
def __iter__(self):
1518
return iter(self.children)
1619

@@ -392,6 +395,14 @@ def __eval_udf(self):
392395
func = self.name.eval()
393396
args = {}
394397

398+
# check param count
399+
l1 = len(func.params)
400+
l2 = len(self.params)
401+
402+
if l1 != l2:
403+
msg = "Invalid number of arguments for function {0}. Expected {1} got {2}"
404+
raise InvalidParamCount(msg.format(self.name.name, l1, l2))
405+
395406
# pair the defined parameters in the function signature with
396407
# whatever is being passed on.
397408
#

mamba/exceptions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,8 @@ class DuplicateSymbol(InterpreterException):
2323

2424

2525
class InterpreterRuntimeError(InterpreterException):
26+
pass
27+
28+
29+
class InvalidParamCount(InterpreterRuntimeError):
2630
pass

0 commit comments

Comments
 (0)