checker: fix -parallel-cc regression (part 1, workaround .filter(fn[c]) used in checker/orm.v) (#21238)

This commit is contained in:
Delyan Angelov 2024-04-09 17:00:14 +03:00 committed by GitHub
parent 95426d53f0
commit d25e349020
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -683,7 +683,8 @@ fn (c &Checker) get_field_foreign_table_type(table_field &ast.StructField) ast.T
// get_orm_non_primitive_fields filters the table fields by selecting only // get_orm_non_primitive_fields filters the table fields by selecting only
// non-primitive fields such as arrays and structs. // non-primitive fields such as arrays and structs.
fn (c &Checker) get_orm_non_primitive_fields(fields []ast.StructField) []ast.StructField { fn (c &Checker) get_orm_non_primitive_fields(fields []ast.StructField) []ast.StructField {
return fields.filter(fn [c] (field ast.StructField) bool { mut res := []ast.StructField{}
for field in fields {
type_with_no_option_flag := field.typ.clear_flag(.option) type_with_no_option_flag := field.typ.clear_flag(.option)
is_struct := c.table.type_symbols[int(type_with_no_option_flag)].kind == .struct_ is_struct := c.table.type_symbols[int(type_with_no_option_flag)].kind == .struct_
is_array := c.table.sym(type_with_no_option_flag).kind == .array is_array := c.table.sym(type_with_no_option_flag).kind == .array
@ -691,8 +692,11 @@ fn (c &Checker) get_orm_non_primitive_fields(fields []ast.StructField) []ast.Str
&& c.table.sym(c.table.sym(type_with_no_option_flag).array_info().elem_type).kind == .struct_ && c.table.sym(c.table.sym(type_with_no_option_flag).array_info().elem_type).kind == .struct_
is_time := c.table.get_type_name(type_with_no_option_flag) == 'time.Time' is_time := c.table.get_type_name(type_with_no_option_flag) == 'time.Time'
return (is_struct || is_array_with_struct_elements) && !is_time if (is_struct || is_array_with_struct_elements) && !is_time {
}) res << field
}
}
return res
} }
// walkingdevel: Now I don't think it's a good solution // walkingdevel: Now I don't think it's a good solution