Function definition with a call of a function using the same dummy identifier name
The following code works
f1(x) = (f2(4) + x)
f2(y) = 2*y
print(f1(2)) # 10
but this does not:
f1(x) = (f2(4) + x)
f2(x) = 2*x
I get this error:
Traceback (most recent call last):
File "../scripts/run_model.py", line 19, in <module>
program = meta.model_from_file(model_file)
File "/home/ubuntu/python3-venv/lib/python3.8/site-packages/textx/metamodel.py", line 634, in model_from_file
return self.internal_model_from_file(
File "/home/ubuntu/python3-venv/lib/python3.8/site-packages/textx/metamodel.py", line 688, in internal_model_from_file
p(model, self)
File "/home/ubuntu/vre-language/constraints/functions.py", line 61, in check_functions_processor
check_function_definition(func, metamodel)
File "/home/ubuntu/vre-language/constraints/functions.py", line 29, in check_function_definition
assert not any(d in args_uniq_names for d in call_dummies)
AssertionError
"""
It is not just because of the same dummy names because it works without a function call in the function definition:
fx1(x) = 1 + x
fx2(x) = 2*x
print(fx1(2)) # 3
There is a test catching the issue. When the issue is solved the test will fail.
Edited by Ivan Kondov