mirror of
https://github.com/ziglang/zig.git
synced 2024-12-03 10:28:48 +00:00
parent
1d4c66b56b
commit
ee22e87296
@ -4667,8 +4667,8 @@ static TypeTableEntry *analyze_generic_fn_call(CodeGen *g, ImportTableEntry *imp
|
||||
|
||||
AstNode **generic_param_type_node = &generic_param_decl_node->data.param_decl.type;
|
||||
|
||||
TypeTableEntry *expected_param_type = analyze_expression(g, decl_node->owner,
|
||||
decl_node->owner->block_context, nullptr, *generic_param_type_node);
|
||||
TypeTableEntry *expected_param_type = analyze_type_expr(g, decl_node->owner,
|
||||
decl_node->owner->block_context, *generic_param_type_node);
|
||||
if (expected_param_type->id == TypeTableEntryIdInvalid) {
|
||||
return expected_param_type;
|
||||
}
|
||||
|
@ -516,12 +516,17 @@ three)";
|
||||
fn simple_generic_fn() {
|
||||
assert(max(i32)(3, -1) == 3);
|
||||
assert(max(f32)(0.123, 0.456) == 0.456);
|
||||
assert(add(2)(3) == 5);
|
||||
}
|
||||
|
||||
fn max(T: type)(a: T, b: T) -> T {
|
||||
return if (a > b) a else b;
|
||||
}
|
||||
|
||||
fn add(a: i32)(b: i32) -> i32 {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
|
||||
#attribute("test")
|
||||
fn constant_equal_function_pointers() {
|
||||
|
Loading…
Reference in New Issue
Block a user