mirror of
https://github.com/vlang/v.git
synced 2025-09-13 09:25:45 -04:00
This commit is contained in:
parent
5ac1e14e7f
commit
157d8e84e5
@ -602,13 +602,18 @@ fn (mut c Checker) alias_type_decl(mut node ast.AliasTypeDecl) {
|
|||||||
}
|
}
|
||||||
if parent_typ_sym.info.is_anon {
|
if parent_typ_sym.info.is_anon {
|
||||||
for field in parent_typ_sym.info.fields {
|
for field in parent_typ_sym.info.fields {
|
||||||
|
mut is_embed := false
|
||||||
field_sym := c.table.sym(field.typ)
|
field_sym := c.table.sym(field.typ)
|
||||||
if field_sym.info is ast.Alias {
|
if field_sym.info is ast.Alias {
|
||||||
if c.table.sym(field_sym.info.parent_type).kind != .struct {
|
if c.table.sym(field_sym.info.parent_type).kind != .struct {
|
||||||
c.error('cannot embed non-struct `${field_sym.name}`',
|
c.error('cannot embed non-struct `${field_sym.name}`',
|
||||||
field.type_pos)
|
field.type_pos)
|
||||||
|
is_embed = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if !is_embed {
|
||||||
|
c.check_valid_snake_case(field.name, 'field name', field.pos)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
vlib/v/checker/tests/type_alias_struct_invalid_field_naming.vv:2:2: error: field name `field_One` cannot contain uppercase letters, use snake_case instead
|
||||||
|
1 | type Struct = struct {
|
||||||
|
2 | field_One int
|
||||||
|
| ~~~~~~~~~~~~~
|
||||||
|
3 | field_two int
|
||||||
|
4 | }
|
@ -0,0 +1,4 @@
|
|||||||
|
type Struct = struct {
|
||||||
|
field_One int
|
||||||
|
field_two int
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user