diff --git a/dag/gunbc/recurring_failure_mode/authored_lexeme_read_as_a_grammar_marker.dag b/dag/gunbc/recurring_failure_mode/authored_lexeme_read_as_a_grammar_marker.dag index d7d3def01e6..8ca4d98deb5 100644 --- a/dag/gunbc/recurring_failure_mode/authored_lexeme_read_as_a_grammar_marker.dag +++ b/dag/gunbc/recurring_failure_mode/authored_lexeme_read_as_a_grammar_marker.dag @@ -13,6 +13,7 @@ data authored_lexeme_read_as_a_grammar_marker: RecurringFailureMode = RecurringF "CENSUS (this change): 222 non-test references to the 65 marker symbols (every `emitted:` identity in `v2.extdeps.languages.dag`, plus the four sugar keys). 185 read the marker through its emission (`parse_production_emitted_identity_optional`) or are declarations; 19 are prose; 10 are BARE; 8 are UNCLEAR. The four ^dag_c3_surface_sugar_* rules had NO producer anywhere (src/v2, dag, seed): only test fixtures built those atoms, so the rules, the SurfaceAtomKey arm and their two fixture claims were deleted rather than re-keyed.", "OPEN, EDGE-LABEL CHANNEL (not fixed here; its fix is a Node-model change the owning lane routes): lowering and the graft put authored parameter, field and declaration names into `Named` edge labels, and edge labels carry no record of whether the grammar or the author named them. Four helpers match marker labels there: `v2.extdeps.languages.dag` `dag_surface_module_header_metadata_edge`, the Absent-emission fallback arm of `dag_node_is_module_root_conj`, `v2.compiler.body_lowering_fold` `body_lower_edge_names_where_clause`, and `v2.lens.module_graph` `site_is_import_syntax_mention`. Specimen, read and not run: `fn f(dag_surface_module_header: Int)` gives the parameter Conj a member edge named like the header, so `dag_node_is_module_root_conj` answers true for it in resolve.", "RUNG FOUND AT: below the floor (a silent rewrite of an identifier) on the atom channel. RUNG NOW: structurally guaranteed on the atom channel -- no marker reader keys on a bare atom, so authored text cannot reach one. The edge channel stays below the floor. CEILING: structurally impossible -- a grammar marker is a construct authored text has no constructor for. NEXT-RUNG TRIGGER, NAMING THE CAPABILITY: a `Named` edge label carries whether the grammar or the author named it, and every marker-label reader reads that provenance, so no authored name can inhabit a marker label.", + "EDGE-LABEL CHANNEL, CLIMBED (quiet-koi-814, the EdgeLabel cut). The four helpers named above match the StructuralLabel arm, so an authored name spelled like a marker label is an Authored value and reaches none of them; the climb, its rung and the frontier that still compares grammar labels by text inside the Authored arm are recorded once, on `gunbc.recurring_failure_mode` `behavior_named_edge_label_validated_not_constructed`, not here.", ], evidence: [ diff --git a/dag/gunbc/recurring_failure_mode/behavior_named_edge_label_validated_not_constructed.dag b/dag/gunbc/recurring_failure_mode/behavior_named_edge_label_validated_not_constructed.dag index 708f005086b..6cd9dede90a 100644 --- a/dag/gunbc/recurring_failure_mode/behavior_named_edge_label_validated_not_constructed.dag +++ b/dag/gunbc/recurring_failure_mode/behavior_named_edge_label_validated_not_constructed.dag @@ -13,9 +13,17 @@ data behavior_named_edge_label_validated_not_constructed: RecurringFailureMode = "CEILING: structurally impossible -- which label a behavior's Named edge may carry is decidable and fully modeled, so the invalid state need not have a constructor. NEXT-RUNG TRIGGER, NAMING THE CAPABILITY: edge labels on behavior nodes become a closed coproduct owned by `v2.std.node`, so a Transform's or Bind's Named edge can only be constructed as the marker that behavior admits and a foreign label has no constructor; `type_binder_labels_conform`'s label arm for behaviors then dissolves, its discriminating red kept as the evidence. It must be ONE authority with the edge-discipline coproduct gentle-koi-724's lane is building, not a second one beside it.", "THE WALL IS SPLIT, NOT WIDENED (MQ-1 PR-B, ruled by gentle-koi-724 and neat-boar-16, 2026-09-26; loyal-crab-333's wall). Named arguments now ride an application as Named edges labelled by the callee's parameter names (v2.compiler.body_lowering_fold body_lower_call_arg_edge), so a Transform is one of two forms: a cast, whose one Named edge is the marker, or an application, whose Named edges are named actuals. v2.std.node states a Transform's shape as positional_prefix_then_labeled_conform (positional first, then distinct Named edges -- an application's positional order carries meaning), while a Bind keeps PositionalPlusOneNamedEdges (one marker, placed freely) and admits only the label (v2.std.type_binder bind_named_labels_conform), and v2.std.type_binder transform_named_labels_conform refuses a Transform that MIXES the marker with any other Named edge, located at that Transform (v2.std.type_binder type_binder_first_mislabelled, read by v2.compiler.resolve's gate). A named label that names no parameter of the callee is a binding fact, refused by the one binding authority (v2.std.arrow_signature application_binding_plan, application_argument_label_unknown) before any program is Accepted. So the rung stays structurally guaranteed, reached by two decidable halves instead of one label list. Discriminating reds: v2.test.claim.body_cast_node bcn_a_foreign_label_on_a_transform_refuses (restated as the mixing case) and bcn_an_unknown_named_label_refuses_at_binding; the cast controls in the same module are unchanged.", "WHAT THE TRIGGER MUST BE SUFFICIENT FOR, stated per DESIGN section 4b(3) (review 72087, MQ-1 PR-B). With named arguments, a Transform is one of two forms: a CAST whose one Named edge is the marker, or an APPLICATION whose Named edges are named actuals labelled by parameter names. v2.std.type_binder transform_named_labels_conform refuses a Transform that MIXES them -- validation over a state the model can still write, because the label is an open Named { name: Symbol }. A Cast behavior is not available (DESIGN section 4 fixes the six behaviors), so the construction route is this row's own trigger: behavior-node edge labels become a closed coproduct owned by v2.std.node. It is met only when that coproduct gives the cast marker and an application's named actual DISTINCT label constructors, so a marker beside an actual has no constructor; transform_named_labels_conform's mix arm then dissolves, and its discriminating red v2.test.claim.body_cast_node bcn_a_foreign_label_on_a_transform_refuses stays enrolled as the evidence (DESIGN section 4b(4)). Owner: the v2 type-binders lane under neat-boar-16, coordinated with the named-arguments edge discipline (v2.std.node positional_prefix_then_labeled_conform)." + "CLIMB, EDGE LABELS (quiet-koi-814; model gunbc#12473, ruled by neat-boar-16, ruling A; scope ruled by gentle-koi-724). `v2.std.node` `EdgeLabel` is now `Authored { name } | StructuralLabel { label: StructuralEdgeLabel } | Positional`, with `StructuralEdgeLabel = CoreMarker { marker: CoreEdgeLabel } | ProductionEdge { language, edge }`; the old `Named { name: Symbol }` arm was deleted first and every site renamed or converted in one change (DESIGN section 3, root-first). CONVERTED, EVERY MINTER AND READER: the core markers (arrow body, arrow signature order, loop bound, carrier and domain, match arm pattern and body, the `v2.std.type_binder` cast target, type annotation, type params, type body and type alias, the declaration reference, the field projection base and field, and the construct tag from gunbc#12714) and the dag surface productions the text-matching readers needed (module header and its qualified name, where-refinement clause, import decl, import block, import decl block, import decl qualified name), plus `v2.std.node` `Path` steps and `v2.compiler.resolution_provenance` `ReferenceSite` position, which now carry whole labels. The four text-matching readers (`v2.extdeps.languages.dag` `dag_surface_module_header_metadata_edge` and the Absent-emission arm of `dag_node_is_module_root_conj`, `v2.compiler.body_lowering_fold` `body_lower_edge_names_where_clause`, `v2.lens.module_graph` `site_is_import_syntax_mention`) match the arm, so no Authored label reaches them whatever it spells. The marker lexemes (`` and siblings) are gone: a marker is an arm, not an unauthorable spelling.", + "RUNG AFTER THE CLIMB, PER PATH. The confusion this row names -- a behavior's marker label read from an authored spelling -- is structurally impossible on every converted reader: an Authored value is never equal to a StructuralLabel value. What stays at rung 3 is the SHAPE half of the behavior rule: a Bind or a Transform can still be handed an Authored label where only its marker belongs (a Bind's only admitted label is its type annotation; a Transform's authored labels are its named actuals), so `type_binder_labels_conform` keeps refusing a foreign Authored label on a Bind and a cast marker mixed with named actuals. Its next-rung trigger is unchanged in kind: per-behavior label coproducts, so a Bind's named edge has no Authored constructor.", + "DECLARED FRONTIER, AUTHORED ARM CARRYING GRAMMAR-EMITTED LABELS (ruled by gentle-koi-724 on the cut). Labels a grammar or a language model emits, but that no converted reader matches, still ride the Authored arm and their readers still compare text inside it. POPULATION, BY MINTING DECLARATION: the per-language edge builders `v2.extdeps.languages` `bash_named_edge`, `c_named_edge`, `c_decl_named_edge`, `cpp_named_edge`, `dag_named_edge` (its non-converted productions) and `dag_round_trip_edge`, `ecmascript_named_edge`, `english_named_edge`, `go_named_edge`, `java_named_edge`, `kotlin_named_edge`, `lean_named_edge`, `python_named_edge`, `rust_named_edge`, `swift_named_edge`, `swift_decl_named_edge`, `ts_named_edge`, `verilog_named_edge`, `wasm_named_edge`; the reflection builders `v2.std.compilers.target_model` `target_model_named_edge`, `v2.std.grammar` `grammar_named_edge` (including the four parse-projection labels `v2.compiler.parse` `parse_tree_projection_edge` rosters), `v2.std.fold_assembly` `named_edge`, `v2.std.integer` `integer_named_edge`, `v2.std.language_model` `language_model_named_edge`, `v2.std.logic` `bool_named_edge`, `v2.std.runtime` `runtime_value_named_edge`, `v2.std.node` `node_offset_named_edge`; and every caller of each. PREVIOUS RUNG: below the floor (one Symbol space). TEMPORARY RUNG: unchanged for this population -- an authored spelling can still inhabit a text comparison inside the Authored arm. TRIGGER, NAMING THE CAPABILITY: every grammar-emitted label is minted Structural -- each language's grammar fold mints ProductionEdge for its productions and the parse-projection roster is Core -- so no Authored label is grammar-emitted and no reader compares a grammar label by text.", ], evidence: [ + DeclarationRef { module_path: "v2.test.claim.edge_label.structural_label_readers", decl_name: "the_header_edges_are_metadata_and_their_spellings_are_not", field: WholeDeclaration }, + DeclarationRef { module_path: "v2.test.claim.edge_label.structural_label_readers", decl_name: "a_member_spelled_like_the_header_does_not_make_a_module_root", field: WholeDeclaration }, + DeclarationRef { module_path: "v2.test.claim.edge_label.structural_label_readers", decl_name: "a_field_spelled_like_the_where_clause_is_not_one", field: WholeDeclaration }, + DeclarationRef { module_path: "v2.test.claim.edge_label.structural_label_readers", decl_name: "a_scope_spelled_like_import_syntax_is_not_import_syntax", field: WholeDeclaration }, + DeclarationRef { module_path: "v2.test.claim.edge_label.structural_label_readers", decl_name: "an_authored_name_spelled_like_a_core_marker_is_not_the_marker", field: WholeDeclaration }, DeclarationRef { module_path: "v2.test.claim.body_cast_node", decl_name: "bcn_a_foreign_label_on_a_transform_refuses", field: WholeDeclaration }, DeclarationRef { module_path: "v2.test.claim.body_cast_node", decl_name: "bcn_a_loop_passes_the_resolver_gate", field: WholeDeclaration }, DeclarationRef { module_path: "v2.test.claim.body_let_annotation", decl_name: "bla_bind_admits_only_its_annotation_label", field: WholeDeclaration }, diff --git a/dag/gunbc/recurring_failure_mode/generic_type_parameter_resolved_as_an_ordinary_atom_in_v2.dag b/dag/gunbc/recurring_failure_mode/generic_type_parameter_resolved_as_an_ordinary_atom_in_v2.dag index 50801c45e60..d17edede6a4 100644 --- a/dag/gunbc/recurring_failure_mode/generic_type_parameter_resolved_as_an_ordinary_atom_in_v2.dag +++ b/dag/gunbc/recurring_failure_mode/generic_type_parameter_resolved_as_an_ordinary_atom_in_v2.dag @@ -18,7 +18,7 @@ data generic_type_parameter_resolved_as_an_ordinary_atom_in_v2: RecurringFailure "NEXT-RUNG TRIGGERS, each naming a capability. (1) TYPE DECLARATIONS -- DISCHARGED for records, coproducts, aliases and bodyless declarations; what still refuses uncarried is a right-hand side that is none of the three. (2) A BODY TYPE POSITION: the first type position body lowering carries (a `let` annotation, a lambda parameter type) needs a position-aware type frame -- one answering in type positions only -- before the fn's frame may widen from its signature to its body; a frame over the whole body was measured to admit `fn f(x: T) -> T { T }`, a type used as a value. (3) EMISSION: a target grammar row rendering a type-parameter list, replacing the serializer's refusals for fns and type declarations. (4) NESTED AND RETURN INSTANTIATION in infer: v2.std.inhabitance inhabitance_formal_declaration recognizes a type variable only when a formal's WHOLE declared type is the bare binder, so a formal `List` still takes the counted UndecidableGenericFormal frontier (an Instantiation formal), and the declared return type is never instantiated from the arguments; the trigger is instantiation that substitutes through a formal's structure and into the codomain (review 70847). A lambda's own Arrow opens its own frame through resolve_arrow_node, so gunbc#12210's fresh lambda type parameter does not wait on (2).", ], evidence: [ - DeclarationRef { module_path: "v2.std.type_binder", decl_name: "type_params_marker", field: WholeDeclaration }, + DeclarationRef { module_path: "v2.std.type_binder", decl_name: "type_params_edge", field: WholeDeclaration }, DeclarationRef { module_path: "v2.std.node", decl_name: "type_binder_conj_conforms", field: WholeDeclaration }, DeclarationRef { module_path: "v2.std.type_binder", decl_name: "type_decl_wrapper", field: WholeDeclaration }, DeclarationRef { module_path: "v2.std.type_binder", decl_name: "type_decl_view", field: WholeDeclaration }, diff --git a/dag/gunbc/scm/commit_closure_json_v2.dag b/dag/gunbc/scm/commit_closure_json_v2.dag index 1f62f5ca008..a4ea0b85e73 100644 --- a/dag/gunbc/scm/commit_closure_json_v2.dag +++ b/dag/gunbc/scm/commit_closure_json_v2.dag @@ -122,7 +122,7 @@ import extdeps.languages.json.parse { import v2.std.node { EdgeLabel, - Named, + Authored, Positional, NodeKind, TypeNode, diff --git a/dag/gunbc/scm/object_store.dag b/dag/gunbc/scm/object_store.dag index 9d5ac94155f..767ecbd489e 100644 --- a/dag/gunbc/scm/object_store.dag +++ b/dag/gunbc/scm/object_store.dag @@ -17,7 +17,7 @@ import v2.std.node { Conj, Edge, EdgeLabel, - Named, + Authored, Symbol, content_hash, node_synthetic, @@ -1513,7 +1513,7 @@ fn collision_probe_atom(identity: Symbol) -> Node { fn collision_probe_parent(child: Node) -> Node { node_synthetic( kind: TypeNode { connective: Conj }, - children: [Edge { label: Named { name: ^only_child }, target: child }], + children: [Edge { label: Authored { name: ^only_child }, target: child }], ) } diff --git a/dag/gunbc/scm/object_table_json.dag b/dag/gunbc/scm/object_table_json.dag index 58c9cfbbe37..45deb0772fc 100644 --- a/dag/gunbc/scm/object_table_json.dag +++ b/dag/gunbc/scm/object_table_json.dag @@ -210,7 +210,7 @@ import extdeps.languages.json.parse { } import v2.std.node { EdgeLabel, - Named, + Authored, StructuralLabel, CoreMarker, ProductionEdge, core_edge_label_canonical_symbol, Positional, NodeKind, TypeNode, @@ -232,6 +232,9 @@ import v2.std.node { Symbol, symbol_intern_lexeme, symbol_lexeme, + core_edge_label, + core_edge_labels, + production_edge_label, } import v2.std.collection { Map, @@ -263,6 +266,8 @@ type NodeEntryMemberContext | NodeEntryAtomKindMembers | NodeEntryComputationKindMembers | NodeEntryNamedEdgeMembers + | NodeEntryCoreMarkerEdgeMembers + | NodeEntryProductionEdgeMembers | NodeEntryPositionalEdgeMembers type NodeEntryDecodeRefusal @@ -535,11 +540,22 @@ fn encode_kind(k: NodeKind) -> JsonValue { fn encode_label(l: EdgeLabel) -> List { match l { - Named { name: n } => + Authored { name: n } => [ json_kv(key: "label", value: json_string(s: "named")), json_kv(key: "name", value: json_string(s: symbol_lexeme(sym: n))), ] + StructuralLabel { label: CoreMarker { marker: m } } => + [ + json_kv(key: "label", value: json_string(s: "structural_core")), + json_kv(key: "marker", value: json_string(s: symbol_lexeme(sym: core_edge_label_canonical_symbol(marker: m)))), + ] + StructuralLabel { label: ProductionEdge { language: lang, edge: p } } => + [ + json_kv(key: "label", value: json_string(s: "structural_production")), + json_kv(key: "language", value: json_string(s: symbol_lexeme(sym: lang))), + json_kv(key: "edge", value: json_string(s: symbol_lexeme(sym: p))), + ] Positional => [json_kv(key: "label", value: json_string(s: "positional"))] } } @@ -970,12 +986,65 @@ fn decode_named_label(edge_value: JsonValue) -> LabelDecode { match read_string_member(v: edge_value, key: "name") { MemberFailed { cause: c } => LabelDecodeFailed { cause: NodeEntryMemberReadRefused { cause: c } } MemberString { value: lexeme } => - LabelDecoded { label: Named { name: symbol_intern_lexeme(lexeme: lexeme) } } + LabelDecoded { label: Authored { name: symbol_intern_lexeme(lexeme: lexeme) } } _ => LabelDecodeFailed { cause: NodeEntryMemberReadRefused { cause: MemberReadWrongShape { key: "name" } } } } } } +// A core marker travels as the marker's canonical symbol and comes back only as one of the closed +// set's arms: a symbol no arm spells is an unknown label and refuses, never an Authored fallback. +fn decode_core_marker_label(edge_value: JsonValue) -> LabelDecode { + match node_entry_member_set_refusal( + v: edge_value, + allowed: ["label", "marker", "target"], + context: NodeEntryCoreMarkerEdgeMembers + ) { + Present { value: c } => LabelDecodeFailed { cause: c } + Absent => + match read_string_member(v: edge_value, key: "marker") { + MemberFailed { cause: c } => LabelDecodeFailed { cause: NodeEntryMemberReadRefused { cause: c } } + MemberString { value: lexeme } => { + let sym = symbol_intern_lexeme(lexeme: lexeme) + fold(core_edge_labels(), init: LabelDecodeFailed { cause: NodeEntryUnknownLabelTag { found: lexeme } }, f: fn(acc, m) { + if core_edge_label_canonical_symbol(marker: m) == sym { LabelDecoded { label: core_edge_label(marker: m) } } else { acc } + }) + } + MemberArray { elements: _ } => LabelDecodeFailed { cause: NodeEntryMemberReadRefused { cause: MemberReadWrongShape { key: "marker" } } } + MemberObject { value: _ } => LabelDecodeFailed { cause: NodeEntryMemberReadRefused { cause: MemberReadWrongShape { key: "marker" } } } + } + } +} + +fn decode_production_label(edge_value: JsonValue) -> LabelDecode { + match node_entry_member_set_refusal( + v: edge_value, + allowed: ["label", "language", "edge", "target"], + context: NodeEntryProductionEdgeMembers + ) { + Present { value: c } => LabelDecodeFailed { cause: c } + Absent => + match read_string_member(v: edge_value, key: "language") { + MemberFailed { cause: c } => LabelDecodeFailed { cause: NodeEntryMemberReadRefused { cause: c } } + MemberString { value: language } => + match read_string_member(v: edge_value, key: "edge") { + MemberFailed { cause: c } => LabelDecodeFailed { cause: NodeEntryMemberReadRefused { cause: c } } + MemberString { value: edge } => + LabelDecoded { + label: production_edge_label( + language: symbol_intern_lexeme(lexeme: language), + edge: symbol_intern_lexeme(lexeme: edge) + ) + } + MemberArray { elements: _ } => LabelDecodeFailed { cause: NodeEntryMemberReadRefused { cause: MemberReadWrongShape { key: "edge" } } } + MemberObject { value: _ } => LabelDecodeFailed { cause: NodeEntryMemberReadRefused { cause: MemberReadWrongShape { key: "edge" } } } + } + MemberArray { elements: _ } => LabelDecodeFailed { cause: NodeEntryMemberReadRefused { cause: MemberReadWrongShape { key: "language" } } } + MemberObject { value: _ } => LabelDecodeFailed { cause: NodeEntryMemberReadRefused { cause: MemberReadWrongShape { key: "language" } } } + } + } +} + fn decode_positional_label(edge_value: JsonValue) -> LabelDecode { match node_entry_member_set_refusal( v: edge_value, @@ -993,6 +1062,10 @@ fn decode_label(edge_value: JsonValue) -> LabelDecode { MemberString { value: tag } => if tag == "named" { decode_named_label(edge_value: edge_value) + } else if tag == "structural_core" { + decode_core_marker_label(edge_value: edge_value) + } else if tag == "structural_production" { + decode_production_label(edge_value: edge_value) } else if tag == "positional" { decode_positional_label(edge_value: edge_value) } else { diff --git a/dag/gunbc/scm/role_requirement_integration.dag b/dag/gunbc/scm/role_requirement_integration.dag index 6eaf7b6aed6..84c32fdc06d 100644 --- a/dag/gunbc/scm/role_requirement_integration.dag +++ b/dag/gunbc/scm/role_requirement_integration.dag @@ -6,7 +6,7 @@ import v2.std.node { Node, Edge, Symbol, - Named, + Authored, StructuralLabel, EdgeLabel, TypeNode, Conj, @@ -272,7 +272,8 @@ type RoleRequirementIntegrationOutcome fn edge_label_role(label: EdgeLabel) -> Symbol? { match label { - Named { name: name } => Present { value: name } + Authored { name: name } => Present { value: name } + StructuralLabel { label: _ } => none Positional => none } } @@ -628,7 +629,7 @@ fn root_edge_for(store: ObjectStore, acc: RoleRequirementRootAcc, role: Symbol, } CheckedOut { program: program } => RoleRequirementRootAcc { - edges: concat([Edge { label: Named { name: role }, target: program }], acc.edges), + edges: concat([Edge { label: Authored { name: role }, target: program }], acc.edges), refusal: none, } } diff --git a/dag/std/effects.dag b/dag/std/effects.dag index 410363acb2c..b5d658bf817 100644 --- a/dag/std/effects.dag +++ b/dag/std/effects.dag @@ -239,7 +239,7 @@ fn derive_op_effect( // AN OPERATION'S DECLARED EFFECT CLAIM: the effect arms of the surface operation modifier // (`readonly`, `idempotent`). This is the one authority for which effect claims exist. A lowered -// Arrow carries them on v2.std.node ^arrow_effect_claims_edge, spelled through +// Arrow carries them on v2.std.node CoreEdgeLabel ArrowEffectClaimsEdge, spelled through // v2.std.arrow_contract effect_claim_label, and check_modifier_vs_derivation judges whether a claim // agrees with the derived EffectShape. `hermetic` is not an effect claim: it is a std.execution_mode // ExecutionMode claim, carried on its own edge (XL-2 ruling 2026-10-01). diff --git a/dag/test/claim/body_lowering_rejection_propagation_test.dag b/dag/test/claim/body_lowering_rejection_propagation_test.dag index 25e155bdde6..b3bde3a1a15 100644 --- a/dag/test/claim/body_lowering_rejection_propagation_test.dag +++ b/dag/test/claim/body_lowering_rejection_propagation_test.dag @@ -5,7 +5,7 @@ import v2.std.text { String } import v2.std.algebra { fold_list } import v2.std.collection { List } import v2.std.diagnostic { Diagnostic, NonEmptyDiagnostics, None } -import v2.std.node { Atom, Conj, Edge, Named, Node, Symbol, TypeNode, node_synthetic } +import v2.std.node { Atom, Conj, Edge, Authored, Node, Symbol, TypeNode, node_synthetic } import v2.compiler.body_lowering_fold { BodyLowered, BodyLowering, @@ -42,7 +42,7 @@ fn emitted_shell(id: Symbol) -> Node { kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: ^grammar_production_identity_node_projection }, + label: Authored { name: ^grammar_production_identity_node_projection }, target: atom_node(id: id) } ] diff --git a/dag/test/claim/node_hash_protocol_witness_test.dag b/dag/test/claim/node_hash_protocol_witness_test.dag index 45022b29356..6f86f5d7e5d 100644 --- a/dag/test/claim/node_hash_protocol_witness_test.dag +++ b/dag/test/claim/node_hash_protocol_witness_test.dag @@ -7,7 +7,7 @@ import v2.std.node { Node, Edge, EdgeLabel, - Named, + Authored, Positional, Symbol, Connective, @@ -30,6 +30,9 @@ import v2.std.node { node_synthetic, node_with_occurrence_id, content_hash, + ArrowBodyEdge, + LoopBoundEdge, + core_edge, } // FNV1A64-STRUCTURAL-NODE-PROTOCOL-0 -- the conformance corpus for the node identity rule. @@ -57,6 +60,14 @@ import v2.std.node { // implementation would never have revealed this. // node = fold over CANONICAL children from the kind digest, each step // combine(combine(acc, label), child) +// label = Authored { name }: combine(atom("canonical_tag_named_edge"), atom(name)) +// core marker: combine(atom("canonical_tag_core_marker_edge"), atom(marker's +// canonical symbol, e.g. "arrow_body_edge")) +// Positional: atom("canonical_tag_positional_edge") +// The arrow-body and loop-bound vectors were re-derived by the same reference +// implementation when those edges became core markers (the EdgeLabel cut); it +// first reproduced their previous values, 838a07cf36bb337b and e1ea7ccc630cdeeb, +// under the old authored-label rule, so only the label rule moved. // // WHAT THIS CORPUS DOES NOT CLAIM, stated here so no reader and no review upgrades it: // - it does not prove injectivity; @@ -84,7 +95,7 @@ fn comp(b: Behavior, children: List) -> Node { } fn named(name: Symbol, target: Node) -> Edge { - Edge { label: Named { name: name }, target: target } + Edge { label: Authored { name: name }, target: target } } fn positional(target: Node) -> Edge { @@ -183,20 +194,20 @@ test fn positional_edges_discipline_matches_its_vector() -> Bool { // canonical order at once. test fn arrow_body_discipline_matches_its_vector() -> Bool { digest_of(n: ty(c: Arrow, children: [ - named(name: ^arrow_body_edge, target: atom_node(identity: ^body)), + core_edge(marker: ArrowBodyEdge, target: atom_node(identity: ^body)), named(name: ^g, target: atom_node(identity: ^beta)), positional(target: atom_node(identity: ^sig)), named(name: ^f, target: atom_node(identity: ^alpha)), - ])) == "838a07cf36bb337b" + ])) == "4b696908eff8d6e5" } test fn loop_bound_discipline_matches_its_vector() -> Bool { digest_of(n: comp(b: Loop, children: [ - named(name: ^loop_bound_edge, target: atom_node(identity: ^bound)), + core_edge(marker: LoopBoundEdge, target: atom_node(identity: ^bound)), named(name: ^g, target: atom_node(identity: ^beta)), positional(target: atom_node(identity: ^body)), named(name: ^f, target: atom_node(identity: ^alpha)), - ])) == "e1ea7ccc630cdeeb" + ])) == "e5456d4b1de1cf38" } // Parent assembly from child identities, two levels deep. @@ -320,10 +331,10 @@ test fn child_content_is_not_erased() -> Bool { // is the quotient), while the body edge carrying different content must change the digest. test fn arrow_body_content_is_not_erased() -> Bool { digest_of(n: ty(c: Arrow, children: [ - named(name: ^arrow_body_edge, target: atom_node(identity: ^body)), + core_edge(marker: ArrowBodyEdge, target: atom_node(identity: ^body)), positional(target: atom_node(identity: ^sig)), ])) != digest_of(n: ty(c: Arrow, children: [ - named(name: ^arrow_body_edge, target: atom_node(identity: ^other_body)), + core_edge(marker: ArrowBodyEdge, target: atom_node(identity: ^other_body)), positional(target: atom_node(identity: ^sig)), ])) } diff --git a/dag/test/claim/record_construction_census_witness_test.dag b/dag/test/claim/record_construction_census_witness_test.dag index b8a325872f3..fcda4b9a547 100644 --- a/dag/test/claim/record_construction_census_witness_test.dag +++ b/dag/test/claim/record_construction_census_witness_test.dag @@ -1,7 +1,7 @@ module test.claim.record_construction_census_witness_test import v2.std.decl_index { DeclFact, decl_facts } -import v2.std.node { Atom, Edge, Named, Node, NodeFold, Positional, Symbol, TypeNode, fold_node } +import v2.std.node { Atom, Edge, Authored, Node, NodeFold, Positional, Symbol, TypeNode, fold_node, StructuralLabel } import v2.std.collection { List } import v2.std.integer { Int } import v2.std.logic { Bool } @@ -41,7 +41,8 @@ type CensusConstructionCount { fn census_edge_is_construction(e: Edge) -> Bool { match e.label { - Named { name: nm } => nm == ^record_construction_spelling + StructuralLabel { label: _ } => false + Authored { name: nm } => nm == ^record_construction_spelling Positional => false } } diff --git a/dag/test/claim/scm/scm_commit_closure_json_v2_witness_test.dag b/dag/test/claim/scm/scm_commit_closure_json_v2_witness_test.dag index 0b84d5d0738..6e560f22003 100644 --- a/dag/test/claim/scm/scm_commit_closure_json_v2_witness_test.dag +++ b/dag/test/claim/scm/scm_commit_closure_json_v2_witness_test.dag @@ -40,7 +40,7 @@ import v2.std.node { Node, Edge, EdgeLabel, - Named, + Authored, Positional, NodeKind, TypeNode, @@ -193,7 +193,7 @@ fn closure_doc_atom(identity: Symbol) -> Node { } fn closure_doc_named(name: Symbol, target: Node) -> Edge { - Edge { label: Named { name: name }, target: target } + Edge { label: Authored { name: name }, target: target } } fn closure_doc_program() -> Node { @@ -783,7 +783,7 @@ fn scm_image_insert_children(kind: NodeKind, children: List, fallbac // carry; the assembly rule under test consumes the locator either way, so the claim is unchanged // while the fixture stops asserting a kind it did not establish. fn scm_image_named_stored(name: Symbol, target: ObjectId) -> StoredEdge { - StoredEdge { label: Named { name: name }, target: SemanticNodeTarget { locator: target } } + StoredEdge { label: Authored { name: name }, target: SemanticNodeTarget { locator: target } } } fn scm_image_positional_stored(target: ObjectId) -> StoredEdge { diff --git a/dag/test/claim/scm/scm_commit_closure_witness_test.dag b/dag/test/claim/scm/scm_commit_closure_witness_test.dag index 00c12253576..807d77688c2 100644 --- a/dag/test/claim/scm/scm_commit_closure_witness_test.dag +++ b/dag/test/claim/scm/scm_commit_closure_witness_test.dag @@ -14,7 +14,7 @@ module test.claim.scm_commit_closure_witness import std.types { Bool, Int, String, List, list_length, NonEmptyStr } import v2.std.algebra { non_empty_to_list } -import v2.std.node { Node, Edge, Symbol, Named, Conj, Atom, Cardinality, Positional, TypeNode, node_synthetic } +import v2.std.node { Node, Edge, Symbol, Authored, Conj, Atom, Cardinality, Positional, TypeNode, node_synthetic } import gunbc.scm.object_store { ObjectId, ObjectStore, @@ -117,7 +117,7 @@ fn child_node() -> Node { fn parent_node() -> Node { node_synthetic( kind: TypeNode { connective: Conj }, - children: [Edge { label: Named { name: ^only_child }, target: child_node() }], + children: [Edge { label: Authored { name: ^only_child }, target: child_node() }], ) } @@ -228,8 +228,8 @@ fn closure_two_child_parent_node() -> Node { node_synthetic( kind: TypeNode { connective: Conj }, children: [ - Edge { label: Named { name: ^alpha }, target: closure_alpha_child_node() }, - Edge { label: Named { name: ^beta }, target: closure_beta_child_node() }, + Edge { label: Authored { name: ^alpha }, target: closure_alpha_child_node() }, + Edge { label: Authored { name: ^beta }, target: closure_beta_child_node() }, ], ) } @@ -642,7 +642,7 @@ fn closure_over_an_occupied_locator() -> OccupiedFixture { store: with_file, kind: TypeNode { connective: Conj }, children: [ - StoredEdge { label: Named { name: ^only_child }, target: SemanticNodeTarget { locator: file.locator } }, + StoredEdge { label: Authored { name: ^only_child }, target: SemanticNodeTarget { locator: file.locator } }, ], ) { LocatorCollision { identity: _, existing: _, incoming: _ } => @@ -785,8 +785,8 @@ fn insert_two_named(store: ObjectStore, first_label: Symbol, first: SemanticNode store: store, kind: TypeNode { connective: Conj }, children: [ - StoredEdge { label: Named { name: first_label }, target: first }, - StoredEdge { label: Named { name: second_label }, target: second }, + StoredEdge { label: Authored { name: first_label }, target: first }, + StoredEdge { label: Authored { name: second_label }, target: second }, ], ) } @@ -1270,7 +1270,7 @@ fn closure_over_a_manifest_locator() -> OccupiedFixture { store: inventory.store, kind: TypeNode { connective: Conj }, children: [ - StoredEdge { label: Named { name: ^only_child }, target: SemanticNodeTarget { locator: inventory.manifest } }, + StoredEdge { label: Authored { name: ^only_child }, target: SemanticNodeTarget { locator: inventory.manifest } }, ], ) { LocatorCollision { identity: _, existing: _, incoming: _ } => diff --git a/dag/test/claim/scm/scm_load_standing_witness_test.dag b/dag/test/claim/scm/scm_load_standing_witness_test.dag index ed011ccdf0f..034f4f443b2 100644 --- a/dag/test/claim/scm/scm_load_standing_witness_test.dag +++ b/dag/test/claim/scm/scm_load_standing_witness_test.dag @@ -11,7 +11,7 @@ module test.claim.scm_load_standing_witness // everything onto one standing would satisfy any single-arm assertion and is caught only here. import std.types { Bool, Int, List } -import v2.std.node { Node, Edge, Named, Conj, Atom, TypeNode, node_synthetic } +import v2.std.node { Node, Edge, Authored, Conj, Atom, TypeNode, node_synthetic } import gunbc.scm.object_store { ObjectId, ObjectStore, StoreOutcome, Stored, LocatorCollision, SemanticNodeTarget, node_target_locator, @@ -67,7 +67,7 @@ fn ls_child() -> Node { fn ls_parent() -> Node { node_synthetic( kind: TypeNode { connective: Conj }, - children: [Edge { label: Named { name: ^only_child }, target: ls_child() }], + children: [Edge { label: Authored { name: ^only_child }, target: ls_child() }], ) } @@ -366,7 +366,7 @@ fn ls_requirement_over_a_file() -> LsOccupied { kind: TypeNode { connective: Conj }, children: [ StoredEdge { - label: Named { name: ^ls_only_child }, + label: Authored { name: ^ls_only_child }, target: SemanticNodeTarget { locator: file.locator }, }, ], diff --git a/dag/test/claim/scm/scm_object_store_witness_test.dag b/dag/test/claim/scm/scm_object_store_witness_test.dag index 37927be7aa0..069ea5daff5 100644 --- a/dag/test/claim/scm/scm_object_store_witness_test.dag +++ b/dag/test/claim/scm/scm_object_store_witness_test.dag @@ -21,7 +21,7 @@ import v2.std.node { Conj, Edge, EdgeLabel, - Named, + Authored, Symbol, ComputationNode, Behavior, @@ -97,7 +97,7 @@ fn atom_node(identity: Symbol) -> Node { } fn named_edge(name: Symbol, target: Node) -> Edge { - Edge { label: Named { name: name }, target: target } + Edge { label: Authored { name: name }, target: target } } fn program_a() -> Node { diff --git a/dag/test/claim/scm/scm_object_table_json_witness_test.dag b/dag/test/claim/scm/scm_object_table_json_witness_test.dag index 7608d25adde..10180cfbadf 100644 --- a/dag/test/claim/scm/scm_object_table_json_witness_test.dag +++ b/dag/test/claim/scm/scm_object_table_json_witness_test.dag @@ -20,7 +20,7 @@ module test.claim.scm_object_table_json_witness // closure document's concern; what is asserted is that the TABLE preserves what it was given. import std.types { Bool, Int, String, List, list_length, NonEmptyStr } -import v2.std.node { Node, Edge, Symbol, Named, Conj, Atom, TypeNode, node_synthetic } +import v2.std.node { Node, Edge, Symbol, Authored, Conj, Atom, TypeNode, node_synthetic } import extdeps.languages.json.emit { json_object, json_kv, json_array, json_string, json_null, JsonValue } import gunbc.scm.object_store { ObjectId, diff --git a/dag/test/claim/scm/scm_repository_envelope_witness_test.dag b/dag/test/claim/scm/scm_repository_envelope_witness_test.dag index e98a95d13ea..35061f4fd8e 100644 --- a/dag/test/claim/scm/scm_repository_envelope_witness_test.dag +++ b/dag/test/claim/scm/scm_repository_envelope_witness_test.dag @@ -23,7 +23,7 @@ import extdeps.languages.json.parse { } import v2.std.node { - Node, Edge, Named, TypeNode, Connective, Atom, Conj, Symbol, node_synthetic, + Node, Edge, Authored, TypeNode, Connective, Atom, Conj, Symbol, node_synthetic, } import gunbc.scm.object_store { @@ -148,7 +148,7 @@ fn scm_env_atom(identity: Symbol) -> Node { } fn scm_env_named(name: Symbol, target: Node) -> Edge { - Edge { label: Named { name: name }, target: target } + Edge { label: Authored { name: name }, target: target } } // Two programs SHARING a subtree. The shared-population claim is meaningless without real sharing. @@ -1705,7 +1705,7 @@ test fn scm_env_a_source_occupied_target_refuses_to_encode_as_its_own_cause() -> store: with_file, kind: TypeNode { connective: Conj }, children: [ - StoredEdge { label: Named { name: ^only_child }, target: SemanticNodeTarget { locator: file.locator } }, + StoredEdge { label: Authored { name: ^only_child }, target: SemanticNodeTarget { locator: file.locator } }, ], ) { LocatorCollision { identity: _, existing: _, incoming: _ } => empty_store() @@ -2038,7 +2038,7 @@ fn scm_env_child_over(store: ObjectStore, locator: ObjectId) -> ObjectStore { store: store, kind: TypeNode { connective: Conj }, children: [ - StoredEdge { label: Named { name: ^only_child }, target: SemanticNodeTarget { locator: locator } }, + StoredEdge { label: Authored { name: ^only_child }, target: SemanticNodeTarget { locator: locator } }, ], ) { LocatorCollision { identity: _, existing: _, incoming: _ } => empty_store() diff --git a/dag/test/claim/scm/scm_role_requirement_integration_witness_test.dag b/dag/test/claim/scm/scm_role_requirement_integration_witness_test.dag index 9af7559ff32..f7c58def96a 100644 --- a/dag/test/claim/scm/scm_role_requirement_integration_witness_test.dag +++ b/dag/test/claim/scm/scm_role_requirement_integration_witness_test.dag @@ -6,7 +6,7 @@ import v2.std.node { Node, Edge, Symbol, - Named, + Authored, TypeNode, Conj, Atom, @@ -79,7 +79,7 @@ fn scope_of(edges: List) -> Node { } fn integration_witness_bind(name: Symbol, target: Node) -> Edge { - Edge { label: Named { name: name }, target: target } + Edge { label: Authored { name: name }, target: target } } type Fixture { @@ -751,7 +751,7 @@ fn integration_witness_role_over_a_file_fixture() -> Fixture { store: with_file, kind: TypeNode { connective: Conj }, children: [ - StoredEdge { label: Named { name: ^s }, target: SemanticNodeTarget { locator: file.locator } }, + StoredEdge { label: Authored { name: ^s }, target: SemanticNodeTarget { locator: file.locator } }, ], ) { LocatorCollision { identity: i, existing: _, incoming: _ } => @@ -780,7 +780,7 @@ fn integration_witness_role_over_a_node_fixture() -> Fixture { store: with_child, kind: TypeNode { connective: Conj }, children: [ - StoredEdge { label: Named { name: ^s }, target: SemanticNodeTarget { locator: child.locator } }, + StoredEdge { label: Authored { name: ^s }, target: SemanticNodeTarget { locator: child.locator } }, ], ) { LocatorCollision { identity: i, existing: _, incoming: _ } => diff --git a/dag/test/claim/scm/scm_supersession_witness_test.dag b/dag/test/claim/scm/scm_supersession_witness_test.dag index 7f6b09df44e..528173457b8 100644 --- a/dag/test/claim/scm/scm_supersession_witness_test.dag +++ b/dag/test/claim/scm/scm_supersession_witness_test.dag @@ -22,7 +22,7 @@ module test.claim.scm_supersession_witness import std.types { Bool, String } import std.decl_ref { DeclarationRef } import v2.std.live_tree { LiveTreeDisposition, SubstrateInputsOnly } -import v2.std.node { Node, Symbol, Edge, Named, Conj, Atom, TypeNode, node_synthetic } +import v2.std.node { Node, Symbol, Edge, Authored, Conj, Atom, TypeNode, node_synthetic } import gunbc.scm.object_store { ObjectId, ObjectStore, Stored, LocatorCollision, empty_store, store_node, object_id_eq, diff --git a/docs/plans/edge-label-coproduct/README.md b/docs/plans/edge-label-coproduct/README.md index a8f9078f28a..b05f9f5fd4f 100644 --- a/docs/plans/edge-label-coproduct/README.md +++ b/docs/plans/edge-label-coproduct/README.md @@ -1,6 +1,6 @@ # Typed EdgeLabel coproduct — model proposal (step 1 of 2) -Status: MODEL PR for neat-boar-16's review. No `.dag` changes; the cut (step 2) lands root-first only after this model is approved. +Status: model approved and landed (gunbc#12473). Step 2, the cut, is the follow-up PR from quiet-koi-814; its scope was ruled by gentle-koi-724 (see "Step 2 as landed" below). Climb on record: `gunbc.recurring_failure_mode` `behavior_named_edge_label_validated_not_constructed` (the next-rung trigger names "edge labels ... a closed coproduct owned by `v2.std.node`"). No parallel RFM row is filed. The text-matching readers below are a second instance of that class, and the step-2 PR adds their evidence to that row. ## Defect @@ -84,3 +84,14 @@ Every declaration below lands in the step-2 cut together with its consumers. Non 2. The real structural labels still route (positive control over the real ingest path). 3. A mutation that re-keys a reader on text makes the control red. 4. Gating: base-vs-head over shape consumers, neat-boar-16's srv1 per-file native census, and self-host. + +## Step 2 as landed + +Arm names differ from the sketch above because `.dag` names are corpus-global and `Structural`, `Production` and `Core`-prefixed spellings already name other types: the arms are `Authored { name }`, `StructuralLabel { label: StructuralEdgeLabel }` and `Positional`, with `StructuralEdgeLabel = CoreMarker { marker: CoreEdgeLabel } | ProductionEdge { language, edge }`. + +- **Root first.** `Named { name: Symbol }` was deleted and every site renamed to `Authored` in the same change; the compiler's exhaustiveness refusals were the census of every reader that had to decide what a structural edge means at its site. +- **Converted, every minter and reader:** the core markers (arrow body and signature order; loop bound, carrier and domain; match arm pattern and body; cast target, type annotation, type params, type body, type alias; declaration reference; field projection base and field) and the dag surface productions the four readers need (module header and its qualified name, where-refinement clause, import decl, import block, import decl block, import decl qualified name). `v2.std.node` `Path` steps and `ReferenceSite.position` carry whole labels. +- **Deviation, stated:** the positional-payload field `"0"` stays Authored. It is consumed as `DeclaredField.name` like every authored field, so making it a marker would fork the field-name authority. +- **Frontier:** grammar-emitted labels no converted reader matches stay on the Authored arm. The population (by minting declaration) and the capability trigger are recorded on `gunbc.recurring_failure_mode` `behavior_named_edge_label_validated_not_constructed`. +- **Identity:** an authored label keeps the tag every Named edge had, so only nodes holding a structural label change identity. The two pinned vectors in `test.claim.node_hash_protocol_witness` that carry converted labels were re-derived by an independent reference implementation that first reproduced their previous values. +- **Coordination:** the construct tag (#12714) landed first, so this cut converted it to `ConstructTagEdge`. `^loop_realized_declaration_edge` (#12550) is not on main; whichever lands second adds its arm. diff --git a/src/v1/stage0/src/coproduct_reflection.rs b/src/v1/stage0/src/coproduct_reflection.rs index dd56ab2fde5..9647b9305a2 100644 --- a/src/v1/stage0/src/coproduct_reflection.rs +++ b/src/v1/stage0/src/coproduct_reflection.rs @@ -188,7 +188,7 @@ fn edge_named(ctx: &InterpContext, name: &str, target: Value) -> Value { ctx.sym("label"), Value::Variant { type_name: ctx.sym("EdgeLabel"), - variant_name: ctx.sym("Named"), + variant_name: ctx.sym("Authored"), fields: Rc::new(vec![(ctx.sym("name"), str_value(name.to_string()))]), }, ), diff --git a/src/v1/stage0/src/data_initializer_identity.rs b/src/v1/stage0/src/data_initializer_identity.rs index f877acc5b34..8a63eac054b 100644 --- a/src/v1/stage0/src/data_initializer_identity.rs +++ b/src/v1/stage0/src/data_initializer_identity.rs @@ -688,7 +688,7 @@ fn projection_edge_named(ctx: &InterpContext, name: &str, target: Value) -> Valu ctx.sym("label"), Value::Variant { type_name: ctx.sym("EdgeLabel"), - variant_name: ctx.sym("Named"), + variant_name: ctx.sym("Authored"), fields: Rc::new(vec![(ctx.sym("name"), str_value(name.to_string()))]), }, ), diff --git a/src/v1/tests/src/decl_facts_dimensionless_projection_test.rs b/src/v1/tests/src/decl_facts_dimensionless_projection_test.rs index fe367d460e8..8208b20f27d 100644 --- a/src/v1/tests/src/decl_facts_dimensionless_projection_test.rs +++ b/src/v1/tests/src/decl_facts_dimensionless_projection_test.rs @@ -111,7 +111,7 @@ fn edge_target_named(ctx: &InterpContext, projection: &Value, label: &str) -> Op fields: label_fields, .. }) => { - if *variant_name != ctx.sym("Named") { + if *variant_name != ctx.sym("Authored") { continue; } match ctx.field(label_fields, "name") { diff --git a/src/v2/compiler/00_compile.dag b/src/v2/compiler/00_compile.dag index 46ba3e6b900..625dc4f660e 100644 --- a/src/v2/compiler/00_compile.dag +++ b/src/v2/compiler/00_compile.dag @@ -192,7 +192,7 @@ import v2.std.diagnostic { outcome_rejected, outcome_with_diagnostics } -import v2.std.node { Arrow, Atom, ComputationNode, Edge, Named, Node, NodeFold, NodeKind, Positional, Symbol, TypeNode, fold_node, symbol_intern_lexeme, symbol_lexeme } +import v2.std.node { Arrow, Atom, ComputationNode, Edge, Node, NodeFold, NodeKind, Positional, Symbol, TypeNode, fold_node, symbol_intern_lexeme, symbol_lexeme, Authored, StructuralLabel } import v2.compiler.inferred_tree { AuthoredOccurrenceCollision, authored_occurrence_collisions } import v2.std.node_query { find_arrow_body_child, find_named_child } import v2.std.optional { Absent, Optional, Present, optional_absent, optional_present } @@ -1645,7 +1645,8 @@ fn native_test_decl_in_children(children: List, name: Symbol) -> Optional< Present { value: v } => optional_present(value: v) Absent => match e.label { - Named { name: edge_name } => + StructuralLabel { label: _ } => optional_absent() + Authored { name: edge_name } => if edge_name == name { optional_present(value: e.target) } else { diff --git a/src/v2/compiler/02_parse.dag b/src/v2/compiler/02_parse.dag index adcdd5aa264..5b1a8ee7ce4 100644 --- a/src/v2/compiler/02_parse.dag +++ b/src/v2/compiler/02_parse.dag @@ -43,7 +43,7 @@ import v2.std.node { Conj, Edge, Hash, - Named, + Authored, Node, Symbol, TypeNode, diff --git a/src/v2/compiler/03_body_producer.dag b/src/v2/compiler/03_body_producer.dag index d6691664c37..320e04023a1 100644 --- a/src/v2/compiler/03_body_producer.dag +++ b/src/v2/compiler/03_body_producer.dag @@ -14,12 +14,14 @@ import v2.std.node { Arrow, ComputationNode, Edge, - Named, + Authored, Node, Symbol, TypeNode, node_rebuild, - well_formed + well_formed, + ArrowBodyEdge, + core_edge_label, } import std.algebra { list_snoc_item } @@ -40,7 +42,7 @@ fn attach_arrow_body(arrow: Node, body: Node) -> Outcome { children: list_snoc_item( xs: arrow.children, item: Edge { - label: Named { name: ^arrow_body_edge }, + label: core_edge_label(marker: ArrowBodyEdge), target: body } ) diff --git a/src/v2/compiler/03_ingest.dag b/src/v2/compiler/03_ingest.dag index cdfef8d43d3..237cbd01fdd 100644 --- a/src/v2/compiler/03_ingest.dag +++ b/src/v2/compiler/03_ingest.dag @@ -37,7 +37,7 @@ import extdeps.communication.medium { Medium } import v2.compiler.translate { coerce_grounded_node } import v2.compiler.target_serialize { target_bundle_child } import v2.std.inhabitant_neutralization { neutralize_core_for_target } -import v2.std.node { Edge, Named, Node, Positional, Symbol, TypeNode, Conj } +import v2.std.node { Edge, Authored, StructuralLabel, Node, Positional, Symbol, TypeNode, Conj } import v2.std.diagnostic { Accepted, Diagnostic, @@ -133,7 +133,8 @@ fn grammar_relation_binding_to_token_class_map(rules: Node) -> Map binding_class_map_merge_row(acc: acc, row: e.target) + Authored { name: _ } => binding_class_map_merge_row(acc: acc, row: e.target) + StructuralLabel { label: _ } => acc Positional => acc } } @@ -165,7 +166,8 @@ fn grammar_relation_token_class_set(rules: Node) -> Map { init: empty_map(), f: fn(acc, e) { match e.label { - Named { name: _ } => token_class_set_merge_row(acc: acc, row: e.target) + Authored { name: _ } => token_class_set_merge_row(acc: acc, row: e.target) + StructuralLabel { label: _ } => acc Positional => acc } } @@ -226,7 +228,7 @@ fn operational_parse_tree_project_to_formal_captures( o: acc, f: fn(prefix) { match edge.label { - Named { name: n } => + Authored { name: n } => if n == ^grammar_production_identity_node_projection { outcome_accepted(value: prefix) } else { @@ -237,6 +239,13 @@ fn operational_parse_tree_project_to_formal_captures( token_classes: token_classes ) } + StructuralLabel { label: _ } => + parse_tree_frontier_extend( + prefix: prefix, + child: edge.target, + binding_to_class: binding_to_class, + token_classes: token_classes + ) Positional => parse_tree_frontier_extend( prefix: prefix, diff --git a/src/v2/compiler/03_name_resolve.dag b/src/v2/compiler/03_name_resolve.dag index bef39a69a83..f8dbc9f222e 100644 --- a/src/v2/compiler/03_name_resolve.dag +++ b/src/v2/compiler/03_name_resolve.dag @@ -26,7 +26,6 @@ import v2.std.resolution_policy { default_name_resolution_policy } import v2.extdeps.languages.dag { - dag_surface_module_header_metadata_edge, qualified_name_from_module_node } import v2.compiler.namespace_graft { @@ -430,9 +429,7 @@ fn module_root_find( fn try_admitted_export_binding(e: Edge) -> DeclaredBinding? { match try_edge_declared_binding(e: e) { Present { value: b } => - if dag_surface_module_header_metadata_edge(name: b.name) { - optional_absent() - } else if parse_tree_projection_edge(name: b.name) { + if parse_tree_projection_edge(name: b.name) { optional_absent() } else { optional_present(value: b) diff --git a/src/v2/compiler/03_resolve.dag b/src/v2/compiler/03_resolve.dag index 1eff8a7a713..2c2597a3014 100644 --- a/src/v2/compiler/03_resolve.dag +++ b/src/v2/compiler/03_resolve.dag @@ -115,6 +115,8 @@ import v2.std.symbol_index { symbol_index_renaming_alias_at } import v2.std.node { + MapLiteralEntriesEdge, + labeled_core_is, named_edges, positional_child_count, positional_edges, @@ -126,7 +128,7 @@ import v2.std.node { Disj, Edge, Match, - Named, + Authored, Node, NodeFold, Positional, @@ -140,28 +142,32 @@ import v2.std.node { loop_edge_role, symbol_intern_lexeme, symbol_lexeme, - match_arm_body, - match_arm_pattern, arrow_domain_binds_a_name, arrow_first_positional_target, - arrow_signature_order_label, - arrow_resource_requirements_label, arrow_named_edge_is_contract, + ArrowResourceRequirementsEdge, FirstPositionalAbsent, FirstPositionalFound, edge_label_of, node_with_occurrence_id, - construct_tag_marker, Instantiation, symbol_eq, symbol_lexeme, labeled_named_is, well_formed, + MatchArmPatternEdge, + ArrowSignatureOrderEdge, + edge_is_core, + StructuralLabel, + label_sort_key, + labeled_named_is, + ConstructTagEdge, + ArrowBodyEdge, + BinderDefaultEdge, } import v2.std.type_binder { GenericTypeDecl, PlainTypeDecl, type_decl_view, edge_is_cast_target, edge_is_type_annotation, edge_is_type_params, type_binder_first_mislabelled, type_binder_labels_conform, type_param_names } import v2.std.node_query { - binder_default_label, - binder_node_label, + binder_node_edge, binder_node_parts, declared_field_from_edge, member_edge_type_node, @@ -178,7 +184,8 @@ import v2.std.node_query { node_positional_child_targets, find_named_child, is_wildcard_pattern, - pattern_wildcard_name + pattern_wildcard_name, + find_core_child, } import std.occurrence_identity { NodeOccurrenceIdentity, OccurrenceId, OccurrenceMinted, OccurrenceProjected, OccurrenceSynthetic } import v2.std.list_introduction { list_introduction_elements_optional, list_introduction_head_path } @@ -190,7 +197,6 @@ import v2.std.map_introduction { MapLiteralEntriesNone, MapLiteralEntriesPresent, map_literal_entries, - map_literal_entries_label, lower_map_introduction, map_introduction_duplicate_key, map_introduction_expected_head_is_map @@ -376,7 +382,8 @@ fn empty_canonical_symbol_set() -> PointwisePower { fn try_edge_declared_binding(e: Edge) -> DeclaredBinding? { match e.label { - Named { name: sym } => optional_present(value: DeclaredBinding { name: sym }) + Authored { name: sym } => optional_present(value: DeclaredBinding { name: sym }) + StructuralLabel { label: _ } => optional_absent() Positional => optional_absent() } } @@ -648,13 +655,23 @@ fn resolve_ctx_with_declaring(ctx: ResolveContext, declaring: DeclaringPosition) // ONE NAMED EDGE'S STEP, AS THE FILL TAKES IT (v2.compiler.symbol_index_fill // symbol_index_fill_containment_edge): metadata and projection edges keep the path, every other // label extends it. -fn resolve_declaring_across_named_edge(declaring: DeclaringPosition, name: Symbol) -> DeclaringPosition { +fn resolve_declaring_across_named_edge(declaring: DeclaringPosition, e: Edge) -> DeclaringPosition { match declaring { DeclaringAt { path: path } => - if dag_surface_module_header_metadata_edge(name: name) || parse_tree_projection_edge(name: name) || binder_node_label(name: name) { - declaring - } else { - DeclaringAt { path: qualified_name_snoc(qn: path, segment: name) } + match e.label { + StructuralLabel { label: _ } => + if dag_surface_module_header_metadata_edge(e: e) || binder_node_edge(e: e) { + declaring + } else { + DeclaringAt { path: qualified_name_snoc(qn: path, segment: label_sort_key(label: e.label)) } + } + Authored { name: name } => + if parse_tree_projection_edge(name: name) { + declaring + } else { + DeclaringAt { path: qualified_name_snoc(qn: path, segment: name) } + } + Positional => declaring } DeclaringInSpine { path: _, body: _ } => declaring NotDeclaring => declaring @@ -1841,12 +1858,13 @@ fn resolve_transform_children( } else { resolve_node_walk(ctx: ctx, n: e.target) } - Named { name: _ } => + StructuralLabel { label: _ } => if edge_is_cast_target(e: e) { resolve_type_role_target(ctx: ctx, target: e.target) } else { resolve_node_walk(ctx: ctx, n: e.target) } + Authored { name: _ } => resolve_node_walk(ctx: ctx, n: e.target) } ) })) @@ -2018,7 +2036,7 @@ fn resolve_pattern_node_walk(ctx: ResolveContext, pat: Node) -> ResolveNodeWalk } // A CONSTRUCT RESOLVES ITS TAG AS A REFERENCE AND ITS FIELDS AS THEIR ROLE DEMANDS. The tag edge -// (v2.std.node construct_tag_marker) targets the constructor's authored path; it is resolved here, +// (v2.std.node CoreEdgeLabel ConstructTagEdge) targets the constructor's authored path; it is resolved here, // once, for a construction and a pattern alike, and the field edges are walked by the caller's // own rule (a value field as an ordinary child, a pattern field as a sub-pattern). The marker label // is a role, not a declaration segment, so it never extends the lookup position. @@ -2050,14 +2068,10 @@ fn resolve_construct_walk_with_tag( ResolveWalkRefused { first: _, rest: _, observation: _ } => Absent } child_walk_node(n: n, w: fold(n.children, init: child_walk_init(), f: fn(acc, e) { - match e.label { - Named { name: label } => - if symbol_eq(a: label, b: construct_tag_marker()) { - child_walk_step(w: acc, e: e, r: tag) - } else { - child_walk_step(w: acc, e: e, r: field(e, tag_path)) - } - Positional => child_walk_step(w: acc, e: e, r: field(e, tag_path)) + if edge_is_core(e: e, marker: ConstructTagEdge) { + child_walk_step(w: acc, e: e, r: tag) + } else { + child_walk_step(w: acc, e: e, r: field(e, tag_path)) } })) } @@ -2292,7 +2306,7 @@ fn resolve_map_first_name_keyed_item(items: List) -> Optional { fold(items, init: optional_absent(), f: fn(acc, e) { match acc { Present { value: _ } => acc - Absent => if labeled_named_is(x: e, label_of: edge_label_of, wanted: map_literal_entries_label()) { optional_absent() } else { optional_present(value: e.target) } + Absent => if labeled_core_is(x: e, label_of: edge_label_of, wanted: MapLiteralEntriesEdge) { optional_absent() } else { optional_present(value: e.target) } } }) } @@ -2428,12 +2442,13 @@ fn resolve_map_entry_walk(ctx: ResolveContext, entry: Node, value_x: ResolveExpe child_walk_step(w: acc, e: e, r: ResolveWalkAccepted { value: e.target, diagnostics: None, lexical: [] }) } else { match e.label { - Named { name: nm } => + Authored { name: nm } => if symbol_eq(a: nm, b: ^value) { child_walk_step(w: acc, e: e, r: resolve_expected_edge(ctx: ctx, e: e, x: value_x)) } else { child_walk_step(w: acc, e: e, r: resolve_child_edge(ctx: ctx, e: e)) } + StructuralLabel { label: _ } => child_walk_step(w: acc, e: e, r: resolve_child_edge(ctx: ctx, e: e)) Positional => child_walk_step(w: acc, e: e, r: resolve_child_edge(ctx: ctx, e: e)) } } @@ -2456,8 +2471,9 @@ fn resolve_record_field_edge(ctx: ResolveContext, e: Edge, record: Optional resolve_child_edge(ctx: ctx, e: e) Present { value: path } => match e.label { + StructuralLabel { label: _ } => resolve_child_edge(ctx: ctx, e: e) Positional => resolve_child_edge(ctx: ctx, e: e) - Named { name: field } => + Authored { name: field } => match resolve_record_field_type_optional(ctx: ctx, record: path, field: field) { Absent => resolve_child_edge(ctx: ctx, e: e) Present { value: t } => @@ -2593,7 +2609,7 @@ fn resolve_construct_tag_not_a_constructor(reference: Node) -> Outcome { } fn resolve_match_arm_walk(ctx: ResolveContext, arm: Node) -> ResolveNodeWalk { - match find_named_child(root: arm, name: match_arm_pattern) { + match find_core_child(root: arm, marker: MatchArmPatternEdge) { Rejected { diagnostics: _ } => resolve_children_homogeneous_scope(ctx: ctx, n: arm) Accepted { value: pat, diagnostics: _ } => let arm_ctx = resolve_ctx_with_scope( @@ -2604,14 +2620,10 @@ fn resolve_match_arm_walk(ctx: ResolveContext, arm: Node) -> ResolveNodeWalk { child_walk_step( w: acc, e: e, - r: match e.label { - Named { name: label } => - if label == match_arm_pattern { - resolve_pattern_node_walk(ctx: arm_ctx, pat: e.target) - } else { - resolve_node_walk(ctx: arm_ctx, n: e.target) - } - Positional => resolve_node_walk(ctx: arm_ctx, n: e.target) + r: if edge_is_core(e: e, marker: MatchArmPatternEdge) { + resolve_pattern_node_walk(ctx: arm_ctx, pat: e.target) + } else { + resolve_node_walk(ctx: arm_ctx, n: e.target) } ) })) @@ -2903,28 +2915,23 @@ fn resolve_where_refinement_clause(ctx: ResolveContext, n: Node) -> ResolveNodeW w: acc, e: e, r: match e.label { - Named { name: sym } => + Authored { name: sym } => if sym == ^grammar_production_captured_node_projection { resolve_where_predicate_set(ctx: ctx, set: e.target) } else { ResolveWalkAccepted { value: e.target, diagnostics: None, lexical: [] } } + StructuralLabel { label: _ } => ResolveWalkAccepted { value: e.target, diagnostics: None, lexical: [] } Positional => resolve_walk_refused_one(chain: diagnostics_singleton(d: malformed_tree_diagnostic(n: e.target))) } ) })) } -fn resolve_preserve_module_root_named_edge(name: Symbol, target: Node) -> Bool { - if dag_surface_module_header_metadata_edge(name: name) { - true - } else if dag_resolve_preserve_module_metadata_subtree(node: target) { - true - } else if name == ^grammar_production_identity_node_projection { - true - } else { - false - } +fn resolve_preserve_module_root_named_edge(e: Edge) -> Bool { + dag_surface_module_header_metadata_edge(e: e) + || dag_resolve_preserve_module_metadata_subtree(node: e.target) + || labeled_named_is(x: e, label_of: edge_label_of, wanted: ^grammar_production_identity_node_projection) } @@ -2935,23 +2942,8 @@ fn resolve_child_edge( e: Edge ) -> ResolveNodeWalk { match e.label { - Named { name: sym } => - if ctx.under_module_root - && resolve_preserve_module_root_named_edge(name: sym, target: e.target) { - ResolveWalkAccepted { value: e.target, diagnostics: None, lexical: [] } - } else { - let child_ctx = if ctx.under_module_root - && !dag_surface_module_header_metadata_edge(name: sym) - && !binder_node_label(name: sym) { - resolve_ctx_snoc_position(ctx: ctx, segment: sym) - } else { - ctx - } - resolve_node_walk( - ctx: resolve_ctx_with_declaring(ctx: child_ctx, declaring: resolve_declaring_across_named_edge(declaring: ctx.declaring, name: sym)), - n: e.target - ) - } + Authored { name: _ } => resolve_labeled_child_edge(ctx: ctx, e: e) + StructuralLabel { label: _ } => resolve_labeled_child_edge(ctx: ctx, e: e) Positional => if ctx.under_module_root && dag_resolve_preserve_module_metadata_subtree(node: e.target) { @@ -2962,6 +2954,24 @@ fn resolve_child_edge( } } +// A labeled edge under the module root extends the lexical position by the label's scope segment +// (label_sort_key), except a preserved metadata edge, which is accepted as its own target. +fn resolve_labeled_child_edge(ctx: ResolveContext, e: Edge) -> ResolveNodeWalk { + if ctx.under_module_root && resolve_preserve_module_root_named_edge(e: e) { + ResolveWalkAccepted { value: e.target, diagnostics: None, lexical: [] } + } else { + let child_ctx = if ctx.under_module_root && !dag_surface_module_header_metadata_edge(e: e) && !binder_node_edge(e: e) { + resolve_ctx_snoc_position(ctx: ctx, segment: label_sort_key(label: e.label)) + } else { + ctx + } + resolve_node_walk( + ctx: resolve_ctx_with_declaring(ctx: child_ctx, declaring: resolve_declaring_across_named_edge(declaring: ctx.declaring, e: e)), + n: e.target + ) + } +} + data arrow_domain_param_scoping_note: String = "Wave 1 Gate 1 A1: param scoping is arrow_domain_frame_binders over lowered Arrow domain Named edges (general-body-producer-design Stage A). dag_fn_decl_param_binding_atoms and scope_with_fn_decl_params dissolved. fn_decl ident now routes through StampLexeme and SymbolIndex fill carries module_qn.fn.param (parity proven by execution); domain construction remains interim param-list-walk (body_lower_domain_from_param_list) until domain is built from SymbolIndex lookup rather than walked from the param list." // Whether an Arrow scopes its domain's binders is v2.std.node arrow_domain_binds_a_name, the same @@ -3112,10 +3122,7 @@ fn resolve_arrow_body_or_named_edge(ctx: ResolveContext, arrow: Node, e: Edge) - } fn resolve_edge_is_arrow_body(e: Edge) -> Bool { - match e.label { - Named { name: sym } => symbol_eq(a: sym, b: ^arrow_body_edge) - Positional => false - } + edge_is_core(e: e, marker: ArrowBodyEdge) } fn resolve_node_consumes_expectation(n: Node) -> Bool { @@ -3156,12 +3163,12 @@ fn resolve_arrow_node_in(outer_ctx: ResolveContext, ctx: ResolveContext, n: Node let inner_ctx = resolve_ctx_leaving_containment(ctx: ctx) child_walk_node(n: n, w: fold(n.children, init: child_walk_init(), f: fn(acc, e) { match e.label { - Named { name: _ } => + StructuralLabel { label: _ } => if edge_is_type_params(e: e) { child_walk_step(w: acc, e: e, r: resolve_type_params_conj(ctx: outer_ctx, conj: e.target)) - } else if (edge_label_of(e: e) == arrow_signature_order_label) { + } else if edge_is_core(e: e, marker: ArrowSignatureOrderEdge) { child_walk_step(w: acc, e: e, r: ResolveWalkAccepted { value: e.target, diagnostics: None, lexical: [] }) - } else if (edge_label_of(e: e) == arrow_resource_requirements_label) { + } else if edge_is_core(e: e, marker: ArrowResourceRequirementsEdge) { child_walk_step(w: acc, e: e, r: resolve_arrow_resource_requirements(ctx: resolve_ctx_with_scope(ctx: inner_ctx, scope: scope_type), requirements: e.target)) } else if arrow_named_edge_is_contract(e: e) { child_walk_step(w: acc, e: e, r: ResolveWalkAccepted { value: e.target, diagnostics: None, lexical: [] }) @@ -3176,6 +3183,12 @@ fn resolve_arrow_node_in(outer_ctx: ResolveContext, ctx: ResolveContext, n: Node ) ) } + Authored { name: _ } => + child_walk_step( + w: acc, + e: e, + r: resolve_node_walk(ctx: resolve_ctx_with_scope(ctx: ctx, scope: scope_body), n: e.target) + ) Positional => if acc.ordinal == 0 { child_walk_step( @@ -3225,14 +3238,10 @@ fn resolve_arrow_domain_member(type_ctx: ResolveContext, default_ctx: ResolveCon } fn resolve_binder_part(type_ctx: ResolveContext, default_ctx: ResolveContext, part: Edge) -> ResolveNodeWalk { - match part.label { - Named { name: sym } => - if sym == binder_default_label() { - resolve_node_walk(ctx: default_ctx, n: part.target) - } else { - resolve_node_walk(ctx: type_ctx, n: part.target) - } - Positional => resolve_node_walk(ctx: type_ctx, n: part.target) + if edge_is_core(e: part, marker: BinderDefaultEdge) { + resolve_node_walk(ctx: default_ctx, n: part.target) + } else { + resolve_node_walk(ctx: type_ctx, n: part.target) } } diff --git a/src/v2/compiler/04_infer.dag b/src/v2/compiler/04_infer.dag index 93298fe88d8..2562e8f07c1 100644 --- a/src/v2/compiler/04_infer.dag +++ b/src/v2/compiler/04_infer.dag @@ -12,7 +12,7 @@ import v2.std.compilers.target_model { canonical_operation_op_add, canonical_operation_op_coerce, canonical_operation_wire_matches_operation, - target_model_canonical_operation_member_declared_type + target_model_canonical_operation_member_declared_type, } import v2.compiler.resolve { ResolvedTree, resolved_tree_lexical_binding } import v2.compiler.inferred_tree { @@ -62,9 +62,9 @@ import v2.std.optional { optional_present } import v2.std.qualified_name { QualifiedName, declaration_reference_node, declaration_reference_path_optional, lexical_reference_label_optional, parameter_reference_path_optional } -import v2.std.node_query { BinderParts, binder_node, binder_node_parts, construct_field_edges, construct_tag_optional, declared_field_from_edge } +import v2.std.node_query { BinderParts, binder_node, binder_node_parts, construct_field_edges, construct_tag_optional, declared_field_from_edge, find_labeled_child } import v2.std.symbol_index { RecordTypePayload, SymbolIndex, VariantArmPayload, symbol_index_declared_payload_at, symbol_index_declared_type_params_at, symbol_index_lookup } -import v2.std.node { Ambiguous, Found, NotMarkedReference, arrow_body_target_lookup, arrow_named_edge_is_contract, arrow_signature_order_edge, match_arm_pattern_edge, resolved_reference_body_kind } +import v2.std.node { Ambiguous, Found, NotMarkedReference, arrow_body_target_lookup, arrow_named_edge_is_contract, arrow_signature_order_edge, match_arm_pattern_edge, resolved_reference_body_kind, edge_label_of, MatchArmBodyEdge, MatchArmPatternEdge, production_edge_label } import v2.std.list_introduction { list_introduction_elements_optional, list_introduction_head_path } import v2.std.arrow_signature { ApplicationBindingRefused, @@ -135,6 +135,7 @@ import v2.std.diagnostic { } import v2.std.logic { Bool } import v2.std.node { + StructuralLabel, host_text_type_node, symbol_type_node, Arrow, @@ -149,7 +150,7 @@ import v2.std.node { Instantiation, Loop, Match, - Named, + Authored, Node, NodeFold, Positional, @@ -164,14 +165,12 @@ import v2.std.node { canonicalize_node_strip_provenance, fold_node, loop_edge_contributes_to_iteration_fold, - match_arm_body, - match_arm_pattern, node_subtree_nodes, well_formed, } import v2.std.type_binder { GenericTypeDecl, OpaqueTypeDecl, PlainTypeDecl, TypeAlias, cast_target_optional, declaration_binder_edge, edge_is_type_params, type_annotation_optional, type_decl_view, type_param_names } import v2.std.coercion { coercion_cast_crossing } -import v2.std.node_query { find_named_child, node_positional_child_targets } +import v2.std.node_query { node_positional_child_targets, find_core_child } import v2.std.witness { Holds, StructuralPropertyWitness, Violates, Witness, witness_from_optional } type AlgebraRef { @@ -1232,7 +1231,7 @@ fn refinement_declaration(index: SymbolIndex, reference: Node) -> Optional Absent Present { value: decl } => - match find_named_child(root: decl, name: ^dag_surface_where_refinement_clause) { + match find_labeled_child(root: decl, label: production_edge_label(language: ^dag_language_model_surface_id, edge: ^dag_surface_where_refinement_clause)) { Rejected { diagnostics: _ } => Absent Accepted { value: clause, diagnostics: _ } => match find_named_child(root: decl, name: ^dag_surface_type_expr) { @@ -1626,11 +1625,11 @@ fn infer_match_bool_arm_row( ) -> Outcome { match arm.kind { TypeNode { connective: Conj } => - match find_named_child(root: arm, name: match_arm_pattern) { + match find_core_child(root: arm, marker: MatchArmPatternEdge) { Rejected { diagnostics: _ } => outcome_rejected(infer_match_shape_invalid_diagnostic(node: arm)) Accepted { value: pat, diagnostics: pd } => - match find_named_child(root: arm, name: match_arm_body) { + match find_core_child(root: arm, marker: MatchArmBodyEdge) { Rejected { diagnostics: _ } => outcome_rejected(infer_match_shape_invalid_diagnostic(node: arm)) Accepted { value: body_target, diagnostics: bd } => @@ -3353,21 +3352,24 @@ fn infer_literal_edge_payload(parent: Node, edge: Edge) -> InferLiteralPayload { match dag_canonical_literal_from_node(node: parent) { Accepted { value: DagCanonicalIntLiteral { magnitude: _ }, diagnostics: _ } => match edge.label { - Named { name: field } => + StructuralLabel { label: _ } => InferNotALiteralPayload + Authored { name: field } => if field == ^integer_literal_magnitude_field { InferIntMagnitudePayload } else { InferNotALiteralPayload } Positional => InferNotALiteralPayload } Accepted { value: DagCanonicalSymbolLiteral { symbol: _ }, diagnostics: _ } => match edge.label { - Named { name: field } => + Authored { name: field } => if field == ^symbol_literal_name_field { InferSymbolNamePayload } else { InferNotALiteralPayload } + StructuralLabel { label: _ } => InferNotALiteralPayload Positional => InferNotALiteralPayload } Accepted { value: DagCanonicalBoolLiteral { value: _ }, diagnostics: _ } => InferNotALiteralPayload Accepted { value: DagCanonicalStringLiteral { value: _ }, diagnostics: _ } => match edge.label { - Named { name: field } => + Authored { name: field } => if field == ^string_literal_value_field { InferStringValuePayload } else { InferNotALiteralPayload } + StructuralLabel { label: _ } => InferNotALiteralPayload Positional => InferNotALiteralPayload } Rejected { diagnostics: _ } => InferNotALiteralPayload @@ -3594,7 +3596,8 @@ fn infer_sum_nullary_payload_edge(parent: Node, edge: Edge) -> Bool { match parent.kind { TypeNode { connective: Disj } => (match edge.label { - Named { name: _ } => true + StructuralLabel { label: _ } => false + Authored { name: _ } => true Positional => false }) && (length(xs: edge.target.children) == 0) @@ -3623,7 +3626,8 @@ fn infer_disj_is_named_sum(n: Node) -> Bool { (length(xs: n.children) > 0) && fold(n.children, init: true, f: fn(acc, e) { acc && match e.label { - Named { name: _ } => true + StructuralLabel { label: _ } => false + Authored { name: _ } => true Positional => false } }) @@ -3906,7 +3910,7 @@ fn infer_record_construct_refusal(reason: Symbol, at: Node, record: Node, field: node: Node { kind: TypeNode { connective: Conj }, children: [ - Edge { label: Named { name: ^inhabitance_record }, target: record }, + Edge { label: Authored { name: ^inhabitance_record }, target: record }, field ], occurrence_id: at.occurrence_id @@ -3945,7 +3949,8 @@ fn infer_record_construct_binding_reason(plan_reason: Symbol) -> Symbol { fn infer_record_actual_label_set(actuals: List) -> Map { fold(actuals, init: empty_map(), f: fn(m, e) { match e.label { - Named { name: label } => map_insert(m: m, key: label, value: true) + Authored { name: label } => map_insert(m: m, key: label, value: true) + StructuralLabel { label: _ } => m Positional => m } }) @@ -3971,8 +3976,9 @@ fn infer_record_first_positional_actual(actuals: List) -> Optional { Present { value: _ } => acc Absent => match e.label { + StructuralLabel { label: _ } => acc Positional => optional_present(value: e) - Named { name: _ } => acc + Authored { name: _ } => acc } } }) @@ -3994,7 +4000,7 @@ fn infer_record_construct_binding_refusal( reason: reason, at: node, record: construct.record, - field: Edge { label: Named { name: missing.parameter_identity }, target: missing.declared } + field: Edge { label: Authored { name: missing.parameter_identity }, target: missing.declared } ) Absent => application_parameter_order_diagnostic(application: node, reason: application_parameter_order_malformed_reason()) } diff --git a/src/v2/compiler/05_eval.dag b/src/v2/compiler/05_eval.dag index dbb60b025c7..d0cfbf90c5f 100644 --- a/src/v2/compiler/05_eval.dag +++ b/src/v2/compiler/05_eval.dag @@ -91,6 +91,7 @@ import v2.std.runtime { runtime_value_resolved_type } import v2.std.node { + StructuralLabel, positional_edges, ArrowBodyForm, Behavior, @@ -100,7 +101,7 @@ import v2.std.node { Edge, Hash, Loop, - Named, + Authored, Node, NodeFold, Positional, @@ -1419,7 +1420,8 @@ fn eval_bind_arrow_params( fn eval_domain_has_named_binder(domain: Node) -> Bool { fold(domain.children, init: false, f: fn(acc, e) { match e.label { - Named { name: _ } => true + StructuralLabel { label: _ } => acc + Authored { name: _ } => true Positional => acc } }) @@ -1509,8 +1511,9 @@ fn eval_transform_has_callee_reference(node: Node) -> Bool { ) { Accepted { value: e0, diagnostics: _ } => match e0.label { + StructuralLabel { label: _ } => false Positional => eval_node_is_callee_reference(node: e0.target) - Named { name: _ } => false + Authored { name: _ } => false } Rejected { diagnostics: _ } => false } diff --git a/src/v2/compiler/06_translate.dag b/src/v2/compiler/06_translate.dag index 2eb2cf1df6a..feb1e93027d 100644 --- a/src/v2/compiler/06_translate.dag +++ b/src/v2/compiler/06_translate.dag @@ -66,6 +66,10 @@ import v2.std.witness { Violates } import v2.std.node { + BinderTypeEdge, + edge_is_core, + is_positional, + StructuralLabel, Arrow, Atom, Cardinality, @@ -74,7 +78,7 @@ import v2.std.node { Disj, Edge, Instantiation, - Named, + Authored, Node, NodeFold, Positional, @@ -93,7 +97,6 @@ import v2.std.type_binder { import v2.std.node_query { binder_node_parts, find_binder_type, - binder_type_label, member_edge_type_node, find_arrow_body_child, find_named_child, @@ -1212,8 +1215,8 @@ fn translate_arrow_signature_split_from(labels: List, domain: Node, codo // the derived module-scoped spelling where the target has one, a located refusal where it has none // -- never the leaf, which is the collapse resolution refused to make. The spine is DONE at init, // so its segment children are never folded as slots. -// A BINDER NODE TRANSLATES AS ITS TYPE (XL-2 PR2b-3). Its child's translation, finalized -// against that type, is the binder's translation; its child is a value, not part of +// A BINDER NODE TRANSLATES AS ITS TYPE (XL-2 PR2b-3). Its BinderTypeEdge child's translation, finalized +// against that type, is the binder's translation; its BinderDefaultEdge child is a value, not part of // the type, so its fold result is discarded here whatever it was. A binder node with no type, or a // second type, refuses. fn translate_binder_node_step( @@ -1223,10 +1226,10 @@ fn translate_binder_node_step( child: Outcome, projection: TargetTypeExpressionProjection ) -> Outcome { - match e.label { - Positional => outcome_rejected(translate_type_expression_shape_missing_diagnostic(node: e.target)) - Named { name: sym } => - if sym == binder_type_label() { + if is_positional(e: e) { + outcome_rejected(translate_type_expression_shape_missing_diagnostic(node: e.target)) + } else { + if edge_is_core(e: e, marker: BinderTypeEdge) { match child { Rejected { diagnostics: cr } => Rejected { diagnostics: rejected_with_pending(pending: d, rejected: cr) } Accepted { value: child_acc, diagnostics: cd } => @@ -1347,7 +1350,11 @@ fn translate_algebra( translate_binder_node_step(done: done, d: d, e: e, child: child, projection: projection) TypeExprTranslateSlots { slots: slots } => match e.label { - Named { name: label } => + StructuralLabel { label: _ } => + outcome_rejected( + translate_type_expression_shape_missing_diagnostic(node: e.target) + ) + Authored { name: label } => match child { Rejected { diagnostics: cr } => Rejected { diagnostics: rejected_with_pending(pending: d, rejected: cr) } @@ -1397,7 +1404,11 @@ fn translate_algebra( } TypeExprTranslateVariants { variants: variants } => match e.label { - Named { name: label } => + StructuralLabel { label: _ } => + outcome_rejected( + translate_type_expression_shape_missing_diagnostic(node: e.target) + ) + Authored { name: label } => match child { Rejected { diagnostics: cr } => Rejected { diagnostics: rejected_with_pending(pending: d, rejected: cr) } diff --git a/src/v2/compiler/body_lowering_fold.dag b/src/v2/compiler/body_lowering_fold.dag index b6400b29a1c..1eb52cb08d6 100644 --- a/src/v2/compiler/body_lowering_fold.dag +++ b/src/v2/compiler/body_lowering_fold.dag @@ -54,6 +54,8 @@ import v2.extdeps.languages.dag { parse_qualified_name_segment_atoms_from_capture, parse_qualified_name_segments_from_capture, qualified_name_from_module_node, + dag_surface_edge_label, + dag_surface_edge_is, } import v2.std.anonymous_binder { DeclaredParameterList, anonymous_binder_mint_parameter_list, fresh_return_type_variable, fresh_type_variable } import v2.std.algebra { fold_list, list_map, length, zip_eq } @@ -84,7 +86,6 @@ import v2.std.compilers.body_lowering { lower_unary_prefix } import v2.std.list_introduction { lower_list_introduction } -import v2.std.map_introduction { map_literal_entries_label, map_literal_entry_label } import v2.std.arrow_signature { anonymous_signature_arrow, declared_signature, signature_order_edge } import v2.std.compilers.sugar { SugarSequencePair, sugar_sequence_pair_optional } import v2.std.grammar { GrammarExpr, GrammarExprFold, fold_grammar_expr } @@ -114,6 +115,14 @@ import v2.std.symbol_index { symbol_index_lookup } import v2.std.node { + ArrowEffectClaimsEdge, + ArrowExecutionModeClaimEdge, + ArrowResourceRequirementsEdge, + MapLiteralEntryEdge, + MapLiteralEntriesEdge, + core_edge, + labeled_core_is, + StructuralLabel, close_lowered_image, close_lowered_image_of, Arrow, @@ -128,21 +137,24 @@ import v2.std.node { Edge, EdgeLabel, Instantiation, - Named, + Authored, Node, Positional, Symbol, Transform, TypeNode, is_empty_conj_root, - match_arm_body, - match_arm_pattern, node_lowered_from, node_rebuild, node_synthetic, node_with_occurrence_id, symbol_intern_lexeme, symbol_lexeme, + ArrowBodyEdge, + MatchArmBodyEdge, + MatchArmPatternEdge, + core_edge_label, + edge_is_core, } import v2.std.type_binder { cast_target_edge, type_alias_wrapper, type_decl_wrapper, type_opaque_wrapper, type_param_names, type_params_edge } import v2.std.arrow_contract { effect_claim_label, hermetic_claim_label } @@ -401,7 +413,8 @@ fn body_lower_arrow_domain_named_bindings(root: Node) -> List { TypeNode { connective: Conj } => fold(root.children, init: Empty, f: fn(acc, e) { match e.label { - Named { name: sym } => Cons { head: sym, tail: acc } + StructuralLabel { label: _ } => acc + Authored { name: sym } => Cons { head: sym, tail: acc } Positional => acc } }) @@ -427,7 +440,8 @@ fn body_lower_param_binding_symbols_from_param_list(param_list: Node) -> Optiona Present { value: fold(edges, init: Empty, f: fn(acc, e) { match e.label { - Named { name: sym } => Cons { head: sym, tail: acc } + StructuralLabel { label: _ } => acc + Authored { name: sym } => Cons { head: sym, tail: acc } Positional => acc } }) @@ -631,7 +645,8 @@ fn body_lower_is_core_substrate(node: Node) -> Bool { fn body_lower_has_grammar_projection_edge(node: Node) -> Bool { fold(node.children, init: false, f: fn(acc, e) { acc || (match e.label { - Named { name: n } => parse_tree_projection_edge(name: n) + Authored { name: n } => parse_tree_projection_edge(name: n) + StructuralLabel { label: _ } => false Positional => false }) }) @@ -701,7 +716,8 @@ fn body_lower_is_pass_through_emitted(emitted: Symbol) -> Bool { fn body_lower_is_identity_projection_edge(edge: Edge) -> Bool { match edge.label { - Named { name: n } => n == ^grammar_production_identity_node_projection + StructuralLabel { label: _ } => false + Authored { name: n } => n == ^grammar_production_identity_node_projection Positional => false } } @@ -856,12 +872,13 @@ fn body_lower_where_leaf_atom_optional(node: Node) -> Optional { Present { value: _ } => acc Absent => match e.label { - Named { name: sym } => + Authored { name: sym } => if sym == ^grammar_production_identity_node_projection { acc } else { body_lower_where_leaf_atom_optional(node: e.target) } + StructuralLabel { label: _ } => body_lower_where_leaf_atom_optional(node: e.target) Positional => body_lower_where_leaf_atom_optional(node: e.target) } } @@ -884,12 +901,13 @@ fn body_lower_where_predicate_productions(node: Node) -> List { fn body_lower_where_predicate_productions_below(node: Node) -> List { fold(node.children, init: Empty, f: fn(acc, e) { match e.label { - Named { name: sym } => + Authored { name: sym } => if sym == ^grammar_production_identity_node_projection { acc } else { list_append(left: acc, right: body_lower_where_predicate_productions(node: e.target)) } + StructuralLabel { label: _ } => list_append(left: acc, right: body_lower_where_predicate_productions(node: e.target)) Positional => list_append(left: acc, right: body_lower_where_predicate_productions(node: e.target)) } }) @@ -974,7 +992,7 @@ fn body_lower_where_labelled_record(args: List, at: Node let labelled = fold(args, init: Empty, f: fn(acc, a) { match a { WhereArgumentLabelled { label: label, value: value } => - list_snoc_item(xs: acc, item: Edge { label: Named { name: label }, target: value }) + list_snoc_item(xs: acc, item: Edge { label: Authored { name: label }, target: value }) WhereArgumentPositional { value: _ } => acc } }) @@ -1056,7 +1074,8 @@ fn body_lower_where_predicates(preds: List, done: List) -> Outcome n == lowered.spelling + Authored { name: n } => n == lowered.spelling + StructuralLabel { label: _ } => false Positional => false } }) { @@ -1064,7 +1083,7 @@ fn body_lower_where_predicates(preds: List, done: List) -> Outcome Outcome { } } -// Conj is LabeledEdges: every child must be Named. The clause is a production-shaped Conj whose +// Conj is LabeledEdges: every child must be labeled. The clause is a production-shaped Conj whose // captured child is the predicate set above. The clause and each predicate call are images of their // sources, closed at the root each returns (v2.std.node close_lowered_image). fn body_lower_kept_where_clause(where_clause: Node) -> Outcome { @@ -1100,7 +1119,7 @@ fn body_lower_kept_where_clause(where_clause: Node) -> Outcome { kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: ^grammar_production_identity_node_projection }, + label: Authored { name: ^grammar_production_identity_node_projection }, target: node_with_occurrence_id( kind: TypeNode { connective: Atom { identity: ^dag_surface_where_refinement_clause } }, children: [], @@ -1108,7 +1127,7 @@ fn body_lower_kept_where_clause(where_clause: Node) -> Outcome { ) }, Edge { - label: Named { name: ^grammar_production_captured_node_projection }, + label: Authored { name: ^grammar_production_captured_node_projection }, target: predicates } ], @@ -1118,7 +1137,7 @@ fn body_lower_kept_where_clause(where_clause: Node) -> Outcome { kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: ^dag_surface_where_refinement_clause }, + label: dag_surface_edge_label(edge: ^dag_surface_where_refinement_clause), target: production } ], @@ -1134,9 +1153,9 @@ fn body_lower_type_variant_children_with_where( fields: Node ) -> List { let with_clause = [ - Edge { label: Named { name: ^dag_surface_type_expr }, target: base }, + Edge { label: Authored { name: ^dag_surface_type_expr }, target: base }, Edge { - label: Named { name: ^dag_surface_where_refinement_clause }, + label: dag_surface_edge_label(edge: ^dag_surface_where_refinement_clause), target: kept_clause } ] @@ -1145,7 +1164,7 @@ fn body_lower_type_variant_children_with_where( } else { list_snoc_item( xs: with_clause, - item: Edge { label: Named { name: ^dag_surface_field_decl_block }, target: fields } + item: Edge { label: Authored { name: ^dag_surface_field_decl_block }, target: fields } ) } } @@ -2990,7 +3009,7 @@ fn body_lower_generic_param_binder_optional(item: Node) -> Optional Edge { - Edge { label: Named { name: b.name }, target: body_lower_param_ref_atom(source: b.item, identity: b.name) } + Edge { label: Authored { name: b.name }, target: body_lower_param_ref_atom(source: b.item, identity: b.name) } } // The repeat tail of comma_list(item): each element is seq(opt(comma), item). @@ -3872,7 +3891,7 @@ fn body_lower_fn_decl_named_member_wrap(arrow: Node, fn_name: Symbol, source: No node_lowered_from( kind: TypeNode { connective: Conj }, children: [ - Edge { label: Named { name: fn_name }, target: arrow } + Edge { label: Authored { name: fn_name }, target: arrow } ], source: source ) @@ -4223,7 +4242,7 @@ fn body_lower_data_decl_to_member(shell: Node) -> Outcome { Edge { label: Positional, target: declared_type }, signature.order, Edge { - label: Named { name: ^arrow_body_edge }, + label: core_edge_label(marker: ArrowBodyEdge), target: body_lower_position_function_values(node: reified_body, path: body_lower_unpositioned_path()) } ] @@ -4275,7 +4294,7 @@ fn body_lower_fn_decl_arrow(shell: Node, sig: BodyLowerFnSignature, body: Option Present { value: b } => list_append( left: signature, - right: [Edge { label: Named { name: ^arrow_body_edge }, target: body_lower_position_function_values(node: b, path: body_lower_unpositioned_path()) }] + right: [Edge { label: core_edge_label(marker: ArrowBodyEdge), target: body_lower_position_function_values(node: b, path: body_lower_unpositioned_path()) }] ) } )), @@ -4926,11 +4945,13 @@ fn body_lower_function_value_signature(binders: List) -> Fu let minted: DeclaredParameterList = anonymous_binder_mint_parameter_list(edges: authored) fold(minted.edges, init: FunctionValueSignature { domain: no_edges, type_params: no_edges, order: minted.order }, f: fn(acc, e) { match e.label { - Named { name: label } => + StructuralLabel { label: _ } => + FunctionValueSignature { domain: list_snoc_item(xs: acc.domain, item: e), type_params: acc.type_params, order: acc.order } + Authored { name: label } => let tv = fresh_type_variable(path: body_lower_unpositioned_path(), label: label) FunctionValueSignature { domain: list_snoc_item(xs: acc.domain, item: binder_edge(name: label, type_node: body_lower_function_value_type_var_atom(tv: tv))), - type_params: list_snoc_item(xs: acc.type_params, item: Edge { label: Named { name: tv }, target: body_lower_function_value_type_var_atom(tv: tv) }), + type_params: list_snoc_item(xs: acc.type_params, item: Edge { label: Authored { name: tv }, target: body_lower_function_value_type_var_atom(tv: tv) }), order: acc.order } Positional => @@ -5011,10 +5032,7 @@ fn body_lower_arrow_declares_a_renamed_type_param(arrow: Node, renames: Map Bool { - match e.label { - Named { name: n } => n == ^arrow_body_edge - Positional => false - } + edge_is_core(e: e, marker: ArrowBodyEdge) } fn body_lower_fresh_type_variable_renames(arrow: Node, path: List) -> Map { @@ -5032,7 +5050,8 @@ fn body_lower_fresh_type_variable_renames(arrow: Node, path: List) -> Map, path: List, init: Map) -> Map { fold(edges, init: init, f: fn(acc, e) { match e.label { - Named { name: l } => + StructuralLabel { label: _ } => acc + Authored { name: l } => map_insert(m: acc, key: fresh_type_variable(path: body_lower_unpositioned_path(), label: l), value: fresh_type_variable(path: path, label: l)) Positional => acc } @@ -5056,9 +5075,10 @@ fn body_lower_rename_fresh_type_variables(node: Node, renames: Map + StructuralLabel { label: _ } => e.label + Authored { name: n } => match map_lookup(m: renames, key: n) { - Present { value: renamed } => Named { name: renamed } + Present { value: renamed } => Authored { name: renamed } Absent => e.label } Positional => e.label @@ -5092,7 +5112,7 @@ fn body_lower_function_value_arrow( CodomainElided => list_append( left: sig.type_params, - right: [Edge { label: Named { name: return_tv }, target: codomain_node }] + right: [Edge { label: Authored { name: return_tv }, target: codomain_node }] ) } let no_edges: List = [] @@ -5118,7 +5138,7 @@ fn body_lower_function_value_arrow( ], right: type_param_edges ), - right: [Edge { label: Named { name: ^arrow_body_edge }, target: reified }] + right: [Edge { label: core_edge_label(marker: ArrowBodyEdge), target: reified }] ) )), diagnostics: bd @@ -5190,7 +5210,7 @@ fn body_lower_call_arg_edge(arg_capture: Node) -> Outcome { Present { value: named } => bind_outcome( o: body_lower_arg_value_read(arg_capture: arg_capture, value_capture: named.value), - f: fn(value) { outcome_accepted(value: Edge { label: Named { name: named.label }, target: value }) } + f: fn(value) { outcome_accepted(value: Edge { label: Authored { name: named.label }, target: value }) } ) Absent => outcome_rejected( @@ -5306,6 +5326,10 @@ fn body_lower_call_arg_edges(items: List) -> Outcome> { bind_outcome(o: acc, f: fn(state) { bind_outcome(o: body_lower_call_arg_edge(arg_capture: item), f: fn(edge) { match edge.label { + StructuralLabel { label: _ } => + outcome_rejected( + d: body_lower_diagnostic(reason: ^body_lowering_reason_call_argument_list_shape_unread, n: item) + ) Positional => if state.seen_named { outcome_rejected( @@ -5318,7 +5342,7 @@ fn body_lower_call_arg_edges(items: List) -> Outcome> { seen_named: false }) } - Named { name: label } => + Authored { name: label } => if body_lowering_surface_identity_list_contains(xs: state.labels, target: label) { outcome_rejected( d: body_lower_diagnostic(reason: ^body_lowering_reason_argument_label_repeated, n: item) @@ -6290,8 +6314,8 @@ fn body_lower_match_arm_wire(pat_node: Node, body: Node) -> Node { node_synthetic( kind: TypeNode { connective: Conj }, children: [ - Edge { label: Named { name: match_arm_pattern }, target: pat_node }, - Edge { label: Named { name: match_arm_body }, target: body } + Edge { label: core_edge_label(marker: MatchArmPatternEdge), target: pat_node }, + Edge { label: core_edge_label(marker: MatchArmBodyEdge), target: body } ] ) } @@ -6490,7 +6514,7 @@ fn body_lower_field_pattern_edge(item: Node) -> Outcome { Present { value: field_name } => outcome_accepted( value: Edge { - label: Named { name: field_name }, + label: Authored { name: field_name }, target: body_lower_param_ref_atom(source: captured, identity: field_name) } ) @@ -6506,7 +6530,7 @@ fn body_lower_field_pattern_edge(item: Node) -> Outcome { match body_lower_pattern_lowered(pattern_capture: after_colon.right) { Rejected { diagnostics: r } => Rejected { diagnostics: r } Accepted { value: sub, diagnostics: d } => - Accepted { value: Edge { label: Named { name: field_name }, target: sub }, diagnostics: d } + Accepted { value: Edge { label: Authored { name: field_name }, target: sub }, diagnostics: d } } } } @@ -6529,7 +6553,7 @@ fn body_lower_pattern_field_edges(items: List, braced: Bool, witness: Node Present { value: only } => bind_outcome(o: body_lower_pattern_lowered(pattern_capture: only), f: fn(sub) { outcome_accepted( - value: [Edge { label: Named { name: positional_payload_field_name() }, target: sub }] + value: [Edge { label: Authored { name: positional_payload_field_name() }, target: sub }] ) }) } @@ -8513,11 +8537,11 @@ fn body_lowering_match_spine_identity_absent_fixture_spine() -> Node { kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: ^grammar_sequence_left_node_projection }, + label: Authored { name: ^grammar_sequence_left_node_projection }, target: lbrace }, Edge { - label: Named { name: ^grammar_sequence_right_node_projection }, + label: Authored { name: ^grammar_sequence_right_node_projection }, target: empty_interior } ] @@ -8526,11 +8550,11 @@ fn body_lowering_match_spine_identity_absent_fixture_spine() -> Node { kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: ^grammar_sequence_left_node_projection }, + label: Authored { name: ^grammar_sequence_left_node_projection }, target: match_kw }, Edge { - label: Named { name: ^grammar_sequence_right_node_projection }, + label: Authored { name: ^grammar_sequence_right_node_projection }, target: braced } ] @@ -8553,11 +8577,11 @@ fn body_lowering_match_field_name_spine() -> Node { kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: ^grammar_sequence_left_node_projection }, + label: Authored { name: ^grammar_sequence_left_node_projection }, target: match_kw }, Edge { - label: Named { name: ^grammar_sequence_right_node_projection }, + label: Authored { name: ^grammar_sequence_right_node_projection }, target: empty_suffix } ] @@ -8758,7 +8782,7 @@ fn body_lower_field_init_edge(item: Node) -> Outcome { Rejected { diagnostics: r } => Rejected { diagnostics: r } Accepted { value: value, diagnostics: d } => outcome_with_diagnostics( - value: Edge { label: Named { name: field_name }, target: value }, + value: Edge { label: Authored { name: field_name }, target: value }, diagnostics: d ) } @@ -8790,7 +8814,7 @@ fn parse_production_captured_child_optional_or_self(node: Node) -> Node { } } -// The entry edge: v2.std.map_introduction map_literal_entry_label, targeting a tag-elided construct +// The entry edge: v2.std.node CoreEdgeLabel MapLiteralEntryEdge, targeting a tag-elided construct // carrying `key` and `value`. Only resolve's map arm reads it. fn body_lower_map_literal_entry_edge(key: Node, after_key: Node, item: Node, refuse: Outcome) -> Outcome { match sugar_sequence_pair_optional(node: after_key) { @@ -8801,11 +8825,11 @@ fn body_lower_map_literal_entry_edge(key: Node, after_key: Node, item: Node, ref Accepted { value: value, diagnostics: d } => outcome_with_diagnostics( value: Edge { - label: Named { name: map_literal_entry_label() }, + label: core_edge_label(marker: MapLiteralEntryEdge), target: close_lowered_image(root: construct_node_elided( field_edges: [ - Edge { label: Named { name: ^key }, target: key }, - Edge { label: Named { name: ^value }, target: value } + Edge { label: Authored { name: ^key }, target: key }, + Edge { label: Authored { name: ^value }, target: value } ], source: item )) @@ -8821,12 +8845,12 @@ fn body_lower_map_literal_entry_edge(key: Node, after_key: Node, item: Node, ref // is returned as it is. fn body_lower_map_literal_entries_collapsed(edges: List, source: Node) -> List { let pairs = fold(edges, init: [], f: fn(acc, e) { - if labeled_named_is(x: e, label_of: edge_label_of, wanted: map_literal_entry_label()) { list_snoc_item(xs: acc, item: e.target) } else { acc } + if labeled_core_is(x: e, label_of: edge_label_of, wanted: MapLiteralEntryEdge) { list_snoc_item(xs: acc, item: e.target) } else { acc } }) match pairs { Empty => edges Cons { head: _, tail: _ } => - [Edge { label: Named { name: map_literal_entries_label() }, target: lower_list_introduction(elements: pairs, source: source) }] + [core_edge(marker: MapLiteralEntriesEdge, target: lower_list_introduction(elements: pairs, source: source))] } } @@ -8843,13 +8867,13 @@ fn body_lower_brace_key_kinds_refusal_optional(reference: Node, edges: List acc - Absent => if labeled_named_is(x: e, label_of: edge_label_of, wanted: map_literal_entry_label()) { optional_present(value: e) } else { optional_absent() } + Absent => if labeled_core_is(x: e, label_of: edge_label_of, wanted: MapLiteralEntryEdge) { optional_present(value: e) } else { optional_absent() } } }) let first_field = fold(edges, init: optional_absent(), f: fn(acc, e) { match acc { Present { value: _ } => acc - Absent => if labeled_named_is(x: e, label_of: edge_label_of, wanted: map_literal_entry_label()) { optional_absent() } else { optional_present(value: e) } + Absent => if labeled_core_is(x: e, label_of: edge_label_of, wanted: MapLiteralEntryEdge) { optional_absent() } else { optional_present(value: e) } } }) match first_entry { @@ -8971,7 +8995,7 @@ fn body_lower_record_literal_tag_optional(captured: Node) -> Optional Outcome> { match body_lower_record_brace_items_optional(brace: captured) { @@ -9275,10 +9299,7 @@ fn body_lower_forward_row_apply(shell: Node, emitted: Symbol) -> Outcome Bool { - match e.label { - Named { name: n } => n == ^dag_surface_where_refinement_clause - Positional => false - } + dag_surface_edge_is(e: e, edge: ^dag_surface_where_refinement_clause) } fn body_lower_find_where_host_conj(root: Node) -> Optional { @@ -9349,7 +9370,7 @@ fn body_lower_type_decl_member(shell: Node, type_name: Symbol, body: Node, type_ kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: type_name }, + label: Authored { name: type_name }, target: body_lower_type_decl_member_body(body: body, type_params: type_params) } ], @@ -9479,7 +9500,7 @@ fn body_lower_type_decl_declared(shell: Node, type_name: Symbol, target: Node) - fn body_lower_type_decl_declared_image(shell: Node, type_name: Symbol, target: Node) -> Node { node_with_occurrence_id( kind: TypeNode { connective: Conj }, - children: [Edge { label: Named { name: type_name }, target: target }], + children: [Edge { label: Authored { name: type_name }, target: target }], occurrence_id: shell.occurrence_id ) } @@ -9923,7 +9944,7 @@ fn body_lower_operation_member(acc: Outcome, member: Node } // `requires R, ..` (v2.extdeps.languages.dag dag_grammar_op_requires_expr) lowers to the target of the -// operation Arrow's ^arrow_resource_requirements_edge: a Conj with one Named edge per member, labelled +// operation Arrow's ArrowResourceRequirementsEdge: a Conj with one Authored edge per member, labelled // by the member's spelling as written and targeting its type reference, lowered by the one type-position // reader (body_lower_type_expr_lowered_optional) a parameter's type goes through. The label is only the // Conj's discipline (v2.std.node LabeledEdges: named, distinct), so a spelling written twice is @@ -9931,7 +9952,7 @@ fn body_lower_operation_member(acc: Outcome, member: Node // a declared resource and is not repeated under another spelling. A member that is not a readable type // expression refuses at the member. // `requires none` and `requires opaque` lower to a single childless Atom on the same edge, so the one -// carrier has three declared states (v2.std.node arrow_resource_requirements_label); an operation with +// carrier has three declared states (v2.std.node CoreEdgeLabel ArrowResourceRequirementsEdge); an operation with // no clause carries no edge, which D13 step (b) reads as Undecided, never as none. fn body_lower_operation_requires(shell: Node) -> Outcome { match parse_production_captured_child_optional(node: shell) { @@ -9961,7 +9982,7 @@ fn body_lower_operation_requires_members(shell: Node, captured: Node) -> Outcome if body_lower_edges_carry_name(edges: edges, name: label) { outcome_rejected(d: body_lower_diagnostic(reason: ^body_lowering_reason_operation_requirement_repeated, n: member)) } else { - outcome_accepted(value: list_snoc_item(xs: edges, item: Edge { label: Named { name: label }, target: type_node })) + outcome_accepted(value: list_snoc_item(xs: edges, item: Edge { label: Authored { name: label }, target: type_node })) } } } @@ -10000,7 +10021,8 @@ fn body_lower_operation_requires_member_label_optional(member: Node, type_node: fn body_lower_edges_carry_name(edges: List, name: Symbol) -> Bool { fold(edges, init: false, f: fn(seen, e) { match e.label { - Named { name: n } => seen || (n == name) + Authored { name: n } => seen || (n == name) + StructuralLabel { label: _ } => seen Positional => seen } }) @@ -10011,15 +10033,15 @@ fn body_lower_edges_carry_name(edges: List, name: Symbol) -> Bool { fn body_lower_operation_arrow_children(signature_edges: List, requires: Optional, claims: BodyLowerOperationClaims) -> List { let with_requires = match requires { Absent => signature_edges - Present { value: target } => list_snoc_item(xs: signature_edges, item: Edge { label: Named { name: ^arrow_resource_requirements_edge }, target: target }) + Present { value: target } => list_snoc_item(xs: signature_edges, item: core_edge(marker: ArrowResourceRequirementsEdge, target: target)) } let with_effects = match claims.effects { Empty => with_requires - Cons { head: _, tail: _ } => list_snoc_item(xs: with_requires, item: Edge { label: Named { name: ^arrow_effect_claims_edge }, target: body_lower_effect_claims_node(labels: claims.effects) }) + Cons { head: _, tail: _ } => list_snoc_item(xs: with_requires, item: core_edge(marker: ArrowEffectClaimsEdge, target: body_lower_effect_claims_node(labels: claims.effects))) } match claims.mode { Absent => with_effects - Present { value: mode } => list_snoc_item(xs: with_effects, item: Edge { label: Named { name: ^arrow_execution_mode_claim_edge }, target: node_synthetic(kind: TypeNode { connective: Atom { identity: mode } }, children: []) }) + Present { value: mode } => list_snoc_item(xs: with_effects, item: core_edge(marker: ArrowExecutionModeClaimEdge, target: node_synthetic(kind: TypeNode { connective: Atom { identity: mode } }, children: []))) } } @@ -10029,7 +10051,7 @@ fn body_lower_effect_claims_node(labels: List) -> Node { node_synthetic( kind: TypeNode { connective: Conj }, children: fold(labels, init: Empty, f: fn(acc, l) { - list_snoc_item(xs: acc, item: Edge { label: Named { name: l }, target: node_synthetic(kind: TypeNode { connective: Atom { identity: l } }, children: []) }) + list_snoc_item(xs: acc, item: Edge { label: Authored { name: l }, target: node_synthetic(kind: TypeNode { connective: Atom { identity: l } }, children: []) }) }) ) } @@ -10153,7 +10175,7 @@ fn body_lower_operation(shell: Node) -> Outcome { outcome_accepted( value: BodyLowerOperation { edge: Edge { - label: Named { name: op_name }, + label: Authored { name: op_name }, target: close_lowered_image(root: node_with_occurrence_id( kind: TypeNode { connective: Arrow }, children: body_lower_operation_arrow_children( @@ -10323,7 +10345,7 @@ fn body_lower_service_node_image(shell: Node, service_name: Symbol, operations: node_with_occurrence_id( kind: TypeNode { connective: Conj }, children: [ - Edge { label: Named { name: service_name }, target: body_lower_payload_node(edges: operations, source: shell) } + Edge { label: Authored { name: service_name }, target: body_lower_payload_node(edges: operations, source: shell) } ], occurrence_id: shell.occurrence_id ) diff --git a/src/v2/compiler/emit_produced.dag b/src/v2/compiler/emit_produced.dag index 34c7bb0c3ff..8dd465ef31d 100644 --- a/src/v2/compiler/emit_produced.dag +++ b/src/v2/compiler/emit_produced.dag @@ -35,7 +35,7 @@ import v2.std.diagnostic { node_locus, outcome_rejected } -import v2.std.node { Arrow, Atom, Conj, Disj, Edge, Named, Node, node_synthetic, Positional, Symbol, TypeNode } +import v2.std.node { Arrow, Atom, Conj, Disj, Edge, Authored, StructuralLabel, Node, node_synthetic, Positional, Symbol, TypeNode } import v2.std.qualified_name { declaration_reference_path_optional } import v2.std.type_binder { GenericTypeDecl, OpaqueTypeDecl, PlainTypeDecl, TypeAlias, type_decl_view } import v2.compiler.emit_semantic_decl { emit_semantic_type_decl, produced_type_binding } @@ -61,7 +61,13 @@ fn emit_produced_decl_inner_arrow(decl: Node) -> Outcome { match list_at_optional(xs: decl.children, index: 0) { Present { value: edge } => match edge.label { - Named { name: _ } => Accepted { value: edge.target, diagnostics: None } + Authored { name: _ } => Accepted { value: edge.target, diagnostics: None } + StructuralLabel { label: _ } => + Rejected { + diagnostics: diagnostics_singleton( + d: emit_produced_decl_diagnostic(reason: ^emit_produced_decl_unnamed, node: decl) + ) + } Positional => Rejected { diagnostics: diagnostics_singleton( @@ -113,11 +119,12 @@ fn emit_produced_decl_inner_arrow(decl: Node) -> Outcome { // variables from a declared parameter type, not from a field-access scrutinee. fn produced_decl_edge_is_decl(edge: Edge) -> Bool { match edge.label { - Named { name: _ } => + Authored { name: _ } => match edge.target.kind { TypeNode { connective: Arrow } => true _ => false } + StructuralLabel { label: _ } => false Positional => false } } @@ -180,8 +187,9 @@ type ModuleMemberClass fn module_member_class(edge: Edge, kinds: FreeMonoid) -> ModuleMemberClass { match edge.label { + StructuralLabel { label: _ } => ModuleMemberUnsupported Positional => ModuleMemberUnsupported - Named { name: n } => + Authored { name: n } => match edge.target.kind { TypeNode { connective: Arrow } => match find_arrow_body_child(root: edge.target) { @@ -370,7 +378,8 @@ fn emit_module_member(edge: Edge, target: TargetModel, realization_host: TargetM fn produced_module_edge_is_production_marker(edge: Edge) -> Bool { match edge.label { - Named { name: n } => n == ^grammar_production_identity_node_projection + Authored { name: n } => n == ^grammar_production_identity_node_projection + StructuralLabel { label: _ } => false Positional => false } } diff --git a/src/v2/compiler/fold_lowering.dag b/src/v2/compiler/fold_lowering.dag index 8a2749d19dc..56cabe1d6ad 100644 --- a/src/v2/compiler/fold_lowering.dag +++ b/src/v2/compiler/fold_lowering.dag @@ -46,14 +46,19 @@ import v2.std.node { Conj, Edge, Loop, - Named, + Authored, Node, Positional, Symbol, TypeNode, is_empty_conj_root, node_synthetic, - symbol_intern_lexeme + symbol_intern_lexeme, + LoopBoundEdge, + LoopCarrierEdge, + LoopDomainEdge, + LoopRealizedDeclarationEdge, + core_edge_label, } import std.decl_ref { DeclarationRef, WholeDeclaration } import v2.std.node_query { find_named_child, node_positional_child_targets } @@ -742,10 +747,10 @@ fn fold_recurrence_encoding(operands: FoldCallOperands) -> Node { kind: ComputationNode { behavior: Loop }, children: [ Edge { label: Positional, target: operands.step }, - Edge { label: Named { name: ^loop_domain_edge }, target: operands.collection }, - Edge { label: Named { name: ^loop_carrier_edge }, target: fold_carrier_binder_atom(binder: operands.carrier) }, - Edge { label: Named { name: ^loop_bound_edge }, target: fold_iteration_measure_atom() }, - Edge { label: Named { name: ^loop_realized_declaration_edge }, target: operands.head } + Edge { label: core_edge_label(marker: LoopDomainEdge), target: operands.collection }, + Edge { label: core_edge_label(marker: LoopCarrierEdge), target: fold_carrier_binder_atom(binder: operands.carrier) }, + Edge { label: core_edge_label(marker: LoopBoundEdge), target: fold_iteration_measure_atom() }, + Edge { label: core_edge_label(marker: LoopRealizedDeclarationEdge), target: operands.head } ] ) ) diff --git a/src/v2/compiler/ingested_fixture_arrows.dag b/src/v2/compiler/ingested_fixture_arrows.dag index 609906faae5..020cdd4cb13 100644 --- a/src/v2/compiler/ingested_fixture_arrows.dag +++ b/src/v2/compiler/ingested_fixture_arrows.dag @@ -24,7 +24,7 @@ import v2.std.node { ComputationNode, Conj, Edge, - Named, + Authored, Node, Positional, Symbol, @@ -220,7 +220,7 @@ fn ingested_add_decl_node(fn_name: Symbol) -> Outcome { kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: fn_name }, + label: Authored { name: fn_name }, target: arrow_with_body } ] diff --git a/src/v2/compiler/namespace_graft.dag b/src/v2/compiler/namespace_graft.dag index 0a7343c587c..eec49b35926 100644 --- a/src/v2/compiler/namespace_graft.dag +++ b/src/v2/compiler/namespace_graft.dag @@ -23,11 +23,14 @@ import v2.std.node { Cardinality, Conj, Edge, - Named, + Authored, Node, Positional, Symbol, TypeNode, + StructuralLabel, + edge_label_of, + labeled_named_is, } import v2.std.qualified_name { QualifiedName } import v2.compiler.parse { parse_tree_projection_edge } @@ -81,20 +84,20 @@ type ModuleRootEdgeDisposition // an export subset). import_decl units DISSOLVE at the unit partition // (NamespaceGraftUnitDisposition UnitDissolved): admitted upstream as Admission.imports. -fn namespace_graft_module_root_edge_disposition(name: Symbol) -> ModuleRootEdgeDisposition { - if dag_surface_module_header_metadata_edge(name: name) { +fn namespace_graft_module_root_edge_disposition(e: Edge) -> ModuleRootEdgeDisposition { + if dag_surface_module_header_metadata_edge(e: e) { ModuleRootEdgeDissolve - } else if name == ^grammar_production_identity_node_projection { + } else if labeled_named_is(x: e, label_of: edge_label_of, wanted: ^grammar_production_identity_node_projection) { ModuleRootEdgeRehomeProvenance - } else if name == ^grammar_production_captured_node_projection { + } else if labeled_named_is(x: e, label_of: edge_label_of, wanted: ^grammar_production_captured_node_projection) { ModuleRootEdgeDissolve } else { ModuleRootEdgeGraftBody } } -fn namespace_graft_is_metadata_edge(name: Symbol) -> Bool { - dag_surface_module_header_metadata_edge(name: name) +fn namespace_graft_is_metadata_edge(e: Edge) -> Bool { + dag_surface_module_header_metadata_edge(e: e) } fn namespace_graft_is_module_shell(root: Node) -> Bool { @@ -115,7 +118,8 @@ fn namespace_graft_is_transparent_sequence_spine(node: Node) -> Bool { false } else { match e.label { - Named { name: sym } => parse_tree_projection_edge(name: sym) + StructuralLabel { label: _ } => false + Authored { name: sym } => parse_tree_projection_edge(name: sym) Positional => true } } @@ -134,10 +138,10 @@ fn namespace_graft_collect_body_edge( acc } else { match edge.label { - Named { name: sym } => - if namespace_graft_is_metadata_edge(name: sym) { - acc - } else if parse_tree_projection_edge(name: sym) { + StructuralLabel { label: _ } => + if namespace_graft_is_metadata_edge(e: edge) { acc } else { list_snoc_item(xs: acc, item: edge) } + Authored { name: sym } => + if parse_tree_projection_edge(name: sym) { concat(acc, namespace_graft_collect_body_edges_from_node(node: edge.target, unit_ids: unit_ids)) } else if dag_resolve_preserve_module_metadata_subtree(node: edge.target) { acc @@ -274,7 +278,7 @@ fn namespace_graft_reconstruct_unit_edge(node: Node) -> Edge { fn namespace_graft_reconstruct_declaration_forest(units: List) -> List { [ Edge { - label: Named { name: ^dag_surface_top_level_item }, + label: Authored { name: ^dag_surface_top_level_item }, target: Node { kind: TypeNode { connective: Cardinality }, children: fold(units, init: [], f: fn(acc, unit) { @@ -317,7 +321,7 @@ fn namespace_graft_kw_ident_named_edge(unit: Node) -> Edge? { Present { value: rest } => optional_present( value: Edge { - label: Named { name: name }, + label: Authored { name: name }, target: rest } ) @@ -444,11 +448,10 @@ fn namespace_graft_partition_decl_units(units: List) -> NamespaceGraftDecl // two Named atoms. fn namespace_graft_keep_flattened_member_edge(edge: Edge) -> Bool { match edge.label { - Named { name: sym } => + StructuralLabel { label: _ } => false + Authored { name: sym } => if parse_tree_projection_edge(name: sym) { false - } else if namespace_graft_is_metadata_edge(name: sym) { - false } else if namespace_graft_target_is_production_shell(edge: edge) { false } else { @@ -474,7 +477,8 @@ fn namespace_graft_named_list_has_name(edges: List, name: Symbol) -> Bool true } else { match edge.label { - Named { name: n } => n == name + StructuralLabel { label: _ } => false + Authored { name: n } => n == name Positional => false } } @@ -484,7 +488,8 @@ fn namespace_graft_named_list_has_name(edges: List, name: Symbol) -> Bool fn namespace_graft_flatten_minus_decl_names(from_decls: List, flattened: List) -> List { fold(flattened, init: [], f: fn(acc, edge) { match edge.label { - Named { name: n } => + StructuralLabel { label: _ } => acc + Authored { name: n } => if namespace_graft_named_list_has_name(edges: from_decls, name: n) { acc } else { @@ -609,7 +614,7 @@ fn namespace_graft_wrap_segment(segment: Symbol, inner: Node, source: Node) -> N kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: segment }, + label: Authored { name: segment }, target: inner } ], @@ -668,10 +673,9 @@ fn namespace_graft_has_explicit_braced_container(root: Node, first_segment: Symb true } else { match edge.label { - Named { name: sym } => - if namespace_graft_is_metadata_edge(name: sym) { - false - } else if sym == first_segment { + StructuralLabel { label: _ } => false + Authored { name: sym } => + if sym == first_segment { match edge.target.kind { TypeNode { connective: Conj } => true _ => false diff --git a/src/v2/compiler/program_partition.dag b/src/v2/compiler/program_partition.dag index e42e9f971da..8f197b140d6 100644 --- a/src/v2/compiler/program_partition.dag +++ b/src/v2/compiler/program_partition.dag @@ -72,7 +72,7 @@ import v2.std.node { Conj, Disj, Edge, - Named, + Authored, Node, Symbol, Transform, @@ -157,7 +157,7 @@ fn partition_collect_user_semantic_type_edge( edge: Edge ) -> List { match edge.label { - Named { name: sym } => + Authored { name: sym } => match partition_semantic_type_from_decl_target(target: edge.target) { Present { value: semantic } => partition_snoc_user_semantic_type_unique( diff --git a/src/v2/compiler/reference_conservation.dag b/src/v2/compiler/reference_conservation.dag index 357c577217b..1137109b2ba 100644 --- a/src/v2/compiler/reference_conservation.dag +++ b/src/v2/compiler/reference_conservation.dag @@ -37,7 +37,7 @@ import v2.std.diagnostic { import v2.compiler.normalize { normalize } import v2.std.language_model { LanguageModel } import v2.std.logic { Bool } -import v2.std.node { Atom, Named, Node, Positional, Symbol, TypeNode, symbol_lexeme } +import v2.std.node { Atom, Authored, StructuralLabel, Node, Positional, Symbol, TypeNode, symbol_lexeme } import v2.std.optional { Absent, Optional, Present, optional_present } import v2.std.provenance { SpanIndex, span_index_resolve_textual_locus } import v2.std.text { String } @@ -736,7 +736,8 @@ fn rebuilt_spelling_pool(acc: Map, node: Node) -> Map } fold(node.children, init: here, f: fn(inner, edge) { let labelled = match edge.label { - Named { name: name } => pool_add(pool: inner, sym: pool_key_of_label(label: name)) + Authored { name: name } => pool_add(pool: inner, sym: pool_key_of_label(label: name)) + StructuralLabel { label: _ } => inner Positional => inner } rebuilt_spelling_pool(acc: labelled, node: edge.target) @@ -755,7 +756,8 @@ fn named_child_optional(node: Node, label: Symbol) -> Optional { Present { value: _ } => acc Absent => match edge.label { - Named { name: name } => if name == label { optional_present(value: edge.target) } else { acc } + Authored { name: name } => if name == label { optional_present(value: edge.target) } else { acc } + StructuralLabel { label: _ } => acc Positional => acc } } @@ -787,8 +789,9 @@ fn declaration_pools(tree: NormalizedTree, module_qn: Outcome Present { value: body } => fold(body.children, init: empty_map(), f: fn(acc, edge) { match edge.label { - Named { name: name } => + Authored { name: name } => map_insert(m: acc, key: name, value: rebuilt_spelling_pool(acc: pool_add(pool: empty_map(), sym: name), node: edge.target)) + StructuralLabel { label: _ } => acc Positional => acc } }) diff --git a/src/v2/compiler/reference_site_collector.dag b/src/v2/compiler/reference_site_collector.dag index d5fa8b59ae6..1d2ae9285df 100644 --- a/src/v2/compiler/reference_site_collector.dag +++ b/src/v2/compiler/reference_site_collector.dag @@ -1,7 +1,9 @@ module v2.compiler.reference_site_collector +import v2.std.collection { List } + import std.algebra { Cons, Empty, FreeMonoid, list_snoc_item } -import v2.std.algebra { fold_list, is_empty } +import v2.std.algebra { fold_list, is_empty, list_map } import v2.std.diagnostic { Accepted, Locus, Rejected, node_locus } import v2.std.integer { Int } import v2.std.logic { Bool } @@ -9,17 +11,18 @@ import v2.std.node { Atom, Conj, Edge, - Named, + Authored, Node, Positional, Symbol, - TypeNode + TypeNode, + EdgeLabel, + StructuralLabel, } import v2.std.optional { Absent, Present } import v2.std.qualified_name { QualifiedName, qualified_name_from_node, - qualified_name_snoc } import v2.compiler.resolution_provenance { ReferenceSite } import v2.extdeps.languages.dag { @@ -143,19 +146,27 @@ import v2.extdeps.languages.dag { // rule as symbol_index_fill_containment_edge and export admission. fn reference_sites_in_edge( acc: ReferenceSiteCollection, - position: QualifiedName, + position: List, edge: Edge ) -> ReferenceSiteCollection { match edge.label { - Named { name: sym } => - if dag_surface_module_header_metadata_edge(name: sym) { + Authored { name: sym } => + if sym == ^grammar_production_identity_node_projection { acc - } else if sym == ^grammar_production_identity_node_projection { + } else { + reference_sites_in_node( + acc: acc, + position: list_snoc_item(xs: position, item: edge.label), + node: edge.target + ) + } + StructuralLabel { label: _ } => + if dag_surface_module_header_metadata_edge(e: edge) { acc } else { reference_sites_in_node( acc: acc, - position: qualified_name_snoc(qn: position, segment: sym), + position: list_snoc_item(xs: position, item: edge.label), node: edge.target ) } @@ -170,7 +181,7 @@ fn reference_sites_in_edge( fn reference_sites_in_children( acc: ReferenceSiteCollection, - position: QualifiedName, + position: List, node: Node ) -> ReferenceSiteCollection { fold(node.children, init: acc, f: fn(inner, edge) { @@ -206,7 +217,7 @@ fn collection_snoc_site( // asks about. fn reference_sites_in_node( acc: ReferenceSiteCollection, - position: QualifiedName, + position: List, node: Node ) -> ReferenceSiteCollection { match qualified_name_from_node(root: node) { @@ -327,7 +338,7 @@ fn module_reference_sites( Accepted { value: module_qn, diagnostics: _ } => reference_sites_in_node( acc: acc, - position: module_qn, + position: list_map(xs: module_qn, f: fn(segment) { Authored { name: segment } }), node: module_spine_unwrapped(root: root) ) Rejected { diagnostics: _ } => diff --git a/src/v2/compiler/repair_input_origin_roster.dag b/src/v2/compiler/repair_input_origin_roster.dag index 2f04101d65c..c8d0655495f 100644 --- a/src/v2/compiler/repair_input_origin_roster.dag +++ b/src/v2/compiler/repair_input_origin_roster.dag @@ -39,7 +39,8 @@ import v2.compiler.resolution_provenance { ResolutionProvenance, answer_site, module_roster_from_roots, - resolve_reference_sites + resolve_reference_sites, + reference_site_scope_path, } import v2.compiler.symbol_index_fill { symbol_index_fill_module_roots } import v2.std.namespace_alias { ModuleBindingSource, module_binding_source_roots } @@ -135,7 +136,7 @@ fn carrier_provenance(answer: ResolutionProvenance) -> RepairInputDeclarationPro fn carrier_from_answer(answer: ResolutionProvenance, site: ReferenceSite) -> RepairInputOriginCandidate { SourceDeclarationCarrier { identity: SourceDeclarationCarrierIdentity { - reference_position: qualified_name_to_dotted_string(qn: site.position), + reference_position: qualified_name_to_dotted_string(qn: reference_site_scope_path(site: site)), authored_spelling: qualified_name_to_dotted_string(qn: site.spelling), provenance: carrier_provenance(answer: answer) } diff --git a/src/v2/compiler/resolution_provenance.dag b/src/v2/compiler/resolution_provenance.dag index ce20fb4d1eb..a74dd7097c8 100644 --- a/src/v2/compiler/resolution_provenance.dag +++ b/src/v2/compiler/resolution_provenance.dag @@ -1,5 +1,7 @@ module v2.compiler.resolution_provenance +import v2.std.collection { List } + import std.algebra { Empty, FreeMonoid, list_snoc_item } import std.dissolution { DissolutionCondition, unbound_dissolution } import std.types { NonEmptyStr } @@ -7,11 +9,12 @@ import v2.std.algebra { contains, fold_list, is_empty, - length + length, + list_map, } import v2.std.diagnostic { Accepted, Rejected } import v2.std.logic { Bool } -import v2.std.node { Node, Symbol } +import v2.std.node { Node, Symbol, EdgeLabel, label_sort_key } import v2.std.optional { Absent, Optional, @@ -49,11 +52,22 @@ import v2.extdeps.languages.dag { qualified_name_from_module_node } // One fact, two resolvers, is the fork DESIGN section 3 names; this module's answers are the second. // It is kept, frozen, until its consumers read the resolved tree -- the row below is the trigger. +// WHERE A MENTION SITS is the chain of edge labels above it, structural and authored, so a reader +// asking whether a mention sits inside a grammar production (v2.lens.module_graph +// site_is_import_syntax_mention) matches the production's arm rather than a spelling an authored +// name could share. Lexical lookup reads the chain as a name path (reference_site_scope_path). type ReferenceSite { - position: QualifiedName + position: List spelling: QualifiedName } +// The position read as a name path for lexical scope lookup: each label contributes the Symbol it +// is canonically ordered by. This is a SCOPE PATH, not an identity: no reader decides what a label +// IS from it. +fn reference_site_scope_path(site: ReferenceSite) -> QualifiedName { + list_map(xs: site.position, f: fn(label) { label_sort_key(label: label) }) +} + type ResolutionProvenance = ProvenanceResolved { site: ReferenceSite, target: QualifiedName, owner: QualifiedName } | ProvenanceOwnerless { site: ReferenceSite, target: QualifiedName } @@ -137,7 +151,7 @@ fn resolve_reference_provenance( Present { value: name } => match symbol_index_lexical_lookup( index: index, - position: site.position, + position: reference_site_scope_path(site: site), name: name ) { LexicalHit { node: _, path: path } => diff --git a/src/v2/compiler/symbol_index_fill.dag b/src/v2/compiler/symbol_index_fill.dag index 472cba4cad7..43a95e19bbc 100644 --- a/src/v2/compiler/symbol_index_fill.dag +++ b/src/v2/compiler/symbol_index_fill.dag @@ -26,13 +26,15 @@ import v2.std.node { Edge, FirstPositionalAbsent, FirstPositionalFound, - Named, + Authored, Node, Positional, Symbol, TypeNode, arrow_first_positional_target, - node_subtree_nodes + node_subtree_nodes, + StructuralLabel, + label_sort_key, } import v2.std.qualified_name { QualifiedName, qualified_name_snoc } import v2.std.symbol_index { @@ -105,11 +107,35 @@ fn symbol_index_declared(target: Node) -> SymbolIndexDeclared { } } +// A labeled child declares a binding at path.segment and its members below it. +fn symbol_index_fill_declared_child(index: SymbolIndex, path: QualifiedName, segment: Symbol, edge: Edge) -> SymbolIndex { + let child_path = qualified_name_snoc(qn: path, segment: segment) + let declared = symbol_index_declared(target: symbol_index_binder_type_or_target(target: edge.target)) + let with_binding = symbol_index_mark_declared_type_params( + index: symbol_index_insert( + index: index, + qualified_path: child_path, + resolved: declared.bound + ), + qualified_path: child_path, + params: declared.type_params + ) + match declared.members { + Present { value: member } => + symbol_index_fill_containment_node( + index: with_binding, + path: child_path, + node: member + ) + Absent => with_binding + } +} + // A BINDER IS INDEXED AT ITS TYPE (XL-2 PR2b-3). A parameter's or field's edge targets a binder node // (v2.std.node_query binder_node_parts), which identifies itself by its own labels; the path binds the // binder's declared type, and an inline record type's fields are indexed under it as before. The binder -// node is never itself indexed as a record, so and never become path -// segments. Any other target is indexed as it is. +// node is never itself indexed as a record, so its BinderTypeEdge and BinderDefaultEdge never become +// path segments. Any other target is indexed as it is. fn symbol_index_binder_type_or_target(target: Node) -> Node { match binder_node_parts(n: target) { Present { value: parts } => parts.type_node @@ -123,40 +149,25 @@ fn symbol_index_fill_containment_edge( edge: Edge ) -> SymbolIndex { match edge.label { - Named { name: sym } => - if dag_surface_module_header_metadata_edge(name: sym) { + StructuralLabel { label: _ } => + if dag_surface_module_header_metadata_edge(e: edge) { symbol_index_fill_containment_node( index: index, path: path, node: edge.target ) - } else if parse_tree_projection_edge(name: sym) { + } else { + symbol_index_fill_declared_child(index: index, path: path, segment: label_sort_key(label: edge.label), edge: edge) + } + Authored { name: sym } => + if parse_tree_projection_edge(name: sym) { symbol_index_fill_containment_node( index: index, path: path, node: edge.target ) } else { - let child_path = qualified_name_snoc(qn: path, segment: sym) - let declared = symbol_index_declared(target: symbol_index_binder_type_or_target(target: edge.target)) - let with_binding = symbol_index_mark_declared_type_params( - index: symbol_index_insert( - index: index, - qualified_path: child_path, - resolved: declared.bound - ), - qualified_path: child_path, - params: declared.type_params - ) - match declared.members { - Present { value: member } => - symbol_index_fill_containment_node( - index: with_binding, - path: child_path, - node: member - ) - Absent => with_binding - } + symbol_index_fill_declared_child(index: index, path: path, segment: sym, edge: edge) } Positional => symbol_index_fill_containment_node( @@ -201,7 +212,8 @@ fn symbol_index_fill_containment_node( TypeNode { connective: Disj } => fold(node.children, init: index, f: fn(acc, edge) { match edge.label { - Named { name: sym } => + StructuralLabel { label: _ } => acc + Authored { name: sym } => let variant_path = qualified_name_snoc(qn: path, segment: sym) let with_variant = symbol_index_mark_declared_payload( index: symbol_index_insert( @@ -263,7 +275,8 @@ fn disj_variant_counts_in_module(root: Node) -> Map { TypeNode { connective: Disj } => fold(n.children, init: counts, f: fn(c, e) { match e.label { - Named { name: sym } => + StructuralLabel { label: _ } => c + Authored { name: sym } => map_insert( m: c, key: sym, @@ -412,7 +425,8 @@ fn symbol_index_fill_unique_variant_aliases( TypeNode { connective: Disj } => fold(n.children, init: acc, f: fn(a2, e) { match e.label { - Named { name: sym } => + StructuralLabel { label: _ } => a2 + Authored { name: sym } => if disj_variant_count_of(counts: counts, sym: sym) == 1 { symbol_index_mark_declared_payload( index: symbol_index_insert( diff --git a/src/v2/compiler/target_serialize.dag b/src/v2/compiler/target_serialize.dag index 53e29b3ed19..6a9f35a85e6 100644 --- a/src/v2/compiler/target_serialize.dag +++ b/src/v2/compiler/target_serialize.dag @@ -5,7 +5,8 @@ import std.occurrence_identity { } import v2.extdeps.languages.dag { dag_surface_operator_canonicalization_member, - dag_value_expression_projection + dag_value_expression_projection, + dag_surface_edge_label, } import extdeps.communication.medium { Medium @@ -54,9 +55,10 @@ import v2.std.node { Atom, Conj, Edge, - Named, + Authored, Node, Positional, + StructuralLabel, Symbol, TypeNode, node_subtree_count @@ -66,7 +68,8 @@ import v2.std.type_binder { } import v2.std.node_query { find_named_child, - node_positional_child_targets + node_positional_child_targets, + find_labeled_child, } import v2.std.compilers.target_model { ConcreteSyntaxToken, @@ -232,22 +235,24 @@ fn target_bundle_child_lookup_step( BundleChildDuplicate => acc BundleChildMissing => match e.label { - Named { name: n } => + Authored { name: n } => if n == edge_name { BundleChildFound { value: e.target } } else { acc } + StructuralLabel { label: _ } => BundleChildInvalidEdge Positional => BundleChildInvalidEdge } BundleChildFound { value: _ } => match e.label { - Named { name: n } => + Authored { name: n } => if n == edge_name { BundleChildDuplicate } else { acc } + StructuralLabel { label: _ } => BundleChildInvalidEdge Positional => BundleChildInvalidEdge } } @@ -368,7 +373,7 @@ fn grammar_relation_row_with_bodied_scaffold(rules: Node) -> Outcome { match acc { Accepted { value: _, diagnostics: _ } => match e.label { - Named { name: _ } => + Authored { name: _ } => match find_named_child( root: e.target, name: ^grammar_relation_field_bodied_scaffold @@ -379,11 +384,12 @@ fn grammar_relation_row_with_bodied_scaffold(rules: Node) -> Outcome { ) Rejected { diagnostics: _ } => acc } + StructuralLabel { label: _ } => acc Positional => acc } Rejected { diagnostics: _ } => match e.label { - Named { name: _ } => + Authored { name: _ } => match find_named_child( root: e.target, name: ^grammar_relation_field_bodied_scaffold @@ -392,6 +398,7 @@ fn grammar_relation_row_with_bodied_scaffold(rules: Node) -> Outcome { Accepted { value: e.target, diagnostics: d } Rejected { diagnostics: _ } => acc } + StructuralLabel { label: _ } => acc Positional => acc } } @@ -444,22 +451,24 @@ fn optional_named_child_ignoring_positional(parent: Node, edge_name: Symbol) -> BundleChildDuplicate => acc BundleChildMissing => match e.label { - Named { name: n } => + Authored { name: n } => if n == edge_name { BundleChildFound { value: e.target } } else { acc } + StructuralLabel { label: _ } => acc Positional => acc } BundleChildFound { value: _ } => match e.label { - Named { name: n } => + Authored { name: n } => if n == edge_name { BundleChildDuplicate } else { acc } + StructuralLabel { label: _ } => acc Positional => acc } } @@ -1194,13 +1203,15 @@ fn type_expr_spelling_for_atom(target: TargetModel, node: Node) -> Outcome Outcome { match edge.label { - Named { name: label } => + Authored { name: label } => bind_outcome( o: target_binding_spelling_lookup(target: target, binding: label), f: fn(spelling) { outcome_accepted(text_atom(lexeme: spelling)) } ) + StructuralLabel { label: _ } => + outcome_rejected(translate_type_expression_shape_missing_diagnostic(node: edge.target)) Positional => outcome_rejected(translate_type_expression_shape_missing_diagnostic(node: edge.target)) } @@ -2132,7 +2143,7 @@ fn serialize_type_expr_boundary_bounded( } fn is_dag_import_carrier(emitted: Node) -> Bool { - match find_named_child(root: emitted, name: ^dag_surface_import_decl) { + match find_labeled_child(root: emitted, label: dag_surface_edge_label(edge: ^dag_surface_import_decl)) { Accepted { value: _, diagnostics: _ } => true Rejected { diagnostics: _ } => false } diff --git a/src/v2/compiler/use_site_verdict.dag b/src/v2/compiler/use_site_verdict.dag index ec07c31be71..a0d0cb0f473 100644 --- a/src/v2/compiler/use_site_verdict.dag +++ b/src/v2/compiler/use_site_verdict.dag @@ -8,7 +8,7 @@ import v2.std.node { Atom, Edge, Found, - Named, + Authored, Node, Positional, Symbol, @@ -49,7 +49,7 @@ fn use_site_verdict_to_node(verdict: UseSiteVerdict) -> Node { node_synthetic( kind: TypeNode { connective: Atom { identity: use_site_verdict_move_field_tag } }, children: [ - Edge { label: Named { name: use_site_verdict_field_edge }, target: use_site_verdict_atom(tag: f) } + Edge { label: Authored { name: use_site_verdict_field_edge }, target: use_site_verdict_atom(tag: f) } ] ) Borrow => use_site_verdict_atom(tag: use_site_verdict_borrow_tag) @@ -101,7 +101,7 @@ fn attach_use_site_verdict(node: Node, verdict: UseSiteVerdict) -> Node { n: node, children: list_snoc_item( xs: node.children, - item: Edge { label: Named { name: use_site_verdict_edge }, target: use_site_verdict_to_node(verdict: verdict) } + item: Edge { label: Authored { name: use_site_verdict_edge }, target: use_site_verdict_to_node(verdict: verdict) } ) ) } diff --git a/src/v2/compiler/wrap_decision.dag b/src/v2/compiler/wrap_decision.dag index 031e8d34e89..95530f7d1a6 100644 --- a/src/v2/compiler/wrap_decision.dag +++ b/src/v2/compiler/wrap_decision.dag @@ -36,7 +36,7 @@ import v2.std.diagnostic { outcome_accepted, outcome_rejected } -import v2.std.node { Atom, Conj, Edge, Named, Node, Positional, Symbol, TypeNode } +import v2.std.node { Atom, Conj, Edge, Authored, Node, Positional, StructuralLabel, Symbol, TypeNode } type WrapDecisionBundleChildLookup = WrapDecisionBundleChildMissing @@ -54,22 +54,24 @@ fn wrap_decision_bundle_child_lookup_step( WrapDecisionBundleChildDuplicate => acc WrapDecisionBundleChildMissing => match e.label { - Named { name: n } => + Authored { name: n } => if n == edge_name { WrapDecisionBundleChildFound { value: e.target } } else { acc } + StructuralLabel { label: _ } => WrapDecisionBundleChildInvalidEdge Positional => WrapDecisionBundleChildInvalidEdge } WrapDecisionBundleChildFound { value: _ } => match e.label { - Named { name: n } => + Authored { name: n } => if n == edge_name { WrapDecisionBundleChildDuplicate } else { acc } + StructuralLabel { label: _ } => WrapDecisionBundleChildInvalidEdge Positional => WrapDecisionBundleChildInvalidEdge } } diff --git a/src/v2/extdeps/formats/sql.dag b/src/v2/extdeps/formats/sql.dag index 5f235db270c..d9a69c72afd 100644 --- a/src/v2/extdeps/formats/sql.dag +++ b/src/v2/extdeps/formats/sql.dag @@ -31,7 +31,7 @@ import v2.std.diagnostic { } import v2.std.nat { Nat } import v2.std.cardinality { NonZeroNat } -import v2.std.node { Atom, Conj, Edge, Named, Node, Symbol, TypeNode } +import v2.std.node { Atom, Conj, Edge, Authored, Node, Symbol, TypeNode } import v2.std.model_core { PrimitiveFactBundle, ModelCoreFactAxisEncoding, diff --git a/src/v2/extdeps/formats/sql_create_table_fold.dag b/src/v2/extdeps/formats/sql_create_table_fold.dag index a42ef50ce5f..61c23d95d94 100644 --- a/src/v2/extdeps/formats/sql_create_table_fold.dag +++ b/src/v2/extdeps/formats/sql_create_table_fold.dag @@ -72,7 +72,7 @@ import v2.std.node { Atom, Conj, Edge, - Named, + Authored, Node, Positional, Symbol, diff --git a/src/v2/extdeps/formats/sql_target.dag b/src/v2/extdeps/formats/sql_target.dag index 8e3dca8d8ab..5348f9a669c 100644 --- a/src/v2/extdeps/formats/sql_target.dag +++ b/src/v2/extdeps/formats/sql_target.dag @@ -36,7 +36,7 @@ import v2.std.node { Atom, Conj, Edge, - Named, + Authored, Node, Positional, Symbol, diff --git a/src/v2/extdeps/languages/bash.dag b/src/v2/extdeps/languages/bash.dag index c2abb55aaae..aad160effb1 100644 --- a/src/v2/extdeps/languages/bash.dag +++ b/src/v2/extdeps/languages/bash.dag @@ -48,7 +48,7 @@ import v2.std.node { Atom, Conj, Edge, - Named, + Authored, Node, Positional, Symbol, @@ -237,7 +237,7 @@ data bash_emitted_command: Node = bash_conj_emitted_from_tokens( ) fn bash_named_edge(name: Symbol, target: Node) -> Edge { - Edge { label: Named { name: name }, target: target } + Edge { label: Authored { name: name }, target: target } } fn bash_translation_rules_node() -> Node { diff --git a/src/v2/extdeps/languages/bash_command_fold.dag b/src/v2/extdeps/languages/bash_command_fold.dag index 8d75494c993..8ec8e08d774 100644 --- a/src/v2/extdeps/languages/bash_command_fold.dag +++ b/src/v2/extdeps/languages/bash_command_fold.dag @@ -103,7 +103,7 @@ import v2.std.node { Atom, Conj, Edge, - Named, + Authored, Node, Positional, Symbol, diff --git a/src/v2/extdeps/languages/c.dag b/src/v2/extdeps/languages/c.dag index f563fa9f1a5..a1c5d883020 100644 --- a/src/v2/extdeps/languages/c.dag +++ b/src/v2/extdeps/languages/c.dag @@ -148,7 +148,7 @@ import v2.std.node { Atom, Conj, Edge, - Named, + Authored, Node, Positional, Symbol, @@ -906,7 +906,7 @@ fn c_atom(id: Symbol) -> Node { } fn c_named_edge(name: Symbol, target: Node) -> Edge { - Edge { label: Named { name: name }, target: target } + Edge { label: Authored { name: name }, target: target } } fn c_concrete_tokens() -> List { diff --git a/src/v2/extdeps/languages/c_decl.dag b/src/v2/extdeps/languages/c_decl.dag index 4b2abd17ea9..d238671535f 100644 --- a/src/v2/extdeps/languages/c_decl.dag +++ b/src/v2/extdeps/languages/c_decl.dag @@ -30,7 +30,7 @@ import v2.std.integer { Int } import v2.std.node { Conj, Edge, - Named, + Authored, Node, Symbol, TypeNode, @@ -92,7 +92,7 @@ fn c_stage1_type_decl_frontier_deferred_count() -> Int { } fn c_decl_named_edge(name: Symbol, target: Node) -> Edge { - Edge { label: Named { name: name }, target: target } + Edge { label: Authored { name: name }, target: target } } fn c_decl_shape_productions() -> List { diff --git a/src/v2/extdeps/languages/cpp.dag b/src/v2/extdeps/languages/cpp.dag index bac1ac5e62d..480abab4fcc 100644 --- a/src/v2/extdeps/languages/cpp.dag +++ b/src/v2/extdeps/languages/cpp.dag @@ -57,7 +57,7 @@ import v2.std.model_core { ModelCoreFactAxisSurfaceSpelling, ModelCoreFactAxisWidth } -import v2.std.node { Arrow, Atom, Conj, Edge, Named, Node, Positional, Symbol, TypeNode } +import v2.std.node { Arrow, Atom, Conj, Edge, Authored, Node, Positional, Symbol, TypeNode } import v2.extdeps.cpp_abi { CppTargetProfile } import v2.std.text { String } @@ -192,7 +192,7 @@ fn cpp_atom(id: Symbol) -> Node { } fn cpp_named_edge(name: Symbol, target: Node) -> Edge { - Edge { label: Named { name: name }, target: target } + Edge { label: Authored { name: name }, target: target } } fn cpp_signed_integer_spelling_node(spelling: CppSignedIntegerSurfaceSpelling) -> Node { diff --git a/src/v2/extdeps/languages/dag.dag b/src/v2/extdeps/languages/dag.dag index c42e7afe46a..e0d9cb7925c 100644 --- a/src/v2/extdeps/languages/dag.dag +++ b/src/v2/extdeps/languages/dag.dag @@ -104,7 +104,6 @@ import v2.std.compilers.lexing { import v2.std.node { host_text_type_node, symbol_lexeme, - construct_tag_marker, symbol_type_node, Arrow, Atom, @@ -115,17 +114,28 @@ import v2.std.node { Edge, Loop, Match, - Named, + Authored, Node, Positional, + StructuralLabel, Symbol, Transform, TypeNode, is_empty_conj_root, node_lowered_from, symbol_intern_lexeme, -} -import v2.std.node_query { binder_edge, NamedChildAmbiguous, NamedChildFound, NamedChildMissing, find_named_child, named_child_lookup } + ArrowBodyEdge, + LoopBoundEdge, + MatchArmBodyEdge, + MatchArmPatternEdge, + core_edge, + core_edge_label, + EdgeLabel, + edge_is_production, + production_edge_label, + ConstructTagEdge, +} +import v2.std.node_query { binder_edge, NamedChildAmbiguous, NamedChildFound, NamedChildMissing, find_named_child, named_child_lookup, find_labeled_child } import v2.std.compilers.target_model { lex_rules_literal_for_class, char_kernel_type_node, @@ -677,11 +687,26 @@ fn dag_grammar_atom(id: Symbol) -> Node { fn dag_named_edge(name: Symbol, target: Node) -> Edge { Edge { - label: Named { name: name }, + label: Authored { name: name }, target: target } } +// A DAG SURFACE PRODUCTION'S EDGE: a structural label keyed by this language, so an authored name +// spelled like a production never reaches a reader of the production (gunbc#12473 plan). Readers +// compare the whole label (edge_is_production), never the spelling. +fn dag_surface_edge_label(edge: Symbol) -> EdgeLabel { + production_edge_label(language: ^dag_language_model_surface_id, edge: edge) +} + +fn dag_surface_edge(edge: Symbol, target: Node) -> Edge { + Edge { label: dag_surface_edge_label(edge: edge), target: target } +} + +fn dag_surface_edge_is(e: Edge, edge: Symbol) -> Bool { + edge_is_production(e: e, language: ^dag_language_model_surface_id, edge: edge) +} + fn dag_positional_edge(target: Node) -> Edge { Edge { label: Positional, @@ -2793,12 +2818,10 @@ fn emit_module_header_emitted_node(qualified_name: Node) -> Node { Node { kind: TypeNode { connective: Conj }, children: [ - dag_named_edge( - name: ^dag_surface_module_header, + dag_surface_edge(edge: ^dag_surface_module_header, target: dag_grammar_atom(id: ^dag_surface_module_header) ), - dag_named_edge( - name: ^dag_surface_module_header_qualified_name, + dag_surface_edge(edge: ^dag_surface_module_header_qualified_name, target: qualified_name ) ], @@ -2826,12 +2849,10 @@ fn emit_import_decl_emitted_node( import_block: Node? ) -> Node { let prefix = [ - dag_named_edge( - name: ^dag_surface_import_decl, + dag_surface_edge(edge: ^dag_surface_import_decl, target: dag_grammar_atom(id: ^dag_surface_import_decl) ), - dag_named_edge( - name: ^dag_surface_import_decl_qualified_name, + dag_surface_edge(edge: ^dag_surface_import_decl_qualified_name, target: qualified_name ) ] @@ -2842,7 +2863,7 @@ fn emit_import_decl_emitted_node( list_append( left: prefix, right: [ - dag_named_edge(name: ^dag_surface_import_decl_block, target: block) + dag_surface_edge(edge: ^dag_surface_import_decl_block, target: block) ] ) Absent => prefix @@ -3761,9 +3782,9 @@ fn dag_target_model_lossless_fidelity_quotient() -> TargetModel { ) } -fn dag_surface_module_header_metadata_edge(name: Symbol) -> Bool { - (name == ^dag_surface_module_header) - || (name == ^dag_surface_module_header_qualified_name) +fn dag_surface_module_header_metadata_edge(e: Edge) -> Bool { + dag_surface_edge_is(e: e, edge: ^dag_surface_module_header) + || dag_surface_edge_is(e: e, edge: ^dag_surface_module_header_qualified_name) } fn dag_resolve_preserve_module_metadata_subtree(node: Node) -> Bool { @@ -3784,14 +3805,7 @@ fn dag_node_is_module_root_conj(n: Node) -> Bool { n.children, init: false, f: fn(found, e) { - if found { - true - } else { - match e.label { - Named { name: sym } => sym == ^dag_surface_module_header - Positional => false - } - } + found || dag_surface_edge_is(e: e, edge: ^dag_surface_module_header) } ) TypeNode { connective: _ } => false @@ -4320,7 +4334,7 @@ fn dag_loop_body_from_literal(lit: Node) -> Node { target: lit }, Edge { - label: Named { name: ^loop_bound_edge }, + label: core_edge_label(marker: LoopBoundEdge), target: dag_loop_measure_node() } ], @@ -4386,19 +4400,20 @@ fn dag_node_is_int_literal_atom(node: Node) -> Bool { fn dag_symbol_literal_node(name: Node, occurrence_id: NodeOccurrenceIdentity) -> Node { Node { kind: TypeNode { connective: Atom { identity: ^dag_token_caret } }, - children: [Edge { label: Named { name: ^symbol_literal_name_field }, target: name }], + children: [Edge { label: Authored { name: ^symbol_literal_name_field }, target: name }], occurrence_id: occurrence_id } } fn dag_symbol_literal_name_edge_target_optional(edge: Edge) -> Optional { match edge.label { - Named { name: field } => + Authored { name: field } => if field == ^symbol_literal_name_field { optional_present(value: edge.target) } else { optional_absent() } + StructuralLabel { label: _ } => optional_absent() Positional => optional_absent() } } @@ -4480,7 +4495,7 @@ fn dag_int_literal_node_from_magnitude(magnitude: DecimalMagnitude, occurrence_i kind: TypeNode { connective: Atom { identity: ^dag_token_int_literal } }, children: [ Edge { - label: Named { name: ^integer_literal_magnitude_field }, + label: Authored { name: ^integer_literal_magnitude_field }, target: integer_decimal_magnitude_node(magnitude: magnitude) } ], @@ -4518,7 +4533,7 @@ fn dag_float_literal_node_from_lexeme(lexeme: String, occurrence_id: NodeOccurre kind: TypeNode { connective: Atom { identity: ^dag_token_float_literal } }, children: [ Edge { - label: Named { name: ^float_literal_lexeme_field }, + label: Authored { name: ^float_literal_lexeme_field }, target: Node { kind: TypeNode { connective: Atom { identity: symbol_intern_lexeme(lexeme: lexeme) } }, children: [], @@ -4541,7 +4556,7 @@ fn dag_float_literal_lexeme_optional(node: Node) -> Optional { Present { value: _ } => acc Absent => match edge.label { - Named { name: field } => + Authored { name: field } => if field == ^float_literal_lexeme_field { match node_atom_identity_optional(node: edge.target) { Present { value: l } => optional_present(value: symbol_lexeme(sym: l)) @@ -4550,6 +4565,7 @@ fn dag_float_literal_lexeme_optional(node: Node) -> Optional { } else { optional_absent() } + StructuralLabel { label: _ } => optional_absent() Positional => optional_absent() } } @@ -4799,7 +4815,7 @@ fn dag_string_literal_node(value: String, occurrence_id: NodeOccurrenceIdentity) kind: TypeNode { connective: Atom { identity: ^dag_token_string_literal } }, children: [ Edge { - label: Named { name: ^string_literal_value_field }, + label: Authored { name: ^string_literal_value_field }, target: Node { kind: TypeNode { connective: Atom { identity: symbol_intern_lexeme(lexeme: value) } }, children: [], @@ -4815,12 +4831,13 @@ fn dag_string_literal_node(value: String, occurrence_id: NodeOccurrenceIdentity) // every other node, including a payload-less string-literal atom. fn dag_string_literal_value_edge_target_optional(edge: Edge) -> Optional { match edge.label { - Named { name: field } => + Authored { name: field } => if field == ^string_literal_value_field { optional_present(value: edge.target) } else { optional_absent() } + StructuralLabel { label: _ } => optional_absent() Positional => optional_absent() } } @@ -4866,12 +4883,13 @@ data dag_float_literal_magnitude_home_dissolve_on: DissolutionCondition = retire fn dag_int_literal_magnitude_edge_target_optional(edge: Edge) -> Optional { match edge { - Edge { label: Named { name: field }, target: magnitude } => + Edge { label: Authored { name: field }, target: magnitude } => if field == ^integer_literal_magnitude_field { optional_present(value: magnitude) } else { optional_absent() } + Edge { label: StructuralLabel { label: _ }, target: _ } => optional_absent() Edge { label: Positional, target: _ } => optional_absent() } } @@ -5004,7 +5022,7 @@ fn dag_arrow_with_body_node( target: dag_type_atom_node(identity: return_type_binding) }, signature.order, - Edge { label: Named { name: ^arrow_body_edge }, target: body } + Edge { label: core_edge_label(marker: ArrowBodyEdge), target: body } ], occurrence_id: OccurrenceSynthetic } @@ -5214,12 +5232,10 @@ fn dag_match_arm_node(pattern_lit: Symbol, body_lit: Symbol) -> Node { Node { kind: TypeNode { connective: Conj }, children: [ - dag_named_edge( - name: ^match_arm_pattern, + core_edge(marker: MatchArmPatternEdge, target: dag_type_atom_node(identity: pattern_lit) ), - dag_named_edge( - name: ^match_arm_body, + core_edge(marker: MatchArmBodyEdge, target: dag_type_atom_node(identity: body_lit) ) ], @@ -5297,8 +5313,7 @@ fn dag_rec_construct_body_node() -> Node { Node { kind: TypeNode { connective: Conj }, children: [ - dag_named_edge( - name: construct_tag_marker(), + core_edge(marker: ConstructTagEdge, target: dag_type_atom_node(identity: ^dag_binding_type_rec) ), dag_named_edge( @@ -5326,8 +5341,7 @@ fn dag_variant_holds_construct_node(value_lit: Symbol) -> Node { Node { kind: TypeNode { connective: Conj }, children: [ - dag_named_edge( - name: construct_tag_marker(), + core_edge(marker: ConstructTagEdge, target: dag_type_atom_node(identity: ^dag_binding_type_variant_holds) ), dag_named_edge( @@ -5347,9 +5361,8 @@ fn dag_variant_match_arm_node(pattern_target: Node, body_lit: Symbol) -> Node { Node { kind: TypeNode { connective: Conj }, children: [ - dag_named_edge(name: ^match_arm_pattern, target: pattern_target), - dag_named_edge( - name: ^match_arm_body, + core_edge(marker: MatchArmPatternEdge, target: pattern_target), + core_edge(marker: MatchArmBodyEdge, target: dag_type_atom_node(identity: body_lit) ) ], @@ -6201,7 +6214,7 @@ fn dag_round_trip_atom(s: Symbol) -> Node { } fn dag_round_trip_edge(name: Symbol, target: Node) -> Edge { - Edge { label: Named { name: name }, target: target } + Edge { label: Authored { name: name }, target: target } } fn dag_round_trip_bool_node(pass: Bool) -> Node { @@ -6862,7 +6875,7 @@ fn import_decl_target_module(decl: Node, module_root: Node) -> Outcome - match find_named_child(root: decl, name: ^dag_surface_import_decl_qualified_name) { + match find_labeled_child(root: decl, label: dag_surface_edge_label(edge: ^dag_surface_import_decl_qualified_name)) { Rejected { diagnostics: d } => Rejected { diagnostics: d } Accepted { value: qn_node, diagnostics: _ } => qualified_name_from_node(root: qn_node) @@ -7003,10 +7016,10 @@ fn qualified_name_from_symbol_segments(segments: List, root: Node) -> Ou } fn qualified_name_from_emit_shaped_module_root(root: Node) -> Outcome { - match find_named_child(root: root, name: ^dag_surface_module_header) { + match find_labeled_child(root: root, label: dag_surface_edge_label(edge: ^dag_surface_module_header)) { Rejected { diagnostics: diags } => Rejected { diagnostics: diags } Accepted { value: _, diagnostics: _ } => - match find_named_child(root: root, name: ^dag_surface_module_header_qualified_name) { + match find_labeled_child(root: root, label: dag_surface_edge_label(edge: ^dag_surface_module_header_qualified_name)) { Rejected { diagnostics: diags } => Rejected { diagnostics: diags } Accepted { value: qn_node, diagnostics: _ } => match qualified_name_from_node(root: qn_node) { @@ -7068,7 +7081,7 @@ fn namespace_graft_unwrap_module_working_root(root: Node) -> Node { } fn namespace_graft_has_module_header(root: Node) -> Bool { - match find_named_child(root: root, name: ^dag_surface_module_header) { + match find_labeled_child(root: root, label: dag_surface_edge_label(edge: ^dag_surface_module_header)) { Accepted { value: _, diagnostics: _ } => true Rejected { diagnostics: _ } => false } @@ -7163,12 +7176,13 @@ fn namespace_graft_spine_shaped_edge_optional(node: Node) -> Optional { Absent => optional_absent() Present { value: edge } => match edge.label { - Named { name: _ } => + Authored { name: _ } => if namespace_graft_node_is_conj(node: edge.target) { optional_present(value: edge) } else { optional_absent() } + StructuralLabel { label: _ } => optional_absent() Positional => optional_absent() } } @@ -7212,11 +7226,17 @@ fn namespace_graft_qualified_name_from_spine_node(node: Node, acc: QualifiedName match namespace_graft_spine_shaped_edge_optional(node: node) { Present { value: edge } => match edge.label { - Named { name: seg } => + Authored { name: seg } => namespace_graft_qualified_name_from_spine_node( node: edge.target, acc: qualified_name_snoc(qn: acc, segment: seg) ) + StructuralLabel { label: _ } => + outcome_rejected(Diagnostic { + reason: ^qualified_name_structure_invalid, + at: node_locus(node: node), + correction: Unavailable { reason: ExternalContractUnknown } + }) Positional => outcome_rejected(Diagnostic { reason: ^qualified_name_structure_invalid, diff --git a/src/v2/extdeps/languages/ecmascript.dag b/src/v2/extdeps/languages/ecmascript.dag index e4418ed3373..db36e5c5048 100644 --- a/src/v2/extdeps/languages/ecmascript.dag +++ b/src/v2/extdeps/languages/ecmascript.dag @@ -74,7 +74,7 @@ import v2.std.node { Atom, Conj, Edge, - Named, + Authored, Node, Positional, Symbol, @@ -234,7 +234,7 @@ fn ecmascript_inhabitant_atom(id: Symbol) -> Node { } fn ecmascript_named_edge(name: Symbol, target: Node) -> Edge { - Edge { label: Named { name: name }, target: target } + Edge { label: Authored { name: name }, target: target } } fn ecmascript_primitive_facts_node( diff --git a/src/v2/extdeps/languages/english.dag b/src/v2/extdeps/languages/english.dag index bbaa6957f45..5f97ad5fa1c 100644 --- a/src/v2/extdeps/languages/english.dag +++ b/src/v2/extdeps/languages/english.dag @@ -21,7 +21,7 @@ import v2.std.node { Atom, Conj, Edge, - Named, + Authored, Node, Positional, TypeNode, @@ -372,7 +372,7 @@ fn english_ingest_grammar_probe() -> GrammarSchemaProbeBinding { data english_add_fn_source_text: String = "the add is a function. the add takes the x. the add takes the y. the add returns the sum. the sum adds the x. the sum adds the y." fn english_named_edge(name: Symbol, target: Node) -> Edge { - Edge { label: Named { name: name }, target: target } + Edge { label: Authored { name: name }, target: target } } fn english_inhabitant_atom(id: Symbol) -> Node { diff --git a/src/v2/extdeps/languages/go.dag b/src/v2/extdeps/languages/go.dag index 8247cf03e66..a5fa4775e39 100644 --- a/src/v2/extdeps/languages/go.dag +++ b/src/v2/extdeps/languages/go.dag @@ -64,7 +64,7 @@ import v2.std.grounding { PerLanguageFactBundleKey, PerLanguageFactBundleRegistry } -import v2.std.node { Arrow, Atom, Conj, Edge, Named, Node, Positional, Symbol, TypeNode } +import v2.std.node { Arrow, Atom, Conj, Edge, Authored, Node, Positional, Symbol, TypeNode } import v2.std.compilers.target_model { ProducedDeclUnwired, ConcreteSyntaxToken, FixedToken, BoundToken, concrete_syntax_token_class, concrete_syntax_token_to_node, target_model_emit_transforms_empty} import v2.std.compilers.target_model { @@ -412,7 +412,7 @@ fn go_inhabitant_atom(id: Symbol) -> Node { } fn go_named_edge(name: Symbol, target: Node) -> Edge { - Edge { label: Named { name: name }, target: target } + Edge { label: Authored { name: name }, target: target } } fn go_int_kind_node(kind: GoIntKind) -> Node { diff --git a/src/v2/extdeps/languages/java.dag b/src/v2/extdeps/languages/java.dag index 401b69d7fec..782d16f776a 100644 --- a/src/v2/extdeps/languages/java.dag +++ b/src/v2/extdeps/languages/java.dag @@ -82,7 +82,7 @@ import v2.std.node { Atom, Conj, Edge, - Named, + Authored, Node, Positional, Symbol, @@ -503,7 +503,7 @@ fn java_void_declared_inhabitant_node() -> Node { } fn java_named_edge(name: Symbol, target: Node) -> Edge { - Edge { label: Named { name: name }, target: target } + Edge { label: Authored { name: name }, target: target } } fn java_declared_inhabitants_root() -> Node { diff --git a/src/v2/extdeps/languages/kotlin.dag b/src/v2/extdeps/languages/kotlin.dag index 2ed581a9e30..37ae0ddbc36 100644 --- a/src/v2/extdeps/languages/kotlin.dag +++ b/src/v2/extdeps/languages/kotlin.dag @@ -85,7 +85,7 @@ import v2.std.node { Atom, Conj, Edge, - Named, + Authored, Node, Positional, Symbol, @@ -342,7 +342,7 @@ fn kotlin_atom(id: Symbol) -> Node { } fn kotlin_named_edge(name: Symbol, target: Node) -> Edge { - Edge { label: Named { name: name }, target: target } + Edge { label: Authored { name: name }, target: target } } fn kotlin_int_width_node(width: KotlinIntWidth) -> Node { diff --git a/src/v2/extdeps/languages/lean.dag b/src/v2/extdeps/languages/lean.dag index 8b748c406f5..4c257948031 100644 --- a/src/v2/extdeps/languages/lean.dag +++ b/src/v2/extdeps/languages/lean.dag @@ -70,7 +70,7 @@ import v2.std.node { Atom, Conj, Edge, - Named, + Authored, Node, Symbol, TypeNode, @@ -482,7 +482,7 @@ fn lean_inhabitant_atom(id: Symbol) -> Node { } fn lean_named_edge(name: Symbol, target: Node) -> Edge { - Edge { label: Named { name: name }, target: target } + Edge { label: Authored { name: name }, target: target } } fn lean_signedness_node(signedness: Signedness) -> Node { diff --git a/src/v2/extdeps/languages/llvm_ir.dag b/src/v2/extdeps/languages/llvm_ir.dag index bf2b671c397..37bc7f1404f 100644 --- a/src/v2/extdeps/languages/llvm_ir.dag +++ b/src/v2/extdeps/languages/llvm_ir.dag @@ -51,7 +51,7 @@ import v2.std.model_core { ModelCoreFactAxisWidth } import v2.std.nat { Nat } -import v2.std.node { Atom, Conj, Edge, Named, Node, Symbol, TypeNode } +import v2.std.node { Atom, Conj, Edge, Authored, Node, Symbol, TypeNode } type FloatKind = HalfFloat @@ -627,19 +627,19 @@ fn llvm_integer_facts_node(facts: LlvmIntegerPrimitiveFacts) -> Node { kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: discriminant(v: ModelCoreFactAxisSurfaceSpelling {}) }, + label: Authored { name: discriminant(v: ModelCoreFactAxisSurfaceSpelling {}) }, target: llvm_inhabitant_atom(id: facts.surface_spelling) }, Edge { - label: Named { name: discriminant(v: ModelCoreFactAxisWidth {}) }, + label: Authored { name: discriminant(v: ModelCoreFactAxisWidth {}) }, target: llvm_integer_bits_node(bits: facts.bits) }, Edge { - label: Named { name: discriminant(v: ModelCoreFactAxisEncoding {}) }, + label: Authored { name: discriminant(v: ModelCoreFactAxisEncoding {}) }, target: llvm_inhabitant_atom(id: ^llvm_repr_sign_agnostic_integer) }, Edge { - label: Named { name: ^llvm_facts_field_std_projection }, + label: Authored { name: ^llvm_facts_field_std_projection }, target: llvm_inhabitant_atom(id: facts.std_projection) } ], @@ -652,15 +652,15 @@ fn llvm_float_facts_node(facts: LlvmFloatPrimitiveFacts) -> Node { kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: discriminant(v: ModelCoreFactAxisSurfaceSpelling {}) }, + label: Authored { name: discriminant(v: ModelCoreFactAxisSurfaceSpelling {}) }, target: llvm_inhabitant_atom(id: facts.surface_spelling) }, Edge { - label: Named { name: discriminant(v: ModelCoreFactAxisEncoding {}) }, + label: Authored { name: discriminant(v: ModelCoreFactAxisEncoding {}) }, target: llvm_float_kind_node(kind: facts.kind) }, Edge { - label: Named { name: ^llvm_facts_field_std_projection }, + label: Authored { name: ^llvm_facts_field_std_projection }, target: llvm_inhabitant_atom(id: facts.std_projection) } ], diff --git a/src/v2/extdeps/languages/machine_code.dag b/src/v2/extdeps/languages/machine_code.dag index 29bef95830b..15477515ef6 100644 --- a/src/v2/extdeps/languages/machine_code.dag +++ b/src/v2/extdeps/languages/machine_code.dag @@ -33,7 +33,7 @@ import v2.std.model_core { ModelCoreFactAxisSurfaceSpelling, ModelCoreFactAxisWidth } -import v2.std.node { Atom, Conj, Edge, Named, Node, Symbol, TypeNode } +import v2.std.node { Atom, Conj, Edge, Authored, Node, Symbol, TypeNode } type Isa = X86_64Isa { revision: Symbol } @@ -344,27 +344,27 @@ fn mc_integer_facts_node(facts: MachineIntegerPrimitiveFacts) -> Node { kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: discriminant(v: ModelCoreFactAxisSurfaceSpelling {}) }, + label: Authored { name: discriminant(v: ModelCoreFactAxisSurfaceSpelling {}) }, target: mc_inhabitant_atom(id: facts.surface_spelling) }, Edge { - label: Named { name: discriminant(v: ModelCoreFactAxisSignedness {}) }, + label: Authored { name: discriminant(v: ModelCoreFactAxisSignedness {}) }, target: mc_int_kind_node(kind: facts.kind) }, Edge { - label: Named { name: discriminant(v: ModelCoreFactAxisWidth {}) }, + label: Authored { name: discriminant(v: ModelCoreFactAxisWidth {}) }, target: mc_int_width_node(width: facts.width) }, Edge { - label: Named { name: discriminant(v: ModelCoreFactAxisOverflowDisposition {}) }, + label: Authored { name: discriminant(v: ModelCoreFactAxisOverflowDisposition {}) }, target: mc_overflow_node(overflow: facts.overflow_release) }, Edge { - label: Named { name: discriminant(v: ModelCoreFactAxisEncoding {}) }, + label: Authored { name: discriminant(v: ModelCoreFactAxisEncoding {}) }, target: mc_inhabitant_atom(id: ^mc_repr_twos_complement) }, Edge { - label: Named { name: ^mc_facts_field_std_projection }, + label: Authored { name: ^mc_facts_field_std_projection }, target: mc_inhabitant_atom(id: facts.std_projection) } ], diff --git a/src/v2/extdeps/languages/python.dag b/src/v2/extdeps/languages/python.dag index eb283b68625..d5b5a24dcd8 100644 --- a/src/v2/extdeps/languages/python.dag +++ b/src/v2/extdeps/languages/python.dag @@ -95,7 +95,7 @@ import v2.std.node { Atom, Conj, Edge, - Named, + Authored, Node, Positional, Symbol, @@ -249,7 +249,7 @@ fn python_inhabitant_atom(id: Symbol) -> Node { } fn python_named_edge(name: Symbol, target: Node) -> Edge { - Edge { label: Named { name: name }, target: target } + Edge { label: Authored { name: name }, target: target } } fn python_primitive_facts_node( diff --git a/src/v2/extdeps/languages/rust.dag b/src/v2/extdeps/languages/rust.dag index af68e966e59..94636ecea8d 100644 --- a/src/v2/extdeps/languages/rust.dag +++ b/src/v2/extdeps/languages/rust.dag @@ -307,7 +307,7 @@ import v2.std.node { Conj, Disj, Edge, - Named, + Authored, StructuralLabel, Node, Positional, Symbol, @@ -953,7 +953,7 @@ fn rust_inhabitant_i32_node() -> Node { } fn rust_named_edge(name: Symbol, target: Node) -> Edge { - Edge { label: Named { name: name }, target: target } + Edge { label: Authored { name: name }, target: target } } fn rust_declared_inhabitants_root() -> Node { @@ -5000,12 +5000,13 @@ fn rust_sg2_emitted_without_named_edge(base: Node, field: Symbol) -> Node { kind: base.kind, children: fold(base.children, init: Empty, f: fn(acc, e) { match e.label { - Named { name: n } => + Authored { name: n } => if n == field { acc } else { list_snoc_item(xs: acc, item: e) } + StructuralLabel { label: _ } => list_snoc_item(xs: acc, item: e) Positional => list_snoc_item(xs: acc, item: e) } }), @@ -5101,7 +5102,8 @@ fn rust_sg2_malformed_atom_zero_positional_emitted() -> Node { children: fold(base.children, init: Empty, f: fn(acc, e) { match e.label { Positional => acc - Named { name: _ } => list_snoc_item(xs: acc, item: e) + Authored { name: _ } => list_snoc_item(xs: acc, item: e) + StructuralLabel { label: _ } => list_snoc_item(xs: acc, item: e) } }), occurrence_id: OccurrenceSynthetic diff --git a/src/v2/extdeps/languages/rust_freemonoid_char_fixtures.dag b/src/v2/extdeps/languages/rust_freemonoid_char_fixtures.dag index 156138942b5..9e1e52010cc 100644 --- a/src/v2/extdeps/languages/rust_freemonoid_char_fixtures.dag +++ b/src/v2/extdeps/languages/rust_freemonoid_char_fixtures.dag @@ -8,7 +8,7 @@ import v2.std.compilers.target_model { import v2.std.compilers.lexing { VoidLexRules } import v2.std.collection { empty_map } import v2.std.host_transport { target_emit_host_runtime_row_unconfigured } -import v2.std.node { Node, Edge, Named, TypeNode, Conj, OccurrenceSynthetic } +import v2.std.node { Node, Edge, Authored, TypeNode, Conj, OccurrenceSynthetic } import v2.std.algebra { fold_list_node, Cons, Empty } import v2.extdeps.languages.rust { rust_type_expression_projection_bundle_node, @@ -32,11 +32,11 @@ fn fmc_fixture_bundle_core() -> Node { kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: ^target_model_edge_type_expression_projection }, + label: Authored { name: ^target_model_edge_type_expression_projection }, target: rust_type_expression_projection_bundle_node() }, Edge { - label: Named { name: ^target_model_edge_collection_realization }, + label: Authored { name: ^target_model_edge_collection_realization }, target: fmc_minimal_collection_realization_catalog() } ], diff --git a/src/v2/extdeps/languages/rust_test_fixtures.dag b/src/v2/extdeps/languages/rust_test_fixtures.dag index a701f88ff48..f312956894f 100644 --- a/src/v2/extdeps/languages/rust_test_fixtures.dag +++ b/src/v2/extdeps/languages/rust_test_fixtures.dag @@ -1,5 +1,7 @@ module v2.extdeps.languages.rust_test +import v2.std.node { ArrowBodyEdge, core_edge_label, Authored, StructuralLabel } + import std.algebra { Cons, Empty } import v2.std.live_tree { LiveTreeDisposition, SubstrateInputsOnly } @@ -1090,7 +1092,7 @@ fn rust_classical_not_target_model_bundle_core() -> Node { init: Empty, f: fn(acc, edge) { match edge.label { - Named { name: n } => + Authored { name: n } => if n == ^target_model_edge_translation_rules { list_snoc_item( xs: acc, @@ -1102,6 +1104,7 @@ fn rust_classical_not_target_model_bundle_core() -> Node { } else { list_snoc_item(xs: acc, item: edge) } + StructuralLabel { label: _ } => list_snoc_item(xs: acc, item: edge) Positional => list_snoc_item(xs: acc, item: edge) } } @@ -3474,7 +3477,7 @@ fn rust_arrow_with_body_node( label: Positional, target: rust_type_atom_node(identity: return_type_binding) }, - Edge { label: Named { name: ^arrow_body_edge }, target: body } + Edge { label: core_edge_label(marker: ArrowBodyEdge), target: body } ], occurrence_id: OccurrenceSynthetic } @@ -3608,7 +3611,7 @@ fn rust_bind_literal_target_model_bundle() -> Node { init: Empty, f: fn(acc, edge) { match edge.label { - Named { name: n } => + Authored { name: n } => if n == ^target_model_edge_translation_rules { list_snoc_item( xs: acc, @@ -3620,6 +3623,7 @@ fn rust_bind_literal_target_model_bundle() -> Node { } else { list_snoc_item(xs: acc, item: edge) } + StructuralLabel { label: _ } => list_snoc_item(xs: acc, item: edge) Positional => list_snoc_item(xs: acc, item: edge) } } diff --git a/src/v2/extdeps/languages/swift.dag b/src/v2/extdeps/languages/swift.dag index 53f1700a870..5b3ae723608 100644 --- a/src/v2/extdeps/languages/swift.dag +++ b/src/v2/extdeps/languages/swift.dag @@ -93,7 +93,7 @@ import v2.std.node { Atom, Conj, Edge, - Named, + Authored, Node, Positional, Symbol, @@ -363,7 +363,7 @@ fn swift_atom(id: Symbol) -> Node { } fn swift_named_edge(name: Symbol, target: Node) -> Edge { - Edge { label: Named { name: name }, target: target } + Edge { label: Authored { name: name }, target: target } } fn swift_signedness_node(signedness: SwiftIntSignedness) -> Node { diff --git a/src/v2/extdeps/languages/swift/rows.dag b/src/v2/extdeps/languages/swift/rows.dag index fffee750f90..ab2318da60c 100644 --- a/src/v2/extdeps/languages/swift/rows.dag +++ b/src/v2/extdeps/languages/swift/rows.dag @@ -7,7 +7,7 @@ import v2.std.algebra { list_append, length } import extdeps.numeric.base16 { int_to_upper_hex } import extdeps.external_authority { ExternalAuthority } import extdeps.uri { Uri, Https } -import v2.std.node { Conj, Edge, Node, Named, Positional, Symbol, TypeNode, Atom } +import v2.std.node { Conj, Edge, Node, Authored, Positional, Symbol, TypeNode, Atom } import v2.std.collection { Map, empty_map, map_insert } import v2.std.diagnostic { Accepted, Rejected } import v2.std.witness { Holds, Violates } @@ -394,7 +394,7 @@ fn swift_row_rules(row: Node) -> Node { } fn swl_named_conj(name: Symbol, target: Node) -> Node { - Node { kind: TypeNode { connective: Conj }, children: [Edge { label: Named { name: name }, target: target }], occurrence_id: OccurrenceSynthetic } + Node { kind: TypeNode { connective: Conj }, children: [Edge { label: Authored { name: name }, target: target }], occurrence_id: OccurrenceSynthetic } } // ── Emission ────────────────────────────────────────────────────────────────────────────────── diff --git a/src/v2/extdeps/languages/swift_decl.dag b/src/v2/extdeps/languages/swift_decl.dag index 0273d5237fc..7dfed880e06 100644 --- a/src/v2/extdeps/languages/swift_decl.dag +++ b/src/v2/extdeps/languages/swift_decl.dag @@ -24,7 +24,7 @@ import std.algebra { list_append } import v2.std.node { Conj, Edge, - Named, + Authored, Node, Symbol, TypeNode, @@ -61,7 +61,7 @@ data swift_decl_primitive_spelling_frontier: DissolutionCondition = unbound_diss ) fn swift_decl_named_edge(name: Symbol, target: Node) -> Edge { - Edge { label: Named { name: name }, target: target } + Edge { label: Authored { name: name }, target: target } } fn swift_decl_type_expr_productions() -> List { diff --git a/src/v2/extdeps/languages/typescript.dag b/src/v2/extdeps/languages/typescript.dag index e450c4d8f13..33a50c487d5 100644 --- a/src/v2/extdeps/languages/typescript.dag +++ b/src/v2/extdeps/languages/typescript.dag @@ -192,7 +192,7 @@ import v2.std.node { Disj, Edge, Instantiation, - Named, + Authored, Node, Positional, Symbol, @@ -287,7 +287,7 @@ fn ts_inhabitant_atom(id: Symbol) -> Node { } fn ts_named_edge(name: Symbol, target: Node) -> Edge { - Edge { label: Named { name: name }, target: target } + Edge { label: Authored { name: name }, target: target } } fn ts_primitive_algebra_witness_node( diff --git a/src/v2/extdeps/languages/verilog.dag b/src/v2/extdeps/languages/verilog.dag index f6e59088dff..359b0c0cbb7 100644 --- a/src/v2/extdeps/languages/verilog.dag +++ b/src/v2/extdeps/languages/verilog.dag @@ -8,7 +8,7 @@ import v2.std.node { Conj, Edge, Node, - Named, + Authored, Positional, Symbol, TypeNode, @@ -1061,7 +1061,7 @@ fn verilog_module_relation_row() -> Witness { } fn verilog_named_edge(name: Symbol, target: Node) -> Edge { - Edge { label: Named { name: name }, target: target } + Edge { label: Authored { name: name }, target: target } } fn verilog_row_or_empty(lhs: Symbol, emitted: Node) -> Node { diff --git a/src/v2/extdeps/languages/wasm.dag b/src/v2/extdeps/languages/wasm.dag index 0fcbc9c6bd2..8140f590a84 100644 --- a/src/v2/extdeps/languages/wasm.dag +++ b/src/v2/extdeps/languages/wasm.dag @@ -88,7 +88,7 @@ import v2.std.node { Atom, Conj, Edge, - Named, + Authored, Node, Positional, Symbol, @@ -336,7 +336,7 @@ fn wasm_float_inhabitant_for_facts(facts: WasmFloatPrimitiveFacts) -> Node { } fn wasm_named_edge(name: Symbol, target: Node) -> Edge { - Edge { label: Named { name: name }, target: target } + Edge { label: Authored { name: name }, target: target } } fn wasm_int_numeric_immediate_node( diff --git a/src/v2/lens/affected_set.dag b/src/v2/lens/affected_set.dag index dcf23b170f9..ec06dec758d 100644 --- a/src/v2/lens/affected_set.dag +++ b/src/v2/lens/affected_set.dag @@ -63,7 +63,7 @@ import v2.std.node { } import v2.std.witness { Holds, Witness } import v2.std.node_reflection { coproduct_arm_keys } -import v2.lens.application { AncestorFrame, AncestorWalk, collect_ancestor_frames, find_child_by_name, subterm_at, substitute_at } +import v2.lens.application { AncestorFrame, AncestorWalk, collect_ancestor_frames, find_child_by_name, subterm_at, substitute_at, find_child_by_label } type Dag = Node @@ -1131,7 +1131,7 @@ fn canonical_changed_dimension_receipt(dag: Dag, edit: Edit) -> ChangedDimension } fn canonical_ancestor_frame_dependencies(frame: AncestorFrame) -> FrontierReceipt { - match find_child_by_name(root: frame.ancestor, name: frame.step) { + match find_child_by_label(root: frame.ancestor, label: frame.step) { Accepted { value: child, diagnostics: _ } => FrontierProduced { dependencies: [ diff --git a/src/v2/lens/affected_set_examples.dag b/src/v2/lens/affected_set_examples.dag index 379cc359212..8903a5f8731 100644 --- a/src/v2/lens/affected_set_examples.dag +++ b/src/v2/lens/affected_set_examples.dag @@ -14,7 +14,7 @@ import v2.std.diagnostic { ExternalContractUnknown, diagnostics_singleton } -import v2.std.node { Atom, Conj, Diff, Edit, Hash, Node, Path, Symbol, TypeNode } +import v2.std.node { Atom, Conj, Diff, Edit, Hash, Node, Path, Symbol, TypeNode, Authored } import v2.lens.affected_set { AffectedBoundaryRead, AffectedFrontierRead, @@ -57,7 +57,7 @@ data affected_set_claim_failure_node: Node = Node { occurrence_id: OccurrenceSynthetic } -data affected_set_example_path: Path = Path { steps: [^affected_set_example_path_symbol] } +data affected_set_example_path: Path = Path { steps: [Authored { name: ^affected_set_example_path_symbol }] } data affected_set_example_edit: Edit = Edit { at: affected_set_example_path, diff --git a/src/v2/lens/application.dag b/src/v2/lens/application.dag index f0ee52ee042..d816233c15c 100644 --- a/src/v2/lens/application.dag +++ b/src/v2/lens/application.dag @@ -1,4 +1,6 @@ module v2.lens.application + +import v2.std.node_query { find_labeled_child } import v2.lens.common.construction_justification { ConstructionJustification, WallAfterGrounding } import std.disposition { RealizationDispatch } @@ -26,18 +28,16 @@ import v2.std.node { Diff, Edge, Edit, - Named, + Authored, Node, NodeKind, Path, Positional, Symbol, TypeNode, - name_occurrences, node_rebuild, -} -import v2.std.node_query { - find_named_child + EdgeLabel, + label_occurrences, } import v2.std.report { Report, report_reason_to_diagnostic_reason } @@ -147,7 +147,13 @@ fn advisory_report_diagnostic(report: Report) -> Diagnostic { } fn find_child_by_name(root: Node, name: Symbol) -> Outcome { - match find_named_child(root: root, name: name) { + find_child_by_label(root: root, label: Authored { name: name }) +} + +// A PATH STEP IS A WHOLE LABEL. An authored step reaches only an authored edge and a structural step +// (an arrow's body, say) only its structural edge, so no authored spelling walks into a marker. +fn find_child_by_label(root: Node, label: EdgeLabel) -> Outcome { + match find_labeled_child(root: root, label: label) { Accepted { value: child, diagnostics: d } => Accepted { value: child, diagnostics: d } Rejected { diagnostics: diags } => if diags.head.reason == ^named_child_ambiguous { @@ -158,7 +164,7 @@ fn find_child_by_name(root: Node, name: Symbol) -> Outcome { } } -fn subterm_at_steps(root: Node, steps: List) -> Outcome { +fn subterm_at_steps(root: Node, steps: List) -> Outcome { fold_list( xs: steps, empty: outcome_accepted(value: root), @@ -166,7 +172,7 @@ fn subterm_at_steps(root: Node, steps: List) -> Outcome { bind_outcome( o: acc, f: fn(current) { - find_child_by_name(root: current, name: step) + find_child_by_label(root: current, label: step) } ) } @@ -182,18 +188,18 @@ fn replace_edge_target(e: Edge, replacement: Node) -> Edge { } type PathSplit { - init: List - last: Symbol + init: List + last: EdgeLabel first: Bool } -fn split_path_steps(root: Node, steps: List) -> Outcome { +fn split_path_steps(root: Node, steps: List) -> Outcome { if is_empty(xs: steps) { outcome_rejected(d: path_unresolvable_diagnostic(at: root)) } else { outcome_accepted(value: fold_list( xs: steps, - empty: PathSplit { init: [], last: ^path_unresolvable_reason, first: true }, + empty: PathSplit { init: [], last: Positional, first: true }, cons: fn(split, step) { match split.first { true => PathSplit { init: [], last: step, first: false } @@ -208,24 +214,21 @@ fn split_path_steps(root: Node, steps: List) -> Outcome { } } -fn rebuild_node_with_child(root: Node, name: Symbol, child: Node) -> Outcome { - if name_occurrences(name: name, children: root.children) == 0 { +fn rebuild_node_with_child(root: Node, label: EdgeLabel, child: Node) -> Outcome { + let hits = if label == Positional { 0 } else { label_occurrences(label: label, children: root.children) } + if hits == 0 { outcome_rejected(d: path_unresolvable_diagnostic(at: root)) - } else if name_occurrences(name: name, children: root.children) == 1 { + } else if hits == 1 { outcome_accepted(value: node_rebuild( n: root, children: fold( root.children, init: Empty, f: fn(current_acc, edge) { - match edge.label { - Named { name: edge_name } => - let next_edge = match edge_name == name { - true => replace_edge_target(e: edge, replacement: child) - false => edge - } - list_snoc_item(xs: current_acc, item: next_edge) - Positional => list_snoc_item(xs: current_acc, item: edge) + if edge.label == label { + list_snoc_item(xs: current_acc, item: replace_edge_target(e: edge, replacement: child)) + } else { + list_snoc_item(xs: current_acc, item: edge) } } ) @@ -237,7 +240,7 @@ fn rebuild_node_with_child(root: Node, name: Symbol, child: Node) -> Outcome } -fn collect_ancestor_frames(root: Node, steps: List) -> Outcome { +fn collect_ancestor_frames(root: Node, steps: List) -> Outcome { fold_list( xs: steps, empty: outcome_accepted(value: AncestorWalk { current: root, frames: [] }), @@ -254,7 +257,7 @@ fn collect_ancestor_frames(root: Node, steps: List) -> Outcome, frame: AncestorFram f: fn(child) { rebuild_node_with_child( root: frame.ancestor, - name: frame.step, + label: frame.step, child: child ) } @@ -305,7 +308,7 @@ fn substitute_at(root: Node, path: Path, replacement: Node) -> Outcome { bind_outcome( o: rebuild_node_with_child( root: walk.current, - name: split.last, + label: split.last, child: replacement ), f: fn(rebuilt_leaf) { diff --git a/src/v2/lens/complexity_accumulator_copy/analyze.dag b/src/v2/lens/complexity_accumulator_copy/analyze.dag index 33ea78d7767..f4a4ff1e029 100644 --- a/src/v2/lens/complexity_accumulator_copy/analyze.dag +++ b/src/v2/lens/complexity_accumulator_copy/analyze.dag @@ -79,7 +79,8 @@ fn postfix_expr_capture(node: Node) -> Optional { fn edge_skips_identifier_count(e: Edge) -> Bool { match e.label { - Named { name: nm } => nm == ^grammar_production_identity_node_projection + Authored { name: nm } => nm == ^grammar_production_identity_node_projection + StructuralLabel { label: _ } => false Positional => false } } diff --git a/src/v2/lens/complexity_accumulator_copy/corpus_census.dag b/src/v2/lens/complexity_accumulator_copy/corpus_census.dag index 35c683814c1..33e3656b090 100644 --- a/src/v2/lens/complexity_accumulator_copy/corpus_census.dag +++ b/src/v2/lens/complexity_accumulator_copy/corpus_census.dag @@ -40,6 +40,8 @@ import v2.lens.cost { cost_lens } import v2.std.node { + StructuralLabel, + label_sort_key, Arrow, Atom, Bind, @@ -50,7 +52,7 @@ import v2.std.node { Disj, Instantiation, Loop, - Named, + Authored, Transform, TypeNode, Value @@ -403,7 +405,8 @@ fn ingested_root_child_labels(path: String) -> String { SourceTreeEstablished { root: r } => fold(r.children, init: "", f: fn(acc, e) { match e.label { - Named { name: n } => join([acc, "|N:", symbol_lexeme(n)], "") + Authored { name: n } => join([acc, "|N:", symbol_lexeme(n)], "") + StructuralLabel { label: _ } => join([acc, "|S:", symbol_lexeme(label_sort_key(label: e.label))], "") Positional => join([acc, "|P"], "") } }) diff --git a/src/v2/lens/cost.dag b/src/v2/lens/cost.dag index 0cefdcf359f..a8c59f3caea 100644 --- a/src/v2/lens/cost.dag +++ b/src/v2/lens/cost.dag @@ -40,7 +40,7 @@ import v2.std.node { CostEdgeNotPriced, CostEdgePricedOnce, cost_edge_role, - Named, + Authored, Node, NodeFold, Symbol, diff --git a/src/v2/lens/cost/copied_port_citations.dag b/src/v2/lens/cost/copied_port_citations.dag index 19ade4d3581..226742c25f3 100644 --- a/src/v2/lens/cost/copied_port_citations.dag +++ b/src/v2/lens/cost/copied_port_citations.dag @@ -28,12 +28,15 @@ import v2.std.node { Conj, Edge, Loop, - Named, + Authored, Node, Positional, Symbol, Transform, TypeNode, + ArrowBodyEdge, + LoopBoundEdge, + core_edge_label, } // Cited combiner Arrow bodies for per-op derivation (Wave 1 Gate 1 C1). Each row pairs a combiner @@ -149,7 +152,7 @@ fn citation_loop_body_linear_in(measure: Node) -> Node { occurrence_id: OccurrenceSynthetic } }, - Edge { label: Named { name: ^loop_bound_edge }, target: measure } + Edge { label: core_edge_label(marker: LoopBoundEdge), target: measure } ], occurrence_id: OccurrenceSynthetic } @@ -180,7 +183,7 @@ fn citation_arrow_two_param_loop( }, signature.order, Edge { - label: Named { name: ^arrow_body_edge }, + label: core_edge_label(marker: ArrowBodyEdge), target: citation_loop_body_linear_in(measure: measure) } ], diff --git a/src/v2/lens/cost/copied_port_derivation.dag b/src/v2/lens/cost/copied_port_derivation.dag index a08cefb3da2..f4c48be1b73 100644 --- a/src/v2/lens/cost/copied_port_derivation.dag +++ b/src/v2/lens/cost/copied_port_derivation.dag @@ -25,9 +25,10 @@ import v2.std.node { Atom, Conj, Edge, - Named, + Authored, Node, Positional, + StructuralLabel, Symbol, TypeNode, arrow_body_target_lookup, @@ -82,7 +83,8 @@ fn arrow_domain_param_nodes(arrow: Node) -> List { ComputationNode { behavior: _ } => acc TypeNode { connective: _ } => acc } - Named { name: _ } => acc + Authored { name: _ } => acc + StructuralLabel { label: _ } => acc } }) ComputationNode { behavior: _ } => Empty diff --git a/src/v2/lens/effect_reach.dag b/src/v2/lens/effect_reach.dag index 84fd468f76a..9b2cfe0c21d 100644 --- a/src/v2/lens/effect_reach.dag +++ b/src/v2/lens/effect_reach.dag @@ -61,6 +61,7 @@ import v2.std.node { Symbol, fold_node, symbol_lexeme, + Authored, StructuralLabel, } import v2.std.text { String, string_eq } @@ -196,8 +197,9 @@ fn path_literal_from_lexeme( fn positional_child_targets(node: Node) -> List { fold(node.children, init: empty_node_list, f: fn(acc, e) { match e.label { + StructuralLabel { label: _ } => acc Positional => list_snoc_item(xs: acc, item: e.target) - Named { name: _ } => acc + Authored { name: _ } => acc } }) } diff --git a/src/v2/lens/enforcement/receipts.dag b/src/v2/lens/enforcement/receipts.dag index b30bbaf4c85..13159add18a 100644 --- a/src/v2/lens/enforcement/receipts.dag +++ b/src/v2/lens/enforcement/receipts.dag @@ -7,7 +7,7 @@ import v2.std.collection { List } import v2.std.integer { Int } import v2.std.logic { Bool } import v2.std.text { String } -import v2.std.node { Atom, ComputationNode, Edge, Loop, Named, Node, Positional, TypeNode } +import v2.std.node { Atom, ComputationNode, Edge, Loop, Authored, Node, Positional, TypeNode, LoopBoundEdge, core_edge_label } import v2.std.witness { Holds, Violates, Witness } import v2.std.decl_index { DeclFact, decl_facts_is_fn_like } import v2.std.qualified_name { QualifiedName, qualified_name_from_dotted_string } @@ -190,8 +190,8 @@ data cost_red_control_probe: Node = Node { kind: ComputationNode { behavior: Loop }, children: [ Edge { label: Positional, target: enforcement_red_probe_body_leaf }, - Edge { label: Named { name: ^loop_bound_edge }, target: enforcement_red_probe_measure_leaf }, - Edge { label: Named { name: ^enforcement_red_probe_extra }, target: enforcement_red_probe_extra_leaf } + Edge { label: core_edge_label(marker: LoopBoundEdge), target: enforcement_red_probe_measure_leaf }, + Edge { label: Authored { name: ^enforcement_red_probe_extra }, target: enforcement_red_probe_extra_leaf } ], occurrence_id: OccurrenceSynthetic } diff --git a/src/v2/lens/fact_density.dag b/src/v2/lens/fact_density.dag index e8f17507018..61b13156ca3 100644 --- a/src/v2/lens/fact_density.dag +++ b/src/v2/lens/fact_density.dag @@ -1,5 +1,8 @@ module v2.lens.fact_density +import v2.std.node { Authored, StructuralLabel } +import v2.lens.common.construction_justification { ConstructionJustification } + import v2.std.witness { Holds } import v2.std.diagnostic { outcome_accepted, outcome_rejected, node_locus } @@ -21,7 +24,8 @@ type SourceSpecReadFact fn named_fact_count(children: List) -> v2.std.nat.Nat { fold(children, init: v2.std.nat.Zero, f: fn(acc, e) { match e.label { - Named { name: _ } => v2.std.nat.Succ { prev: acc } + Authored { name: _ } => v2.std.nat.Succ { prev: acc } + StructuralLabel { label: _ } => acc Positional => acc } }) diff --git a/src/v2/lens/fallback_arm_census.dag b/src/v2/lens/fallback_arm_census.dag index d9c7d98d8c7..aa57e5d583b 100644 --- a/src/v2/lens/fallback_arm_census.dag +++ b/src/v2/lens/fallback_arm_census.dag @@ -17,10 +17,10 @@ import v2.std.node { Node, Symbol, TypeNode, - match_arm_body, - match_arm_pattern + MatchArmBodyEdge, + MatchArmPatternEdge, } -import v2.std.node_query { find_named_child, node_positional_child_targets } +import v2.std.node_query { node_positional_child_targets, find_core_child } import v2.std.diagnostic { Accepted, Rejected } import v2.extdeps.languages.dag { dag_match_arm_node, @@ -123,9 +123,9 @@ fn classify_planted_arm( scrutinee_closed_total: Bool, interim_declared: Bool ) -> FallbackArmClass { - match find_named_child(root: arm, name: match_arm_pattern) { + match find_core_child(root: arm, marker: MatchArmPatternEdge) { Accepted { value: pat_node, diagnostics: _ } => - match find_named_child(root: arm, name: match_arm_body) { + match find_core_child(root: arm, marker: MatchArmBodyEdge) { Accepted { value: body_node, diagnostics: _ } => classify_fallback_arm( input: FallbackArmClassifyInput { diff --git a/src/v2/lens/identity_captured_navigation/analyze.dag b/src/v2/lens/identity_captured_navigation/analyze.dag index c628004c178..6b776ac168e 100644 --- a/src/v2/lens/identity_captured_navigation/analyze.dag +++ b/src/v2/lens/identity_captured_navigation/analyze.dag @@ -76,7 +76,8 @@ fn symbol_list_length(xs: List) -> Int { fn edge_is_identity_projection(e: Edge) -> Bool { match e.label { - Named { name: nm } => nm == ^grammar_production_identity_node_projection + Authored { name: nm } => nm == ^grammar_production_identity_node_projection + StructuralLabel { label: _ } => false Positional => false } } diff --git a/src/v2/lens/lifecycle_carrier.dag b/src/v2/lens/lifecycle_carrier.dag index 1b82066dc66..9a111458681 100644 --- a/src/v2/lens/lifecycle_carrier.dag +++ b/src/v2/lens/lifecycle_carrier.dag @@ -15,12 +15,13 @@ import v2.std.witness { Holds, Witness } import v2.std.node { ComputationNode, Edge, - Named, + Authored, Node, Positional, Symbol, TypeNode, symbol_lexeme, + StructuralLabel, } import v2.std.node_query { edge_field_type_name, member_edge_type_node, member_not_a_binder_diagnostic } import v2.std.collection { List } @@ -114,7 +115,7 @@ fn lifecycle_carrier_diagnostic(carrier: Node) -> Diagnostic { // fields ever reach the walk. fn field_lifecycle_violation(carrier: Node, edge: Edge) -> Optional { match edge.label { - Named { name: nm } => + Authored { name: nm } => match member_edge_type_node(e: edge) { Absent => optional_present(value: member_not_a_binder_diagnostic(e: edge)) Present { value: t } => @@ -124,6 +125,7 @@ fn field_lifecycle_violation(carrier: Node, edge: Edge) -> Optional optional_absent() } } + StructuralLabel { label: _ } => optional_absent() Positional => optional_absent() } } diff --git a/src/v2/lens/live_read_classification.dag b/src/v2/lens/live_read_classification.dag index 5063e888aa0..430831f1147 100644 --- a/src/v2/lens/live_read_classification.dag +++ b/src/v2/lens/live_read_classification.dag @@ -1,5 +1,7 @@ module v2.lens.live_read_classification +import v2.std.node { Authored, StructuralLabel } + // THE IMPORT THIS MODULE'S BARE REFERENCES WERE RELYING ON THE POOL TO SUPPLY. Every call to // witness_import_closure here resolved only when some unrelated module elsewhere in the assembled // closure had already pulled v2.lens.witness_cost_locality in — the pool-membership coincidence @@ -213,8 +215,9 @@ fn carrier_for_callee_text( fn positional_child_targets(node: Node) -> List { fold(node.children, init: empty_node_list, f: fn(acc, e) { match e.label { + StructuralLabel { label: _ } => acc Positional => list_snoc_item(xs: acc, item: e.target) - Named { name: _ } => acc + Authored { name: _ } => acc } }) } diff --git a/src/v2/lens/module_graph.dag b/src/v2/lens/module_graph.dag index 134e1b7fb89..c0699485519 100644 --- a/src/v2/lens/module_graph.dag +++ b/src/v2/lens/module_graph.dag @@ -64,7 +64,8 @@ import v2.compiler.source_authority_read { source_root_ingest_from_source_refs } import v2.compiler.symbol_index_fill { symbol_index_fill_module_root } import v2.extdeps.languages.dag { dag_language_model, - qualified_name_from_module_node + qualified_name_from_module_node, + dag_surface_edge_label, } type ModuleDeclarationFact { @@ -313,14 +314,16 @@ fn located_roots_from_source_root_ingest( ) } +// Whether the mention sits under an import production. Each position label is compared WHOLE with +// the dag surface production's label, so an authored name spelled like an import production is a +// different label and never makes an ordinary mention read as import syntax. fn site_is_import_syntax_mention(site: ReferenceSite) -> Bool { - contains(xs: site.position, item: ^dag_surface_import_decl, eq: symbol_eq) - || contains(xs: site.position, item: ^dag_surface_import_block, eq: symbol_eq) - || contains( - xs: site.position, - item: ^dag_surface_import_decl_qualified_name, - eq: symbol_eq - ) + fold(site.position, init: false, f: fn(found, label) { + found + || (label == dag_surface_edge_label(edge: ^dag_surface_import_decl)) + || (label == dag_surface_edge_label(edge: ^dag_surface_import_block)) + || (label == dag_surface_edge_label(edge: ^dag_surface_import_decl_qualified_name)) + }) } fn reference_sites_excluding_import_syntax( diff --git a/src/v2/lens/reference_deps.dag b/src/v2/lens/reference_deps.dag index 96c44598f0b..08767158170 100644 --- a/src/v2/lens/reference_deps.dag +++ b/src/v2/lens/reference_deps.dag @@ -1,6 +1,7 @@ module v2.lens.reference_deps -import v2.extdeps.languages.dag { dag_language_model, parse_production_emitted_identity_optional, qualified_name_from_module_node } +import v2.std.node_query { find_labeled_child } +import v2.extdeps.languages.dag { dag_language_model, parse_production_emitted_identity_optional, qualified_name_from_module_node, dag_surface_edge_label } import v2.std.algebra { fold_list, list_reverse } import std.algebra { Cons, Empty, FreeMonoid } import v2.compiler.name_resolve { Admission, Import, ImportVisible, ResolutionSubject, resolve_diagnostics } @@ -47,7 +48,7 @@ fn reference_qn_from_import_decl_strict(node: Node, module_root: Node) -> Outcom emitted: ^dag_surface_qualified_name ) { ParseSubtreeAbsent => - match find_named_child(root: node, name: ^dag_surface_import_decl_qualified_name) { + match find_labeled_child(root: node, label: dag_surface_edge_label(edge: ^dag_surface_import_decl_qualified_name)) { Rejected { diagnostics: d } => v2.std.diagnostic.Rejected { diagnostics: d } Accepted { value: qn_node, diagnostics: _ } => qualified_name_from_node(root: qn_node) diff --git a/src/v2/lens/reference_derived_residency_reading.dag b/src/v2/lens/reference_derived_residency_reading.dag index 2e1c439f807..44217c642ec 100644 --- a/src/v2/lens/reference_derived_residency_reading.dag +++ b/src/v2/lens/reference_derived_residency_reading.dag @@ -34,6 +34,7 @@ import v2.std.node { Symbol, TypeNode, node_subtree_nodes, + Authored, StructuralLabel, symbol_intern_lexeme, } @@ -154,10 +155,11 @@ fn decl_first_unrecognised_atom(decl: Node) -> Optional { Present { value: _ } => acc Absent => match edge.label { - Named { name: _ } => match member_edge_type_node(e: edge) { + Authored { name: _ } => match member_edge_type_node(e: edge) { Present { value: t } => first_unrecognised_atom(target: t) Absent => acc } + StructuralLabel { label: _ } => acc Positional => acc } } @@ -177,7 +179,8 @@ fn decl_first_member_not_a_binder(decl: Node) -> Optional { Absent => match edge.label { Positional => acc - Named { name: nm } => + StructuralLabel { label: _ } => acc + Authored { name: nm } => match member_edge_type_node(e: edge) { Present { value: _ } => acc Absent => optional_present(value: nm) @@ -233,7 +236,8 @@ fn decl_has_keyed_population_field(decl: Node) -> Bool { TypeNode { connective: _ } => fold(decl.children, init: false, f: fn(acc, edge) { match edge.label { - Named { name: _ } => acc || residency_member_type_shows(e: edge, shows: fn(t) { type_expr_is_keyed_population(target: t) }) + Authored { name: _ } => acc || residency_member_type_shows(e: edge, shows: fn(t) { type_expr_is_keyed_population(target: t) }) + StructuralLabel { label: _ } => acc Positional => acc } }) @@ -246,7 +250,8 @@ fn decl_has_syntax_field(decl: Node) -> Bool { TypeNode { connective: _ } => fold(decl.children, init: false, f: fn(acc, edge) { match edge.label { - Named { name: _ } => acc || residency_member_type_shows(e: edge, shows: fn(t) { type_expr_holds_syntax(target: t) }) + Authored { name: _ } => acc || residency_member_type_shows(e: edge, shows: fn(t) { type_expr_holds_syntax(target: t) }) + StructuralLabel { label: _ } => acc Positional => acc } }) diff --git a/src/v2/lens/testgen.dag b/src/v2/lens/testgen.dag index e5d70640e87..8994547be28 100644 --- a/src/v2/lens/testgen.dag +++ b/src/v2/lens/testgen.dag @@ -52,7 +52,7 @@ import v2.std.node { Atom, Edge, Node, - Named, + Authored, Positional, Connective, Conj, @@ -477,9 +477,9 @@ fn refinement_preservation_list_node(xs: List) -> Node { Node { kind: TypeNode { connective: Atom { identity: ^refinement_preservation_list_cons_node } }, children: [ - Edge { label: Named { name: ^refinement_preservation_list_head_edge }, target: h }, + Edge { label: Authored { name: ^refinement_preservation_list_head_edge }, target: h }, Edge { - label: Named { name: ^refinement_preservation_list_tail_edge }, + label: Authored { name: ^refinement_preservation_list_tail_edge }, target: tail_node } ], @@ -769,9 +769,9 @@ fn algebra_law_subject_node(subject: AlgebraLawSubject) -> Node { Node { kind: TypeNode { connective: Conj }, children: [ - Edge { label: Named { name: ^t19_algebra_law_algebra_field }, target: algebra_law_subject_atom(s: subject.algebra) }, - Edge { label: Named { name: ^t19_algebra_law_inhabitant_field }, target: algebra_law_subject_atom(s: subject.inhabitant) }, - Edge { label: Named { name: ^t19_algebra_law_law_field }, target: algebra_law_subject_atom(s: subject.law) }, + Edge { label: Authored { name: ^t19_algebra_law_algebra_field }, target: algebra_law_subject_atom(s: subject.algebra) }, + Edge { label: Authored { name: ^t19_algebra_law_inhabitant_field }, target: algebra_law_subject_atom(s: subject.inhabitant) }, + Edge { label: Authored { name: ^t19_algebra_law_law_field }, target: algebra_law_subject_atom(s: subject.law) }, ], occurrence_id: OccurrenceSynthetic } @@ -781,8 +781,8 @@ fn algebra_law_claim_term(subject: AlgebraLawSubject, expression: Node) -> Node Node { kind: TypeNode { connective: Conj }, children: [ - Edge { label: Named { name: ^t19_algebra_law_subject_field }, target: algebra_law_subject_node(subject: subject) }, - Edge { label: Named { name: ^t19_algebra_law_expression_field }, target: expression }, + Edge { label: Authored { name: ^t19_algebra_law_subject_field }, target: algebra_law_subject_node(subject: subject) }, + Edge { label: Authored { name: ^t19_algebra_law_expression_field }, target: expression }, ], occurrence_id: OccurrenceSynthetic } @@ -800,9 +800,9 @@ fn witness_validity_predicate_node(p: PreservationPredicate) -> Node { Node { kind: TypeNode { connective: Conj }, children: [ - Edge { label: Named { name: ^witness_validity_field_algebra }, target: p.algebra }, + Edge { label: Authored { name: ^witness_validity_field_algebra }, target: p.algebra }, Edge { - label: Named { name: ^witness_validity_field_preservation_rule }, + label: Authored { name: ^witness_validity_field_preservation_rule }, target: witness_validity_symbol_atom_node(s: p.preservation_rule) } ], @@ -815,10 +815,10 @@ fn witness_validity_witness_node(w: StructuralPropertyWitness) -> Node { kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: ^witness_validity_field_property }, + label: Authored { name: ^witness_validity_field_property }, target: witness_validity_symbol_atom_node(s: w.property) }, - Edge { label: Named { name: ^witness_validity_field_evidence }, target: w.evidence } + Edge { label: Authored { name: ^witness_validity_field_evidence }, target: w.evidence } ], occurrence_id: OccurrenceSynthetic } @@ -852,18 +852,18 @@ fn witness_validity_subject_node( value: Node { kind: TypeNode { connective: Conj }, children: [ - Edge { label: Named { name: ^witness_validity_field_source_facts }, target: source_facts }, - Edge { label: Named { name: ^witness_validity_field_candidate }, target: candidate }, + Edge { label: Authored { name: ^witness_validity_field_source_facts }, target: source_facts }, + Edge { label: Authored { name: ^witness_validity_field_candidate }, target: candidate }, Edge { - label: Named { name: ^witness_validity_field_predicate }, + label: Authored { name: ^witness_validity_field_predicate }, target: witness_validity_predicate_node(p: predicate) }, Edge { - label: Named { name: ^witness_validity_field_witness }, + label: Authored { name: ^witness_validity_field_witness }, target: witness_validity_witness_node(w: witness) }, Edge { - label: Named { name: ^witness_validity_field_oracle_outcome }, + label: Authored { name: ^witness_validity_field_oracle_outcome }, target: oracle_outcome } ], @@ -894,7 +894,7 @@ fn witness_validity_correction_node(c: Correction) -> Node { Node { kind: TypeNode { connective: Conj }, children: [ - Edge { label: Named { name: ^witness_validity_correction_tag_suggested }, target: n } + Edge { label: Authored { name: ^witness_validity_correction_tag_suggested }, target: n } ], occurrence_id: OccurrenceSynthetic } @@ -903,7 +903,7 @@ fn witness_validity_correction_node(c: Correction) -> Node { kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: ^witness_validity_correction_tag_unavailable }, + label: Authored { name: ^witness_validity_correction_tag_unavailable }, target: witness_validity_no_correction_reason_node(r: r) } ], @@ -937,16 +937,16 @@ fn witness_validity_locus_node(l: Locus) -> Outcome { kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: ^witness_validity_locus_tag_textual }, + label: Authored { name: ^witness_validity_locus_tag_textual }, target: Node { kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: ^witness_validity_locus_textual_file }, + label: Authored { name: ^witness_validity_locus_textual_file }, target: witness_validity_symbol_atom_node(s: f) }, Edge { - label: Named { name: ^witness_validity_locus_textual_extent }, + label: Authored { name: ^witness_validity_locus_textual_extent }, target: en } ], @@ -964,7 +964,7 @@ fn witness_validity_locus_node(l: Locus) -> Outcome { value: Node { kind: TypeNode { connective: Conj }, children: [ - Edge { label: Named { name: ^witness_validity_locus_tag_node }, target: a.at } + Edge { label: Authored { name: ^witness_validity_locus_tag_node }, target: a.at } ], occurrence_id: OccurrenceSynthetic }, @@ -977,15 +977,15 @@ fn witness_validity_locus_node(l: Locus) -> Outcome { kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: ^witness_validity_locus_tag_source_port }, + label: Authored { name: ^witness_validity_locus_tag_source_port }, target: witness_validity_symbol_atom_node(s: a.at) }, Edge { - label: Named { name: ^witness_validity_locus_source_port_file }, + label: Authored { name: ^witness_validity_locus_source_port_file }, target: witness_validity_symbol_atom_node(s: f) }, Edge { - label: Named { name: ^witness_validity_locus_source_port_extent }, + label: Authored { name: ^witness_validity_locus_source_port_extent }, target: en } ], @@ -1000,11 +1000,11 @@ fn witness_validity_locus_node(l: Locus) -> Outcome { kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: ^witness_validity_locus_tag_invariant_port }, + label: Authored { name: ^witness_validity_locus_tag_invariant_port }, target: witness_validity_symbol_atom_node(s: a.at) }, Edge { - label: Named { name: ^witness_validity_locus_invariant }, + label: Authored { name: ^witness_validity_locus_invariant }, target: witness_validity_symbol_atom_node(s: invariant) } ], @@ -1020,7 +1020,7 @@ fn witness_validity_locus_node(l: Locus) -> Outcome { xs: declaration, empty: [ Edge { - label: Named { name: ^witness_validity_locus_tag_declaration }, + label: Authored { name: ^witness_validity_locus_tag_declaration }, target: witness_validity_symbol_atom_node(s: ^witness_validity_locus_tag_declaration) } ], @@ -1045,15 +1045,15 @@ fn witness_validity_diagnostic_node(d: Diagnostic) -> Outcome { kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: ^witness_validity_diag_field_reason }, + label: Authored { name: ^witness_validity_diag_field_reason }, target: witness_validity_symbol_atom_node(s: d.reason) }, Edge { - label: Named { name: ^witness_validity_diag_field_at }, + label: Authored { name: ^witness_validity_diag_field_at }, target: at_node }, Edge { - label: Named { name: ^witness_validity_diag_field_correction }, + label: Authored { name: ^witness_validity_diag_field_correction }, target: witness_validity_correction_node(c: d.correction) } ], @@ -1078,8 +1078,8 @@ fn witness_validity_diagnostic_list_node(xs: FreeMonoid) -> Outcome< value: Node { kind: TypeNode { connective: Conj }, children: [ - Edge { label: Named { name: ^witness_validity_list_cons_head }, target: hn }, - Edge { label: Named { name: ^witness_validity_list_cons_tail }, target: prev_node } + Edge { label: Authored { name: ^witness_validity_list_cons_head }, target: hn }, + Edge { label: Authored { name: ^witness_validity_list_cons_tail }, target: prev_node } ], occurrence_id: OccurrenceSynthetic }, @@ -1099,11 +1099,11 @@ fn witness_validity_non_empty_diagnostics_node(d: NonEmptyDiagnostics) -> Outcom kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: ^witness_validity_diags_field_head }, + label: Authored { name: ^witness_validity_diags_field_head }, target: hn }, Edge { - label: Named { name: ^witness_validity_diags_field_tail }, + label: Authored { name: ^witness_validity_diags_field_tail }, target: tn } ], @@ -1129,7 +1129,7 @@ fn witness_validity_diagnostics_node(ds: Diagnostics) -> Outcome { kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: ^witness_validity_diagnostics_tag_some }, + label: Authored { name: ^witness_validity_diagnostics_tag_some }, target: ndn } ], @@ -1150,16 +1150,16 @@ fn witness_validity_outcome_node(o: Outcome) -> Outco kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: ^witness_validity_outcome_holds }, + label: Authored { name: ^witness_validity_outcome_holds }, target: Node { kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: ^witness_validity_outcome_accepted_value }, + label: Authored { name: ^witness_validity_outcome_accepted_value }, target: witness_validity_witness_node(w: w) }, Edge { - label: Named { name: ^witness_validity_outcome_accepted_diagnostics }, + label: Authored { name: ^witness_validity_outcome_accepted_diagnostics }, target: dsn } ], @@ -1179,7 +1179,7 @@ fn witness_validity_outcome_node(o: Outcome) -> Outco kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: ^witness_validity_outcome_violates }, + label: Authored { name: ^witness_validity_outcome_violates }, target: dn } ], @@ -1648,7 +1648,7 @@ fn coproduct_exhaustiveness_input(anchor: GeneratedAnchorKey) -> Node { }, children: [ Edge { - label: Named { name: ^coproduct_exhaustiveness_omitted_variant_edge }, + label: Authored { name: ^coproduct_exhaustiveness_omitted_variant_edge }, target: coproduct_exhaustiveness_variant_node( omitted_variant: coproduct_exhaustiveness_anchor_omitted_variant(anchor: anchor) ) diff --git a/src/v2/lens/undecidable_verdict_collapse.dag b/src/v2/lens/undecidable_verdict_collapse.dag index 3c6cc0ef9cf..7ee7f09ec98 100644 --- a/src/v2/lens/undecidable_verdict_collapse.dag +++ b/src/v2/lens/undecidable_verdict_collapse.dag @@ -45,10 +45,10 @@ import v2.std.node { Symbol, TypeNode, fold_node_topdown, - match_arm_body, - match_arm_pattern + MatchArmBodyEdge, + MatchArmPatternEdge, } -import v2.std.node_query { find_named_child, node_positional_child_targets } +import v2.std.node_query { node_positional_child_targets, find_core_child } import v2.std.qualified_name { QualifiedName, qualified_name_to_dotted_string } // UNDECIDABLE-VERDICT ROUTING WALL (DESIGN §5 typed-and-located diagnostic; recurring failure mode @@ -194,11 +194,11 @@ fn match_positional_arms(match_node: Node) -> List { } fn arm_collapse_findings(arm: Node) -> List { - match find_named_child(root: arm, name: match_arm_pattern) { + match find_core_child(root: arm, marker: MatchArmPatternEdge) { Rejected { diagnostics: _ } => [] Accepted { value: pat, diagnostics: _ } => if pattern_names_undecidable_verdict(pattern: pat) { - match find_named_child(root: arm, name: match_arm_body) { + match find_core_child(root: arm, marker: MatchArmBodyEdge) { Rejected { diagnostics: _ } => [] Accepted { value: body, diagnostics: _ } => if body_is_decidable_literal(body: body) { diff --git a/src/v2/lens/unit_modeling.dag b/src/v2/lens/unit_modeling.dag index 45369647f6a..5e04af5bf3f 100644 --- a/src/v2/lens/unit_modeling.dag +++ b/src/v2/lens/unit_modeling.dag @@ -1,5 +1,7 @@ module v2.lens.unit_modeling +import v2.std.node { Authored, StructuralLabel } + import v2.lens.common.construction_justification { ConstructionJustification, WallAfterGrounding } import std.disposition { SingleAuthority } @@ -92,7 +94,7 @@ fn type_is_flat_scalar(target: Node) -> Bool { fn field_unit_violation(carrier: Node, edge: Edge) -> Optional { match edge.label { - Named { name: nm } => + Authored { name: nm } => match member_edge_type_node(e: edge) { Absent => optional_present(value: member_not_a_binder_diagnostic(e: edge)) Present { value: t } => @@ -106,6 +108,7 @@ fn field_unit_violation(carrier: Node, edge: Edge) -> Optional { optional_absent() } } + StructuralLabel { label: _ } => optional_absent() Positional => optional_absent() } } diff --git a/src/v2/std/algebra.dag b/src/v2/std/algebra.dag index 764fa69aa9a..8f696f2a02c 100644 --- a/src/v2/std/algebra.dag +++ b/src/v2/std/algebra.dag @@ -1,7 +1,7 @@ module v2.std.algebra import std.occurrence_identity { OccurrenceSynthetic } -import v2.std.node { Conj, Edge, Named, Node, TypeNode } +import v2.std.node { Conj, Edge, Authored, Node, TypeNode } import v2.std.optional { Optional, optional_absent, optional_present } import std.algebra { AbelianGroup, @@ -123,8 +123,8 @@ fn fold_list_node( Node { kind: TypeNode { connective: Conj }, children: [ - Edge { label: Named { name: ^fold_list_node_head }, target: item_node(item) }, - Edge { label: Named { name: ^fold_list_node_tail }, target: tail_node }, + Edge { label: Authored { name: ^fold_list_node_head }, target: item_node(item) }, + Edge { label: Authored { name: ^fold_list_node_tail }, target: tail_node }, ], occurrence_id: OccurrenceSynthetic } diff --git a/src/v2/std/algebra_structure_signature.dag b/src/v2/std/algebra_structure_signature.dag index 91890337c09..3494e3b9c9c 100644 --- a/src/v2/std/algebra_structure_signature.dag +++ b/src/v2/std/algebra_structure_signature.dag @@ -4,7 +4,7 @@ import v2.std.algebra { algebra_empty_conj } import v2.std.arrow_signature { anonymous_signature_arrow } import v2.std.node_query { binder_edge } import v2.std.logic { bool_node } -import v2.std.node { Atom, Conj, Disj, Edge, Named, Node, TypeNode } +import v2.std.node { Atom, Conj, Disj, Edge, Authored, Node, TypeNode } // THE ALGEBRA'S STRUCTURE SIGNATURES AS NODES: each algebraic structure std.algebra declares (magma // through boolean algebra, equivalence, the free monoid) projected to the TypeNode its instances @@ -17,7 +17,7 @@ fn free_monoid_tail_type_fixpoint(inhabitant: Node) -> Node { algebra: Node { kind: TypeNode { connective: Conj }, children: [ - Edge { label: Named { name: ^free_monoid_type_fixpoint }, target: algebra_empty_conj() }, + Edge { label: Authored { name: ^free_monoid_type_fixpoint }, target: algebra_empty_conj() }, ], occurrence_id: OccurrenceSynthetic }, @@ -29,9 +29,9 @@ fn free_monoid_type_node(inhabitant: Node) -> Node { Node { kind: TypeNode { connective: Disj }, children: [ - Edge { label: Named { name: ^free_monoid_variant_empty }, target: algebra_empty_conj() }, + Edge { label: Authored { name: ^free_monoid_variant_empty }, target: algebra_empty_conj() }, Edge { - label: Named { name: ^free_monoid_variant_cons }, + label: Authored { name: ^free_monoid_variant_cons }, target: Node { kind: TypeNode { connective: Conj }, children: [ @@ -58,9 +58,9 @@ fn ordering_type_node() -> Node { Node { kind: TypeNode { connective: Disj }, children: [ - Edge { label: Named { name: ^ordering_variant_less }, target: algebra_empty_conj() }, - Edge { label: Named { name: ^ordering_variant_equal }, target: algebra_empty_conj() }, - Edge { label: Named { name: ^ordering_variant_greater }, target: algebra_empty_conj() }, + Edge { label: Authored { name: ^ordering_variant_less }, target: algebra_empty_conj() }, + Edge { label: Authored { name: ^ordering_variant_equal }, target: algebra_empty_conj() }, + Edge { label: Authored { name: ^ordering_variant_greater }, target: algebra_empty_conj() }, ], occurrence_id: OccurrenceSynthetic } @@ -257,8 +257,8 @@ fn algebra_inhabitance_node(algebra: Node, inhabitant: Node) -> Node { Node { kind: TypeNode { connective: Conj }, children: [ - Edge { label: Named { name: ^algebra_edge }, target: algebra }, - Edge { label: Named { name: ^inhabitant_edge }, target: inhabitant }, + Edge { label: Authored { name: ^algebra_edge }, target: algebra }, + Edge { label: Authored { name: ^inhabitant_edge }, target: inhabitant }, ], occurrence_id: OccurrenceSynthetic } @@ -380,8 +380,8 @@ fn bool_type_node() -> Node { Node { kind: TypeNode { connective: Disj }, children: [ - Edge { label: Named { name: ^bool_variant_true }, target: algebra_empty_conj() }, - Edge { label: Named { name: ^bool_variant_false }, target: algebra_empty_conj() }, + Edge { label: Authored { name: ^bool_variant_true }, target: algebra_empty_conj() }, + Edge { label: Authored { name: ^bool_variant_false }, target: algebra_empty_conj() }, ], occurrence_id: OccurrenceSynthetic } diff --git a/src/v2/std/anonymous_binder.dag b/src/v2/std/anonymous_binder.dag index 7d479272fbb..2ee3d3d5bd4 100644 --- a/src/v2/std/anonymous_binder.dag +++ b/src/v2/std/anonymous_binder.dag @@ -5,7 +5,7 @@ import v2.std.algebra { list_reverse } import v2.std.collection { List } import v2.std.integer { Int, integer_int_to_decimal_string } import v2.std.logic { Bool } -import v2.std.node { Edge, Named, Positional, Symbol, symbol_intern_lexeme, symbol_lexeme } +import v2.std.node { Edge, Authored, Positional, Symbol, symbol_intern_lexeme, symbol_lexeme, StructuralLabel } import v2.std.node_query { binder_relabelled, pattern_wildcard_name } // AN ANONYMOUS PARAMETER SLOT IS A MINTED BINDER, NOT A FIELD NAMED `_`. A function's domain is a @@ -107,13 +107,15 @@ fn anonymous_binder_mint_parameter_list(edges: List) -> DeclaredParameterL let minted = fold(edges, init: AnonymousBinderMint { slot: 0, edges: Empty, order: Empty }, f: fn(acc, e) { let slot = acc.slot + 1 match e.label { - Named { name: sym } => + Authored { name: sym } => let label = if sym == pattern_wildcard_name() { anonymous_param_label(slot: slot) } else { sym } AnonymousBinderMint { slot: slot, edges: Cons { head: binder_relabelled(binder: e, name: label), tail: acc.edges }, order: Cons { head: label, tail: acc.order } } + StructuralLabel { label: _ } => + AnonymousBinderMint { slot: slot, edges: Cons { head: e, tail: acc.edges }, order: acc.order } Positional => AnonymousBinderMint { slot: slot, edges: Cons { head: e, tail: acc.edges }, order: acc.order } } diff --git a/src/v2/std/arrow_contract.dag b/src/v2/std/arrow_contract.dag index 6faeaf4d13f..ab3080a2b39 100644 --- a/src/v2/std/arrow_contract.dag +++ b/src/v2/std/arrow_contract.dag @@ -9,21 +9,25 @@ import v2.std.node { Conj, Edge, Found, - Named, + Authored, + ArrowEffectClaimsEdge, + ArrowExecutionModeClaimEdge, + ArrowResourceRequirementsEdge, Node, Positional, + StructuralLabel, Symbol, TypeNode, all_names_distinct, - named_edge_target_lookup, + core_edge_target_lookup, symbol_intern_lexeme } // THE VOCABULARY OF AN ARROW'S CONTRACT EDGES (the resource-requirements edge's vocabulary is the open // set of declared resources, checked at resolution; see arrow_resource_requirements_edge_target_reads) (XL-2 PR2a; docs/plans/arrow-contract-edges.md). // v2.std.node owns the edges' structure (at most one each, never a binder). This module checks their -// TARGETS against the vocabularies' homes: std.effects EffectClaim for ^arrow_effect_claims_edge and -// std.execution_mode ExecutionMode for ^arrow_execution_mode_claim_edge. Each label is the PROJECTION +// TARGETS against the vocabularies' homes: std.effects EffectClaim for ArrowEffectClaimsEdge and +// std.execution_mode ExecutionMode for ArrowExecutionModeClaimEdge. Each label is the PROJECTION // of one home variant, spelled once below as an exhaustive match, so a variant added to a home cannot // be lowered or admitted without a spelling here. The spelling is the surface keyword the grammar // admits (v2.extdeps.languages.dag dag_grammar_op_modifier_expr), so lowering and this check agree. @@ -79,7 +83,8 @@ fn arrow_contract_atom_is_self_named(label: Symbol, target: Node) -> Bool { fn arrow_effect_claim_edge_conforms(e: Edge) -> Bool { match e.label { Positional => false - Named { name: sym } => effect_claim_label_is_admitted(label: sym) && arrow_contract_atom_is_self_named(label: sym, target: e.target) + StructuralLabel { label: _ } => false + Authored { name: sym } => effect_claim_label_is_admitted(label: sym) && arrow_contract_atom_is_self_named(label: sym, target: e.target) } } @@ -120,7 +125,7 @@ fn arrow_contract_conforms(children: List) -> Bool { // member names a declared resource, and whether two spellings name one, are facts of resolution // (v2.compiler.resolve), not of this pre-resolve wall. fn arrow_resource_requirements_edge_target_reads(children: List) -> Bool { - match named_edge_target_lookup(children: children, name: ^arrow_resource_requirements_edge) { + match core_edge_target_lookup(children: children, marker: ArrowResourceRequirementsEdge) { Found { target: requirements } => match requirements.kind { TypeNode { connective: Conj } => count(requirements.children) > 0 @@ -133,14 +138,14 @@ fn arrow_resource_requirements_edge_target_reads(children: List) -> Bool { } fn arrow_effect_claims_edge_target_reads(children: List) -> Bool { - match named_edge_target_lookup(children: children, name: ^arrow_effect_claims_edge) { + match core_edge_target_lookup(children: children, marker: ArrowEffectClaimsEdge) { Found { target: claims } => arrow_effect_claims_target_conforms(claims: claims) _ => true } } fn arrow_execution_mode_edge_target_reads(children: List) -> Bool { - match named_edge_target_lookup(children: children, name: ^arrow_execution_mode_claim_edge) { + match core_edge_target_lookup(children: children, marker: ArrowExecutionModeClaimEdge) { Found { target: mode } => arrow_execution_mode_claim_target_conforms(mode: mode) _ => true } diff --git a/src/v2/std/arrow_signature.dag b/src/v2/std/arrow_signature.dag index 00c2641fe79..f5625cdd929 100644 --- a/src/v2/std/arrow_signature.dag +++ b/src/v2/std/arrow_signature.dag @@ -11,7 +11,7 @@ import v2.std.node { Atom, Conj, Edge, - Named, + Authored, Node, OrderAbsent, OrderLabels, @@ -23,7 +23,10 @@ import v2.std.node { arrow_signature_order_label, arrow_signature_order_read, edge_label_of, - node_with_occurrence_id + node_with_occurrence_id, + ArrowSignatureOrderEdge, + core_edge_label, + StructuralLabel, } import v2.std.node_query { binder_edge, node_positional_child_targets, pattern_wildcard_name } @@ -35,7 +38,7 @@ import v2.std.node_query { binder_edge, node_positional_child_targets, pattern_w // (v2.extdeps.languages.dag dag_arrow_with_body_node). fn signature_order_edge(order: List, source: Node) -> Edge { Edge { - label: Named { name: ^arrow_signature_order_edge }, + label: core_edge_label(marker: ArrowSignatureOrderEdge), target: lower_list_introduction( elements: fold(order, init: Empty, f: fn(acc, sym) { list_snoc_item(xs: acc, item: node_with_occurrence_id( @@ -218,12 +221,13 @@ fn application_binding_plan_over(labels: List, actuals: List) -> A acc } else { match e.label { + StructuralLabel { label: _ } => application_walk_refuse(acc: acc, reason: ^application_argument_label_unknown) Positional => match map_lookup(m: declared.label_at, key: acc.positional_next) { Absent => application_walk_refuse(acc: acc, reason: ^application_positional_surplus) Present { value: label } => application_walk_fill(acc: acc, label: label, positional: true) } - Named { name: label } => + Authored { name: label } => match map_lookup(m: declared.position_of, key: label) { Absent => application_walk_refuse(acc: acc, reason: ^application_argument_label_unknown) Present { value: _ } => application_walk_fill(acc: acc, label: label, positional: false) diff --git a/src/v2/std/bounded_lattice_completeness.dag b/src/v2/std/bounded_lattice_completeness.dag index 7b4c804c842..d3019929108 100644 --- a/src/v2/std/bounded_lattice_completeness.dag +++ b/src/v2/std/bounded_lattice_completeness.dag @@ -33,12 +33,13 @@ import v2.std.diagnostic { import v2.std.logic { Bool } import v2.std.node { Edge, - Named, + Authored, Node, NodeFold, Positional, Symbol, - fold_node + fold_node, + StructuralLabel, } import v2.std.optional { Absent, Present } import v2.std.node_query { @@ -143,12 +144,13 @@ fn infer_bounded_lattice_instance_gate(instance: Node) -> Outcome { fn infer_edge_consumes_bounded_lattice_partial(edge: Edge, partials: List) -> Bool { if any(xs: partials, predicate: fn(p) { edge.target == p }) { match edge.label { - Named { name: sym } => + Authored { name: sym } => sym == ^algebra_edge || sym == ^inhabitant_edge || sym == ^lattice_field_meet || sym == ^lattice_field_join || sym == ^boolean_algebra_field_bounded_lattice + StructuralLabel { label: _ } => false Positional => false } } else { diff --git a/src/v2/std/cardinality.dag b/src/v2/std/cardinality.dag index a892a60f035..f0b258534d8 100644 --- a/src/v2/std/cardinality.dag +++ b/src/v2/std/cardinality.dag @@ -38,7 +38,7 @@ import v2.std.node { Edge, Instantiation, Loop, - Named, + Authored, Node, NodeFold, Symbol, @@ -48,7 +48,9 @@ import v2.std.node { fold_node, loop_behavior_edges_conform, loop_bound_measure_target, - name_occurrences + name_occurrences, + LoopBoundEdge, + core_occurrences, } import v2.std.witness { Holds, Violates, Witness } @@ -173,7 +175,7 @@ fn loop_bound_not_loop_diagnostic(n: Node) -> Diagnostic { fn loop_measure_node(n: Node) -> Witness { match n.kind { ComputationNode { behavior: Loop } => { - let bound_count = name_occurrences(name: ^loop_bound_edge, children: n.children) + let bound_count = core_occurrences(marker: LoopBoundEdge, children: n.children) if bound_count == 0 { Violates { diagnostic: loop_bound_undeclared_diagnostic(n: n) } } else if bound_count > 1 { diff --git a/src/v2/std/coercion.dag b/src/v2/std/coercion.dag index 9a932fdea55..9a19399f9fb 100644 --- a/src/v2/std/coercion.dag +++ b/src/v2/std/coercion.dag @@ -35,7 +35,7 @@ import v2.std.find_witness { find_witness, } import v2.std.optional { Absent, Optional, Present } -import v2.std.node { Conj, Edge, Named, Node, Symbol, TypeNode, well_formed } +import v2.std.node { Conj, Edge, Authored, Node, Symbol, TypeNode, well_formed } import v2.std.refinement_widening_predicate { refinement_widening_is_strict_coarsening } import v2.std.witness { HomomorphismWitness, StructuralPropertyWitness } @@ -150,10 +150,10 @@ fn coercion_homomorphism_evidence_for_node( Node { kind: TypeNode { connective: Conj }, children: [ - Edge { label: Named { name: ^coercion_homomorphism_evidence_source }, target: source }, - Edge { label: Named { name: ^coercion_homomorphism_evidence_candidate }, target: fw.candidate }, + Edge { label: Authored { name: ^coercion_homomorphism_evidence_source }, target: source }, + Edge { label: Authored { name: ^coercion_homomorphism_evidence_candidate }, target: fw.candidate }, Edge { - label: Named { name: ^coercion_homomorphism_evidence_find_witness }, + label: Authored { name: ^coercion_homomorphism_evidence_find_witness }, target: fw.witness.evidence } ], diff --git a/src/v2/std/compilers/body_lowering.dag b/src/v2/std/compilers/body_lowering.dag index 5f16ca05b2a..3c698c59037 100644 --- a/src/v2/std/compilers/body_lowering.dag +++ b/src/v2/std/compilers/body_lowering.dag @@ -30,16 +30,22 @@ import v2.std.node { Match, Atom, Arrow, - Named, + Authored, Node, Positional, + StructuralLabel, Symbol, Transform, TypeNode, positional_prefix_then_labeled_conform, is_empty_conj_root, node_synthetic, - symbol_eq + symbol_eq, + LoopBoundEdge, + core_edge_label, + MatchArmBodyEdge, + MatchArmPatternEdge, + edge_is_core, } import v2.std.compilers.sugar { sugar_sequence_pair_optional } import v2.std.list_introduction { list_introduction_elements_optional } @@ -92,7 +98,7 @@ fn lower_loop(value: Node, bound: Node) -> Node { kind: ComputationNode { behavior: Loop }, children: [ Edge { label: Positional, target: value }, - Edge { label: Named { name: ^loop_bound_edge }, target: bound } + Edge { label: core_edge_label(marker: LoopBoundEdge), target: bound } ] ) } @@ -236,7 +242,8 @@ fn view_whole_positional_children(site: Node) -> Outcome> { Rejected { diagnostics: r } => Rejected { diagnostics: r } Accepted { value: xs, diagnostics: _ } => match e.label { - Named { name: _ } => view_refusal(reason: ^body_view_unexpected_named_edge, at: site) + Authored { name: _ } => view_refusal(reason: ^body_view_unexpected_named_edge, at: site) + StructuralLabel { label: _ } => view_refusal(reason: ^body_view_unexpected_named_edge, at: site) Positional => match operand_slot_of(n: e.target) { ResidueOperand { node: r } => view_refusal(reason: ^body_view_operand_residue, at: r) @@ -340,7 +347,8 @@ fn application_positional_targets(site: Node) -> Outcome> { Absent => outcome_accepted(value: Empty) Present { value: first } => match first.label { - Named { name: _ } => view_refusal(reason: ^body_view_unexpected_named_edge, at: site) + Authored { name: _ } => view_refusal(reason: ^body_view_unexpected_named_edge, at: site) + StructuralLabel { label: _ } => view_refusal(reason: ^body_view_unexpected_named_edge, at: site) Positional => outcome_accepted(value: fold(site.children, init: Empty, f: fn(acc, e) { if edge_is_cast_target(e: e) { acc } else { list_snoc_item(xs: acc, item: e.target) } @@ -543,21 +551,13 @@ fn match_arm_view(arm: Node) -> Outcome { Present { value: p } => match list_at_optional(xs: arm.children, index: 1) { Present { value: b } => - match p.label { - Named { name: pn } => - match b.label { - Named { name: bn } => - if (pn == ^match_arm_pattern) && (bn == ^match_arm_body) { - match operand_slot_of(n: b.target) { - ResidueOperand { node: r } => view_refusal(reason: ^body_view_operand_residue, at: r) - WholeOperand { node: body } => outcome_accepted(value: MatchArmView { arm: arm, pattern: p.target, body: body }) - } - } else { - view_refusal(reason: ^body_view_match_arm_malformed, at: arm) - } - Positional => view_refusal(reason: ^body_view_match_arm_malformed, at: arm) - } - Positional => view_refusal(reason: ^body_view_match_arm_malformed, at: arm) + if edge_is_core(e: p, marker: MatchArmPatternEdge) && edge_is_core(e: b, marker: MatchArmBodyEdge) { + match operand_slot_of(n: b.target) { + ResidueOperand { node: r } => view_refusal(reason: ^body_view_operand_residue, at: r) + WholeOperand { node: body } => outcome_accepted(value: MatchArmView { arm: arm, pattern: p.target, body: body }) + } + } else { + view_refusal(reason: ^body_view_match_arm_malformed, at: arm) } Absent => view_refusal(reason: ^body_view_match_arm_malformed, at: arm) } diff --git a/src/v2/std/compilers/compilation_unit.dag b/src/v2/std/compilers/compilation_unit.dag index f8a28af229e..d229e4e7b92 100644 --- a/src/v2/std/compilers/compilation_unit.dag +++ b/src/v2/std/compilers/compilation_unit.dag @@ -22,7 +22,7 @@ import v2.std.node { Atom, Conj, Edge, - Named, + Authored, Node, Symbol, TypeNode, diff --git a/src/v2/std/compilers/semantic_decl_emission.dag b/src/v2/std/compilers/semantic_decl_emission.dag index a168f751ea3..b5e5dc02ceb 100644 --- a/src/v2/std/compilers/semantic_decl_emission.dag +++ b/src/v2/std/compilers/semantic_decl_emission.dag @@ -67,7 +67,7 @@ import v2.std.node { Conj, Disj, Edge, - Named, + Authored, StructuralLabel, Node, Positional, Symbol, @@ -1984,7 +1984,7 @@ fn target_semantic_decl_tagged_union_variant_surface_from_edge( type_binding: fn(Node) -> Outcome ) -> Outcome { match edge.label { - Named { name: vname } => + Authored { name: vname } => if coproduct_variant_edge_has_payload(edge: edge) { bind_outcome( o: target_semantic_decl_field_surfaces( @@ -2004,6 +2004,12 @@ fn target_semantic_decl_tagged_union_variant_surface_from_edge( } else { outcome_accepted(value: target_semantic_decl_surface_variant_nullary(name: vname)) } + StructuralLabel { label: _ } => + outcome_rejected(d: Diagnostic { + reason: ^target_semantic_decl_variant_not_named, + at: node_locus(node: edge.target), + correction: Unavailable { reason: ExternalContractUnknown } + }) Positional => outcome_rejected(d: Diagnostic { reason: ^target_semantic_decl_variant_not_named, @@ -2047,7 +2053,7 @@ fn target_semantic_decl_variant_surface_from_edge( type_binding: fn(Node) -> Outcome ) -> Outcome { match edge.label { - Named { name: vname } => + Authored { name: vname } => if coproduct_variant_edge_has_payload(edge: edge) { bind_outcome( o: target_semantic_decl_field_surfaces( @@ -2064,6 +2070,12 @@ fn target_semantic_decl_variant_surface_from_edge( } else { outcome_accepted(value: target_semantic_decl_surface_variant_nullary(name: vname)) } + StructuralLabel { label: _ } => + outcome_rejected(d: Diagnostic { + reason: ^target_semantic_decl_variant_not_named, + at: node_locus(node: edge.target), + correction: Unavailable { reason: ExternalContractUnknown } + }) Positional => outcome_rejected(d: Diagnostic { reason: ^target_semantic_decl_variant_not_named, diff --git a/src/v2/std/compilers/sugar.dag b/src/v2/std/compilers/sugar.dag index 99f5f9346c8..ade644b413c 100644 --- a/src/v2/std/compilers/sugar.dag +++ b/src/v2/std/compilers/sugar.dag @@ -25,7 +25,7 @@ import v2.std.node { Disj, Edge, LabeledEdges, - Named, + Authored, Node, Symbol, TypeNode, @@ -216,7 +216,7 @@ fn sugar_variant_to_disj_edge(variant_node: Node) -> Outcome { Present { value: name } => Accepted { value: Edge { - label: Named { name: name }, + label: Authored { name: name }, target: sugar_type_node(connective: Conj, children: [], n: variant) }, diagnostics: None diff --git a/src/v2/std/compilers/target_model.dag b/src/v2/std/compilers/target_model.dag index e15ad724341..0375d3e0d80 100644 --- a/src/v2/std/compilers/target_model.dag +++ b/src/v2/std/compilers/target_model.dag @@ -1,5 +1,6 @@ module v2.std.compilers.target_model + import std.occurrence_identity { OccurrenceSynthetic } import std.layout { Doc, DocText, DocLine, DocConcat, LayoutProtocol, render, doc_nest_by } import std.dissolution { @@ -93,6 +94,7 @@ import v2.std.passing_candidate_fold { } import v2.std.type_binder { cast_target_optional, type_annotation_optional } import v2.std.node { + StructuralLabel, LoopBoundMeasure, LoopCarrierBinder, LoopDomainValue, @@ -124,9 +126,7 @@ import v2.std.node { LabeledEdges, LoopBoundEdges, Match, - match_arm_body, - match_arm_pattern, - Named, + Authored, NoEdges, Node, NodeFold, @@ -145,6 +145,12 @@ import v2.std.node { node_rebuild, symbol_intern_lexeme, symbol_lexeme, + MatchArmBodyEdge, + MatchArmPatternEdge, + core_edge, + core_occurrences, + edge_is_core, + production_edge_label, } import v2.std.witness { StructuralPropertyWitness @@ -165,8 +171,10 @@ import v2.std.node_query { nullary_inhabitant_by_discriminant, is_wildcard_pattern_identity, pattern_wildcard_name, + find_core_child, + find_labeled_child, construct_field_edges, - construct_tag_optional + construct_tag_optional, } import v2.std.qualified_name { QualifiedName, @@ -410,8 +418,15 @@ fn produced_decl_param_segment_tokens( outcome_accepted(value: [FixedToken { token_class: tc }]) ProducedParamName { token_class: tc } => match edge.label { - Named { name: pname } => + Authored { name: pname } => outcome_accepted(value: [BoundToken { token_class: tc, binding: pname }]) + StructuralLabel { label: _ } => + outcome_rejected( + d: produced_decl_render_diagnostic( + reason: ^produced_decl_render_param_unnamed, + node: edge.target + ) + ) Positional => outcome_rejected( d: produced_decl_render_diagnostic( @@ -765,7 +780,7 @@ fn produced_decl_ordered_params(arrow: Node, domain: Node) -> Outcome // binder here is a wall the reader already holds; it still refuses typed rather than dropping one. fn produced_decl_domain_binder(arrow: Node, domain: Node, label: Symbol) -> Outcome { match named_child_lookup(root: domain, name: label) { - NamedChildFound { target: t } => outcome_accepted(value: Edge { label: Named { name: label }, target: t }) + NamedChildFound { target: t } => outcome_accepted(value: Edge { label: Authored { name: label }, target: t }) NamedChildMissing => outcome_rejected( d: produced_decl_render_diagnostic(reason: ^produced_decl_render_parameter_order_malformed, node: arrow) @@ -821,11 +836,18 @@ fn produced_decl_subject_from_decl(decl: Node) -> Outcome match decl_edge.label { - Named { name: fn_name } => + Authored { name: fn_name } => produced_decl_subject_from_name_and_arrow( fn_name: fn_name, arrow: decl_edge.target ) + StructuralLabel { label: _ } => + outcome_rejected( + d: produced_decl_render_diagnostic( + reason: ^produced_decl_render_decl_unnamed, + node: decl + ) + ) Positional => outcome_rejected( d: produced_decl_render_diagnostic( @@ -968,7 +990,7 @@ fn concrete_syntax_token_to_node(token: ConcreteSyntaxToken) -> Node { kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: ^concrete_syntax_token_field_kind }, + label: Authored { name: ^concrete_syntax_token_field_kind }, target: Node { kind: TypeNode { connective: Atom { identity: ^concrete_syntax_token_kind_fixed } }, children: [], @@ -976,7 +998,7 @@ fn concrete_syntax_token_to_node(token: ConcreteSyntaxToken) -> Node { } }, Edge { - label: Named { name: ^concrete_syntax_token_field_class }, + label: Authored { name: ^concrete_syntax_token_field_class }, target: Node { kind: TypeNode { connective: Atom { identity: c } }, children: [], @@ -991,7 +1013,7 @@ fn concrete_syntax_token_to_node(token: ConcreteSyntaxToken) -> Node { kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: ^concrete_syntax_token_field_kind }, + label: Authored { name: ^concrete_syntax_token_field_kind }, target: Node { kind: TypeNode { connective: Atom { identity: ^concrete_syntax_token_kind_bound } }, children: [], @@ -999,7 +1021,7 @@ fn concrete_syntax_token_to_node(token: ConcreteSyntaxToken) -> Node { } }, Edge { - label: Named { name: ^concrete_syntax_token_field_class }, + label: Authored { name: ^concrete_syntax_token_field_class }, target: Node { kind: TypeNode { connective: Atom { identity: c } }, children: [], @@ -1007,7 +1029,7 @@ fn concrete_syntax_token_to_node(token: ConcreteSyntaxToken) -> Node { } }, Edge { - label: Named { name: ^concrete_syntax_token_field_binding }, + label: Authored { name: ^concrete_syntax_token_field_binding }, target: Node { kind: TypeNode { connective: Atom { identity: b } }, children: [], @@ -1959,7 +1981,7 @@ fn target_model_canonical_operation_atom_field_from_wire( Present { value: _ } => acc Absent => match edge.label { - Named { name: n } => + Authored { name: n } => if n == field_name { match edge.target.kind { TypeNode { connective: Atom { identity: id } } => @@ -1969,6 +1991,7 @@ fn target_model_canonical_operation_atom_field_from_wire( } else { acc } + StructuralLabel { label: _ } => acc Positional => acc } } @@ -2120,7 +2143,7 @@ fn target_model_canonical_operation_roster_edge( operation: CanonicalOperation ) -> Edge { Edge { - label: Named { name: name }, + label: Authored { name: name }, target: target_model_canonical_operation_wire_node(operation: operation) } } @@ -2243,7 +2266,7 @@ fn target_model_canonical_operation_wire_predicate_type(wire: Node) -> Optional< fn target_model_canonical_operation_wire_child_declared_type(wire: Node, edge: Edge) -> Optional { match edge.label { - Named { name: field } => + Authored { name: field } => if field == ^target_canonical_operation_field_predicate { target_model_canonical_operation_wire_predicate_type(wire: wire) } else { @@ -2593,7 +2616,8 @@ fn target_operator_shape_wire_schema_valid(wire: Node) -> Outcome { f: fn(acc, edge) { if acc { match edge.label { - Named { name: n } => n == ^target_operator_shape_field_token + Authored { name: n } => n == ^target_operator_shape_field_token + StructuralLabel { label: _ } => false Positional => false } } else { @@ -2620,7 +2644,7 @@ fn target_operator_shape_token_from_wire(wire: Node) -> Outcome { Present { value: _ } => acc Absent => match edge.label { - Named { name: n } => + Authored { name: n } => if n == ^target_operator_shape_field_token { match edge.target.kind { TypeNode { connective: Atom { identity: token } } => @@ -2630,6 +2654,7 @@ fn target_operator_shape_token_from_wire(wire: Node) -> Outcome { } else { acc } + StructuralLabel { label: _ } => acc Positional => acc } } @@ -2704,9 +2729,10 @@ fn target_operator_realization_row_wire_schema_valid(row: Node) -> Outcome f: fn(acc, edge) { if acc { match edge.label { - Named { name: n } => + Authored { name: n } => n == ^target_operator_realization_field_operation || n == ^target_operator_realization_field_shape + StructuralLabel { label: _ } => false Positional => false } } else { @@ -3357,7 +3383,7 @@ fn decode_effect_apply_callee_rows(bundle: Node) -> Outcome acc Accepted { value: rows, diagnostics: d } => match edge.label { - Named { name: n } => + Authored { name: n } => if n == ^target_value_expr_effect_callee_row_edge { bind_outcome( o: target_value_expr_effect_callee_row_from_wire(row: edge.target), @@ -3368,6 +3394,7 @@ fn decode_effect_apply_callee_rows(bundle: Node) -> Outcome acc Positional => acc } } @@ -4414,10 +4441,11 @@ fn concrete_syntax_token_wire_schema_valid(token: Node) -> Outcome { f: fn(acc, edge) { if acc { match edge.label { - Named { name: n } => + Authored { name: n } => n == ^concrete_syntax_token_field_kind || n == ^concrete_syntax_token_field_class || n == ^concrete_syntax_token_field_binding + StructuralLabel { label: _ } => false Positional => false } } else { @@ -4639,7 +4667,7 @@ fn source_atom_string(value: Node) -> SourceAtomValue { } fn target_model_named_edge(name: Symbol, target: Node) -> Edge { - Edge { label: Named { name: name }, target: target } + Edge { label: Authored { name: name }, target: target } } fn source_atom_symbol_projection_from_node(source: Node) -> Optional { @@ -4890,7 +4918,7 @@ fn target_value_expression_int_literal_lexeme_from_wire(wire: Node) -> Outcome acc Absent => match edge.label { - Named { name: n } => + Authored { name: n } => if n == ^target_value_expression_field_value { match edge.target.kind { TypeNode { connective: Atom { identity: id } } => optional_present(value: id) @@ -4899,6 +4927,7 @@ fn target_value_expression_int_literal_lexeme_from_wire(wire: Node) -> Outcome acc Positional => acc } } @@ -4993,7 +5022,8 @@ fn target_value_expr_binding_ref_wire_schema_valid(wire: Node) -> Outcome f: fn(acc, edge) { if acc { match edge.label { - Named { name: n } => n == ^target_value_expr_field_binding + Authored { name: n } => n == ^target_value_expr_field_binding + StructuralLabel { label: _ } => false Positional => false } } else { @@ -5029,7 +5059,7 @@ fn target_value_expr_binding_ref_binding_from_wire(wire: Node) -> Outcome acc Absent => match edge.label { - Named { name: n } => + Authored { name: n } => if n == ^target_value_expr_field_binding { match edge.target.kind { TypeNode { connective: Atom { identity: id } } => @@ -5039,6 +5069,7 @@ fn target_value_expr_binding_ref_binding_from_wire(wire: Node) -> Outcome acc Positional => acc } } @@ -5082,9 +5113,10 @@ fn target_value_expr_primitive_apply_wire_schema_valid(wire: Node) -> Outcome + Authored { name: n } => n == ^target_value_expr_field_operation || n == ^target_value_expr_field_operand + StructuralLabel { label: _ } => false Positional => false } } else { @@ -5118,7 +5150,7 @@ fn target_value_expr_primitive_apply_operand_bindings(wire: Node) -> Outcome acc Accepted { value: bindings, diagnostics: d } => match edge.label { - Named { name: n } => + Authored { name: n } => if n == ^target_value_expr_field_operation { acc } else if n == ^target_value_expr_field_operand { @@ -5135,6 +5167,10 @@ fn target_value_expr_primitive_apply_operand_bindings(wire: Node) -> Outcome + outcome_rejected( + target_value_expr_operand_wire_malformed_diagnostic(wire: wire) + ) Positional => outcome_rejected( target_value_expr_operand_wire_malformed_diagnostic(wire: wire) @@ -5220,9 +5256,10 @@ fn target_value_expr_effect_apply_wire_schema_valid(wire: Node) -> Outcome f: fn(acc, edge) { if acc { match edge.label { - Named { name: n } => + Authored { name: n } => n == ^target_value_expr_field_effect_kind || n == ^target_value_expr_field_operand + StructuralLabel { label: _ } => false Positional => false } } else { @@ -5253,7 +5290,7 @@ fn target_value_expr_effect_apply_kind_from_wire(wire: Node) -> Outcome Present { value: _ } => acc Absent => match edge.label { - Named { name: n } => + Authored { name: n } => if n == ^target_value_expr_field_effect_kind { match edge.target.kind { TypeNode { connective: Atom { identity: id } } => @@ -5263,6 +5300,7 @@ fn target_value_expr_effect_apply_kind_from_wire(wire: Node) -> Outcome } else { acc } + StructuralLabel { label: _ } => acc Positional => acc } } @@ -5288,7 +5326,7 @@ fn target_value_expr_effect_apply_operand_bindings(wire: Node) -> Outcome acc Accepted { value: bindings, diagnostics: d } => match edge.label { - Named { name: n } => + Authored { name: n } => if n == ^target_value_expr_field_effect_kind { acc } else if n == ^target_value_expr_field_operand { @@ -5305,6 +5343,10 @@ fn target_value_expr_effect_apply_operand_bindings(wire: Node) -> Outcome + outcome_rejected( + target_value_expr_operand_wire_malformed_diagnostic(wire: wire) + ) Positional => outcome_rejected( target_value_expr_operand_wire_malformed_diagnostic(wire: wire) @@ -5563,6 +5605,7 @@ fn target_value_expr_match_arm_edges_after_scrutinee(children: List) -> Li init: TargetValueExprMatchArmEdgeFold { edges: Empty, skipped_scrutinee: false }, f: fn(acc, edge) { match edge.label { + StructuralLabel { label: _ } => acc Positional => if !acc.skipped_scrutinee { TargetValueExprMatchArmEdgeFold { @@ -5575,7 +5618,7 @@ fn target_value_expr_match_arm_edges_after_scrutinee(children: List) -> Li skipped_scrutinee: true } } - Named { name: _ } => acc + Authored { name: _ } => acc } } ) @@ -5586,8 +5629,8 @@ fn target_value_expr_match_arm_wire(arm: TargetValueExprMatchArmSlot) -> Node { Node { kind: TypeNode { connective: Conj }, children: [ - target_model_named_edge(name: match_arm_pattern, target: arm.pattern.node), - target_model_named_edge(name: match_arm_body, target: arm.body.node) + core_edge(marker: MatchArmPatternEdge, target: arm.pattern.node), + core_edge(marker: MatchArmBodyEdge, target: arm.body.node) ], occurrence_id: OccurrenceSynthetic } @@ -5727,7 +5770,7 @@ fn target_value_expr_closure_tokens_from_wire(wire: Node, field: Symbol) -> Outc o: acc, f: fn(so_far) { match edge.label { - Named { name: n } => + Authored { name: n } => if n == field { match edge.target.kind { TypeNode { connective: Atom { identity: tc } } => @@ -5737,6 +5780,7 @@ fn target_value_expr_closure_tokens_from_wire(wire: Node, field: Symbol) -> Outc } else { outcome_accepted(so_far) } + StructuralLabel { label: _ } => outcome_accepted(so_far) Positional => outcome_accepted(so_far) } } @@ -5832,8 +5876,9 @@ fn target_operator_realization_catalog_wire_schema_valid(catalog: Node) -> Outco f: fn(acc, e) { if acc { match e.label { + StructuralLabel { label: _ } => false Positional => false - Named { name: n } => n == ^target_operator_realization_row_edge + Authored { name: n } => n == ^target_operator_realization_row_edge } } else { false @@ -5890,7 +5935,7 @@ fn target_operator_realization_catalog_lookup( init: NoPassingCandidate, f: fn(acc, e) { match e.label { - Named { name: n } => + Authored { name: n } => if n == ^target_operator_realization_row_edge { target_operator_realization_catalog_lookup_step( acc: acc, @@ -5900,6 +5945,7 @@ fn target_operator_realization_catalog_lookup( } else { acc } + StructuralLabel { label: _ } => acc Positional => acc } } @@ -5933,7 +5979,7 @@ fn target_value_expr_primitive_apply_operation_from_wire(wire: Node) -> Outcome< Present { value: _ } => acc Absent => match e.label { - Named { name: n } => + Authored { name: n } => if n == ^target_value_expr_field_operation { match canonical_operation_from_wire_node(wire: e.target) { Accepted { value: canonical_op, diagnostics: _ } => @@ -5943,6 +5989,7 @@ fn target_value_expr_primitive_apply_operation_from_wire(wire: Node) -> Outcome< } else { acc } + StructuralLabel { label: _ } => acc Positional => acc } } @@ -6175,7 +6222,7 @@ fn target_value_expression_symbol_identity_from_wire(wire: Node) -> Outcome acc Absent => match edge.label { - Named { name: n } => + Authored { name: n } => if n == ^target_value_expression_field_identity { match edge.target.kind { TypeNode { connective: Atom { identity: id } } => @@ -6185,6 +6232,7 @@ fn target_value_expression_symbol_identity_from_wire(wire: Node) -> Outcome acc Positional => acc } } @@ -6362,12 +6410,13 @@ fn target_value_expr_conditional_child_from_wire( Present { value: _ } => acc Absent => match edge.label { - Named { name: n } => + Authored { name: n } => if n == field { optional_present(value: edge.target) } else { acc } + StructuralLabel { label: _ } => acc Positional => acc } } @@ -6751,7 +6800,7 @@ fn target_value_expr_record_construct_type_from_wire(wire: Node) -> Outcome acc Absent => match edge.label { - Named { name: n } => + Authored { name: n } => if n == ^target_value_expr_field_record_type { match edge.target.kind { TypeNode { connective: Atom { identity: id } } => @@ -6761,6 +6810,7 @@ fn target_value_expr_record_construct_type_from_wire(wire: Node) -> Outcome acc Positional => acc } } @@ -6785,7 +6835,7 @@ fn target_value_expr_record_construct_field_slots_from_wire( Rejected { diagnostics: r } => acc Accepted { value: slots, diagnostics: d } => match edge.label { - Named { name: n } => + Authored { name: n } => if n == ^target_value_expr_field_record_type { acc } else { @@ -6801,6 +6851,10 @@ fn target_value_expr_record_construct_field_slots_from_wire( } ) } + StructuralLabel { label: _ } => + outcome_rejected( + target_value_expr_operand_wire_malformed_diagnostic(wire: wire) + ) Positional => outcome_rejected( target_value_expr_operand_wire_malformed_diagnostic(wire: wire) @@ -7079,13 +7133,13 @@ fn import_name_symbols_from_block(block: Node) -> Outcome> { fn import_value_from_carrier(carrier: Node) -> Outcome { bind_outcome( - o: find_named_child(root: carrier, name: ^dag_surface_import_decl_qualified_name), + o: find_labeled_child(root: carrier, label: production_edge_label(language: ^dag_language_model_surface_id, edge: ^dag_surface_import_decl_qualified_name)), f: fn(qn_node) { bind_outcome( o: qualified_name_from_node(root: qn_node), f: fn(qn) { bind_outcome( - o: find_named_child(root: carrier, name: ^dag_surface_import_decl_block), + o: find_labeled_child(root: carrier, label: production_edge_label(language: ^dag_language_model_surface_id, edge: ^dag_surface_import_decl_block)), f: fn(block) { bind_outcome( o: import_name_symbols_from_block(block: block), @@ -7291,9 +7345,10 @@ fn target_value_expr_field_access_wire_schema_valid(wire: Node) -> Outcome f: fn(acc, edge) { if acc { match edge.label { - Named { name: n } => + Authored { name: n } => n == ^target_value_expr_field_field_access_base || n == ^target_value_expr_field_field_access_field + StructuralLabel { label: _ } => false Positional => false } } else { @@ -7333,7 +7388,7 @@ fn target_value_expr_field_access_field_from_wire(wire: Node) -> Outcome Present { value: _ } => acc Absent => match edge.label { - Named { name: n } => + Authored { name: n } => if n == ^target_value_expr_field_field_access_field { match edge.target.kind { TypeNode { connective: Atom { identity: id } } => @@ -7343,6 +7398,7 @@ fn target_value_expr_field_access_field_from_wire(wire: Node) -> Outcome } else { acc } + StructuralLabel { label: _ } => acc Positional => acc } } @@ -7410,11 +7466,11 @@ fn target_value_expression_field_access_to_concrete_tokens( fn target_value_expr_match_arm_wire_schema_valid(arm_wire: Node) -> Outcome { match arm_wire.kind { TypeNode { connective: Conj } => - if name_occurrences(name: match_arm_pattern, children: arm_wire.children) != 1 { + if core_occurrences(marker: MatchArmPatternEdge, children: arm_wire.children) != 1 { outcome_rejected( target_value_expr_operand_wire_malformed_diagnostic(wire: arm_wire) ) - } else if name_occurrences(name: match_arm_body, children: arm_wire.children) != 1 { + } else if core_occurrences(marker: MatchArmBodyEdge, children: arm_wire.children) != 1 { outcome_rejected( target_value_expr_operand_wire_malformed_diagnostic(wire: arm_wire) ) @@ -7424,11 +7480,7 @@ fn target_value_expr_match_arm_wire_schema_valid(arm_wire: Node) -> Outcome - n == match_arm_pattern || n == match_arm_body - Positional => false - } + edge_is_core(e: edge, marker: MatchArmPatternEdge) || edge_is_core(e: edge, marker: MatchArmBodyEdge) } else { false } @@ -7474,7 +7526,7 @@ fn target_value_expr_match_wire_schema_valid(wire: Node) -> Outcome { acc } else { match edge.label { - Named { name: n } => + Authored { name: n } => if n == ^target_value_expr_field_match_scrutinee { acc } else { @@ -7482,6 +7534,7 @@ fn target_value_expr_match_wire_schema_valid(wire: Node) -> Outcome { target_value_expr_operand_wire_malformed_diagnostic(wire: wire) ) } + StructuralLabel { label: _ } => outcome_rejected(target_value_expr_operand_wire_malformed_diagnostic(wire: wire)) Positional => bind_outcome( o: target_value_expr_match_arm_wire_schema_valid(arm_wire: edge.target), @@ -7521,10 +7574,10 @@ fn target_value_expr_match_arm_slot_from_wire(arm_wire: Node) -> Outcome acc Accepted { value: arms, diagnostics: d } => match edge.label { - Named { name: _ } => acc + Authored { name: _ } => acc + StructuralLabel { label: _ } => acc Positional => bind_outcome( o: target_value_expr_match_arm_slot_from_wire(arm_wire: edge.target), @@ -7691,12 +7745,13 @@ fn target_value_expression_bool_literal_value_from_wire(wire: Node) -> Optional< Present { value: _ } => acc Absent => match edge.label { - Named { name: n } => + Authored { name: n } => if n == ^target_value_expression_field_value { target_value_expr_bool_literal_value_from_atom(node: edge.target) } else { acc } + StructuralLabel { label: _ } => acc Positional => acc } } @@ -8240,7 +8295,7 @@ fn target_value_expr_callable_apply_callee_from_wire(wire: Node) -> Outcome acc Absent => match edge.label { - Named { name: n } => + Authored { name: n } => if n == ^target_value_expr_field_callee { match edge.target.kind { TypeNode { connective: Atom { identity: id } } => @@ -8250,6 +8305,7 @@ fn target_value_expr_callable_apply_callee_from_wire(wire: Node) -> Outcome acc Positional => acc } } @@ -8274,7 +8330,7 @@ fn target_value_expr_callable_apply_args_from_wire( Rejected { diagnostics: _ } => acc Accepted { value: args, diagnostics: _ } => match edge.label { - Named { name: n } => + Authored { name: n } => if n == ^target_value_expr_field_callable_arg { bind_outcome( o: target_value_expression_reify_from_wire(wire: edge.target), @@ -8289,6 +8345,10 @@ fn target_value_expr_callable_apply_args_from_wire( target_value_expr_operand_wire_malformed_diagnostic(wire: wire) ) } + StructuralLabel { label: _ } => + outcome_rejected( + target_value_expr_operand_wire_malformed_diagnostic(wire: wire) + ) Positional => outcome_rejected( target_value_expr_operand_wire_malformed_diagnostic(wire: wire) @@ -8403,7 +8463,7 @@ fn target_value_expr_closure_params_from_wire(wire: Node) -> Outcome acc Accepted { value: ps, diagnostics: _ } => match edge.label { - Named { name: n } => + Authored { name: n } => if n == ^target_value_expr_field_closure_param { match edge.target.kind { TypeNode { connective: Atom { identity: id } } => @@ -8424,6 +8484,10 @@ fn target_value_expr_closure_params_from_wire(wire: Node) -> Outcome + outcome_rejected( + target_value_expr_operand_wire_malformed_diagnostic(wire: wire) + ) Positional => outcome_rejected( target_value_expr_operand_wire_malformed_diagnostic(wire: wire) @@ -9320,7 +9384,7 @@ fn target_constructor_template_from_node( fn target_model_bundle_core_keep_edge(acc: List, edge: Edge) -> List { match edge.label { - Named { name: n } => + Authored { name: n } => match n == ^target_model_edge_atom_realizations || n == ^target_model_edge_signature_realizations @@ -9328,6 +9392,7 @@ fn target_model_bundle_core_keep_edge(acc: List, edge: Edge) -> List true => acc false => list_snoc_item(xs: acc, item: edge) } + StructuralLabel { label: _ } => list_snoc_item(xs: acc, item: edge) Positional => list_snoc_item(xs: acc, item: edge) } } @@ -9581,12 +9646,13 @@ fn target_atom_realization_conj_child(row_node: Node, edge_name: Symbol) -> Node init: row_node, f: fn(acc, e) { match e.label { - Named { name: n } => + Authored { name: n } => if n == edge_name { e.target } else { acc } + StructuralLabel { label: _ } => acc Positional => acc } } @@ -10252,7 +10318,8 @@ fn target_type_expr_declaration_reference_form_node(form: DeclarationReferenceFo fn projection_bundle_has_child(bundle: Node, name: Symbol) -> Bool { fold(bundle.children, init: false, f: fn(acc, e) { acc || (match e.label { - Named { name: sym } => sym == name + Authored { name: sym } => sym == name + StructuralLabel { label: _ } => false Positional => false }) }) @@ -10297,7 +10364,7 @@ fn decode_declaration_reference_form_bundle(bundle: Node) -> Outcome Edge { Edge { - label: Named { name: ^target_type_expr_field_surface }, + label: Authored { name: ^target_type_expr_field_surface }, target: Node { kind: TypeNode { connective: Atom { identity: surface } }, children: [], @@ -10351,7 +10418,7 @@ type TargetTypeExprKindEdgeDecode fn target_type_expr_decode_kind_edge(edge: Edge) -> TargetTypeExprKindEdgeDecode { match edge.label { - Named { name: n } => + Authored { name: n } => if n == ^target_type_expr_field_kind { match edge.target.kind { TypeNode { connective: Atom { identity: id } } => @@ -10364,6 +10431,7 @@ fn target_type_expr_decode_kind_edge(edge: Edge) -> TargetTypeExprKindEdgeDecode } else { KindEdgeNotKindField } + StructuralLabel { label: _ } => KindEdgeNotKindField Positional => KindEdgeNotKindField } } @@ -10400,7 +10468,7 @@ fn target_type_expr_emitted_kind(node: Node) -> TargetTypeExprKindProbe { fn target_type_expr_kind_edge(kind: TargetTypeExprKind) -> Edge { Edge { - label: Named { name: ^target_type_expr_field_kind }, + label: Authored { name: ^target_type_expr_field_kind }, target: Node { kind: TypeNode { connective: Atom { identity: discriminant(v: kind) } @@ -10518,7 +10586,7 @@ fn target_type_expr_field_slot_edges(fields: List) -> L fold(fields, init: Empty, f: fn(acc, field) { list_snoc_item( xs: acc, - item: Edge { label: Named { name: field.label }, target: field.type_expr } + item: Edge { label: Authored { name: field.label }, target: field.type_expr } ) }) } @@ -10527,7 +10595,7 @@ fn target_type_expr_arrow_param_slot_edges(params: List fold(variants, init: Empty, f: fn(acc, variant) { list_snoc_item( xs: acc, - item: Edge { label: Named { name: variant.label }, target: variant.type_expr } + item: Edge { label: Authored { name: variant.label }, target: variant.type_expr } ) }) } @@ -10544,12 +10612,13 @@ fn target_type_expr_variant_slot_edges(variants: List fn target_type_expr_emitted_slot_type_nodes(node: Node) -> List { fold(node.children, init: Empty, f: fn(acc, e) { match e.label { - Named { name: n } => + Authored { name: n } => if n == ^target_type_expr_field_surface || n == ^target_type_expr_field_kind { acc } else { list_snoc_item(xs: acc, item: e.target) } + StructuralLabel { label: _ } => acc Positional => acc } }) @@ -10573,8 +10642,9 @@ fn target_type_expr_fold_named_metadata_edges(node: Node) -> TargetTypeExprNamed NamedMetadataFoldMalformed => acc NamedMetadataFoldOk { kind_seen: kind_seen, surface_seen: surface_seen, extra_named: extra_named } => match e.label { + StructuralLabel { label: _ } => NamedMetadataFoldMalformed Positional => acc - Named { name: n } => + Authored { name: n } => if n == ^target_type_expr_field_kind { if kind_seen { NamedMetadataFoldMalformed @@ -10855,12 +10925,13 @@ fn target_type_expr_emitted_labeled_slot_edges(node: Node) -> Outcome Accepted { value: fold(node.children, init: Empty, f: fn(acc, e) { match e.label { - Named { name: n } => + Authored { name: n } => if n == ^target_type_expr_field_surface || n == ^target_type_expr_field_kind { acc } else { list_snoc_item(xs: acc, item: e) } + StructuralLabel { label: _ } => acc Positional => acc } }), @@ -10917,7 +10988,7 @@ fn target_type_expr_arrow_emitted_named( left: target_type_expr_arrow_param_slot_edges(params: params), right: Cons { head: Edge { - label: Named { name: ^target_type_expr_field_codomain }, + label: Authored { name: ^target_type_expr_field_codomain }, target: output }, tail: Empty @@ -10957,7 +11028,7 @@ fn target_type_expr_arrow_labeled_param_slots(node: Node) -> Outcome + Authored { name: label } => if label == ^target_type_expr_field_surface || label == ^target_type_expr_field_kind || label == ^target_type_expr_field_codomain { @@ -10968,6 +11039,7 @@ fn target_type_expr_arrow_labeled_param_slots(node: Node) -> Outcome acc Positional => acc } } @@ -12798,7 +12870,7 @@ fn target_use_site_ownership_catalog_lookup_step( TargetUseSiteOwnershipCatalogInvalid => TargetUseSiteOwnershipCatalogInvalid _ => match edge.label { - Named { name: display_name } => + Authored { name: display_name } => target_use_site_ownership_catalog_lookup_step_for_row( acc: acc, row_node: edge.target, @@ -12806,6 +12878,7 @@ fn target_use_site_ownership_catalog_lookup_step( source_carrier: source_carrier, use_site: use_site ) + StructuralLabel { label: _ } => TargetUseSiteOwnershipCatalogInvalid Positional => target_use_site_ownership_catalog_lookup_step_for_row( acc: acc, @@ -13094,7 +13167,7 @@ fn target_model_bundle_replace_edge_target( init: Empty, f: fn(acc, edge) { match edge.label { - Named { name: n } => + Authored { name: n } => if n == edge_name { list_snoc_item( xs: acc, @@ -13103,6 +13176,7 @@ fn target_model_bundle_replace_edge_target( } else { list_snoc_item(xs: acc, item: edge) } + StructuralLabel { label: _ } => list_snoc_item(xs: acc, item: edge) Positional => list_snoc_item(xs: acc, item: edge) } } @@ -13196,12 +13270,13 @@ fn target_model_augment_use_site_ownership_catalog( init: optional_absent(), f: fn(acc, edge) { match edge.label { - Named { name: n } => + Authored { name: n } => if n == ^target_model_edge_use_site_ownership_realizations { optional_present(value: edge.target) } else { acc } + StructuralLabel { label: _ } => acc Positional => acc } } @@ -13246,12 +13321,13 @@ fn target_model_augment_value_semantics_carriers( init: optional_absent(), f: fn(acc, edge) { match edge.label { - Named { name: n } => + Authored { name: n } => if n == ^target_model_edge_value_semantics_carriers { optional_present(value: edge.target) } else { acc } + StructuralLabel { label: _ } => acc Positional => acc } } @@ -13309,7 +13385,7 @@ fn target_value_semantics_carriers_node(atoms: List) -> Node { fn target_value_semantics_carrier_snoc(acc: List, edge: Edge) -> List { match edge.label { - Named { name: n } => list_snoc_item(xs: acc, item: n) + Authored { name: n } => list_snoc_item(xs: acc, item: n) _ => acc } } @@ -14465,12 +14541,13 @@ fn target_value_expr_int_literal_magnitude_node_optional(node: Node) -> Optional Present { value: _ } => acc Absent => match edge { - Edge { label: Named { name: field }, target: magnitude } => + Edge { label: Authored { name: field }, target: magnitude } => if field == ^integer_literal_magnitude_field { optional_present(value: magnitude) } else { optional_absent() } + Edge { label: StructuralLabel { label: _ }, target: _ } => optional_absent() Edge { label: Positional, target: _ } => optional_absent() } } @@ -14703,7 +14780,7 @@ fn target_value_expr_record_construct_field_slots_from_edges( Rejected { diagnostics: r } => acc Accepted { value: slots, diagnostics: d } => match edge.label { - Named { name: field_label } => + Authored { name: field_label } => bind_outcome( o: target_value_expr_project_body_subexpression( arrow: arrow, @@ -14724,6 +14801,13 @@ fn target_value_expr_record_construct_field_slots_from_edges( ) } ) + StructuralLabel { label: _ } => + outcome_rejected( + target_value_expr_diagnostic( + reason: ^target_value_expr_reason_transform_shape_invalid, + node: edge.target + ) + ) Positional => outcome_rejected( target_value_expr_diagnostic( @@ -14891,10 +14975,10 @@ fn target_value_expr_match_arm_slot_from_arm_edge( handle_transform: fn(Node, Node, TargetModel) -> Outcome ) -> Outcome { bind_outcome( - o: find_named_child(root: arm_edge.target, name: match_arm_pattern), + o: find_core_child(root: arm_edge.target, marker: MatchArmPatternEdge), f: fn(pattern_node) { bind_outcome( - o: find_named_child(root: arm_edge.target, name: match_arm_body), + o: find_core_child(root: arm_edge.target, marker: MatchArmBodyEdge), f: fn(body_node) { bind_outcome( o: target_value_expr_project_body_subexpression( @@ -15488,7 +15572,8 @@ fn arrow_domain_edge_names(edges: List) -> List { fn arrow_domain_edge_name_step(acc: List, edge: Edge) -> List { match edge.label { - Named { name: n } => list_snoc_item(xs: acc, item: n) + Authored { name: n } => list_snoc_item(xs: acc, item: n) + StructuralLabel { label: _ } => acc Positional => acc } } diff --git a/src/v2/std/decl_facts_skeleton.dag b/src/v2/std/decl_facts_skeleton.dag index 5cd0574d1fc..f41c5e86c64 100644 --- a/src/v2/std/decl_facts_skeleton.dag +++ b/src/v2/std/decl_facts_skeleton.dag @@ -14,7 +14,7 @@ import v2.std.algebra { } import v2.std.collection { Absent, Present } import v2.std.decl_index { DeclFact } -import v2.std.node { Edge, Named, Node, NodeFold, Positional, TypeNode, Atom, Symbol, fold_node, labeled_named_is, edge_label_of, symbol_lexeme } +import v2.std.node { Edge, Authored, StructuralLabel, Node, NodeFold, Positional, TypeNode, Atom, Symbol, fold_node, labeled_named_is, edge_label_of, symbol_lexeme, EdgeLabel } type OuterRecordConstructorLexeme = String @@ -184,7 +184,8 @@ type AtomLexemeCensus { fn skeleton_edge_is_construction_spelling(e: Edge) -> Bool { match e.label { - Named { name: nm } => nm == ^record_construction_spelling + Authored { name: nm } => nm == ^record_construction_spelling + StructuralLabel { label: _ } => false Positional => false } } diff --git a/src/v2/std/dependency.dag b/src/v2/std/dependency.dag index b4304faba3e..306c29f8f47 100644 --- a/src/v2/std/dependency.dag +++ b/src/v2/std/dependency.dag @@ -7,7 +7,7 @@ import v2.std.node { Bind, ComputationNode, Edge, - Named, + Authored, StructuralLabel, Node, NodeFold, Positional, @@ -179,7 +179,8 @@ fn classify_named_edge_usage(parent: Node, sym: Symbol) -> DependencyKind { fn classify_node_edge_usage(parent: Node, edge: Edge) -> DependencyKind { match edge.label { - Named { name: sym } => classify_named_edge_usage(parent: parent, sym: sym) + Authored { name: sym } => classify_named_edge_usage(parent: parent, sym: sym) + StructuralLabel { label: _ } => Contains Positional => Contains } } diff --git a/src/v2/std/effects.dag b/src/v2/std/effects.dag index 8a10463bdd1..b96a7cd1c8a 100644 --- a/src/v2/std/effects.dag +++ b/src/v2/std/effects.dag @@ -1,7 +1,7 @@ module v2.std.effects import std.occurrence_identity { OccurrenceSynthetic } -import v2.std.node { Atom, Conj, ComputationNode, Edge, Named, Node, Symbol, Transform, TypeNode } +import v2.std.node { Atom, Conj, ComputationNode, Edge, Authored, Node, Symbol, Transform, TypeNode } import std.effects { EffectShape, ReadEffect, UpsertEffect, DeleteEffect, CreateEffect, AppendEffect, ExecuteEffect, PostAlways, CreateIfAbsent, KeylessFallback @@ -131,11 +131,11 @@ fn key_source_node(key_source: SubstrateKeySource) -> Node { kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: ^key_source_path_param_field }, + label: Authored { name: ^key_source_path_param_field }, target: atom_node(s: ^key_source_path_param_field) }, Edge { - label: Named { name: ^key_source_path_param_value_field }, + label: Authored { name: ^key_source_path_param_value_field }, target: atom_node(s: p) }, ], @@ -146,11 +146,11 @@ fn key_source_node(key_source: SubstrateKeySource) -> Node { kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: ^key_source_input_field_field }, + label: Authored { name: ^key_source_input_field_field }, target: atom_node(s: ^key_source_input_field_field) }, Edge { - label: Named { name: ^key_source_input_value_field }, + label: Authored { name: ^key_source_input_value_field }, target: atom_node(s: f) }, ], @@ -164,11 +164,11 @@ fn keyed_shape_node(variant_marker: Symbol, key_source: SubstrateKeySource) -> N kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: variant_marker }, + label: Authored { name: variant_marker }, target: atom_node(s: variant_marker) }, Edge { - label: Named { name: ^idempotent_operation_key_source_field }, + label: Authored { name: ^idempotent_operation_key_source_field }, target: key_source_node(key_source: key_source) }, ], @@ -200,11 +200,11 @@ fn classified_idempotent_effect_node(shape: EffectShape) -> kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: ^effect_shape_is_idempotent_field }, + label: Authored { name: ^effect_shape_is_idempotent_field }, target: atom_node(s: ^effect_shape_is_idempotent_field) }, Edge { - label: Named { name: ^effect_shape_inner_field }, + label: Authored { name: ^effect_shape_inner_field }, target: effect_shape_node(shape: shape) }, ], @@ -217,7 +217,7 @@ fn idempotent_operation_ref_node(operation: IdempotentOperationRef) -> Node { kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: ^idempotent_operation_callable_field }, + label: Authored { name: ^idempotent_operation_callable_field }, target: atom_node(s: operation.callable) }, ], @@ -232,11 +232,11 @@ fn idempotent_operation_witness_node(subject: ComposableIdempotentOperationSubje kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: ^effect_shape_inner_field }, + label: Authored { name: ^effect_shape_inner_field }, target: classified_idempotent_effect_node(shape: ReadEffect) }, Edge { - label: Named { name: ^idempotent_operation_callable_field }, + label: Authored { name: ^idempotent_operation_callable_field }, target: idempotent_operation_ref_node(operation: operation) }, ], @@ -247,11 +247,11 @@ fn idempotent_operation_witness_node(subject: ComposableIdempotentOperationSubje kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: ^effect_shape_inner_field }, + label: Authored { name: ^effect_shape_inner_field }, target: classified_idempotent_effect_node(shape: UpsertEffect { key_source: key_source }) }, Edge { - label: Named { name: ^idempotent_operation_callable_field }, + label: Authored { name: ^idempotent_operation_callable_field }, target: idempotent_operation_ref_node(operation: operation) }, ], @@ -262,11 +262,11 @@ fn idempotent_operation_witness_node(subject: ComposableIdempotentOperationSubje kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: ^effect_shape_inner_field }, + label: Authored { name: ^effect_shape_inner_field }, target: classified_idempotent_effect_node(shape: DeleteEffect { key_source: key_source }) }, Edge { - label: Named { name: ^idempotent_operation_callable_field }, + label: Authored { name: ^idempotent_operation_callable_field }, target: idempotent_operation_ref_node(operation: operation) }, ], @@ -277,13 +277,13 @@ fn idempotent_operation_witness_node(subject: ComposableIdempotentOperationSubje kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: ^effect_shape_inner_field }, + label: Authored { name: ^effect_shape_inner_field }, target: classified_idempotent_effect_node( shape: CreateEffect { cause: CreateIfAbsent { key_source: key_source } } ) }, Edge { - label: Named { name: ^idempotent_operation_callable_field }, + label: Authored { name: ^idempotent_operation_callable_field }, target: idempotent_operation_ref_node(operation: operation) }, ], @@ -297,11 +297,11 @@ fn idempotent_operation_apply_node(state: Node, subject: ComposableIdempotentOpe kind: ComputationNode { behavior: Transform }, children: [ Edge { - label: Named { name: ^idempotent_apply_state_field }, + label: Authored { name: ^idempotent_apply_state_field }, target: state }, Edge { - label: Named { name: ^idempotent_apply_operation_field }, + label: Authored { name: ^idempotent_apply_operation_field }, target: idempotent_operation_witness_node(subject: subject) }, ], diff --git a/src/v2/std/fold_assembly.dag b/src/v2/std/fold_assembly.dag index f123026409e..e7b46cd47a5 100644 --- a/src/v2/std/fold_assembly.dag +++ b/src/v2/std/fold_assembly.dag @@ -1,7 +1,7 @@ module v2.std.fold_assembly import v2.std.node { - Node, Edge, EdgeLabel, Named, + Node, Edge, EdgeLabel, Authored, NodeKind, TypeNode, Connective, Conj, Symbol, node_synthetic, node_subtree_nodes, NamedEdgeTargetLookup, Found, Ambiguous, Absent, named_edge_target_lookup @@ -20,7 +20,7 @@ data fold_template_edge: Symbol = ^fold_template data fold_elements_edge: Symbol = ^fold_elements fn named_edge(name: Symbol, target: Node) -> Edge { - Edge { label: Named { name: name }, target: target } + Edge { label: Authored { name: name }, target: target } } fn conj_record(children: FreeMonoid) -> Node { diff --git a/src/v2/std/grammar.dag b/src/v2/std/grammar.dag index 2870d5a53e5..bd8795b6f7e 100644 --- a/src/v2/std/grammar.dag +++ b/src/v2/std/grammar.dag @@ -48,11 +48,12 @@ import v2.std.node { Atom, Conj, Edge, - Named, + Authored, Node, Positional, Symbol, TypeNode, + StructuralLabel, } import v2.std.node_shape { stamp_node_shape_synthetic, type_shape } import v2.std.compilers.target_model { @@ -445,7 +446,7 @@ fn grammar_atom(identity: Symbol) -> Node { fn grammar_named_edge(name: Symbol, target: Node) -> Edge { Edge { - label: Named { name: name }, + label: Authored { name: name }, target: target } } @@ -833,7 +834,8 @@ fn formal_rhs_from_node(node: Node) -> Witness> { } Violates { diagnostic: d } => Violates { diagnostic: d } } - Named { name: _ } => acc + Authored { name: _ } => acc + StructuralLabel { label: _ } => acc } } } @@ -942,13 +944,14 @@ fn grammar_relation_rules_formal_productions_from_rows(rules: Node) -> Outcome + Authored { name: n } => if n == ^grammar_relation_rules_formal_productions { acc } else { grammar_relation_rules_formal_productions_step(acc: acc, row: edge.target) } Positional => acc + StructuralLabel { label: _ } => acc } } ) @@ -1004,7 +1007,8 @@ fn formal_productions_from_catalog_node(node: Node) -> Outcome outcome_rejected(d) } - Named { name: _ } => outcome_accepted(value: productions) + Authored { name: _ } => outcome_accepted(value: productions) + StructuralLabel { label: _ } => outcome_accepted(value: productions) } } ) @@ -1149,7 +1153,8 @@ fn conj_positional_children(parent: Node) -> List { f: fn(acc, edge) { match edge.label { Positional => list_snoc_item(xs: acc, item: edge.target) - Named { name: _ } => acc + Authored { name: _ } => acc + StructuralLabel { label: _ } => acc } } ) @@ -2892,7 +2897,7 @@ fn grammar_relation_row_reverse_parse_selection(rules: Node, emitted: Node) -> O init: BackwardRowNone, f: fn(acc, edge) { match edge.label { - Named { name: n } => + Authored { name: n } => if n == ^grammar_relation_rules_formal_productions { acc } else { @@ -2904,6 +2909,7 @@ fn grammar_relation_row_reverse_parse_selection(rules: Node, emitted: Node) -> O ) } Positional => acc + StructuralLabel { label: _ } => acc } } ) { @@ -2967,7 +2973,7 @@ fn grammar_relation_row_forward_select( init: GrammarRelationForwardRowNone, f: fn(acc, e) { match e.label { - Named { name: n } => + Authored { name: n } => if grammar_relation_forward_row_select_skip_catalog_edge(name: n) { acc } else { @@ -2978,6 +2984,7 @@ fn grammar_relation_row_forward_select( ) } Positional => acc + StructuralLabel { label: _ } => acc } } ) @@ -3098,12 +3105,17 @@ fn grammar_node_carries_surface_identity(node: Node, surface_identity: Symbol) - acc } else { match e.label { - Named { name: n } => + Authored { name: n } => (n == surface_identity) || grammar_node_carries_surface_identity( node: e.target, surface_identity: surface_identity ) + StructuralLabel { label: _ } => + grammar_node_carries_surface_identity( + node: e.target, + surface_identity: surface_identity + ) Positional => grammar_node_carries_surface_identity( node: e.target, diff --git a/src/v2/std/inhabitance.dag b/src/v2/std/inhabitance.dag index a69164178c0..0987c38d8f8 100644 --- a/src/v2/std/inhabitance.dag +++ b/src/v2/std/inhabitance.dag @@ -22,7 +22,7 @@ import v2.std.node { Cardinality, Conj, Edge, - Named, + Authored, Node, Positional, Symbol, @@ -387,9 +387,9 @@ fn inhabitance_position_context_edges(position: DeclaredTypePosition) -> List [] PositionDeclaredReturn => [] - PositionRecordField { record: record } => [Edge { label: Named { name: ^inhabitance_record }, target: record }] - PositionLetAnnotation { bound: bound } => [Edge { label: Named { name: ^inhabitance_bound_value }, target: bound }] - PositionBinderDefault { default: default } => [Edge { label: Named { name: ^inhabitance_default_value }, target: default }] + PositionRecordField { record: record } => [Edge { label: Authored { name: ^inhabitance_record }, target: record }] + PositionLetAnnotation { bound: bound } => [Edge { label: Authored { name: ^inhabitance_bound_value }, target: bound }] + PositionBinderDefault { default: default } => [Edge { label: Authored { name: ^inhabitance_default_value }, target: default }] } } @@ -512,19 +512,19 @@ fn application_argument_does_not_inhabit_diagnostic( kind: TypeNode { connective: Conj }, children: list_append(left: [ Edge { - label: Named { name: inhabitance_position_symbol(position: obligation.position) }, + label: Authored { name: inhabitance_position_symbol(position: obligation.position) }, target: obligation.application }, Edge { - label: Named { name: obligation.parameter_identity }, + label: Authored { name: obligation.parameter_identity }, target: obligation.declared }, Edge { - label: Named { name: ^inhabitance_produced_type }, + label: Authored { name: ^inhabitance_produced_type }, target: obligation.produced }, Edge { - label: Named { name: find_witness_reason }, + label: Authored { name: find_witness_reason }, target: obligation.produced } ], right: inhabitance_position_context_edges(position: obligation.position)), diff --git a/src/v2/std/integer.dag b/src/v2/std/integer.dag index 7f1e174c4d2..ed2153969ec 100644 --- a/src/v2/std/integer.dag +++ b/src/v2/std/integer.dag @@ -16,7 +16,7 @@ import v2.std.optional { optional_present } import v2.std.diagnostic { Correction, Diagnostic, ExternalContractUnknown, Locus, NoCorrectionReason, Outcome, Accepted, None, Rejected, diagnostics_singleton, node_locus, outcome_accepted, outcome_rejected, invariant_port_locus, port_refusal_locus, Unavailable } -import v2.std.node { Atom, Conj, Edge, Named, Node, Symbol, TypeNode, is_empty_conj_root } +import v2.std.node { Atom, Conj, Edge, Authored, Node, Symbol, TypeNode, is_empty_conj_root } import v2.std.node_query { find_named_child } import std.integer { Signedness, Signed, Unsigned } import std.content_hash { Fnv1a64Structural, content_hash_atom, content_hash_tagged_structural } @@ -810,7 +810,7 @@ fn integer_inhabitant_atom(id: Symbol) -> Node { } fn integer_named_edge(name: Symbol, target: Node) -> Edge { - Edge { label: Named { name: name }, target: target } + Edge { label: Authored { name: name }, target: target } } fn integer_bound_sign_node(sign: IntegerBoundSign) -> Node { diff --git a/src/v2/std/integer_value_set.dag b/src/v2/std/integer_value_set.dag index 63f07021071..2e4dfc430fb 100644 --- a/src/v2/std/integer_value_set.dag +++ b/src/v2/std/integer_value_set.dag @@ -16,7 +16,7 @@ import v2.std.diagnostic { Unavailable } import v2.std.integer { integer_interval_spec_node_contains } -import v2.std.node { Atom, Conj, Edge, Named, Node, Symbol, TypeNode, well_formed } +import v2.std.node { Atom, Conj, Edge, Authored, Node, Symbol, TypeNode, well_formed } import v2.std.node_query { find_named_child } type IntegerValueSet @@ -36,7 +36,7 @@ fn integer_unbounded_value_set_node() -> Node { kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: ^integer_value_set_field_kind }, + label: Authored { name: ^integer_value_set_field_kind }, target: integer_value_set_atom(id: ^integer_value_set_kind_unbounded) } ], @@ -49,11 +49,11 @@ fn integer_interval_value_set_node(interval: Node) -> Node { kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: ^integer_value_set_field_kind }, + label: Authored { name: ^integer_value_set_field_kind }, target: integer_value_set_atom(id: ^integer_value_set_kind_interval) }, Edge { - label: Named { name: ^integer_value_set_field_interval }, + label: Authored { name: ^integer_value_set_field_interval }, target: interval } ], diff --git a/src/v2/std/language_model.dag b/src/v2/std/language_model.dag index a6ec000bb3b..421dbcab88c 100644 --- a/src/v2/std/language_model.dag +++ b/src/v2/std/language_model.dag @@ -15,7 +15,7 @@ import v2.std.model_core { model_core_first_primitive_substrate, bool_model_core } -import v2.std.node { Conj, Edge, Named, Node, Symbol, TypeNode } +import v2.std.node { Conj, Edge, Authored, Node, Symbol, TypeNode } type LanguageModel { lex: LexRules @@ -27,7 +27,7 @@ type LanguageModel { fn language_model_named_edge(name: Symbol, target: Node) -> Edge { Edge { - label: Named { name: name }, + label: Authored { name: name }, target: target } } diff --git a/src/v2/std/logic.dag b/src/v2/std/logic.dag index 19c4402708c..4eb478f7475 100644 --- a/src/v2/std/logic.dag +++ b/src/v2/std/logic.dag @@ -2,7 +2,7 @@ module v2.std.logic import std.occurrence_identity { OccurrenceSynthetic } import std.algebra { BooleanAlgebra, BoundedLattice, Lattice } -import v2.std.node { Atom, Conj, Edge, Named, Node, Symbol, TypeNode } +import v2.std.node { Atom, Conj, Edge, Authored, Node, Symbol, TypeNode } type Bool = True | False type BoolWidthFact {} @@ -55,7 +55,7 @@ fn bool_fact_atom(id: Symbol) -> Node { } fn bool_named_edge(name: Symbol, target: Node) -> Edge { - Edge { label: Named { name: name }, target: target } + Edge { label: Authored { name: name }, target: target } } fn bool_width_fact_node(width: BoolWidthFact) -> Node { diff --git a/src/v2/std/map_introduction.dag b/src/v2/std/map_introduction.dag index c0cc9575d69..30d97d89878 100644 --- a/src/v2/std/map_introduction.dag +++ b/src/v2/std/map_introduction.dag @@ -7,8 +7,8 @@ import v2.std.optional { Absent, Optional, Present, optional_absent } import v2.std.integer { Int } import v2.std.list_introduction { list_introduction_elements_optional, list_introduction_head_path } import v2.std.logic { Bool } -import v2.std.node { ComputationNode, Edge, Named, Node, Positional, Symbol, Transform, node_with_occurrence_id } -import v2.std.node_query { NamedChildAmbiguous, NamedChildFound, NamedChildMissing, construct_node, named_child_lookup } +import v2.std.node { Authored, ComputationNode, Edge, MapLiteralEntriesEdge, Node, Positional, Symbol, Transform, node_with_occurrence_id } +import v2.std.node_query { NamedChildAmbiguous, NamedChildFound, NamedChildMissing, construct_node, core_child_lookup } import v2.std.qualified_name { QualifiedName, declaration_reference_node } // THE MAP-LITERAL INTRODUCTION, ONE AUTHORITY FOR ITS PATHS, ITS CONSTRUCTOR AND ITS KEY LAW @@ -25,19 +25,11 @@ import v2.std.qualified_name { QualifiedName, declaration_reference_node } // literals elaborate to it (an import cycle otherwise). // A STRING-KEYED BRACE, as body lowering records it. Each item is first an edge labelled -// map_literal_entry_label targeting a tag-elided `{ key, value }` construct; once the brace is +// CoreEdgeLabel MapLiteralEntryEdge targeting a tag-elided `{ key, value }` construct; once the brace is // known to be all string keys, lowering collapses those items into ONE edge labelled -// map_literal_entries_label whose target is a list literal of the pairs -- one edge, because a +// CoreEdgeLabel MapLiteralEntriesEdge whose target is a list literal of the pairs -- one edge, because a // construct's named edges must be distinct (v2.std.node well_formed). Lowering records the key's // KIND and chooses nothing; resolve's map arm reads the list. -fn map_literal_entry_label() -> Symbol { - ^map_literal_entry -} - -fn map_literal_entries_label() -> Symbol { - ^map_literal_entries -} - // THE AUTHORED PAIRS OF A STRING-KEYED BRACE, read totally through the one named-child lookup // (v2.std.node_query named_child_lookup): no entries edge, exactly one carrying a list literal of // pairs, or a malformed carrier (two entries edges, or one that is not a list literal) -- which the @@ -48,7 +40,7 @@ type MapLiteralEntries | MapLiteralEntriesMalformed fn map_literal_entries(n: Node) -> MapLiteralEntries { - match named_child_lookup(root: n, name: map_literal_entries_label()) { + match core_child_lookup(root: n, marker: MapLiteralEntriesEdge) { NamedChildMissing => MapLiteralEntriesNone NamedChildAmbiguous => MapLiteralEntriesMalformed NamedChildFound { target: t } => @@ -142,8 +134,8 @@ fn lower_map_introduction(entries: List, source: Node item: construct_node( reference: declaration_reference_node(qn: map_introduction_entry_path(), occurrence_id: e.source.occurrence_id), field_edges: [ - Edge { label: Named { name: ^key }, target: e.key }, - Edge { label: Named { name: ^value }, target: e.value } + Edge { label: Authored { name: ^key }, target: e.key }, + Edge { label: Authored { name: ^value }, target: e.value } ], source: e.source ) @@ -153,7 +145,7 @@ fn lower_map_introduction(entries: List, source: Node kind: ComputationNode { behavior: Transform }, children: [ Edge { label: Positional, target: declaration_reference_node(qn: map_introduction_head_path(), occurrence_id: source.occurrence_id) }, - Edge { label: Named { name: ^entries }, target: map_introduction_resolved_list(elements: entry_nodes, source: source) } + Edge { label: Authored { name: ^entries }, target: map_introduction_resolved_list(elements: entry_nodes, source: source) } ], occurrence_id: source.occurrence_id ) diff --git a/src/v2/std/model_core.dag b/src/v2/std/model_core.dag index 06ecf87c4cb..b263354c4fd 100644 --- a/src/v2/std/model_core.dag +++ b/src/v2/std/model_core.dag @@ -21,7 +21,7 @@ import v2.std.logic { bool_primitive_facts_node, bool_width_fact_node } -import v2.std.node { Atom, Conj, Edge, Named, Node, Symbol, TypeNode } +import v2.std.node { Atom, Conj, Edge, Authored, Node, Symbol, TypeNode } import v2.std.witness { Holds, Violates, Witness } type ModelCorePrimitiveFactAxis @@ -186,15 +186,15 @@ fn model_core_law_node(key: ModelCoreBoolLawKey) -> Node { kind: TypeNode { connective: Conj }, children: [ Edge { - label: Named { name: ^model_core_law_field_subject }, + label: Authored { name: ^model_core_law_field_subject }, target: model_core_bool_inhabitance_witness() }, Edge { - label: Named { name: ^model_core_law_field_algebra }, + label: Authored { name: ^model_core_law_field_algebra }, target: model_core_bool_algebra_node() }, Edge { - label: Named { name: ^model_core_law_field_kind }, + label: Authored { name: ^model_core_law_field_kind }, target: model_core_atom(id: discriminant(v: key)) }, ], diff --git a/src/v2/std/node.dag b/src/v2/std/node.dag index 1e484ed51a5..3c489764849 100644 --- a/src/v2/std/node.dag +++ b/src/v2/std/node.dag @@ -128,16 +128,153 @@ fn behavior_coproduct_variants() -> List { [Value, Transform, Branch, Loop, Bind, Match] } -data match_arm_pattern: Symbol = ^match_arm_pattern -data match_arm_body: Symbol = ^match_arm_body type NodeKind = TypeNode { connective: Connective } | ComputationNode { behavior: Behavior } +// AN EDGE LABEL SAYS WHO NAMED THE EDGE. An authored name (a field, a binder, a named actual, a +// declaration) carries the source spelling; a structural label is minted by the substrate or by a +// language's grammar and is compared by ARM, never by text, so no authored spelling can inhabit it. +// Grammar productions are keyed by their language (the language model's identity) because +// v2.std.node may not enumerate any grammar's productions (DESIGN section 3); the substrate's own +// edge-discipline markers are closed here. Plan: docs/plans/edge-label-coproduct/README.md. type EdgeLabel - = Named { name: Symbol } + = Authored { name: Symbol } + | StructuralLabel { label: StructuralEdgeLabel } | Positional + +type StructuralEdgeLabel + = CoreMarker { marker: CoreEdgeLabel } + | ProductionEdge { language: Symbol, edge: Symbol } + +type CoreEdgeLabel + = ArrowBodyEdge + | ArrowSignatureOrderEdge + | LoopBoundEdge + | LoopCarrierEdge + | LoopDomainEdge + | LoopRealizedDeclarationEdge + | MatchArmPatternEdge + | MatchArmBodyEdge + | CastTargetEdge + | TypeAnnotationEdge + | TypeParamsEdge + | TypeBodyEdge + | TypeAliasEdge + | DeclarationReferenceEdge + | FieldProjectionBaseEdge + | FieldProjectionFieldEdge + | ConstructTagEdge + | ConstructTagElidedEdge + | ParameterReferenceEdge + | ArrowEffectClaimsEdge + | ArrowExecutionModeClaimEdge + | BinderTypeEdge + | BinderDefaultEdge + | ArrowResourceRequirementsEdge + | LexicalReferenceEdge + | MapLiteralEntryEdge + | MapLiteralEntriesEdge + +fn core_edge_label(marker: CoreEdgeLabel) -> EdgeLabel { + StructuralLabel { label: CoreMarker { marker: marker } } +} + +fn production_edge_label(language: Symbol, edge: Symbol) -> EdgeLabel { + StructuralLabel { label: ProductionEdge { language: language, edge: edge } } +} + +fn core_edge(marker: CoreEdgeLabel, target: Node) -> Edge { + Edge { label: core_edge_label(marker: marker), target: target } +} + +// THE ONE READER OF A CORE MARKER: it matches the arm, so an authored name spelled like a marker +// answers false by construction. +fn edge_is_core(e: Edge, marker: CoreEdgeLabel) -> Bool { + match e.label { + StructuralLabel { label: CoreMarker { marker: m } } => m == marker + StructuralLabel { label: ProductionEdge { language: _, edge: _ } } => false + Authored { name: _ } => false + Positional => false + } +} + +fn edge_is_production(e: Edge, language: Symbol, edge: Symbol) -> Bool { + match e.label { + StructuralLabel { label: ProductionEdge { language: l, edge: p } } => (l == language) && (p == edge) + StructuralLabel { label: CoreMarker { marker: _ } } => false + Authored { name: _ } => false + Positional => false + } +} + +// THE CLOSED SET, listed once, for a codec that must invert a wire marker (gunbc.scm.object_table_json). +fn core_edge_labels() -> List { + [ + ArrowBodyEdge, + ArrowSignatureOrderEdge, + LoopBoundEdge, + LoopCarrierEdge, + LoopDomainEdge, + LoopRealizedDeclarationEdge, + MatchArmPatternEdge, + MatchArmBodyEdge, + CastTargetEdge, + TypeAnnotationEdge, + TypeParamsEdge, + TypeBodyEdge, + TypeAliasEdge, + DeclarationReferenceEdge, + FieldProjectionBaseEdge, + FieldProjectionFieldEdge, + ConstructTagEdge, + ConstructTagElidedEdge, + ParameterReferenceEdge, + ArrowEffectClaimsEdge, + ArrowExecutionModeClaimEdge, + BinderTypeEdge, + BinderDefaultEdge, + ArrowResourceRequirementsEdge, + LexicalReferenceEdge, + MapLiteralEntryEdge, + MapLiteralEntriesEdge, + ] +} + +// The Symbol a core marker contributes to CANONICAL ORDER AND CONTENT HASH ONLY. It is not a +// reading key: a reader that compares it with a label's text re-opens the defect this type closes. +fn core_edge_label_canonical_symbol(marker: CoreEdgeLabel) -> Symbol { + match marker { + ArrowBodyEdge => ^arrow_body_edge + ArrowSignatureOrderEdge => ^arrow_signature_order_edge + LoopBoundEdge => ^loop_bound_edge + LoopCarrierEdge => ^loop_carrier_edge + LoopDomainEdge => ^loop_domain_edge + LoopRealizedDeclarationEdge => ^loop_realized_declaration_edge + MatchArmPatternEdge => ^match_arm_pattern + MatchArmBodyEdge => ^match_arm_body + CastTargetEdge => ^core_cast_target_edge + TypeAnnotationEdge => ^core_type_annotation_edge + TypeParamsEdge => ^core_type_params_edge + TypeBodyEdge => ^core_type_body_edge + TypeAliasEdge => ^core_type_alias_edge + DeclarationReferenceEdge => ^core_declaration_reference_edge + FieldProjectionBaseEdge => ^core_field_projection_base_edge + FieldProjectionFieldEdge => ^core_field_projection_field_edge + ConstructTagEdge => ^core_construct_tag_edge + ConstructTagElidedEdge => ^core_construct_tag_elided_edge + ParameterReferenceEdge => ^core_parameter_reference_edge + ArrowEffectClaimsEdge => ^core_arrow_effect_claims_edge + ArrowExecutionModeClaimEdge => ^core_arrow_execution_mode_claim_edge + BinderTypeEdge => ^core_binder_type_edge + BinderDefaultEdge => ^core_binder_default_edge + ArrowResourceRequirementsEdge => ^core_arrow_resource_requirements_edge + LexicalReferenceEdge => ^core_lexical_reference_edge + MapLiteralEntryEdge => ^core_map_literal_entry_edge + MapLiteralEntriesEdge => ^core_map_literal_entries_edge + } +} type Edge { label: EdgeLabel target: Node @@ -487,16 +624,19 @@ fn connective_edge_discipline_for_children(c: Connective, children: List) connective_edge_discipline_for_child_count(c: c, child_count: count(children)) } +// A NAMED EDGE is any non-positional edge: authored or structural. Edge discipline counts both. fn is_named(e: Edge) -> Bool { match e.label { - Named { name: _ } => true + Authored { name: _ } => true + StructuralLabel { label: _ } => true Positional => false } } fn is_positional(e: Edge) -> Bool { match e.label { - Named { name: _ } => false + Authored { name: _ } => false + StructuralLabel { label: _ } => false Positional => true } } @@ -523,20 +663,26 @@ fn all_edges_positional(children: List) -> Bool { acc && is_positional(e: e) }) } +// How many edges carry this AUTHORED name. A structural label never counts, whatever its spelling. fn name_occurrences(name: Symbol, children: List) -> Int { fold(children, init: 0, f: fn(acc, e) { match e.label { - Named { name: n } => if n == name { acc + 1 } else { acc } + Authored { name: n } => if n == name { acc + 1 } else { acc } + StructuralLabel { label: _ } => acc Positional => acc } }) } + +fn core_occurrences(marker: CoreEdgeLabel, children: List) -> Int { + fold(children, init: 0, f: fn(acc, e) { + if edge_is_core(e: e, marker: marker) { acc + 1 } else { acc } + }) +} + fn positional_child_count(children: List) -> Int { fold(children, init: 0, f: fn(acc, e) { - match e.label { - Positional => acc + 1 - Named { name: _ } => acc - } + if is_positional(e: e) { acc + 1 } else { acc } }) } @@ -564,18 +710,19 @@ type LoopEdgeRole fn loop_edge_role(e: Edge) -> LoopEdgeRole { match e.label { Positional => LoopIteratedBody - Named { name: sym } => - if sym == ^loop_domain_edge { + StructuralLabel { label: _ } => + if edge_is_core(e: e, marker: LoopDomainEdge) { LoopDomainValue - } else if sym == ^loop_bound_edge { + } else if edge_is_core(e: e, marker: LoopBoundEdge) { LoopBoundMeasure - } else if sym == ^loop_carrier_edge { + } else if edge_is_core(e: e, marker: LoopCarrierEdge) { LoopCarrierBinder - } else if sym == ^loop_realized_declaration_edge { + } else if edge_is_core(e: e, marker: LoopRealizedDeclarationEdge) { LoopRealizedDeclaration } else { LoopEdgeUnrecognized } + Authored { name: _ } => LoopEdgeUnrecognized } } @@ -593,10 +740,10 @@ fn loop_body_edges_conform(children: List) -> Bool { } fn loop_behavior_edges_conform(children: List) -> Bool { - let bound_edges = name_occurrences(name: ^loop_bound_edge, children: children) - let carrier_edges = name_occurrences(name: ^loop_carrier_edge, children: children) - let domain_edges = name_occurrences(name: ^loop_domain_edge, children: children) - let realized_edges = name_occurrences(name: ^loop_realized_declaration_edge, children: children) + let bound_edges = core_occurrences(marker: LoopBoundEdge, children: children) + let carrier_edges = core_occurrences(marker: LoopCarrierEdge, children: children) + let domain_edges = core_occurrences(marker: LoopDomainEdge, children: children) + let realized_edges = core_occurrences(marker: LoopRealizedDeclarationEdge, children: children) (bound_edges == 1) && (carrier_edges <= 1) && (domain_edges <= 1) @@ -613,34 +760,30 @@ fn loop_behavior_edges_conform(children: List) -> Bool { // THE DECLARED-ORDER EDGE'S LABEL, as one value every stage compares against through edge_label_of // (v2.compiler.resolve, v2.compiler.infer, v2.std.compilers.body_lowering), so the label is spelled in // one place and no stage writes its own variant match. -data arrow_signature_order_label: EdgeLabel = Named { name: ^arrow_signature_order_edge } +data arrow_signature_order_label: EdgeLabel = StructuralLabel { label: CoreMarker { marker: ArrowSignatureOrderEdge } } // AN ARROW'S CONTRACT EDGES (XL-2 PR2a; ruling 2026-10-01, docs/plans/arrow-contract-edges.md). Two -// optional named edges that state what the Arrow promises: ^arrow_effect_claims_edge (its declared -// effect claims) and ^arrow_execution_mode_claim_edge (its declared execution-mode claim). This module +// optional core-marker edges that state what the Arrow promises: ArrowEffectClaimsEdge (its declared +// effect claims) and ArrowExecutionModeClaimEdge (its declared execution-mode claim). This module // owns only their STRUCTURE: each appears at most once, and neither is a binder, so neither counts // toward the one type-binder Conj and the binder, order and body readers never consume them. Their // VOCABULARY -- which claims and modes exist -- is not this module's fact: it lives in std.effects // EffectClaim and std.execution_mode ExecutionMode, and v2.std.arrow_contract checks a contract edge's // target against those homes (v2.std.type_binder type_binder_node_conforms runs it on every Arrow). -data arrow_effect_claims_label: EdgeLabel = Named { name: ^arrow_effect_claims_edge } -data arrow_execution_mode_claim_label: EdgeLabel = Named { name: ^arrow_execution_mode_claim_edge } - // THE THIRD CONTRACT EDGE, an operation's declared RESOURCE REQUIREMENTS (D13 step a, // docs/plans/arrow-contract-edges.md): `requires Network` on an opaque operation, whose requirement -// cannot be derived from a body because it has none. Its target is a nonempty Conj of references to -// `resource` declarations. Unlike the claims and mode edges it names DECLARATIONS, an open set, so its -// members are resolved: v2.compiler.resolve walks it in the Arrow's OUTER scope (a requirement may not -// see the operation's parameters) and refuses a member that does not resolve to a declared resource +// cannot be derived from a body because it has none. It is the core marker ArrowResourceRequirementsEdge, +// and its target is a nonempty Conj of references to `resource` declarations, one Authored member per +// spelling. Unlike the claims and mode edges it names DECLARATIONS, an open set, so its members are +// resolved: v2.compiler.resolve walks it in the Arrow's OUTER scope (a requirement may not see the +// operation's parameters) and refuses a member that does not resolve to a declared resource // (v2.std.symbol_index symbol_index_declares_resource_at) or that repeats one. Like the other two it is // metadata to every value reader: v2.compiler.infer and v2.std.type_binder node_inferred_subtree_nodes // skip every arrow_named_edge_is_contract edge. -data arrow_resource_requirements_label: EdgeLabel = Named { name: ^arrow_resource_requirements_edge } - fn arrow_named_edge_is_contract(e: Edge) -> Bool { - (edge_label_of(e: e) == arrow_effect_claims_label) - || (edge_label_of(e: e) == arrow_execution_mode_claim_label) - || (edge_label_of(e: e) == arrow_resource_requirements_label) + edge_is_core(e: e, marker: ArrowEffectClaimsEdge) + || edge_is_core(e: e, marker: ArrowExecutionModeClaimEdge) + || edge_is_core(e: e, marker: ArrowResourceRequirementsEdge) } @@ -650,9 +793,10 @@ fn arrow_named_edge_is_contract(e: Edge) -> Bool { fn arrow_named_edge_is_non_binder(e: Edge) -> Bool { match e.label { Positional => false - Named { name: sym } => - (sym == ^arrow_body_edge) - || (edge_label_of(e: e) == arrow_signature_order_label) + Authored { name: _ } => false + StructuralLabel { label: _ } => + edge_is_core(e: e, marker: ArrowBodyEdge) + || edge_is_core(e: e, marker: ArrowSignatureOrderEdge) || arrow_named_edge_is_contract(e: e) } } @@ -663,7 +807,7 @@ fn arrow_named_edge_is_non_binder(e: Edge) -> Bool { // no reader keeps its own list of metadata labels. fn arrow_signature_order_edge(parent: Node, edge: Edge) -> Bool { match parent.kind { - TypeNode { connective: Arrow } => (edge_label_of(e: edge) == arrow_signature_order_label) + TypeNode { connective: Arrow } => edge_is_core(e: edge, marker: ArrowSignatureOrderEdge) _ => false } } @@ -672,18 +816,20 @@ fn arrow_signature_edges_conform(children: List) -> Bool { let binder_edges = fold(children, init: 0, f: fn(acc, e) { match e.label { Positional => acc - Named { name: _ } => if arrow_named_edge_is_non_binder(e: e) { acc } else { acc + 1 } + StructuralLabel { label: _ } => if arrow_named_edge_is_non_binder(e: e) { acc } else { acc + 1 } + Authored { name: _ } => acc + 1 } }) (binder_edges <= 1) && arrow_signature_order_conforms(children: children) - && (name_occurrences(name: ^arrow_effect_claims_edge, children: children) <= 1) - && (name_occurrences(name: ^arrow_execution_mode_claim_edge, children: children) <= 1) - && (name_occurrences(name: ^arrow_resource_requirements_edge, children: children) <= 1) + && (core_occurrences(marker: ArrowEffectClaimsEdge, children: children) <= 1) + && (core_occurrences(marker: ArrowExecutionModeClaimEdge, children: children) <= 1) + && (core_occurrences(marker: ArrowResourceRequirementsEdge, children: children) <= 1) && fold(children, init: true, f: fn(acc, e) { match e.label { Positional => acc - Named { name: _ } => acc && (arrow_named_edge_is_non_binder(e: e) || type_binder_conj_conforms(t: e.target)) + StructuralLabel { label: _ } => acc && (arrow_named_edge_is_non_binder(e: e) || type_binder_conj_conforms(t: e.target)) + Authored { name: _ } => acc && type_binder_conj_conforms(t: e.target) } }) } @@ -709,7 +855,7 @@ type ArrowParameterOrderStep { } fn arrow_signature_order_read(children: List) -> ArrowParameterOrderRead { - match named_edge_target_lookup(children: children, name: ^arrow_signature_order_edge) { + match core_edge_target_lookup(children: children, marker: ArrowSignatureOrderEdge) { Absent => OrderAbsent Ambiguous => OrderUnreadable Found { target: list } => arrow_signature_order_list_read(list: list) @@ -792,7 +938,14 @@ fn arrow_domain_binds_a_name(children: List) -> Bool { FirstPositionalAbsent => false FirstPositionalFound { target: domain } => match domain.kind { - TypeNode { connective: Conj } => fold(domain.children, init: false, f: fn(acc, e) { acc || is_named(e: e) }) + TypeNode { connective: Conj } => + fold(domain.children, init: false, f: fn(acc, e) { + acc || match e.label { + Authored { name: _ } => true + StructuralLabel { label: _ } => false + Positional => false + } + }) _ => false } } @@ -840,7 +993,8 @@ fn arrow_domain_binder_labels(children: List) -> DomainBinderLabelsRead { DomainBinderLabelsUnreadable => DomainBinderLabelsUnreadable DomainBinderLabels { labels: ls } => match d.label { - Named { name: sym } => DomainBinderLabels { labels: Cons { head: sym, tail: ls } } + Authored { name: sym } => DomainBinderLabels { labels: Cons { head: sym, tail: ls } } + StructuralLabel { label: _ } => DomainBinderLabelsUnreadable Positional => DomainBinderLabelsUnreadable } } @@ -862,7 +1016,8 @@ fn arrow_first_positional_target(children: List) -> FirstPositionalTarget FirstPositionalAbsent => match e.label { Positional => FirstPositionalFound { target: e.target } - Named { name: _ } => acc + Authored { name: _ } => acc + StructuralLabel { label: _ } => acc } } }) @@ -878,7 +1033,8 @@ fn arrow_first_positional_target(children: List) -> FirstPositionalTarget fn type_binder_conforms(e: Edge) -> Bool { match e.label { Positional => false - Named { name: sym } => + StructuralLabel { label: _ } => false + Authored { name: sym } => match e.target.kind { TypeNode { connective: Atom { identity: id } } => (id == sym) && (count(e.target.children) == 0) _ => false @@ -900,26 +1056,37 @@ type NamedEdgeTargetLookup | Ambiguous | Absent +fn edge_target_lookup_step(acc: NamedEdgeTargetLookup, hit: Bool, target: Node) -> NamedEdgeTargetLookup { + if hit { + match acc { + Absent => Found { target: target } + Found { target: _ } => Ambiguous + Ambiguous => Ambiguous + } + } else { + acc + } +} + +// The edge carrying this AUTHORED name. A structural label is never found by spelling. fn named_edge_target_lookup(children: List, name: Symbol) -> NamedEdgeTargetLookup { fold(children, init: Absent, f: fn(acc, e) { match e.label { - Named { name: sym } => - if sym == name { - match acc { - Absent => Found { target: e.target } - Found { target: _ } => Ambiguous - Ambiguous => Ambiguous - } - } else { - acc - } + Authored { name: sym } => edge_target_lookup_step(acc: acc, hit: sym == name, target: e.target) + StructuralLabel { label: _ } => acc Positional => acc } }) } +fn core_edge_target_lookup(children: List, marker: CoreEdgeLabel) -> NamedEdgeTargetLookup { + fold(children, init: Absent, f: fn(acc, e) { + edge_target_lookup_step(acc: acc, hit: edge_is_core(e: e, marker: marker), target: e.target) + }) +} + fn arrow_body_target_lookup(children: List) -> NamedEdgeTargetLookup { - named_edge_target_lookup(children: children, name: ^arrow_body_edge) + core_edge_target_lookup(children: children, marker: ArrowBodyEdge) } // ArrowBodyForm classifies arrow-body targets for structural admission @@ -982,42 +1149,26 @@ fn symbol_lexeme(sym: Symbol) -> String { // qualified-name spine (v2.std.qualified_name declaration_reference_node). A spine is a cons list, // and a cons list is not only a path -- an integer literal and a list literal lower to the same // shape (gunbc.recurring_failure_mode declaration_reference_recognised_by_a_shape_a_literal_also_has) -// -- so every reader keys on this label. Its lexeme is not an identifier in the dag grammar, so no -// authored record field, binder or name can carry it. -// Interned ONCE, as a value: well_formed compares every candidate arrow body against it, so a -// function that re-interned per call would pay an interning per node over every tree it walks. -data declaration_reference_marker_symbol: Symbol = symbol_intern_lexeme(lexeme: "") - -fn declaration_reference_marker() -> Symbol { - declaration_reference_marker_symbol -} - -// A REFERENCE TO A NAMED FN'S PARAMETER IS THE SAME CARRIER UNDER ITS OWN MARKER. v2.compiler.resolve -// mints it from a ParameterFrame (resolve_frame_bound_reference) over the parameter's declaring path -// .