mirror of
https://github.com/github/codeql.git
synced 2026-04-28 18:25:24 +02:00
Merge pull request #1110 from xiemaisi/js/yield-in-non-generator
Approved by asger-semmle
This commit is contained in:
@@ -15,6 +15,6 @@ import javascript
|
||||
from YieldExpr yield, Function f
|
||||
where
|
||||
f = yield.getEnclosingFunction() and
|
||||
not f.isGenerator()
|
||||
not isGenerator(f)
|
||||
select yield, "This yield expression is contained in $@ which is not marked as a generator.",
|
||||
f.getFirstToken(), f.describe()
|
||||
|
||||
@@ -79,7 +79,12 @@ class Function extends @function, Parameterized, TypeParameterized, StmtContaine
|
||||
TypeExpr getReturnTypeAnnotation() { typeexprs(result, _, this, -3, _) }
|
||||
|
||||
/** Holds if this function is a generator function. */
|
||||
predicate isGenerator() { isGenerator(this) }
|
||||
predicate isGenerator() {
|
||||
isGenerator(this)
|
||||
or
|
||||
// we also support `yield` in non-generator functions
|
||||
exists(YieldExpr yield | this = yield.getEnclosingFunction())
|
||||
}
|
||||
|
||||
/** Holds if the last parameter of this function is a rest parameter. */
|
||||
predicate hasRestParameter() { hasRestParameter(this) }
|
||||
|
||||
Reference in New Issue
Block a user