File tree Expand file tree Collapse file tree
ruby/ql/lib/codeql/ruby/dataflow/internal Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1658,6 +1658,19 @@ private module ReturnNodes {
16581658 result = n
16591659 }
16601660
1661+ private Expr getLast ( StmtSequence s ) {
1662+ result = getLast ( s .( BodyStmt ) .getElse ( ) )
1663+ or
1664+ result = getLast ( s .( BodyStmt ) .getARescue ( ) .getBody ( ) )
1665+ or
1666+ not exists ( s .( BodyStmt ) .getElse ( ) ) and
1667+ exists ( Stmt last | last = s .getLastStmt ( ) |
1668+ result = getLast ( last )
1669+ or
1670+ result = last and not last instanceof StmtSequence
1671+ )
1672+ }
1673+
16611674 /**
16621675 * A data-flow node that represents an expression implicitly returned by
16631676 * a callable. An implicit return happens when an expression can be the
@@ -1666,7 +1679,7 @@ private module ReturnNodes {
16661679 class ExprReturnNode extends SourceReturnNode , ExprNode {
16671680 ExprReturnNode ( ) {
16681681 // exists(Callable c | implicitReturn(c, this) = c.getBody().getAStmt())
1669- this .getExprNode ( ) .getExpr ( ) = desugar ( any ( Callable c ) .getBody ( ) . getLastStmt ( ) )
1682+ this .getExprNode ( ) .getExpr ( ) = desugar ( getLast ( any ( Callable c ) .getBody ( ) ) )
16701683 }
16711684
16721685 override ReturnKind getKindSource ( ) {
You can’t perform that action at this time.
0 commit comments