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

improve the C struct check

This commit is contained in:
Alexander Medvednikov 2019-12-08 04:23:22 +03:00
parent 6ae51b2cbf
commit 8b0de95c0a

View File

@ -187,9 +187,10 @@ fn (p mut Parser) name_expr() string {
p.check(.dot) p.check(.dot)
name = p.lit name = p.lit
// C struct initialization // C struct initialization
if p.peek() == .lcbr { if p.peek() == .lcbr && p.expected_type == '' { // not an expression
if !p.table.known_type(name) { if !p.table.known_type(name) {
p.error('unknown C type `$name`') p.error('unknown C type `$name`, ' +
'define it with `struct C.$name { ... }`')
} }
return p.get_struct_type(name, true, ptr) return p.get_struct_type(name, true, ptr)
} }