From 8b0de95c0a518b09573ab24b3ef8cf4db166fdfc Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sun, 8 Dec 2019 04:23:22 +0300 Subject: [PATCH] improve the C struct check --- vlib/compiler/expression.v | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vlib/compiler/expression.v b/vlib/compiler/expression.v index b339c31d6c..7ff32b7838 100644 --- a/vlib/compiler/expression.v +++ b/vlib/compiler/expression.v @@ -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) }