private Node tryReduceReturn ( Node n ) { Node result = n . getFirstChild ( ) ; if ( result != null ) { switch ( result . getToken ( ) ) { case VOID : Node operand = result . getFirstChild ( ) ; if ( ! mayHaveSideEffects ( operand ) ) { n . removeFirstChild ( ) ; reportChangeToEnclosingScope ( n ) ; } break ; case NAME : String name = result . getString ( ) ; if ( name . equals ( "undefined" ) ) { n . removeFirstChild ( ) ; reportChangeToEnclosingScope ( n ) ; } break ; default : break ; } } return n ; }
Reduce return undefined or return void 0 to simply return .