improve the C struct check

pull/3009/head
Alexander Medvednikov 2019-12-08 04:23:22 +03:00
parent 6ae51b2cbf
commit 8b0de95c0a
1 changed files with 3 additions and 2 deletions

View File

@ -187,9 +187,10 @@ fn (p mut Parser) name_expr() string {
p.check(.dot)
name = p.lit
// C struct initialization
if p.peek() == .lcbr {
if p.peek() == .lcbr && p.expected_type == '' { // not an expression
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)
}