cloud-custodian/cel-python

crash when call function without parameters

lovew opened this issue · 1 comments

lovew commented
import celpy
import celpy.celtypes

cel_source = """
shake_hands()
"""

env = celpy.Environment()
ast = env.compile(cel_source)

def shake_hands(*args, **kwargs) -> celpy.celtypes.StringType:
    return celpy.celtypes.StringType(f"call shake_hands")

prgm = env.program(ast, functions=[shake_hands])
activation = {}

result = prgm.evaluate(activation)
print(result)

got

    name_token, exprlist = cast(Tuple[lark.Token, lark.Tree], child.children)
ValueError: not enough values to unpack (expected 2, got 1)

This production

ident_arg : IDENT "(" [exprlist] ")"

Unsurprisingly, produced two variant trees. This will be fixed in the next release.