cloud-custodian / cel-python

Pure Python implementation of the Common Expression Language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

crash when call function without parameters

lovew opened this issue · comments

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.