Skip to content

Commit 9defd68

Browse files
committed
Improve error message.
1 parent 50a949c commit 9defd68

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/pdl/pdl_interpreter.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,6 +1430,15 @@ def step_call(
14301430
background: Messages = []
14311431
args, block = process_expr_of(block, "args", scope, loc)
14321432
closure, _ = process_expr_of(block, "call", scope, loc)
1433+
if not isinstance(closure, FunctionBlock):
1434+
msg = f"Type error: {block.call} is of type {type(closure)} but should be a function."
1435+
if isinstance(closure, str) and isinstance(scope.get(closure), FunctionBlock):
1436+
msg += " You might want to call `${ "+ block.call + " }`."
1437+
raise PDLRuntimeError(
1438+
msg,
1439+
loc=append(loc, "call"),
1440+
trace=block.model_copy(),
1441+
)
14331442
args_loc = append(loc, "args")
14341443
type_errors = type_check_args(args, closure.function, args_loc)
14351444
if len(type_errors) > 0:

0 commit comments

Comments
 (0)