cgen: fix generics struct_init (#9661)
							parent
							
								
									cf64001474
								
							
						
					
					
						commit
						9f093203a4
					
				|  | @ -5002,7 +5002,7 @@ fn (mut g Gen) struct_init(struct_init ast.StructInit) { | ||||||
| 		g.go_back_out(3) | 		g.go_back_out(3) | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| 	sym := g.table.get_final_type_symbol(struct_init.typ) | 	sym := g.table.get_final_type_symbol(g.unwrap_generic(struct_init.typ)) | ||||||
| 	is_amp := g.is_amp | 	is_amp := g.is_amp | ||||||
| 	is_multiline := struct_init.fields.len > 5 | 	is_multiline := struct_init.fields.len > 5 | ||||||
| 	g.is_amp = false // reset the flag immediately so that other struct inits in this expr are handled correctly
 | 	g.is_amp = false // reset the flag immediately so that other struct inits in this expr are handled correctly
 | ||||||
|  |  | ||||||
|  | @ -0,0 +1,15 @@ | ||||||
|  | struct Blah { | ||||||
|  | mut: | ||||||
|  | 	arr []string | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | fn test<T>() T { | ||||||
|  | 	return T{} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | fn test_generics_struct_init() { | ||||||
|  | 	mut b := test<Blah>() | ||||||
|  | 	b.arr << 'item' | ||||||
|  | 	println(b.arr) | ||||||
|  | 	assert b.arr == ['item'] | ||||||
|  | } | ||||||
		Loading…
	
		Reference in New Issue