You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class C {
procinit() {
init this;
writeln(super.x);
}
}
var c =new C();
results in error: unresolved call 'RootClass.x'. I don't think we should be exposing RootClass (no, we should). A class that doesn't inherit anything explicitly should not be able to use super. If there's some meaning to RootClass that should be exposed to the user, I still think this error message could be better. #26051 looks thematically related.
The related real-world case might be hairier. What's the meaning of super in a method that's implemented in an inner module? Reading the docs, I think, in the context of modules, super can only be used to find other modules and not variables within them. But my real-world attempt was:
module superTest {
var x =10;
module Inner {
class C {
var myX:int;
procinit() {
this.myX =super.x; // I wanted this to be `superTest.x`
}
}
}
importthis.Inner;
procmain() {
var c =new Inner.C();
}
}
But looks like I had to use superTest in the inner module first. I kind of wished super to look also into the parent module, but I understand that it can get complicated with actual inheritance at play. This may be a case for --detailed-errors or a hint in the error message that super can only be used to access superclass(es)'s fields/methods and not module-scope variables.
The text was updated successfully, but these errors were encountered:
Rename object root class? #20414
[sample rationale: I want to write a well-typed routine that specifies that it can take any class, so constrain the argument to : RootClass].
Given that, I don't think the error message is particularly bad, but also wouldn't object to improving it further.
What's the meaning of super in a method that's implemented in an inner module?
I believe that, outside of a class/record/method, super can only be used in import statements (and maybe use, though I'm having trouble coming up with a working example)? E.g., see this example.
(this error message could also stand to be improved since it doesn't mention the potential to use super in import/use).
Starting simple:
results in
error: unresolved call 'RootClass.x'
. I don't think we should be exposingRootClass
(no, we should). A class that doesn't inherit anything explicitly should not be able to usesuper
. If there's some meaning to RootClass that should be exposed to the user, I still think this error message could be better. #26051 looks thematically related.The related real-world case might be hairier. What's the meaning of
super
in a method that's implemented in an inner module? Reading the docs, I think, in the context of modules,super
can only be used to find other modules and not variables within them. But my real-world attempt was:But looks like I had to
use superTest
in the inner module first. I kind of wishedsuper
to look also into the parent module, but I understand that it can get complicated with actual inheritance at play. This may be a case for--detailed-errors
or a hint in the error message thatsuper
can only be used to access superclass(es)'s fields/methods and not module-scope variables.The text was updated successfully, but these errors were encountered: