ast, cgen: fix const fixed array of reference value (#13022)
							parent
							
								
									4b55800ffd
								
							
						
					
					
						commit
						00a0c1886e
					
				|  | @ -835,7 +835,7 @@ pub fn (t &Table) array_fixed_cname(elem_type Type, size int) string { | |||
| 	if elem_type.is_ptr() { | ||||
| 		res = '_ptr$elem_type.nr_muls()' | ||||
| 	} | ||||
| 	return 'Array_fixed_${elem_type_sym.cname}_$size' + res | ||||
| 	return 'Array_fixed_$elem_type_sym.cname${res}_$size' | ||||
| } | ||||
| 
 | ||||
| [inline] | ||||
|  |  | |||
|  | @ -1138,6 +1138,9 @@ pub fn (mut g Gen) write_typedef_types() { | |||
| 					if fixed.starts_with('C__') { | ||||
| 						fixed = fixed[3..] | ||||
| 					} | ||||
| 					if fixed.contains('ptr') { | ||||
| 						fixed = 'void*' | ||||
| 					} | ||||
| 					if elem_sym.info is ast.FnType { | ||||
| 						pos := g.out.len | ||||
| 						g.write_fn_ptr_decl(&elem_sym.info, '') | ||||
|  |  | |||
|  | @ -0,0 +1,10 @@ | |||
| const ( | ||||
| 	foo         = u32(1) | ||||
| 	bar         = u32(2) | ||||
| 	weapon_keys = [&foo, &bar]! | ||||
| ) | ||||
| 
 | ||||
| fn test_const_fixed_array_of_ref_value() { | ||||
| 	assert weapon_keys[0] == &foo | ||||
| 	assert weapon_keys[1] == &bar | ||||
| } | ||||
		Loading…
	
		Reference in New Issue