Menu

#1141 ECMAScript: getFinallyBlock() is buggy.

PMD-5.1.0
closed
ECMAScript (9)
PMD
2-Critical
Bug
5.0.x
2014-11-01
2013-10-15
No

Hello,

I think that in pmd.lang.ecmascript.ast.ASTCatchClause the function in getFinallyBlock() is buggy.

public EcmascriptNode getFinallyBlock() {
    return (EcmascriptNode) jjtGetChild(jjtGetNumChildren() - 1);
}

This function returns the last child of the ASTTryStatement as representing the finally block.
But if there is no finally block in the source code the last child is the ASTCatchClause.

The last child is associated to a finally block only if its type is ASTScope.

According to function isFinally(), getFinallyBlock() should return null when there is no finally block.

Regards

Discussion

  • Jimmy Profit

    Jimmy Profit - 2013-10-15

    Sorry, there is a typo in my ticket. The first line sould be:

    I think that in pmd.lang.ecmascript.ast.ASTTryStatement the function getFinallyBlock() is buggy.

     
  • Andreas Dangel

    Andreas Dangel - 2013-10-15
    • status: open --> closed
    • assigned_to: Andreas Dangel
    • Milestone: New Tickets --> PMD-5.1.0
     

Log in to post a comment.