JS: Avoid spurious recursion in AMD

This commit is contained in:
Asger F
2024-02-28 14:58:04 +01:00
parent 9ecac04709
commit 052a8e7f81

View File

@@ -102,9 +102,10 @@ class AmdModuleDefinition extends CallExpr instanceof AmdModuleDefinition::Range
/**
* Holds if `p` is the parameter corresponding to dependency `dep`.
*/
predicate dependencyParameter(PathExpr dep, Parameter p) {
predicate dependencyParameter(Expr dep, Parameter p) {
exists(int i |
dep = this.getDependency(i) and
// Note: to avoid spurious recursion, do not depend on PathExpr here
dep = this.getDependencies().getElement(i) and
p = this.getFactoryParameter(i)
)
}
@@ -122,9 +123,9 @@ class AmdModuleDefinition extends CallExpr instanceof AmdModuleDefinition::Range
* `dep1` and `dep2`.
*/
Parameter getDependencyParameter(string name) {
exists(PathExpr dep |
exists(Expr dep |
this.dependencyParameter(dep, result) and
dep.getValue() = name
name = dep.getStringValue()
)
}