cloud-custodian / cel-python

Pure Python implementation of the Common Expression Language
Apache License 2.0
116 stars 22 forks source link

crash when call function without parameters #10

Closed lovew closed 4 years ago

lovew commented 4 years ago
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)
slott56 commented 4 years ago

This production

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

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