Analyzer checks access permissions when using named types

This commit is contained in:
Sasha Koshka 2024-02-15 01:08:21 -05:00
parent 159317965d
commit ed498a3bc0

View File

@ -99,10 +99,19 @@ func (this *Tree) analyzeTypeInternal (
Unit: unit,
Name: ty.Name,
}, acceptIncomplete)
if err == nil {
ty.Type = def.Type
if err != nil {
return nil, err
}
return ty, err
// check access permissions
if def.Acc == entity.AccessPrivate && def.Unit != this.unit {
return nil, errors.Errorf (
ty.Position, "type %v is private",
ty)
}
ty.Type = def.Type
return ty, nil
// pointer type
case *entity.TypePointer: