1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

compiler: prevent multiple same field initialization

This commit is contained in:
Henrixounez 2019-08-25 19:51:59 +02:00 committed by Alexander Medvednikov
parent db525524ee
commit fe50aeb130

View File

@ -2856,6 +2856,9 @@ p.gen('($no_star*)memdup(&($no_star) {') //sizeof(Node));
if !t.has_field(field) { if !t.has_field(field) {
p.error('`$t.name` has no field `$field`') p.error('`$t.name` has no field `$field`')
} }
if inited_fields.contains(field) {
p.error('already initialized field `$field` in `$t.name`')
}
f := t.find_field(field) f := t.find_field(field)
inited_fields << field inited_fields << field
p.gen('.$field = ') p.gen('.$field = ')