crates.sage_ir.symbols.definition_identity

Resolution may use names, paths, scopes, and namespaces to discover a definition, but every successful downstream semantic reference records the resulting symbol. Renaming an import or choosing another path to the same definition must not mint a different definition identity.

Read in specification context · design/crates/sage_ir/symbols.sage

Implementation

Implemented crates/sage-ir/src/check/resolve/ribs.rs:11–16

sage_ir::check::resolve::ribs · lib:sage_ir

#![allow(unused)]
fn main() {
// {anchor}`crates.sage_ir.symbols.definition_identity`
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum Resolution<'db> {
    Local(LocalId),
    Param(GenericParam<'db>),
    Sym(Symbol<'db>),

}

See more source ↗

Implemented crates/sage-ir/src/check/resolve/mod.rs:128–133

sage_ir::check::resolve · lib:sage_ir

#![allow(unused)]
fn main() {
    // {anchor}`crates.sage_ir.symbols.definition_identity`
    #[sage::item(crate::resolution::Resolver::resolve)]
    // {anchor}`crates.sage_ir.resolution.lookup.precedence`
    // {anchor}`crates.sage_ir.resolution.lookup.identity_only`
    // {anchor}`crates.sage_ir.resolution.lookup.dependencies`
    pub fn resolve_path(

}

See more source ↗

Implemented crates/sage-ir/src/symbol/mod.rs:329–334

sage_ir::symbol · lib:sage_ir

#![allow(unused)]
fn main() {
// {anchor}`crates.sage_ir.symbols.definition_identity`
// {anchor}`crates.sage_ir.symbols.kind_wrappers`
define_kind_symbols! {
    #[sage::item(crate::symbols::Symbol)]
    pub struct Symbol<'db> { data: SymbolDataPriv<'db> }
    pub enum SymbolData<'db> { .. }

}

See more source ↗

Implemented crates/sage-ir/src/ty.rs:20–25

sage_ir::ty · lib:sage_ir

--- primitives ---

#![allow(unused)]
fn main() {
// {anchor}`crates.sage_ir.symbols.definition_identity`
pub enum Ty<'db> {
    // --- primitives ---
    Bool,
    Char,
    Int(IntTy),

}

See more source ↗

Tests and review

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

TODO sage_meta::todo::symbols_definition_identity

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

#![allow(unused)]
fn main() {
#[test]
    #[sage::test(crates.sage_ir.symbols.definition_identity)]
    fn symbols_definition_identity() {
        // TODO: Add the distinct-path/same-symbol and equal-spelling/different-scope
        // resolution matrix; current output examples do not establish it.
    }
}

See more source ↗

Review: Accepted · macro_fix_precedence/definition_identity.

Reviewed the full definition-identity claim, all four ordinary implementation associations (resolver, ribs, symbol wrappers, resolved types), and the sole TODO test. Captured the typed-body representation as additional context for downstream reference storage. No production or test sources were changed.

The claim separates discovery spelling/path from successful semantic reference identity and requires aliases and alternate routes to preserve the same definition. resolve_path returns Resolution::Sym around the symbol found by module/path lookup, rather than wrapping the spelling used to reach it. Named-use resolution follows the imported path and returns its target symbol; glob traversal likewise carries target symbols. Candidate deduplication uses Symbol equality, not names. The new ambiguity audit compares generated and glob target identities; it examines the binding item's origin without allocating a replacement definition for that binding. Thus provenance is used for ambiguity classification but not substituted for semantic identity.

ribs.rs represents local variables by body LocalId, generic parameters by GenericParam, and item references by Symbol; it copies stored entries instead of re-interning by the queried name. symbol/mod.rs wraps the existing local tracked identity or external SymExt in canonical kind wrappers, with derived equality/hash and conversions retaining the payload. External named-child lookup uses exported edge names and namespaces for discovery but constructs SymExt from the defining crate/index/kind; aliases do not enter that key. ty.rs stores Symbol in ADT applications, TypeAliasSymbol in named/opaque/projection identities, and TraitSymbol in trait references, preserving definitions while keeping substitutions separate. The additionally captured typed-body context agrees: PathResolution::Def stores Symbol, resolved calls store FnSymbol, and resolved fields carry owner identity plus field index. Those body-specific contracts have their own existing associations; this capture does not claim broader body coverage for this anchor.

The associated representation_spec::todo::symbols_definition_identity explicitly defers the distinct-path/same-symbol and equal-spelling/different-scope resolution matrix, noting that displayed examples do not establish identity. This remains a substantive verification gap: snapshots of equal names can conceal different internal symbols, and direct identity/equality assertions across aliases, paths and separate scopes are the needed prerequisite. No ordinary test is associated with this anchor, and this review does not promote other anchors' output examples into evidence. There are no N/A entries. The ordinary code structure supports the intended identity boundary; accepting the explicit TODO does not assert that the complete matrix has been tested. This review ran start/read/record commands only and did not execute new behavioral tests. No new violation was identified in the changed resolver; no edits requested.

Browse crates anchors

139 anchors

Specification anchors and declared coverage
AnchorImplementationTests
crates (139)114 Implemented37 TODO2 N/A74 Implemented107 TODO
crates.sage_inspector (15)13 Implemented1 TODO2 N/A3 Implemented15 TODO
crates.sage_inspector.inspection (15)13 Implemented1 TODO2 N/A3 Implemented15 TODO
balanced_tracesImplementedTODO
canonical_ownershipImplementedImplementedTODO
derive_reflectionImplementedImplementedTODO
detail_free_indexImplementedTODO
deterministic_traceImplementedTODO
durable_navigationN/ATODO
generic_browserN/ATODO
owned_reflectionImplementedImplementedTODO
product_availabilityImplementedTODO
revision_and_demandImplementedTODO
semantic_phase_boundaryImplementedTODO
source_evidenceImplementedTODO
typed_serviceImplementedTODO
unknown_workImplementedTODOTODO
workspace_actorImplementedTODO
crates.sage_ir (90)67 Implemented34 TODO40 Implemented88 TODO
crates.sage_ir.checking (12)12 Implemented3 TODO5 Implemented12 TODO
crates.sage_ir.checking.body (5)5 Implemented2 TODO3 Implemented5 TODO
elaborationImplementedImplementedTODO
expected_typesImplementedTODOTODO
interface_dependenciesImplementedImplementedTODO
isolated_completionImplementedImplementedTODO
operator_callsImplementedTODOTODO
identity_mintingImplementedTODO
owned_productsImplementedImplementedTODO
crates.sage_ir.checking.signature (4)4 Implemented1 TODO1 Implemented4 TODO
body_independenceImplementedTODO
narrow_detailImplementedTODOTODO
owner_binderImplementedImplementedTODO
storageImplementedTODO
symbol_keyed_interfacesImplementedTODO
crates.sage_ir.crate (9)9 TODO9 TODO
explicit_restrictionsTODOTODO
identity_before_detailTODOTODO
incremental_evidenceTODOTODO
narrow_demandsTODOTODO
reexecution_and_invalidationTODOTODO
represented_completenessTODOTODO
restrictions_and_gapsTODOTODO
semantic_query_boundariesTODOTODO
terminal_incompletenessTODOTODO
crates.sage_ir.inference (8)8 Implemented6 Implemented8 TODO
atomic_checkingImplementedImplementedTODO
body_local_quiescenceImplementedImplementedTODO
canonical_boundaryImplementedImplementedTODO
completed_body_boundaryImplementedTODO
numeric_domainsImplementedImplementedTODO
subtyping_and_coercionImplementedImplementedTODO
terminal_obligationsImplementedTODO
transaction_isolationImplementedImplementedTODO
crates.sage_ir.metadata (4)4 Implemented1 TODO4 TODO
explicit_incompletenessImplementedTODO
keyed_reuseImplementedTODOTODO
product_boundariesImplementedTODO
provider_authorityImplementedTODO
crates.sage_ir.modules (8)7 Implemented1 TODO4 Implemented8 TODO
crates.sage_ir.modules.expand (4)4 Implemented2 Implemented4 TODO
completenessImplementedImplementedTODO
dependenciesImplementedTODO
direct_membersImplementedTODO
recursion_and_fixpointImplementedImplementedTODO
crates.sage_ir.modules.parse (4)3 Implemented1 TODO2 Implemented4 TODO
dependenciesImplementedTODO
detail_firewallImplementedImplementedTODO
recovery_completenessTODOTODO
syntax_identitiesImplementedImplementedTODO
crates.sage_ir.resolution (5)5 Implemented1 TODO3 Implemented4 TODO
crates.sage_ir.resolution.lookup (5)5 Implemented1 TODO3 Implemented4 TODO
completenessImplementedTODOImplementedTODO
dependenciesImplementedTODO
expansion_import_ambiguityImplementedImplemented
identity_onlyImplementedTODO
precedenceImplementedImplementedTODO
crates.sage_ir.solver (9)7 Implemented7 TODO5 Implemented9 TODO
alternative_isolationImplementedTODOImplementedTODO
bounded_completenessImplementedTODOTODO
candidate_completenessImplementedTODO
canonical_cyclesTODOTODO
canonical_outputsImplementedImplementedTODO
local_index_firewallTODOTODO
normalization_demandImplementedTODOImplementedTODO
schedule_independenceImplementedTODOImplementedTODO
shared_final_resultImplementedTODOImplementedTODO
crates.sage_ir.symbols (8)8 Implemented4 Implemented7 TODO
associated_identityImplementedImplemented
associated_interfacesImplementedTODO
body_interfacesImplementedImplementedTODO
definition_identityImplementedTODO
external_fact_queriesImplementedTODO
external_identityImplementedTODO
kind_wrappersImplementedImplementedTODO
local_identityImplementedImplementedTODO
crates.sage_ir.types (27)16 Implemented12 TODO13 Implemented27 TODO
crates.sage_ir.types.aliases (2)1 Implemented1 TODO1 Implemented2 TODO
identityImplementedImplementedTODO
revelationTODOTODO
crates.sage_ir.types.binder (1)1 Implemented1 TODO1 Implemented1 TODO
owner_parametersImplementedTODOImplementedTODO
crates.sage_ir.types.body (13)4 Implemented9 TODO3 Implemented13 TODO
awaitTODOTODO
closuresTODOTODO
conditional_patternsTODOTODO
coroutinesTODOTODO
diagnosed_recoveryImplementedImplementedTODO
elaboratedTODOImplementedTODO
for_iterationTODOTODO
indexingTODOTODO
macro_expansionTODOTODO
no_inferenceImplementedImplementedTODO
resolved_referencesImplementedTODO
try_residualTODOTODO
typed_provenanceImplementedTODO
crates.sage_ir.types.calls (2)1 Implemented1 TODO1 Implemented2 TODO
dispatch_familiesTODOTODO
selected_semanticsImplementedImplementedTODO
crates.sage_ir.types.lifetimes (2)2 Implemented2 Implemented2 TODO
dummyImplementedImplementedTODO
unchecked_borrowsImplementedImplementedTODO
crates.sage_ir.types.operators (2)2 Implemented1 Implemented2 TODO
lazy_control_flowImplementedTODO
trait_callsImplementedImplementedTODO
scoped_identitiesImplementedTODO
crates.sage_ir.types.spans (4)4 Implemented4 Implemented4 TODO
generated_identityImplementedImplementedTODO
item_originImplementedImplementedTODO
offset_reuseImplementedImplementedTODO
relative_compositionImplementedImplementedTODO
crates.sage_oracle_harness (4)4 Implemented2 TODO1 Implemented4 TODO
crates.sage_oracle_harness.crate (4)4 Implemented2 TODO1 Implemented4 TODO
deterministic_emissionImplementedTODO
exact_comparisonImplementedTODOImplementedTODO
fixed_projectionImplementedTODO
independent_coverageImplementedTODOTODO
crates.sage_stash (5)5 Implemented5 Implemented
crates.sage_stash.storage (5)5 Implemented5 Implemented
handle_ownershipImplementedImplemented
immutable_entriesImplementedImplemented
query_valueImplementedImplemented
rooted_equalityImplementedImplemented
typed_interningImplementedImplemented
crates.sage_test_harness (25)25 Implemented25 Implemented
crates.sage_test_harness.compile_tests (25)25 Implemented25 Implemented
annotation_validationImplementedImplemented
blessing_gateImplementedImplemented
callsite_updatesImplementedImplemented
checking_scopeImplementedImplemented
compiler_conditionsImplementedImplemented
completed_typesImplementedImplemented
coordinatesImplementedImplemented
dependenciesImplementedImplemented
diagnostic_countsImplementedImplemented
diagnostic_locationsImplementedImplemented
editionImplementedImplemented
fixturesImplementedImplemented
grouped_observationsImplementedImplemented
invocationImplementedImplemented
production_executionImplementedImplemented
project_isolationImplementedImplemented
query_captureImplementedImplemented
query_projectionImplementedImplemented
renderingImplementedImplemented
resolved_symbolsImplementedImplemented
review_visibilityImplementedImplemented
rustc_executionImplementedImplemented
rustc_lintsImplementedImplemented
starting_expressionsImplementedImplemented
target_lineImplementedImplemented