meta.language.contexts.inheritance

Contexts are a distinct declaration kind and may inherit only from contexts. An ordinary or abstract class cannot inherit from a context.

Read in specification context · design/meta/language.md

Implementation

Implemented crates/sage-meta/src/validate.rs:385–390

sage_meta::validate · lib:sage_meta

#![allow(unused)]
fn main() {
                        // {anchor}`meta.language.contexts.inheritance`
                        if (entry.class.kind == ClassKind::Context)
                            != (self.classes[&target].class.kind == ClassKind::Context)
                        {
                            report(
                                &mut errors,

}

See more source ↗

Tests and review

Indexed tests and the implementation-completeness and test-adequacy review; no test run is implied.

Implemented sage_meta::context_inheritance_stays_within_the_context_kind

crates/sage-meta/tests/envelopes.rs · test:envelopes

#![allow(unused)]
fn main() {
#[test]
#[sage::test(meta.language.contexts.inheritance)]
fn context_inheritance_stays_within_the_context_kind() {
    let document = valid(
        r#"context Base { """Working state.""" }
        context Child extends crate::Base { """Extended state.""" }"#,
    );
    assert_eq!(class(&document, "Child").kind, ClassKind::Context);
    for (base, child) in [
        ("class", "context"),
        ("abstract class", "context"),
        ("context", "class"),
        ("context", "abstract class"),
    ] {
        let document = parse(&format!(
            r#"{base} Base {{ """Base.""" }}
            {child} Child extends crate::Base {{ """Child.""" }}"#
        ));
        assert!(sage_meta::validate(&[document]).iter().any(|error| {
            error
                .message
                .contains("contexts and symbol classes cannot inherit from each other")
        }));
    }
}
}

See more source ↗

Review: Accepted · Codex /root/anchor_192.

Independently reassessed the complete two-sentence claim and its single ordinary implementation and single ordinary test; no TODO/N/A entries or deferral prerequisites exist. Verified exact byte equality of current validate.rs and envelopes.rs against the historical implementation_sources/test_sources snapshots, then checked the current claim, association metadata, full implementation context and annotated test body. Model::check resolves each declared base, rejects unknown bases, and compares whether child and resolved base have ClassKind::Context. Unequal classifications produce the specific cross-kind diagnostic, so contexts cannot extend ordinary or abstract classes and neither class kind can extend a context; context-to-context inheritance is allowed by this check. The associated context_inheritance_stays_within_the_context_kind test parses and validates a Base/Child context pair and asserts Child retains ClassKind::Context, establishing the distinct declaration kind in the actual parsed model. Its four (base, child) combinations explicitly cover both prohibited directions for ordinary and abstract classes and assert the specific diagnostic, detecting removal or one-sided enforcement of the rule. Captured parse/valid/class helpers show that valid asserts zero validation errors and class selects the named declaration, so the positive case checks acceptance, not just parse success. All claim aspects and associated entries are accounted for, consistent with the prior rationale. Source inspection and byte comparison are this reviewer's evidence; personally executed review start/read and record, not behavior tests or a build. The coordinator reports 321 passing sage-meta tests and a passing root cargo build; that is separate baseline execution, not execution by this reviewer. No source edits or additional tests were needed.

Browse meta anchors

116 anchors

Specification anchors and declared coverage
AnchorImplementationTests
meta (116)102 Implemented24 TODO103 Implemented36 TODO
meta.anchors (22)22 Implemented21 Implemented12 TODO
anchor_pagesImplementedImplementedTODO
book_explorerImplementedImplementedTODO
canonical_sourcesImplementedImplementedTODO
meta.anchors.content (7)7 Implemented7 Implemented
blocksImplementedImplemented
explicit_endImplementedImplemented
headingImplementedImplemented
literal_syntaxImplementedImplemented
next_anchorImplementedImplemented
source_endImplementedImplemented
unmatched_endImplementedImplemented
context_navigationImplementedImplementedTODO
evidence_statusImplementedImplementedTODO
explorer_navigationImplementedTODO
implementation_coverageImplementedImplementedTODO
implementation_referencesImplementedImplementedTODO
placeholder_statusImplementedImplementedTODO
point_excerptsImplementedImplementedTODO
region_balanceImplementedImplemented
region_excerptsImplementedImplementedTODO
test_coverageImplementedImplemented
test_referencesImplementedImplemented
unique_namesImplementedImplementedTODO
meta.book (21)10 Implemented18 TODO12 Implemented18 TODO
anchor_movesImplementedTODOImplementedTODO
authorityImplementedTODOImplementedTODO
browser_deliveryTODOImplementedTODO
browser_dependenciesTODOTODO
browser_rust_sourceTODOTODO
browser_searchTODOTODO
browser_serveTODOTODO
browser_structureTODOTODO
chapter_namesImplementedTODOImplementedTODO
crate_ownershipImplementedImplemented
crates_landingImplementedImplemented
entity_linksTODOTODO
index_groupsImplementedTODOImplementedTODO
index_namespace_pagesImplementedImplemented
index_rowsImplementedTODOImplementedTODO
index_statusImplementedTODOImplementedTODO
rfd_changesTODOTODO
sage_chaptersTODOImplementedTODO
self_descriptionTODOTODO
shared_modelImplementedTODOImplementedTODO
source_rolesTODOTODO
meta.contracts (4)4 Implemented3 TODO4 Implemented3 TODO
cache_invocationsImplementedTODOImplementedTODO
correspondenceImplementedImplemented
observation_coverageImplementedTODOImplementedTODO
validated_sessionImplementedTODOImplementedTODO
meta.language (39)39 Implemented39 Implemented
meta.language.calls (2)2 Implemented2 Implemented
declaredImplementedImplemented
forbiddenImplementedImplemented
meta.language.classes (3)3 Implemented3 Implemented
abstract_completeImplementedImplemented
override_signatureImplementedImplemented
single_inheritanceImplementedImplemented
meta.language.contexts (1)1 Implemented1 Implemented
inheritanceImplementedImplemented
meta.language.envelopes (7)7 Implemented7 Implemented
class_callsImplementedImplemented
createsImplementedImplemented
direct_callsImplementedImplemented
leafImplementedImplemented
permissionsImplementedImplemented
readsImplementedImplemented
receiver_callsImplementedImplemented
meta.language.fields (2)2 Implemented2 Implemented
context_stateImplementedImplemented
kindsImplementedImplemented
meta.language.methods (2)2 Implemented2 Implemented
kindsImplementedImplemented
proseImplementedImplemented
meta.language.model (3)3 Implemented3 Implemented
forbidden_pathsImplementedImplemented
inherited_prohibitionsImplementedImplemented
virtual_dispatchImplementedImplemented
meta.language.types (19)19 Implemented19 Implemented
argument_arityImplementedImplemented
declaration_proseImplementedImplemented
enum_variantsImplementedImplemented
field_proseImplementedImplemented
generic_parametersImplementedImplemented
member_commasImplementedImplemented
name_resolutionImplementedImplemented
opaque_representationImplementedImplemented
preludeImplementedImplemented
qualified_namesImplementedImplemented
recursive_valuesImplementedImplemented
struct_fieldsImplementedImplemented
tuplesImplementedImplemented
type_expressionsImplementedImplemented
unique_fieldsImplementedImplemented
unique_parametersImplementedImplemented
unique_variantsImplementedImplemented
unknown_namesImplementedImplemented
variant_proseImplementedImplemented
meta.reviews (27)27 Implemented27 Implemented
claim_textImplementedImplemented
complete_test_setImplementedImplemented
decisionsImplementedImplemented
fragment_associationsImplementedImplemented
fragment_formatImplementedImplemented
fragment_freshnessImplementedImplemented
gateImplementedImplemented
input_formatImplementedImplemented
input_fragmentsImplementedImplemented
output_formatImplementedImplemented
preparationImplementedImplemented
record_requiredImplementedImplemented
recorded_readsImplementedImplemented
recordingImplementedImplemented
review_delegationImplementedImplemented
review_diagnosticsImplementedImplemented
review_instructionsImplementedImplemented
review_scopeImplementedImplemented
selector_claimImplementedImplemented
selector_line_rangeImplementedImplemented
selector_testImplementedImplemented
selector_whole_fileImplementedImplemented
source_representationImplementedImplemented
stalenessImplementedImplemented
summary_formatImplementedImplemented
test_sourceImplementedImplemented
validation_layoutImplementedImplemented
meta.validation (3)3 TODO3 TODO
claim_specific_evidenceTODOTODO
independent_inspectionTODOTODO
review_packetsTODOTODO