Analyzer does not allow marking functions/methods as restricted
This commit is contained in:
parent
6ea10c3783
commit
3039bdbaf7
|
@ -26,6 +26,11 @@ func (this *Tree) analyzeFunction (
|
|||
// set unit
|
||||
function.Unit = key.Unit
|
||||
|
||||
// functions cannot be marked as restricted
|
||||
if function.Acc == entity.AccessRestricted {
|
||||
return nil, errors.Errorf(pos, "cannot mark function as restricted")
|
||||
}
|
||||
|
||||
// create a new scope context for this function
|
||||
this.pushScopeContext(function)
|
||||
this.pushScope(function)
|
||||
|
|
|
@ -40,13 +40,18 @@ func (this *Tree) analyzeMethod (
|
|||
// set method's unit, very important information yes
|
||||
method.Unit = owner.Unit
|
||||
|
||||
// create a new scope context for this function
|
||||
// methods cannot be marked as restricted
|
||||
if method.Acc == entity.AccessRestricted {
|
||||
return nil, errors.Errorf(pos, "cannot mark method as restricted")
|
||||
}
|
||||
|
||||
// create a new scope context for this method
|
||||
this.pushScopeContext(method)
|
||||
this.pushScope(method)
|
||||
defer this.popScopeContext()
|
||||
defer this.popScope()
|
||||
|
||||
// analyze signature and add arguments to root scope of function
|
||||
// analyze signature and add arguments to root scope of method
|
||||
method.Signature, err = this.assembleSignatureMap(method.Signature)
|
||||
if err != nil { return method, err }
|
||||
for name, argument := range method.Signature.ArgumentMap {
|
||||
|
|
|
@ -156,13 +156,13 @@ testUnitsErr (test,
|
|||
|
||||
func TestFunctionRestrictedErr (test *testing.T) {
|
||||
testStringErr (test,
|
||||
"cannot mark function as restricted", 0, 0,
|
||||
"cannot mark function as restricted", 1, 1,
|
||||
`~ [f]`,
|
||||
)}
|
||||
|
||||
func TestMethodRestrictedErr (test *testing.T) {
|
||||
testStringErr (test,
|
||||
"cannot mark method as restricted", 0, 0,
|
||||
"cannot mark method as restricted", 2, 1,
|
||||
`T:Int
|
||||
~ T.[f]`,
|
||||
)}
|
||||
|
|
Loading…
Reference in New Issue