compiler: enhance non-pub struct fields error message

pull/2347/head
Nicolas Sauzede 2019-10-14 09:15:21 +02:00 committed by Alexander Medvednikov
parent 2d127cb694
commit eb031b6800
1 changed files with 7 additions and 1 deletions

View File

@ -2189,7 +2189,13 @@ struct $f.parent_fn {
if field.access_mod == .private && !p.builtin_mod && !p.pref.translated && p.mod != typ.mod && p.file_path_id != 'vgen' {
// println('$typ.name :: $field.name ')
// println(field.access_mod)
p.error_with_token_index('cannot refer to unexported field `$struct_field` (type `$typ.name`)', fname_tidx)
p.error_with_token_index('cannot refer to unexported field `$struct_field` (type `$typ.name`)\n' +
'declare the field with `pub:`
struct $typ.name {
pub:
$struct_field $field.typ
}
', fname_tidx)
}
p.gen(dot + struct_field)
p.next()