Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fresh objects not treated as fresh? #263

Open
KimBruce opened this issue Jul 18, 2018 · 4 comments
Open

Fresh objects not treated as fresh? #263

KimBruce opened this issue Jul 18, 2018 · 4 comments

Comments

@KimBruce
Copy link
Contributor

The following code should represent legal inheritance as e(j) tail-returns an object. However it crashes:

class mka(n: Number) {
    method m → String {"mka: calling m"}
    print "Creating mka"
}

method e(k: Number) {mka(k)}

class d(j: Number) {
    inherit e(j)
    method p → Number {
        print "calling p"
        m.size
    }
    print "creating d"
}

The error message is

Syntax error: unknown variable or method 'm'. This may be a spelling mistake or an attempt to access a variable in another scope.
    in "indirectInheritance" (line 12, column 9)

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!

@kjx
Copy link

kjx commented Jul 19, 2018 via email

@apblack
Copy link
Contributor

apblack commented Jul 20, 2018

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.

@KimBruce
Copy link
Contributor Author

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)
    }

@apblack
Copy link
Contributor

apblack commented Sep 26, 2019

@KimBruce's original example is in file known-failing/transitive_freshness_test.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.

apblack added a commit that referenced this issue Sep 26, 2019
I found these failing tests in my working copy.  The issues that they
reveal have been reported as #304 and #263 repectively.
apblack added a commit that referenced this issue Oct 8, 2019
I found these failing tests in my working copy.  The issues that they
reveal have been reported as #304 and #263 repectively.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants