fix: fix infering int and float literal in generic fn calls (#9287)
							parent
							
								
									c0779e8455
								
							
						
					
					
						commit
						db152868c0
					
				|  | @ -443,7 +443,7 @@ pub fn (mut c Checker) infer_fn_types(f table.Fn, mut call_expr ast.CallExpr) { | |||
| 			arg := call_expr.args[arg_i] | ||||
| 			param_type_sym := c.table.get_type_symbol(param.typ) | ||||
| 			if param.typ.has_flag(.generic) && param_type_sym.name == gt_name { | ||||
| 				typ = arg.typ | ||||
| 				typ = c.table.mktyp(arg.typ) | ||||
| 				break | ||||
| 			} | ||||
| 			arg_sym := c.table.get_type_symbol(arg.typ) | ||||
|  |  | |||
|  | @ -19,6 +19,15 @@ fn test_explicit_calls_should_also_work() { | |||
| 	assert true | ||||
| } | ||||
| 
 | ||||
| fn get_type_name<T>(x T) string { | ||||
| 	return T.name | ||||
| } | ||||
| 
 | ||||
| fn test_literal() { | ||||
| 	assert get_type_name(1) == 'int' | ||||
| 	assert get_type_name(1.0) == 'f64' | ||||
| } | ||||
| 
 | ||||
| //
 | ||||
| fn choose4<T>(a T, b T, c T, d T) T { | ||||
| 	// NB: a similar construct is used in prime31's via engine
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue