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

checker, parser, fmt: fix visibility of anon struct in different modules.(fix #15763) (#15787)

This commit is contained in:
shove
2022-09-18 23:08:33 +08:00
committed by GitHub
parent 0ff74dae63
commit 202585e175
6 changed files with 28 additions and 4 deletions

View File

@@ -290,8 +290,9 @@ pub fn (mut c Checker) struct_init(mut node ast.StructInit) ast.Type {
&& c.table.cur_concrete_types.len == 0 {
pos := type_sym.name.last_index('.') or { -1 }
first_letter := type_sym.name[pos + 1]
if !first_letter.is_capital() && type_sym.kind != .placeholder
&& !type_sym.name.starts_with('main._VAnonStruct') {
if !first_letter.is_capital()
&& (type_sym.kind != .struct_ || !(type_sym.info as ast.Struct).is_anon)
&& type_sym.kind != .placeholder {
c.error('cannot initialize builtin type `$type_sym.name`', node.pos)
}
}