public static boolean canMergeBlock ( Node block ) { for ( Node c = block . getFirstChild ( ) ; c != null ; c = c . getNext ( ) ) { switch ( c . getToken ( ) ) { case LABEL : if ( canMergeBlock ( c ) ) { continue ; } else { return false ; } case CONST : case LET : case CLASS : case FUNCTION : return false ; default : continue ; } } return true ; }
A check inside a block to see if there are const let class or function declarations to be safe and not hoist them into the upper block .