cgen: fix if expr with optional method call (#14600)
							parent
							
								
									4288c40bee
								
							
						
					
					
						commit
						9699afc1fd
					
				|  | @ -29,7 +29,8 @@ fn (mut g Gen) need_tmp_var_in_if(node ast.IfExpr) bool { | |||
| 							if left_sym.kind in [.array, .array_fixed, .map] { | ||||
| 								return true | ||||
| 							} | ||||
| 						} else if stmt.expr.or_block.kind != .absent { | ||||
| 						} | ||||
| 						if stmt.expr.or_block.kind != .absent { | ||||
| 							return true | ||||
| 						} | ||||
| 					} | ||||
|  |  | |||
|  | @ -0,0 +1,13 @@ | |||
| fn to_bit_string(i rune) []u8 { | ||||
| 	return if i == 0 { []u8{} } else { '${i:b}'.split('').map(it.u8()) } | ||||
| } | ||||
| 
 | ||||
| fn from_bit_string(bits []u8) rune { | ||||
| 	return if bits == [] { 0 } else { bits.map(it.str()).join('').parse_uint(2, 8) or { 0 } } | ||||
| } | ||||
| 
 | ||||
| fn test_if_expr_with_method_call_optional() { | ||||
| 	a := from_bit_string(to_bit_string(u32(100))) | ||||
| 	println(a) | ||||
| 	assert a == `d` | ||||
| } | ||||
		Loading…
	
		Reference in New Issue