@@ -1225,7 +1225,7 @@ function OutputStream(options) {
12251225 }
12261226
12271227 AST_StatementWithBody . DEFMETHOD ( "_do_print_body" , function ( output ) {
1228- force_statement ( this . body , output ) ;
1228+ print_maybe_braced_body ( this . body , output ) ;
12291229 } ) ;
12301230
12311231 DEFPRINT ( AST_Statement , function ( self , output ) {
@@ -1554,7 +1554,7 @@ function OutputStream(options) {
15541554 b = b . body ;
15551555 } else break ;
15561556 }
1557- force_statement ( self . body , output ) ;
1557+ print_maybe_braced_body ( self . body , output ) ;
15581558 }
15591559 DEFPRINT ( AST_If , function ( self , output ) {
15601560 output . print ( "if" ) ;
@@ -1571,7 +1571,7 @@ function OutputStream(options) {
15711571 if ( self . alternative instanceof AST_If )
15721572 self . alternative . print ( output ) ;
15731573 else
1574- force_statement ( self . alternative , output ) ;
1574+ print_maybe_braced_body ( self . alternative , output ) ;
15751575 } else {
15761576 self . _do_print_body ( output ) ;
15771577 }
@@ -2266,12 +2266,15 @@ function OutputStream(options) {
22662266 }
22672267 } ) ;
22682268
2269- function force_statement ( stat , output ) {
2269+ /** if, for, while, may or may not have braces surrounding its body */
2270+ function print_maybe_braced_body ( stat , output ) {
22702271 if ( output . option ( "braces" ) ) {
22712272 make_block ( stat , output ) ;
22722273 } else {
22732274 if ( ! stat || stat instanceof AST_EmptyStatement )
22742275 output . force_semicolon ( ) ;
2276+ else if ( stat instanceof AST_Let || stat instanceof AST_Const || stat instanceof AST_Class )
2277+ make_block ( stat , output ) ;
22752278 else
22762279 stat . print ( output ) ;
22772280 }
0 commit comments