fmt: fix possible removal of PrefixExpr or blocks (#9351)
							parent
							
								
									c2b574384f
								
							
						
					
					
						commit
						0a06a83d9b
					
				|  | @ -764,26 +764,23 @@ pub fn (mut f Fmt) enum_decl(node ast.EnumDecl) { | |||
| 	f.writeln('}\n') | ||||
| } | ||||
| 
 | ||||
| pub fn (mut f Fmt) prefix_expr_cast_expr(fexpr ast.Expr) { | ||||
| pub fn (mut f Fmt) prefix_expr_cast_expr(node ast.Expr) { | ||||
| 	mut is_pe_amp_ce := false | ||||
| 	if fexpr is ast.PrefixExpr { | ||||
| 		if fexpr.right is ast.CastExpr && fexpr.op == .amp { | ||||
| 			mut ce := fexpr.right as ast.CastExpr | ||||
| 	if node is ast.PrefixExpr { | ||||
| 		if node.right is ast.CastExpr && node.op == .amp { | ||||
| 			mut ce := node.right as ast.CastExpr | ||||
| 			ce.typname = f.table.get_type_symbol(ce.typ).name | ||||
| 			is_pe_amp_ce = true | ||||
| 			f.expr(ce) | ||||
| 		} | ||||
| 	} else if fexpr is ast.CastExpr { | ||||
| 	} else if node is ast.CastExpr { | ||||
| 		last := f.out.cut_last(1) | ||||
| 		if last != '&' { | ||||
| 			f.out.write_string(last) | ||||
| 		} | ||||
| 	} | ||||
| 	if !is_pe_amp_ce { | ||||
| 		f.expr(fexpr) | ||||
| 		if fexpr is ast.PrefixExpr { | ||||
| 			f.or_expr(fexpr.or_block) | ||||
| 		} | ||||
| 		f.expr(node) | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
|  | @ -1253,6 +1250,7 @@ pub fn (mut f Fmt) postfix_expr(node ast.PostfixExpr) { | |||
| pub fn (mut f Fmt) prefix_expr(node ast.PrefixExpr) { | ||||
| 	f.write(node.op.str()) | ||||
| 	f.prefix_expr_cast_expr(node.right) | ||||
| 	f.or_expr(node.or_block) | ||||
| } | ||||
| 
 | ||||
| pub fn (mut f Fmt) range_expr(node ast.RangeExpr) { | ||||
|  |  | |||
|  | @ -32,3 +32,9 @@ fn or_with_one_multi_line_stmt() { | |||
| 		} | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| fn channel_pop() { | ||||
| 	var_init := <-ch or { -1.25 } | ||||
| 	var_assign = <-ch or { -2.5 } | ||||
| 	arr_push << <-ch or { -3.75 } | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue