checker: fix lambda expr with fntype params and restore fixed_array_any_all_test.v (#22625)

This commit is contained in:
yuyi 2024-10-23 20:38:53 +08:00 committed by GitHub
parent 399de3ec3e
commit fe6af05b59
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 5 deletions

View File

@ -46,8 +46,8 @@ fn test_any_all_of_fns() {
fa := [a, b, c]!
assert fa.any(it == b)
// assert fa.any(|x| x == b)
assert fa.any(|x| x == b)
assert !fa.all(it == v)
// assert !fa.all(|x| x == v)
assert !fa.all(|x| x == v)
}

View File

@ -156,14 +156,22 @@ pub fn (mut c Checker) support_lambda_expr_in_sort(param_type ast.Type, return_t
}
pub fn (mut c Checker) support_lambda_expr_one_param(param_type ast.Type, return_type ast.Type, mut expr ast.LambdaExpr) {
mut expected_fn := ast.Fn{
expected_fn := ast.Fn{
params: [
ast.Param{
name: 'xx'
typ: param_type
typ: if c.table.final_sym(param_type).kind == .function {
ast.voidptr_type
} else {
param_type
}
},
]
return_type: return_type
return_type: if c.table.final_sym(return_type).kind == .function {
ast.voidptr_type
} else {
return_type
}
}
cb_type := c.table.find_or_register_fn_type(expected_fn, true, false)
expected_fn_type := ast.new_type(cb_type)