cgen: make .alias fields in structs use their proper string format, instead of the default %d (#9197)
							parent
							
								
									2ed73bf243
								
							
						
					
					
						commit
						b893373e63
					
				|  | @ -45,8 +45,7 @@ fn (g &Gen) type_to_fmt(typ table.Type) string { | ||||||
| 	if typ.is_ptr() && (typ.is_int() || typ.is_float()) { | 	if typ.is_ptr() && (typ.is_int() || typ.is_float()) { | ||||||
| 		return '%.*s\\000' | 		return '%.*s\\000' | ||||||
| 	} else if sym.kind in [.struct_, .array, .array_fixed, .map, .bool, .enum_, .interface_, .sum_type, | 	} else if sym.kind in [.struct_, .array, .array_fixed, .map, .bool, .enum_, .interface_, .sum_type, | ||||||
| 		.function, | 		.function, .alias] { | ||||||
| 	] { |  | ||||||
| 		return '%.*s\\000' | 		return '%.*s\\000' | ||||||
| 	} else if sym.kind == .string { | 	} else if sym.kind == .string { | ||||||
| 		return "'%.*s\\000'" | 		return "'%.*s\\000'" | ||||||
|  |  | ||||||
|  | @ -0,0 +1,12 @@ | ||||||
|  | type Duration = i64 | ||||||
|  | 
 | ||||||
|  | struct Abc { | ||||||
|  | 	d Duration | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | fn test_string_interpolation_of_alias() { | ||||||
|  | 	x := Abc{ | ||||||
|  | 		d: i64(9_123_456_789) | ||||||
|  | 	} | ||||||
|  | 	assert '$x' == 'Abc{\n    d:     Duration(9123456789)\n}' | ||||||
|  | } | ||||||
		Loading…
	
		Reference in New Issue