Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions dag/std/decl_ref.dag
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@ fn decl_field_ref(module_path: String, decl_name: String, field_name: String) ->
}
}

fn declaration_ref_member_name(reference: DeclarationRef) -> NonEmptyStr {
match reference.field {
WholeDeclaration => reference.decl_name
NamedField { field_name } => field_name
}
}

fn declaration_ref_qualified_key(reference: DeclarationRef) -> NonEmptyStr {
match reference.field {
WholeDeclaration => concat(reference.module_path, ".", reference.decl_name) as NonEmptyStr
NamedField { field_name } => concat(reference.module_path, ".", reference.decl_name, ".", field_name) as NonEmptyStr
}
}

fn decl_field_eq(a: DeclField, b: DeclField) -> Bool {
match a {
WholeDeclaration =>
Expand Down
25 changes: 25 additions & 0 deletions dag/std/occurrence_identity.dag
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,31 @@ type OccurrenceId {
value: Int
}

// The parser mints the declaration-form axis at the same occurrence boundary that mints the
// declaration identity. Later resolver and index stages preserve this row; they never infer a
// constructor from a resolved Node shape.
type AuthoredTypeTarget {
spelling: String
}

type SourceDeclarationConstructor
= FunctionDeclaration
| DataDeclaration
| ServiceDeclaration
| ResourceDeclaration
| PatternDeclaration
| InterfaceDeclaration
| NominalTypeDeclaration
| ProductTypeDeclaration
| CoproductTypeDeclaration
| TransparentTypeAlias { representation_target: AuthoredTypeTarget }
| NamespaceAlias { referent_key: String }

type ParsedDeclarationConstructorRow {
declaration_occurrence: NodeOccurrenceIdentity
constructor: SourceDeclarationConstructor
}

data occurrence_containment_storage_projection_note: String = "OccurrenceContainmentPath is the concrete compact storage projection of std.occurrence_binding.ContainmentPath<OccurrenceId>. Generic stage0 emission of ContainmentPath<N> with #[derive] carriers needed v1.compiler.trait_derive_emit item-level Clone bounds (PR #7570); that emitter work is prerequisite but does not by itself dissolve this projection — std_occurrence_binding is not on the stage0 roster until PR #7515 lands and proves ContainmentPath<OccurrenceId> compiles there."

type OccurrenceContainmentPath {
Expand Down
67 changes: 63 additions & 4 deletions dag/std/repair_input_origin.dag
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module std.repair_input_origin

import std.types { String, List }
import std.decl_ref { DeclarationRef }

// XL-0A splits the emitter's six candidate-bearing inputs BEFORE their historical string union.
// The source branch is deliberately named Candidate rather than DeclarationCarrier: XL-0B/C will
Expand All @@ -19,12 +20,26 @@ type SourceCarrierOrigin

type RenderedTypeSurfaceOrigin {}

type NonSourceValueReason
= RuntimePrimitiveValue
| ValueTargetUndetermined

type SourceCarrierCandidateIdentity {
emitting_module: String
candidate_spelling: CandidateSpelling
producer_origin: SourceCarrierOrigin
}

// XL-0B's resolver/value channels arrive here only after the upstream authority has preserved
// the declaration it selected. Candidate spelling remains independent: aliases and re-exports
// can make the authored qualifier differ from the declaring module.
type SourceDeclarationCarrierIdentity {
emitting_module: String
candidate_spelling: CandidateSpelling
declaring_declaration: DeclarationRef
producer_origin: SourceCarrierOrigin
}

type RenderedTargetVocabularyIdentity {
emitting_module: String
rendered_identifier: String
Expand All @@ -33,8 +48,40 @@ type RenderedTargetVocabularyIdentity {

type RepairInputOriginCandidate
= SourceCarrierCandidate { identity: SourceCarrierCandidateIdentity }
| SourceDeclarationCarrier { identity: SourceDeclarationCarrierIdentity }
| NonSourceValueCompatibilityCandidate {
emitting_module: String,
candidate_spelling: CandidateSpelling,
reason: NonSourceValueReason,
}
| RenderedTargetVocabularyCarrier { identity: RenderedTargetVocabularyIdentity }

fn source_declaration_carrier(
emitting_module: String,
candidate_spelling: CandidateSpelling,
declaring_declaration: DeclarationRef,
producer_origin: SourceCarrierOrigin,
) -> RepairInputOriginCandidate {
SourceDeclarationCarrier { identity: SourceDeclarationCarrierIdentity {
emitting_module: emitting_module,
candidate_spelling: candidate_spelling,
declaring_declaration: declaring_declaration,
producer_origin: producer_origin,
} }
}

fn non_source_value_compatibility_candidate(
emitting_module: String,
candidate_spelling: CandidateSpelling,
reason: NonSourceValueReason,
) -> RepairInputOriginCandidate {
NonSourceValueCompatibilityCandidate {
emitting_module: emitting_module,
candidate_spelling: candidate_spelling,
reason: reason,
}
}

fn candidate_spelling_from_text(name: String) -> CandidateSpelling {
let segments = name |> split(delimiter: ".")
if (segments |> count) > 1 {
Expand Down Expand Up @@ -75,17 +122,17 @@ fn rendered_origin_candidates(
// disposition is accepted here. The old name union is now only the compatibility projection below.
fn repair_input_origin_candidates(
emitting_module: String,
unlisted_type_names: List<String>,
value_reference_names: List<String>,
unlisted_type_candidates: List<RepairInputOriginCandidate>,
value_reference_candidates: List<RepairInputOriginCandidate>,
item_emit_surface_names: List<String>,
field_import_surface_names: List<String>,
variant_payload_surface_names: List<String>,
rendered_type_surface_names: List<String>,
) -> List<RepairInputOriginCandidate> {
concat(
source_origin_candidates(emitting_module: emitting_module, names: unlisted_type_names, origin: UnlistedTypeResolutionOrigin),
unlisted_type_candidates,
concat(
source_origin_candidates(emitting_module: emitting_module, names: value_reference_names, origin: ValueReferenceResolutionOrigin),
value_reference_candidates,
concat(
source_origin_candidates(emitting_module: emitting_module, names: item_emit_surface_names, origin: ItemEmitSurfaceOrigin),
concat(
Expand All @@ -107,6 +154,16 @@ fn repair_input_origin_candidate_name(candidate: RepairInputOriginCandidate) ->
BareCandidate { name } => name
QualifiedCandidate { authored_qualifier, member } => concat(authored_qualifier, ".", member)
}
SourceDeclarationCarrier { identity } =>
match identity.candidate_spelling {
BareCandidate { name } => name
QualifiedCandidate { authored_qualifier, member } => concat(authored_qualifier, ".", member)
}
NonSourceValueCompatibilityCandidate { emitting_module: _, candidate_spelling, reason: _ } =>
match candidate_spelling {
BareCandidate { name } => name
QualifiedCandidate { authored_qualifier, member } => concat(authored_qualifier, ".", member)
}
RenderedTargetVocabularyCarrier { identity } => identity.rendered_identifier
}
}
Expand Down Expand Up @@ -135,6 +192,8 @@ fn qualified_item_emit_surface_compatibility_names(
FieldImportSurfaceOrigin => []
VariantPayloadSurfaceOrigin => []
}
SourceDeclarationCarrier { identity: _ } => []
NonSourceValueCompatibilityCandidate { emitting_module: _, candidate_spelling: _, reason: _ } => []
RenderedTargetVocabularyCarrier { identity: _ } => []
}
)
Expand Down
22 changes: 12 additions & 10 deletions src/v1/00_core.dag
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import std.syntax {
}
import std.algebra { CollectionSizeEffect, CostShape, AlgebraFieldTemplate }
import std.induction { SubValueRelation }
import std.decl_ref { DeclarationRef }
import std.occurrence_identity {
NodeOccurrenceIdentity,
OccurrenceSynthetic,
Expand Down Expand Up @@ -89,7 +90,7 @@ fn has_inferred(n: Node) -> Bool {

type VarBindingKind
= LocalValueBinding
| FunctionValueBinding
| FunctionValueBinding { target: CallTargetIdentity }
| VariantValueBinding { parent_enum: String }
| MatchBoundBinding

Expand Down Expand Up @@ -123,6 +124,7 @@ type VarBindingKind
type DeclaredCallableIdentity {
owner_module_path: String
decl_name: String
declaration: DeclarationRef
}

// A PRIMITIVE'S IDENTITY AND ITS PER-TARGET REALIZATION ARE TWO FACTS, AND `projected_from`
Expand All @@ -147,7 +149,7 @@ type DeclaredCallableIdentity {
// declaration answered and there is nothing to fall back to.
type CallTargetIdentity
= RuntimePrimitiveCall { primitive_name: String, projected_from: DeclaredCallableIdentity? }
| SourceDeclarationCall { owner_module_path: String, decl_name: String }
| SourceDeclarationCall { declaration: DeclarationRef }
| CallableTargetUndetermined

type CallSemantics
Expand All @@ -173,7 +175,7 @@ type ExprData
| ExprMatch
| ExprIf
| ExprLet
| ExprRecordLit { parent_enum: String? }
| ExprRecordLit { parent_enum: String?, target: CallTargetIdentity }
| ExprListLit
| ExprBinOp { op: BinOp, algebra_field: AlgebraFieldKind? }
| ExprUnaryOp { op: UnaryOpKind }
Expand Down Expand Up @@ -269,7 +271,7 @@ type CompilerDiagnostic
| AdmitCallersEntryNotDeclRef { constructor_decl_name: String, span: SourceSpan }
| DeclaredTypeNotInhabited { position: String, expected: String, got: String, span: SourceSpan }
| DeclaredTypeInhabitanceUndecided { position: String, reason: String, span: SourceSpan }
| UnlistedImportUse { name: String, span: SourceSpan }
| UnlistedImportUse { name: String, declaration: DeclarationRef, span: SourceSpan }
| ReferenceDerivedImportProviderUnknown { name: String, referencing_module: String, span: SourceSpan }
| ReferenceDerivedImportExportUnproven { name: String, referencing_module: String, provider_module: String, span: SourceSpan }
| UnlistedVariantValueUse { name: String, span: SourceSpan }
Expand Down Expand Up @@ -426,7 +428,7 @@ fn diagnostic_to_span(d: CompilerDiagnostic) -> SourceSpan {
AdmitCallersEntryNotDeclRef { constructor_decl_name: _, span: s } => s
DeclaredTypeNotInhabited { position: _, expected: _, got: _, span: s } => s
DeclaredTypeInhabitanceUndecided { position: _, reason: _, span: s } => s
UnlistedImportUse { name: _, span: s } => s
UnlistedImportUse { name: _, declaration: _, span: s } => s
ReferenceDerivedImportProviderUnknown { name: _, referencing_module: _, span: s } => s
ReferenceDerivedImportExportUnproven { name: _, referencing_module: _, provider_module: _, span: s } => s
UnlistedVariantValueUse { name: _, span: s } => s
Expand Down Expand Up @@ -514,7 +516,7 @@ fn diagnostic_to_message(d: CompilerDiagnostic) -> String {
concat("value does not inhabit its declared type at the ", pos, ": declared '", e, "', produced '", g, "'")
DeclaredTypeInhabitanceUndecided { position: pos, reason: r, span: _ } =>
concat("declared-type inhabitance is undecidable at the ", pos, " (", r, "): the modeled facts do not settle whether the produced value inhabits its declared type, so no verdict is asserted in either direction")
UnlistedImportUse { name: n, span: _ } => concat("unlisted import use '", n, "' (referenced but not in any import's name list)")
UnlistedImportUse { name: n, declaration: _, span: _ } => concat("unlisted import use '", n, "' (referenced but not in any import's name list)")
ReferenceDerivedImportProviderUnknown { name: n, referencing_module: rm, span: _ } =>
concat("no provider is present for '", n, "', referenced by module '", rm, "': the compile closure carries no module that declares the name, so no use-line can be synthesized and the emitted Rust references a name it never imported. The remedy is to AUTHOR AN IMPORT -- closure membership is driven by imports, so a name the module never imported is a name the closure was never asked to supply")
ReferenceDerivedImportExportUnproven { name: n, referencing_module: rm, provider_module: p, span: _ } =>
Expand Down Expand Up @@ -580,7 +582,7 @@ data diagnostic_frontier_occurrence_key_note: String = "The canonical accessor f

fn is_error_diagnostic(d: CompilerDiagnostic) -> Bool {
match d {
UnlistedImportUse { name: _, span: _ } => false
UnlistedImportUse { name: _, declaration: _, span: _ } => false
ReferenceDerivedImportProviderUnknown { name: _, referencing_module: _, span: _ } => false
ReferenceDerivedImportExportUnproven { name: _, referencing_module: _, provider_module: _, span: _ } => false
UnlistedVariantValueUse { name: _, span: _ } => false
Expand All @@ -601,7 +603,7 @@ fn is_interpreter_blocking_diagnostic(d: CompilerDiagnostic) -> Bool {
ComplexityUnknown { func_name: _, reason: _, span: _ } => false
WhereRefinementUnenforced { predicate: _, formal_type: _, reason: r, span: _ } =>
!is_where_refinement_unenforced_advisory_reason(reason: r)
UnlistedImportUse { name: _, span: _ } => false
UnlistedImportUse { name: _, declaration: _, span: _ } => false
UnlistedVariantValueUse { name: _, span: _ } => false
MethodExistenceFrontierAdmitted { method: _, receiver_type: _, trigger: _, span: _ } => false
ReceiverTypeUnestablished { method: _, span: _ } => false
Expand All @@ -615,7 +617,7 @@ fn is_interpreter_blocking_diagnostic(d: CompilerDiagnostic) -> Bool {

fn is_discovery_corpus_advisory_typecheck_diagnostic(d: CompilerDiagnostic) -> Bool {
match d {
UnlistedImportUse { name: _, span: _ } => true
UnlistedImportUse { name: _, declaration: _, span: _ } => true
UnlistedVariantValueUse { name: _, span: _ } => true
MethodExistenceFrontierAdmitted { method: _, receiver_type: _, trigger: _, span: _ } => true
ReceiverTypeUnestablished { method: _, span: _ } => true
Expand Down Expand Up @@ -1531,7 +1533,7 @@ fn expr_is_any_literal(expr: Node) -> Bool {

fn record_lit_expr_optional(expr: Node) -> Node? {
match expr.expr_data {
ExprRecordLit { parent_enum: _ } => Present { value: expr }
ExprRecordLit { parent_enum: _, target: _ } => Present { value: expr }
_ => none
}
}
Expand Down
Loading
Loading