mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
ast.table: fix aggregate field type equality check (#11210)
This commit is contained in:
parent
eee71cebd4
commit
d2ce1f74d6
@ -412,9 +412,14 @@ fn (t &Table) register_aggregate_field(mut sym TypeSymbol, name string) ?StructF
|
||||
if !found_once {
|
||||
found_once = true
|
||||
new_field = type_field
|
||||
} else if !new_field.equals(type_field) {
|
||||
} else if new_field.typ != type_field.typ {
|
||||
return error('field `${t.type_to_str(typ)}.$name` type is different')
|
||||
}
|
||||
new_field = StructField{
|
||||
...new_field
|
||||
is_mut: new_field.is_mut && type_field.is_mut
|
||||
is_pub: new_field.is_pub && type_field.is_pub
|
||||
}
|
||||
} else {
|
||||
return error('type `${t.type_to_str(typ)}` has no field or method `$name`')
|
||||
}
|
||||
|
@ -193,6 +193,8 @@ fn (a Alfa) letter() rune {
|
||||
struct Bravo {
|
||||
// A field so that Alfa and Bravo structures aren't the same
|
||||
dummy_field int
|
||||
pub mut:
|
||||
// NB: the `char` field is not `pub` or `mut` in all sumtype variants, but using it in aggregates should still work
|
||||
char rune = `b`
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user