[BUGFIX] Fix custom function lambda cycle detection
This commit is contained in:
parent
7ac525f875
commit
f4c8405dc2
2 changed files with 18 additions and 3 deletions
|
|
@ -66,6 +66,21 @@ class Script:
|
|||
deps=deps + [dep.name],
|
||||
)
|
||||
|
||||
for custom_func in variable_dependency.custom_function_dependencies(
|
||||
custom_function_definitions=self._functions
|
||||
):
|
||||
for dep in self._functions[custom_func.name].variables:
|
||||
self._ensure_no_cycle(
|
||||
name=variable_name, dep=dep.name, deps=deps, definitions=self._variables
|
||||
)
|
||||
self._traverse_variable_dependencies(
|
||||
variable_name=variable_name,
|
||||
variable_dependency=self._variables[dep.name],
|
||||
deps=deps + [dep.name],
|
||||
)
|
||||
|
||||
|
||||
|
||||
def _ensure_no_variable_cycles(self, variables: Dict[str, SyntaxTree]):
|
||||
for variable_name, variable_definition in variables.items():
|
||||
self._traverse_variable_dependencies(
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ class VariableDependency(ABC):
|
|||
raise UNREACHABLE
|
||||
|
||||
@final
|
||||
def _custom_function_dependencies(
|
||||
def custom_function_dependencies(
|
||||
self, custom_function_definitions: Dict[str, "VariableDependency"]
|
||||
) -> Set[ParsedCustomFunction]:
|
||||
custom_functions = self.custom_functions
|
||||
|
|
@ -185,7 +185,7 @@ class VariableDependency(ABC):
|
|||
True if it contains all input variables as a dependency. False otherwise.
|
||||
"""
|
||||
# If there are lambdas, see if they are custom functions. If so, check them
|
||||
for custom_function in self._custom_function_dependencies(custom_function_definitions):
|
||||
for custom_function in self.custom_function_dependencies(custom_function_definitions):
|
||||
if not custom_function_definitions[custom_function.name].is_subset_of(
|
||||
variables=variables, custom_function_definitions=custom_function_definitions
|
||||
):
|
||||
|
|
@ -205,7 +205,7 @@ class VariableDependency(ABC):
|
|||
True if it contains any of the input variables. False otherwise.
|
||||
"""
|
||||
# If there are lambdas, see if they are custom functions. If so, check them
|
||||
for custom_function in self._custom_function_dependencies(custom_function_definitions):
|
||||
for custom_function in self.custom_function_dependencies(custom_function_definitions):
|
||||
if custom_function_definitions[custom_function.name].contains(
|
||||
variables=variables, custom_function_definitions=custom_function_definitions
|
||||
):
|
||||
|
|
|
|||
Loading…
Reference in a new issue