Open KimBruce opened 6 years ago
Hmm. Kernan here http://homepages.ecs.vuw.ac.nz/~mwh/js-kernan/entry/
says "InheritanceError: R2017: The method «e(_)» does not return an object that can be inherited."
I can't run Kernan itself easily as I'm still rebuilding a laptop - J
e(j)
should be fresh, but minigrace doesn't recognize it as such.
Smallgrace does so recognize it, but crashed because it needs to disambiguate the request mka(_)
, which in general requires that inherited names be collected ... which is what we are doing. I just put in a patch to resolve the issue in this case, but I'm not sure how general it is — it will probably work so long as there is no cyclic inheritance.
I would like to port all of smallGrace's name resolution back into minigrace. I'm thinking about partially-automated Smalltalk to Grace method translation.
Here is another, slightly different, example we ran into today:
class numList → List⟦Number⟧ {
inherit list⟦Number⟧.empty
}
print (numList.size)
Crashes with the error message:
ProgrammingError on line 2 of temp: attempting to inherit from 'empty' on the list class. This is not a fresh method.
raised at numList at line 2 of temp
requested from module initialization at line 5 of temp
requested on line 5 of temp.
1: class numList → List⟦Number⟧ {
2: inherit list⟦Number⟧.empty
3: }
Yet, if you replace ".empty" by ".withall[]" it works fine, even though the code in the standard prelude is
method empty -> List⟦T⟧ {
withAll(emptySequence)
}
@KimBruce's original example is in file _known-failing/transitive_freshnesstest.grace. The error message is
ProgrammingError: attempting to inherit from 'e(_)' on the "transitive_freshness_test" module (defined in module transitive_freshness_test, line 1). This is not a fresh method.
raised at d(_) at line 9 of transitive_freshness_test
requested from module initialization at line 17 of /Users/black/Development/mg/gracelang/minigrace/js/tests/known-failing/transitive_freshness_test.js
and is produced at runtime, because e(_)
has not been compiled as a fresh method.
The following code should represent legal inheritance as e(j) tail-returns an object. However it crashes:
The error message is
So, it doesn't complain about the inheritance, but it doesn't see the method m from the superclass. This is likely to be a symbol table issue in getting the inherited methods. Or I could be misunderstanding our rules for inheritance!