Skip to content

Conversation

@munificent
Copy link
Member

Fix #3690.

@munificent munificent requested a review from lrhn October 24, 2025 00:25
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
Copy link
Member

@lrhn lrhn Oct 24, 2025

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.

Copy link
Member

@lrhn lrhn left a 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Comma after "it"?)

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

Successfully merging this pull request may close these issues.

Specify which errors are reported before and which after augmentations are applied

3 participants