checker: make pub field check an error

pull/4805/head
Alexander Medvednikov 2020-05-09 18:34:04 +02:00
parent 53989daf9a
commit d7c4630d33
3 changed files with 5 additions and 2 deletions

View File

@ -14,12 +14,14 @@ enum FileType {
}
struct FilePermission {
pub:
read bool
write bool
execute bool
}
struct FileMode {
pub:
typ FileType
owner FilePermission
group FilePermission

View File

@ -27,11 +27,12 @@ pub:
module_path string
mut:
pref &pref.Preferences
module_search_paths []string
parsed_files []ast.File
global_scope &ast.Scope
out_name_c string
out_name_js string
pub mut:
module_search_paths []string
}
pub fn new_builder(pref &pref.Preferences) Builder {

View File

@ -1011,7 +1011,7 @@ pub fn (mut c Checker) selector_expr(selector_expr mut ast.SelectorExpr) table.T
}
if field := c.table.struct_find_field(typ_sym, field_name) {
if typ_sym.mod != c.mod && !field.is_pub{
c.warn('field `${typ_sym.name}.$field_name` is not public', selector_expr.pos)
c.error('field `${typ_sym.name}.$field_name` is not public', selector_expr.pos)
}
return field.typ
}