-
Couldn't load subscription status.
- Fork 227
Clarify how augmentations affect existing compile-time errors. #4545
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
base: main
Are you sure you want to change the base?
Conversation
| This error says that a non-abstract class must fully implement its interface. | ||
| We don't know what methods a class even has until semantic analysis lets us | ||
| see inherited methods, and that happens after augmentation. Thus this error is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have never formally specified the order that things happen in.
We have definitely not defined that they must happen globally in the same order.
(We can do a lot of things to a superclass before we even start looking at a subclass, otherwise modular compilation wouldn't work, so we could rely on a superclass having found out which members are concrete before we even start looking at which members a subclass have.)
That means that "Augmentation happening" is not a well-defined step.
Consider, instead of using temporal language, where augmentation is something that happens at some point, as if it changes something, rather be declarative and just say what a set of augmenting declarations mean. That way they colletively define something new, instead of changing something existing. ("Changing" something is horribly complicated to get right, because now there is a before and an after which both exist, so we now have to define twice as many things, and specifiy precisely which of them other things refer to, and keep that straight.)
Individual syntactic declarations, introducing or augmenting, combine to define
a single definition. Whether a class definition has a member or not, and
whether that member is abstract or concrete, depends on all the class declarations
that contribute to that definition.Syntactic errors usually apply to a single syntactic declaration.
Only if a declaration is syntactically valid does it make sense to interpret
it in the context of the rest of the program.This feature changes some of the syntactic rules, to introduce the new
augment
syntax and to allow some new incomplete declarations.
The feature also introduces new errors to ensure that the declaring and augmenting
declarations for a single name are well-formed: All of the same kind, at most one
introducing declaration, and that one must be before augmenting declarations,
and at most one complete declaration adding implementation.If those requirements are satisfied, then the set of declarations for the same thing
can be combined and and the properties they define can be derived.Existing non-syntactic errors for declarations, for example how they interact with other
definitions and with inheritance, should then be applied to the combined definitions.
Or something. The idea is: Don't say that augementations are applied, as if there is a before and after. Say that they define something new, which is effectively meaning of a pre-feature declaration. Then say that existing checks apply to that new thing, instead of the individual declarations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to ignore my usual "denotational semantics are better" spiel.
What you have is consistent with the rest. (It's not more under-specified than the rest, and probably not than the entire existing specification, it'll fit right in.)
| error, then that error should not be reported. | ||
|
|
||
| Put another way, moving code out of an introductory declaration into an | ||
| augmentation of it should not cause new errors to appear. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Comma after "it"?)
Fix #3690.