[Grace-core] Inheritance in Javascript version

Kim Bruce kim at cs.pomona.edu
Mon Aug 12 13:00:15 PDT 2013


This breaks in Jameson's version of minigrace as well.

Kim



On Aug 12, 2013, at 12:41 PM, Andrew P Black <andrew.p.black at gmail.com> wrote:

> 
> On 12 Aug 2013, at 11:18 , Kim Bruce wrote:
> 
>> The following code works in the C-backend, but not in the javascript backend:
>> 
>> class c.new {
>>   var theWidth := 0
>> }
>> 
>> class d.new {
>>   inherits c.new
>>   method width := (w:Number) -> Done {
>>       theWidth := w
>>       print(theWidth)
>>   }
>> }
>> 
>> def x = d.new
>> x.width:= 5
>> 
>> ---------------
>> My understanding was that unlabeled variables were considered confidential.  If not, then how do we label them to be confidential readable or confidential writeable (or both)?
> 
> There were bugs in the Javascript library that implemented the checks for confidentiality incorrectly.  Jameson and I fixed these on Thursday 8th; they are in commit 52016944ce19c661846a0581c40c5aeea0d0a4e8 in my repository.  Michael, can you please pull this into the mwh repository?
> 
> Even better, there are tests for all cases of definition and method access that I could think of in GUnit project/VisibilityTests.grace.
> These tests all pass in the Javascript backend with the above fix.  All but one of them pass in the C backend:
> 
>> $  mg VisibilityTests.grace
>> 8 run, 1 failed, 0 errors
>> Failures:
>>    testPrivateDefFromSub: code did not raise an exception
>> $
> 
> The one that fails is accessing a private def from a subclass; this should raise a RuntimeError, but does not.
> 
>> #pragma DefaultDefVisibility=private
>> #pragma DefaultVarVisibility=private
>> #pragma DefaultMethodVisibility=public
>> 
>> import "GUnit" as GU
>> 
>> class aVisibilityTest.forMethod(m) {
>>    inherits GU.aTestCase.forMethod(m)
>> 
>>    method testPrivateDefFromSub {
>>        class aSuperclass.new {
>>            def x = "Private"
>>        }
>>        class aSubclass.new {
>>            inherits aSuperclass.new
>>            method xVal { x }
>>        }
>>        assert {aSubclass.new.xVal} shouldRaise (RuntimeError)
> 
> I have not tested overriding.
> 
> 	Andrew
> 




More information about the Grace-core mailing list