@@ -254,22 +254,18 @@ class AnalyzedFunction extends DataFlow::AnalyzedValueNode {
254254 * Gets a return value for a call to this function.
255255 */
256256 AbstractValue getAReturnValue ( ) {
257- if astNode .isGenerator ( ) or astNode .isAsync ( ) then
258- result = TAbstractOtherObject ( )
259- else (
260- // explicit return value
261- result = astNode .getAReturnedExpr ( ) .analyze ( ) .getALocalValue ( )
257+ // explicit return value
258+ result = astNode .getAReturnedExpr ( ) .analyze ( ) .getALocalValue ( )
259+ or
260+ // implicit return value
261+ (
262+ // either because execution of the function may terminate normally
263+ mayReturnImplicitly ( )
262264 or
263- // implicit return value
264- (
265- // either because execution of the function may terminate normally
266- mayReturnImplicitly ( )
267- or
268- // or because there is a bare `return;` statement
269- exists ( ReturnStmt ret | ret = astNode .getAReturnStmt ( ) | not exists ( ret .getExpr ( ) ) )
270- ) and
271- result = TAbstractUndefined ( )
272- )
265+ // or because there is a bare `return;` statement
266+ exists ( ReturnStmt ret | ret = astNode .getAReturnStmt ( ) | not exists ( ret .getExpr ( ) ) )
267+ ) and
268+ result = TAbstractUndefined ( )
273269 }
274270
275271 /**
@@ -288,5 +284,26 @@ class AnalyzedFunction extends DataFlow::AnalyzedValueNode {
288284 not final instanceof ThrowStmt
289285 )
290286 }
287+ }
288+
289+ /**
290+ * Flow analysis for generator functions.
291+ */
292+ private class AnalyzedGeneratorFunction extends AnalyzedFunction {
293+ AnalyzedGeneratorFunction ( ) { astNode .isGenerator ( ) }
294+
295+ override AbstractValue getAReturnValue ( ) {
296+ result = TAbstractOtherObject ( )
297+ }
298+ }
299+
300+ /**
301+ * Flow analysis for async functions.
302+ */
303+ private class AnalyzedAsyncFunction extends AnalyzedFunction {
304+ AnalyzedAsyncFunction ( ) { astNode .isAsync ( ) }
291305
306+ override AbstractValue getAReturnValue ( ) {
307+ result = TAbstractOtherObject ( )
308+ }
292309}
0 commit comments