checker: show concretes type name in error message (#11333)

pull/11335/head
yuyi 2021-08-29 17:08:57 +08:00 committed by GitHub
parent ac442abc11
commit 985fe85de2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -3524,7 +3524,8 @@ pub fn (mut c Checker) selector_expr(mut node ast.SelectorExpr) ast.Type {
} }
if has_field { if has_field {
if sym.mod != c.mod && !field.is_pub && sym.language != .c { if sym.mod != c.mod && !field.is_pub && sym.language != .c {
c.error('field `${sym.name}.$field_name` is not public', node.pos) unwrapped_sym := c.table.get_type_symbol(c.unwrap_generic(typ))
c.error('field `${unwrapped_sym.name}.$field_name` is not public', node.pos)
} }
field_sym := c.table.get_type_symbol(field.typ) field_sym := c.table.get_type_symbol(field.typ)
if field_sym.kind in [.sum_type, .interface_] { if field_sym.kind in [.sum_type, .interface_] {
@ -3539,7 +3540,8 @@ pub fn (mut c Checker) selector_expr(mut node ast.SelectorExpr) ast.Type {
} }
if sym.kind !in [.struct_, .aggregate, .interface_, .sum_type] { if sym.kind !in [.struct_, .aggregate, .interface_, .sum_type] {
if sym.kind != .placeholder { if sym.kind != .placeholder {
c.error('`$sym.name` has no property `$node.field_name`', node.pos) unwrapped_sym := c.table.get_type_symbol(c.unwrap_generic(typ))
c.error('`$unwrapped_sym.name` has no property `$node.field_name`', node.pos)
} }
} else { } else {
if sym.info is ast.Struct { if sym.info is ast.Struct {