gracelang / minigrace

Self-hosting compiler for the Grace programming language
39 stars 22 forks source link

Inheriting from a confidential method fails #226

Closed milosonator closed 7 years ago

milosonator commented 7 years ago

Given the following program:

class A is confidential { }
object  {
    inherit A
}

The following error is produced:

NoSuchMethod on line 3 of Welcome: requested confidential method 'A$build(_,_,_)' of the "Welcome" module from outside.
  raised at module.A at line 3 of Welcome
  requested from line 3 of module Welcome.
   2: 
   3: object  {
   4:     inherit A
Stack frames:
  Welcome module

I expect this program to successfully evaluate, since the access to A is from the inside. The following program illustrates this when requesting the A method from the body of the object constructor, and from the same scope as the A method is defined in:

class A is confidential { }
object  {
    A
}
A

Executes successfully.

apblack commented 7 years ago

This is a compiler bug. The memberNode generated for A in the inherit A statement is not being tagged as onSelf

apblack commented 7 years ago

The missing onSelf flag is added in commit fbd4e9bf8. The reason that it was missing is that the original request in the inherit statement is represented as a memberNode,because it is a request without arguments. Where the arguments are added, this is transformed into a callNode; the isSelfRequest flag was not being copied.

The incorrect line number in the error message is fixed in commit 929d331f.

The incorrect method name (A$build(_,_,_) rather than A) in the error message is fixed in commit 61df4bc5b.

milosonator commented 7 years ago

Thanks for looking into this and letting me know what was going on.