From 5f12d042309fffa112fa7b97e35f1637a7b3f2d3 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 29 Aug 2026 04:36:39 +0000 Subject: [PATCH 01/75] Emitted v2 compiler crate: a declaration's identity is its last segment, and a primitive with no realization refuses instead of inventing one Two roots behind 175 of the 260 rustc errors on the emitted v2 compiler closure (issue #9664, milestones 1 and 2): - 102 x E0425: the four DeclaredCallableIdentity constructions in v1.compiler.infer_lookup took decl_name from the AUTHORED spelling, so a qualified call carried the whole dotted path as the declaration name and emission rendered crate::v2_std_grammar::v2.std.grammar.f(..). - 73 x E0425: v2.std.algebra length is a ModeledProjection of the `length` primitive and rt_function_registry has no `length` row, so emission took rust_runtime_bridge_name's identity arm and wrote v1_rt::length -- a symbol the seed does not define. A primitive's identity and its per-target realization are two facts; CallTargetIdentity carried only the first, so every emitter had to ASSUME a bridge exists. RuntimePrimitiveCall now carries projected_from, the declaration the roster projected it from, and emit_rust routes to the bridge only when its own registry holds the primitive, falls back to the declaration otherwise, and refuses when neither exists. DeclaredCallableIdentity moves to v1.std.core so the target type can carry it without forking the pair. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01GXfYKNQTD3VfYyQcnJpxNU --- src/v1/00_core.dag | 40 +++++++++++++++++++++++++++++- src/v1/04_infer.dag | 12 ++++----- src/v1/04_lookup.dag | 30 +++++++++++++++++------ src/v1/04_sigs.dag | 18 ++++---------- src/v1/05_emit_rust.dag | 54 +++++++++++++++++++++++++++++++++++------ src/v1/compile.dag | 2 +- 6 files changed, 119 insertions(+), 37 deletions(-) diff --git a/src/v1/00_core.dag b/src/v1/00_core.dag index 2c3ba31126e..9aaa6dfe0d7 100644 --- a/src/v1/00_core.dag +++ b/src/v1/00_core.dag @@ -107,8 +107,46 @@ type VarBindingKind // where the declaration and the primitive genuinely disagree and the declaration is what was // called. CallableTargetUndetermined is a refusal-bearing residue -- it is not permission for // emission to fall back to a name lookup, and emission refuses on it. +// THE DECLARED HALF OF AN IDENTITY, HOISTED SO THE RESOLVED ARM CAN CARRY IT WITHOUT +// CARRYING THE BUILTIN ARM. +// +// `decide_callable_candidates` proves a builtin never answers -- it can make a population +// ambiguous and on its own hands the call back to the known-builtin bridge -- so the owner a +// resolution binds is ALWAYS a declared one. Spelling FuncSigResolved's owner as +// CallableIdentity would therefore admit a state the decision already ruled out, and spelling +// it as a loose owner/decl String pair beside DeclaredCallable would be a second representation +// of the pair v1.compiler.sigs already owns (DESIGN section 3). One record, two consumers. +// +// It is declared HERE rather than in v1.compiler.sigs, its former home, because +// CallTargetIdentity below carries one and this module sits under that one. Re-spelling the pair +// in either direction to avoid the import would fork it. +type DeclaredCallableIdentity { + owner_module_path: String + decl_name: String +} + +// A PRIMITIVE'S IDENTITY AND ITS PER-TARGET REALIZATION ARE TWO FACTS, AND `projected_from` +// IS WHAT KEEPS THEM APART. +// +// The resolver knows both halves at once: that this call resolved to declaration D, and that +// std.primitive_projection says D projects primitive P. It used to record only P, and every +// emitter then had to assume P has a bridge in ITS runtime. That assumption is false and was +// fabricating: v2.std.algebra length is a ModeledProjection of the `length` primitive, the Rust +// registry has no `length` row (its list realization is `count`, its string realization is +// `string_length`), and 05_emit_rust rendered `v1_rt::length` -- a symbol that does not exist in +// the seed -- at 73 sites. That is DESIGN section 5 fabricated-plausible-output: the emitter +// produced a well-formed call to nothing and only rustc refused, downstream of every gate we own. +// +// Which realization a target has is a REALIZATION fact and belongs peripheral to the target +// (DESIGN section 3: the dispatch that selects a realization is itself realization), so the +// resolver states only what it knows and carries the declaration alongside. An emitter routes to +// the bridge when its own registry has the primitive, falls back to the declaration when one was +// projected, and REFUSES otherwise -- it never invents a runtime symbol from a name. +// +// `projected_from` is Absent exactly when the target came from builtin resolution, where no +// declaration answered and there is nothing to fall back to. type CallTargetIdentity - = RuntimePrimitiveCall { primitive_name: String } + = RuntimePrimitiveCall { primitive_name: String, projected_from: DeclaredCallableIdentity? } | SourceDeclarationCall { owner_module_path: String, decl_name: String } | CallableTargetUndetermined diff --git a/src/v1/04_infer.dag b/src/v1/04_infer.dag index f12ac6130be..823902c9938 100644 --- a/src/v1/04_infer.dag +++ b/src/v1/04_infer.dag @@ -5119,7 +5119,7 @@ fn infer_expr_body(texpr: Node, scope: InferScope, expected: Node?) -> InferResu if node_is_keyed_collection(n: exp, source_indices: scope.type_env.source_indices) { InferResult { typed: make_named_expr_node(occurrence_identity: texpr.occurrence_identity, - name: func_name, expr_data: ExprCall { call_semantics: Present { value: PlainCallSemantics { target: RuntimePrimitiveCall { primitive_name: "empty_map" } } }, descent_evidence: none }, + name: func_name, expr_data: ExprCall { call_semantics: Present { value: PlainCallSemantics { target: RuntimePrimitiveCall { primitive_name: "empty_map", projected_from: none } } }, descent_evidence: none }, children: typed_arg_nodes, inferred: Present { value: Resolved { node: exp } }, span: span, @@ -5133,7 +5133,7 @@ fn infer_expr_body(texpr: Node, scope: InferScope, expected: Node?) -> InferResu Present { value: map_t } => InferResult { typed: make_named_expr_node(occurrence_identity: texpr.occurrence_identity, - name: func_name, expr_data: ExprCall { call_semantics: Present { value: PlainCallSemantics { target: RuntimePrimitiveCall { primitive_name: "empty_map" } } }, descent_evidence: none }, + name: func_name, expr_data: ExprCall { call_semantics: Present { value: PlainCallSemantics { target: RuntimePrimitiveCall { primitive_name: "empty_map", projected_from: none } } }, descent_evidence: none }, children: typed_arg_nodes, inferred: Present { value: Resolved { node: map_t } }, span: span, @@ -5144,7 +5144,7 @@ fn infer_expr_body(texpr: Node, scope: InferScope, expected: Node?) -> InferResu Absent => InferResult { typed: make_named_expr_node(occurrence_identity: texpr.occurrence_identity, - name: func_name, expr_data: ExprCall { call_semantics: Present { value: PlainCallSemantics { target: RuntimePrimitiveCall { primitive_name: "empty_map" } } }, descent_evidence: none }, + name: func_name, expr_data: ExprCall { call_semantics: Present { value: PlainCallSemantics { target: RuntimePrimitiveCall { primitive_name: "empty_map", projected_from: none } } }, descent_evidence: none }, children: typed_arg_nodes, inferred: Present { value: CompilerError { message: "empty_map(): Map kernel container profile missing (compiler misconfigured)", span: span } }, span: span, @@ -5159,7 +5159,7 @@ fn infer_expr_body(texpr: Node, scope: InferScope, expected: Node?) -> InferResu Present { value: map_t } => InferResult { typed: make_named_expr_node(occurrence_identity: texpr.occurrence_identity, - name: func_name, expr_data: ExprCall { call_semantics: Present { value: PlainCallSemantics { target: RuntimePrimitiveCall { primitive_name: "empty_map" } } }, descent_evidence: none }, + name: func_name, expr_data: ExprCall { call_semantics: Present { value: PlainCallSemantics { target: RuntimePrimitiveCall { primitive_name: "empty_map", projected_from: none } } }, descent_evidence: none }, children: typed_arg_nodes, inferred: Present { value: Resolved { node: map_t } }, span: span, @@ -5170,7 +5170,7 @@ fn infer_expr_body(texpr: Node, scope: InferScope, expected: Node?) -> InferResu Absent => InferResult { typed: make_named_expr_node(occurrence_identity: texpr.occurrence_identity, - name: func_name, expr_data: ExprCall { call_semantics: Present { value: PlainCallSemantics { target: RuntimePrimitiveCall { primitive_name: "empty_map" } } }, descent_evidence: none }, + name: func_name, expr_data: ExprCall { call_semantics: Present { value: PlainCallSemantics { target: RuntimePrimitiveCall { primitive_name: "empty_map", projected_from: none } } }, descent_evidence: none }, children: typed_arg_nodes, inferred: Present { value: CompilerError { message: "empty_map(): Map kernel container profile missing (compiler misconfigured)", span: span } }, span: span, @@ -5252,7 +5252,7 @@ fn infer_expr_body(texpr: Node, scope: InferScope, expected: Node?) -> InferResu let tier2b = infer_tier2b_builtin_with_kernel_diags(func_name: func_name, typed_args: typed_args, scope: scope, span: span) let bt = tier2b.bt let call_semantics = if func_name == "lookup" { - Present { value: LookupCallSemantics { target: RuntimePrimitiveCall { primitive_name: func_name } } } + Present { value: LookupCallSemantics { target: RuntimePrimitiveCall { primitive_name: func_name, projected_from: none } } } } else { Present { value: PlainCallSemantics { target: resolved_plain_call_target(func_name: func_name, sig_lookup: call_sig_lookup) } } } diff --git a/src/v1/04_lookup.dag b/src/v1/04_lookup.dag index 84f8406d71a..643e5b59421 100644 --- a/src/v1/04_lookup.dag +++ b/src/v1/04_lookup.dag @@ -9,6 +9,7 @@ import std.primitive_projection { } import v1.std.core { + DeclaredCallableIdentity, Node, param_node_type_expr, authored_name_at, NewlineIndex, find_child_named, has_child_named, qualified_last_segment, @@ -58,7 +59,7 @@ import v1.compiler.infer_emit_info { import v1.compiler.infer_sigs { ResolvedFuncSig, ResolvedFuncEnv, lookup_resolved_sig, FuncSigLookup, FuncSigResolved, FuncSigUnresolved, FuncSigAmbiguous, - CallableCandidate, CallableIdentity, DeclaredCallableIdentity, DeclaredCallable, BuiltinCallable, + CallableCandidate, CallableIdentity, DeclaredCallable, BuiltinCallable, parent_closure_callable_candidates, decide_callable_candidates } @@ -231,6 +232,19 @@ fn builtin_is_a_rival_authority(declared: List) -> Bool { declared |> any(c => declared_candidate_rivals_the_builtin(candidate: c)) } +// A DECLARATION'S IDENTITY IS ITS LAST SEGMENT, NEVER THE SPELLING THE CALLER USED. +// +// The four DeclaredCallableIdentity constructions in this module took `decl_name` from the +// authored name. For a qualified call that name is the whole dotted path, so `v2.std.grammar.f(..)` +// resolved with owner `v2.std.grammar` AND decl_name `v2.std.grammar.f`, and 05_emit_rust rendered +// `crate::v2_std_grammar::v2.std.grammar.f(..)` -- 102 E0425s in the v2 compiler closure. The same +// pair also keys `lookup_item` for default-argument filling and `decl_ref` for the primitive +// projection roster, so both silently missed on every qualified call. +// +// `qualified_last_segment` is the idiom `constructor_declaration_for_admission` already uses for +// exactly this, and it is the identity on a bare name -- so it is applied at all four sites rather +// than at the one that was measured failing, which removes the class instead of an instance. +// // TARGET SELECTION, DECIDED HERE AND CONSUMED VERBATIM BY EMISSION. // // A call's target is chosen once, from the declaration resolution actually bound, and 05_emit @@ -249,8 +263,8 @@ fn resolved_declaration_call_target(declared: DeclaredCallableIdentity) -> CallT ) { Present { value: row } => match row.fidelity { - HostRealizedSeam => RuntimePrimitiveCall { primitive_name: primitive_identity_runtime_name(identity: row.primitive) } - ModeledProjection => RuntimePrimitiveCall { primitive_name: primitive_identity_runtime_name(identity: row.primitive) } + HostRealizedSeam => RuntimePrimitiveCall { primitive_name: primitive_identity_runtime_name(identity: row.primitive), projected_from: Present { value: declared } } + ModeledProjection => RuntimePrimitiveCall { primitive_name: primitive_identity_runtime_name(identity: row.primitive), projected_from: Present { value: declared } } DivergentProjection { divergence: _ } => SourceDeclarationCall { owner_module_path: declared.owner_module_path, decl_name: declared.decl_name } } @@ -274,7 +288,7 @@ fn resolved_plain_call_target(func_name: String, sig_lookup: FuncSigLookup) -> C fn builtin_call_target_or_undetermined(func_name: String) -> CallTargetIdentity { match infer_builtin_call_type(name: func_name) { - Present { value: _ } => RuntimePrimitiveCall { primitive_name: func_name } + Present { value: _ } => RuntimePrimitiveCall { primitive_name: func_name, projected_from: none } Absent => CallableTargetUndetermined } } @@ -347,7 +361,7 @@ fn callable_lookup_over_candidates( ) -> FuncSigLookup { match map_get(func_env.local, name) { Present { value: sig } => - FuncSigResolved { sig: sig, declared: DeclaredCallableIdentity { owner_module_path: func_env.name, decl_name: name } } + FuncSigResolved { sig: sig, declared: DeclaredCallableIdentity { owner_module_path: func_env.name, decl_name: qualified_last_segment(name: name) } } Absent => let declared = parent_closure_callable_candidates(env: func_env, name: name) let builtin_admissible = match author_named_visibility(type_env: type_env, name: name) { @@ -561,7 +575,7 @@ fn borrowed_census_callable_candidate(type_env: TypeEnv, name: String, candidate excluded: excluded ) CallableCandidate { - identity: DeclaredCallable { identity: DeclaredCallableIdentity { owner_module_path: candidate.module_path, decl_name: name } }, + identity: DeclaredCallable { identity: DeclaredCallableIdentity { owner_module_path: candidate.module_path, decl_name: qualified_last_segment(name: name) } }, sig: ResolvedFuncSig { name: name, params: node.params, @@ -606,7 +620,7 @@ fn func_sig_from_global_bare(type_env: TypeEnv, name: String) -> FuncSigLookup { is_async: false, output_provenance: [], variant_provenance: empty_map() - }, declared: DeclaredCallableIdentity { owner_module_path: bd.owner_module_path, decl_name: name } } + }, declared: DeclaredCallableIdentity { owner_module_path: bd.owner_module_path, decl_name: qualified_last_segment(name: name) } } } else { let qualified_return = qualify_borrowed_type_names(n: raw_return, owner_module_path: bd.owner_module_path, env: type_env, excluded: excluded) FuncSigResolved { sig: ResolvedFuncSig { @@ -616,7 +630,7 @@ fn func_sig_from_global_bare(type_env: TypeEnv, name: String) -> FuncSigLookup { is_async: false, output_provenance: [], variant_provenance: empty_map() - }, declared: DeclaredCallableIdentity { owner_module_path: bd.owner_module_path, decl_name: name } } + }, declared: DeclaredCallableIdentity { owner_module_path: bd.owner_module_path, decl_name: qualified_last_segment(name: name) } } } } BorrowedCensusDeclAmbiguous { candidates: cands } => diff --git a/src/v1/04_sigs.dag b/src/v1/04_sigs.dag index 3199c92bc3e..cfb236e596a 100644 --- a/src/v1/04_sigs.dag +++ b/src/v1/04_sigs.dag @@ -6,6 +6,7 @@ import v1.std.core { ErrorNode, make_error_node, MissingAnnotation, no_span, DeclaredFuncSig, + DeclaredCallableIdentity, NewlineIndex, authored_name_at } @@ -110,19 +111,10 @@ type ParentSigScan { // the collision this vocabulary exists to describe (gap-analysis row 30 -- `map_get` is both // `v2.std.collection.map_get` returning Outcome> and a builtin returning // Optional). So the candidate is the identity, and the label is a projection of it. -// THE DECLARED HALF OF AN IDENTITY, HOISTED SO THE RESOLVED ARM CAN CARRY IT WITHOUT -// CARRYING THE BUILTIN ARM. -// -// `decide_callable_candidates` proves a builtin never answers -- it can make a population -// ambiguous and on its own hands the call back to the known-builtin bridge -- so the owner a -// resolution binds is ALWAYS a declared one. Spelling FuncSigResolved's owner as -// CallableIdentity would therefore admit a state the decision already ruled out, and spelling -// it as a loose owner/decl String pair beside DeclaredCallable would be a second representation -// of the pair this file already owns (DESIGN section 3). One record, two consumers. -type DeclaredCallableIdentity { - owner_module_path: String - decl_name: String -} +// DeclaredCallableIdentity IS NOT DECLARED HERE ANY MORE. It moved to v1.std.core because +// CallTargetIdentity -- which lives there, below this module -- now carries one, and a second +// spelling of the pair in this file to break the import direction would be the nicknaming defect +// DESIGN section 3 names. The reasoning for the record itself travels with the declaration. type CallableIdentity = DeclaredCallable { identity: DeclaredCallableIdentity } diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index 0dd7d0534bb..b33836d3df6 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -18,7 +18,7 @@ import v1.std.core { ExprCast, ExprForEach, ExprIndex, ExprSlice, ExprReturn, make_expr_node, FieldSummary, StoredField, EnumAccessor, OptionalUnwrap, TupleFirst, TupleSecond, OptionalValue, VarBindingKind, LocalValueBinding, FunctionValueBinding, VariantValueBinding, - MatchBoundBinding, CallTargetIdentity, RuntimePrimitiveCall, SourceDeclarationCall, CallableTargetUndetermined, + MatchBoundBinding, CallTargetIdentity, DeclaredCallableIdentity, RuntimePrimitiveCall, SourceDeclarationCall, CallableTargetUndetermined, CallSemantics, PlainCallSemantics, LookupCallSemantics, FunctionValueCallSemantics, MethodSemantics, PlainMethodSemantics, AlgebraMethodSemantics, ServiceMethodSemantics, MatchPattern, field_binding_pattern, TextFile, ErrorNode, make_error_node, InternalError, @@ -8769,8 +8769,16 @@ fn rust_runtime_bridge_passes_receiver_by_ref(function_name: String) -> Bool { // rt_bridge_function_names ever becomes hand-authored rather than derived from // rt_function_registry, a miss stops meaning "spelled the same" and this arm // becomes a fabrication, so that change invalidates this argument. -// An unknown name cannot reach either use of the result, which a reader of this -// function alone cannot see. THE MECHANISM CHANGED WITH CallTargetIdentity and +// AN UNKNOWN NAME COULD REACH THIS, AND DID -- the claim that stood here was false and the +// receipt is worth keeping. `length` is a primitive with a projection row and NO row in +// rt_function_registry, so it arrived as a runtime primitive, missed rt_bridge_function_names, +// took the identity arm, and emitted `v1_rt::length` at 73 sites in the v2 compiler closure -- +// a symbol the seed does not define. The Absent arm was never the defect: the derivation +// argument below is sound for every name the registry HOLDS, and the hole was that nothing +// checked membership first. `rust_runtime_primitive_has_bridge` is now that check, asked before +// this function is reached, so the Absent arm's premise -- this primitive is in the registry and +// merely spelled the same -- is established rather than assumed. +// THE MECHANISM CHANGED WITH CallTargetIdentity and // the argument is restated rather than kept, because the old wording named the // two name-matching guards that no longer exist: emit_typed_call consumed // runtime_name only inside `if is_rt`, and is_rt was @@ -8881,8 +8889,11 @@ fn emit_rust_empty_set_expr(set_type: Node, shared_types: Set, source_in // The method roster had no template on that path -- nothing was lowered by it -- so its wrap was // unpaired by construction. The repair is to pair each wrap with the roster that produced the text // beside it, and at the plain-call position to derive the gate from the SAME predicate that chose -// the emission form (rust_plain_call_emits_as_runtime_bridge, read by emit_typed_call for is_rt and -// by emit_typed_call_expr for the wrap), so no second opinion about the form exists to drift. +// the emission form. That fusion is now stated on the PRIMITIVE's identity rather than the leaf +// spelling: emit_typed_call's is_rt and emit_typed_call_expr's wrap both key on the target's +// runtime_primitive_name, and both ask the same registry, so no second opinion about the form +// exists to drift. rust_plain_call_emits_as_runtime_bridge below is the older leaf-spelling +// statement of that predicate and has no caller. // RUNG (DESIGN 4b): this moves the plain-call half of the class from silent wrongness -- emitted, // compiled by us, refused only by rustc downstream -- to STRUCTURALLY IMPOSSIBLE for the // cross-roster direction specifically: after this change no method-roster row can reach a plain @@ -8958,7 +8969,7 @@ fn call_semantics_target(cs: CallSemantics?) -> CallTargetIdentity { fn call_target_runtime_primitive_name(target: CallTargetIdentity) -> String? { match target { - RuntimePrimitiveCall { primitive_name: primitive_name } => Present { value: primitive_name } + RuntimePrimitiveCall { primitive_name: primitive_name, projected_from: _ } => Present { value: primitive_name } SourceDeclarationCall { owner_module_path: _, decl_name: _ } => none CallableTargetUndetermined => none } @@ -8968,6 +8979,26 @@ fn call_target_is_runtime_primitive(target: CallTargetIdentity) -> Bool { call_target_runtime_primitive_name(target: target) != none } +// THE DECLARATION A RUNTIME TARGET WAS PROJECTED FROM, WHICH IS THE ONLY HONEST ROUTE WHEN THIS +// TARGET HAS NO ROW IN THIS TARGET'S RUNTIME REGISTRY. Absent means builtin resolution produced +// the target and no declaration ever answered, so there is nothing to fall back to and the one +// remaining arm is a refusal. +fn call_target_projected_declaration(target: CallTargetIdentity) -> DeclaredCallableIdentity? { + match target { + RuntimePrimitiveCall { primitive_name: _, projected_from: projected_from } => projected_from + SourceDeclarationCall { owner_module_path: _, decl_name: _ } => none + CallableTargetUndetermined => none + } +} + +// THE REALIZATION HALF OF THE DECISION, ASKED OF THE PRIMITIVE'S OWN IDENTITY RATHER THAN THE +// AUTHORED LEAF SPELLING. `rt_functions()` is derived from rt_function_registry, so membership +// here is exactly `this primitive has a v1_rt realization`. A target that is a runtime primitive +// but has no row is NOT a bridge call, and treating it as one is what emitted `v1_rt::length`. +fn rust_runtime_primitive_has_bridge(primitive_name: String) -> Bool { + map_contains_key(rt_functions(), primitive_name) +} + fn emit_rust_expr_call(expr: Node, registry: Map, scope: InferScope, depth: Int, shared_types: Set, emit_info: EmitGraphInfo) -> String { match expr.expr_data { ExprCall { call_semantics: cs, descent_evidence: _ } => @@ -9535,6 +9566,7 @@ fn emit_typed_call(func: String, args: List, callee_is_function_value: Boo Absent => "" } let is_rt = callee_is_function_value == false && target_is_runtime + && rust_runtime_primitive_has_bridge(primitive_name: runtime_primitive_name) let is_rt_ref_map = is_rt && map_contains_key(rt_ref_map_functions(), runtime_primitive_name) let arg_strs = filled_args |> enumerate |> map(pair => let idx = pair.first @@ -9574,8 +9606,14 @@ fn emit_typed_call(func: String, args: List, callee_is_function_value: Boo else { concat("crate::", module_to_filename(name: owner), "::", emit_ident(name: decl, target: Rust)) } CallableTargetUndetermined => emit_error_expr(message: "call target identity was not established before Rust emission", target: Rust) - RuntimePrimitiveCall { primitive_name: _ } => - emit_error_expr(message: "runtime call target lost its bridge identity", target: Rust) + RuntimePrimitiveCall { primitive_name: unbridged_primitive, projected_from: projected_from } => + match projected_from { + Present { value: declared } => + if declared.owner_module_path == scope.module_name { emit_ident(name: declared.decl_name, target: Rust) } + else { concat("crate::", module_to_filename(name: declared.owner_module_path), "::", emit_ident(name: declared.decl_name, target: Rust)) } + Absent => + emit_error_expr(message: concat("primitive ", unbridged_primitive, " has no v1_rt realization and no declaration to emit"), target: Rust) + } } } let func_name = if callee_self_capture { concat(func_ident, ".clone()") } else { func_ident } let call_str = if is_rt && func == "concat" && all_args |> count > 2 { diff --git a/src/v1/compile.dag b/src/v1/compile.dag index 44be7cb8620..f1b21bf910a 100644 --- a/src/v1/compile.dag +++ b/src/v1/compile.dag @@ -385,7 +385,7 @@ fn var_binding_kind_name(value: VarBindingKind) -> String { fn serialize_call_target_identity(value: CallTargetIdentity) -> String { match value { - RuntimePrimitiveCall { primitive_name: primitive_name } => + RuntimePrimitiveCall { primitive_name: primitive_name, projected_from: _ } => concat("{\"kind\": \"RuntimePrimitiveCall\", \"primitive_name\": ", json_quote(s: primitive_name), "}") SourceDeclarationCall { owner_module_path: owner, decl_name: decl } => concat("{\"kind\": \"SourceDeclarationCall\", \"owner_module_path\": ", json_quote(s: owner), ", \"decl_name\": ", json_quote(s: decl), "}") From 15c25ad86e8f7269590fccfb020619802fe45ed4 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 29 Aug 2026 04:48:31 +0000 Subject: [PATCH 02/75] Class B: the algebra method fallback asserted a v1_rt bridge it had not checked tier0 method resolution resolves an ordinary fn-typed RECORD FIELD through lookup_field_in_product, so `algebra.step(..)` arrives as AlgebraMethodSemantics carrying the field node as its method_def. The fallback at the end of that arm hardcoded runtime_bridge: true, which emitted `v1_rt::step` -- and made emit_rust_generic_method_call's own callable-field arm, guarded on runtime_bridge == false, unreachable for the exact receiver it was written for. 65 E0425s on the emitted v2 compiler closure (member, apply, is_empty, step, init, allocate_literal, ...) were that one literal. It now passes the realization question keyed on the same registry as the plain-call seam, so a real bridge method still lowers to a bridge, a callable field lowers as a field, and a name that is neither reaches the existing loud refusal rather than a fabricated symbol. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01GXfYKNQTD3VfYyQcnJpxNU --- src/v1/05_emit_rust.dag | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index b33836d3df6..fdcd70afe2d 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -10246,6 +10246,19 @@ fn emit_rust_first_method_call(receiver: Node, registry: Map, // method's NAME appears in `rt_functions()`, which is the same leaf-spelling re-lookup the call // path above removed: a record field holding a callable named `contains` lost to the bridge // roster purely on spelling. +// +// ONE CALLER DID NOT KNOW, AND SAID `true` ANYWAY. The algebra fallback in emit_typed_method_call +// hardcoded runtime_bridge: true, and tier0 method resolution resolves an ordinary fn-typed RECORD +// FIELD through lookup_field_in_product -- so `algebra.step(..)` arrived as AlgebraMethodSemantics +// with the field node as its method_def, took that fallback, and emitted `v1_rt::step`. The +// callable-field arm directly below exists for exactly that receiver and was unreachable, because +// it is guarded on runtime_bridge == false. 65 E0425s in the v2 compiler closure -- `member`, +// `apply`, `is_empty`, `step`, `init`, `allocate_literal` and friends -- were that one `true`. +// +// It now passes the realization question, keyed on the same registry as the plain-call seam +// (rust_runtime_primitive_has_bridge), so a method that IS a bridge still lowers to one, a +// callable field lowers as a field, and a name that is neither reaches the loud refusal below +// instead of a fabricated v1_rt symbol. fn emit_rust_generic_method_call(method_name: String, receiver: Node, args: List, result_type: InferredNode?, runtime_bridge: Bool, registry: Map, scope: InferScope, depth: Int, shared_types: Set, emit_info: EmitGraphInfo) -> String { let function_name = method_name if runtime_bridge == false && rust_receiver_has_callable_method_field(receiver: receiver, method_name: function_name, scope: scope) { @@ -10348,7 +10361,7 @@ fn emit_typed_method_call(method_call_node: Node, receiver: Node, method: String rust_shared_wrap_ctor(inner_expr: raw) } else { raw } Absent => - emit_rust_generic_method_call(method_name: method_name, receiver: receiver, args: args, result_type: result_type, runtime_bridge: true, registry: registry, scope: scope, depth: depth, shared_types: shared_types, emit_info: emit_info) + emit_rust_generic_method_call(method_name: method_name, receiver: receiver, args: args, result_type: result_type, runtime_bridge: rust_runtime_primitive_has_bridge(primitive_name: method_name), registry: registry, scope: scope, depth: depth, shared_types: shared_types, emit_info: emit_info) } } } From 3d41ffb057b4cce43adb2409a51720c151d0dc22 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 29 Aug 2026 04:49:45 +0000 Subject: [PATCH 03/75] Only ModeledProjection carries projected_from: a HostRealizedSeam body is a self-call, so falling back to it would emit a nonterminating function The declaration fallback is sound only where the declaration's body is real code. HostRealizedSeam means the body IS a self-call, so emitting it compiles and then loops forever -- silent wrongness, strictly worse than the unresolved symbol it would have replaced. A seam whose target has no realization has no honest lowering, so it carries nothing and reaches emission's refusal. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01GXfYKNQTD3VfYyQcnJpxNU --- src/v1/04_lookup.dag | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/v1/04_lookup.dag b/src/v1/04_lookup.dag index 643e5b59421..33ec77e2563 100644 --- a/src/v1/04_lookup.dag +++ b/src/v1/04_lookup.dag @@ -257,13 +257,22 @@ fn builtin_is_a_rival_authority(declared: List) -> Bool { // The runtime NAME comes from the roster row's primitive identity, never from the call's leaf // spelling. That is the whole repair: a bare `contains` resolving to a v2 declaration no longer // reaches the bridge merely because `contains` is also a v1_rt name. +// +// ONLY ModeledProjection CARRIES `projected_from`, AND THE FIDELITY DISTINCTION IS WHY. +// `projected_from` is what an emitter falls back to when its own runtime has no realization for +// the primitive, so it is only sound where the declaration's body is real code -- which is +// precisely what ModeledProjection means. A HostRealizedSeam body is a SELF-CALL by construction +// (decl_facts is `decl_facts(pool_roots: pool_roots)`), so emitting it would produce a +// well-formed, compiling, NONTERMINATING function: silent wrongness, strictly worse than the +// unresolved-symbol refusal it would replace. A seam with no realization in the target has no +// honest lowering at all, so it carries nothing and reaches emission's refusal arm. fn resolved_declaration_call_target(declared: DeclaredCallableIdentity) -> CallTargetIdentity { match primitive_projection_row_for_declaration( declaration: decl_ref(module_path: declared.owner_module_path, decl_name: declared.decl_name) ) { Present { value: row } => match row.fidelity { - HostRealizedSeam => RuntimePrimitiveCall { primitive_name: primitive_identity_runtime_name(identity: row.primitive), projected_from: Present { value: declared } } + HostRealizedSeam => RuntimePrimitiveCall { primitive_name: primitive_identity_runtime_name(identity: row.primitive), projected_from: none } ModeledProjection => RuntimePrimitiveCall { primitive_name: primitive_identity_runtime_name(identity: row.primitive), projected_from: Present { value: declared } } DivergentProjection { divergence: _ } => SourceDeclarationCall { owner_module_path: declared.owner_module_path, decl_name: declared.decl_name } From a3938354c39893883bdf3810506089a210f9a1d1 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 29 Aug 2026 05:14:55 +0000 Subject: [PATCH 04/75] M1: realize the two symbol bridges, which were host seams nothing declared to be host seams v2.std.compilers.lexing symbol_lexeme and symbol_intern_lexeme have self-call bodies -- the HostRealizedSeam shape exactly -- and the interpreter has carried real arms for both (v4_bridge.symbol_lexeme, v4_bridge.symbol_intern_lexeme). With no projection roster row the resolver saw ordinary declarations, so Rust emission emitted the declaration, and pub fn symbol_lexeme(sym: String) -> String { symbol_lexeme(sym) } COMPILES. The emitted closure carried two functions that type-check, pass every gate we own, and diverge from the interpreter by not terminating. Unlike the sibling seams (decl_facts and friends, which at least refuse loudly as unresolved v1_rt symbols) nothing anywhere reported this one -- it is absent from the E0425 census precisely because it is silent. extdeps.languages.rust.types already declares Symbol's target type as String, so on this target both bridges are the identity. That is a realization of the declared row, not a second opinion about it. Residue named, not closed: a self-call body is a DECIDABLE structural marker of a host seam, so the compiler could refuse an unrealized one rather than emit it. It does not yet; that check is the class's next-rung trigger. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01GXfYKNQTD3VfYyQcnJpxNU --- dag/extdeps/languages/rust/emit.dag | 5 ++++- dag/std/primitive_identity.dag | 2 ++ dag/std/primitive_projection.dag | 10 ++++++++++ src/v1/runtime_rust.dag | 12 ++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/dag/extdeps/languages/rust/emit.dag b/dag/extdeps/languages/rust/emit.dag index eb8d97a3668..bc6be0952ec 100644 --- a/dag/extdeps/languages/rust/emit.dag +++ b/dag/extdeps/languages/rust/emit.dag @@ -255,7 +255,10 @@ data rt_function_registry: List = [ { name: "is_xid_start", bridge_name: "is_xid_start", passes_by_ref: false, wraps_result: false }, { name: "is_xid_continue", bridge_name: "is_xid_continue", passes_by_ref: false, wraps_result: false }, - { name: "is_emoji_ident", bridge_name: "is_emoji_ident", passes_by_ref: false, wraps_result: false } + { name: "is_emoji_ident", bridge_name: "is_emoji_ident", passes_by_ref: false, wraps_result: false }, + + { name: "symbol_lexeme", bridge_name: "symbol_lexeme", passes_by_ref: false, wraps_result: false }, + { name: "symbol_intern_lexeme", bridge_name: "symbol_intern_lexeme", passes_by_ref: false, wraps_result: false } ] fn rt_functions() -> Map { diff --git a/dag/std/primitive_identity.dag b/dag/std/primitive_identity.dag index aa7f80f2806..157368375c9 100644 --- a/dag/std/primitive_identity.dag +++ b/dag/std/primitive_identity.dag @@ -1010,6 +1010,8 @@ data primitive_projection_target_canonical_names: List = [ "data_decl_type_facts", "concept_decl_facts", "concept_decl_facts_live", + "symbol_lexeme", + "symbol_intern_lexeme", ] fn primitive_declared_definitions() -> List { diff --git a/dag/std/primitive_projection.dag b/dag/std/primitive_projection.dag index a252f902ce8..47a2caa21b9 100644 --- a/dag/std/primitive_projection.dag +++ b/dag/std/primitive_projection.dag @@ -53,6 +53,14 @@ data primitive_export_signature_facts: PrimitiveIdentity = primitive_identity_sl data primitive_data_decl_type_facts: PrimitiveIdentity = primitive_identity_slug(name: "data_decl_type_facts") data primitive_concept_decl_facts: PrimitiveIdentity = primitive_identity_slug(name: "concept_decl_facts") data primitive_concept_decl_facts_live: PrimitiveIdentity = primitive_identity_slug(name: "concept_decl_facts_live") +data primitive_symbol_lexeme: PrimitiveIdentity = primitive_identity_slug(name: "symbol_lexeme") +data primitive_symbol_intern_lexeme: PrimitiveIdentity = primitive_identity_slug(name: "symbol_intern_lexeme") + +data symbol_lexeme_seam_disposition_note: String = "THE TWO SYMBOL BRIDGES WERE HOST SEAMS THAT NOTHING SAID WERE HOST SEAMS, and the cost of that silence is why they are rostered here rather than left alone. v2.std.compilers.lexing symbol_lexeme and symbol_intern_lexeme have self-call bodies -- the HostRealizedSeam shape exactly, correct by construction because reaching one recurses to the evaluation-budget refusal -- and the interpreter has carried real arms for both since they were written (gunbc.v1_interpreter_primitive_surface v4_bridge.symbol_lexeme, v4_bridge.symbol_intern_lexeme). But with no roster row the RESOLVER saw an ordinary declaration, so Rust emission emitted the declaration, and `pub fn symbol_lexeme(sym: String) -> String { symbol_lexeme(sym) }` COMPILES. The emitted v2 compiler closure therefore carried two functions that type-check, pass every gate we own, and diverge from the interpreter by not terminating -- the DESIGN section 5 fabricated-plausible-output failure in its quietest form, since unlike the sibling seams (decl_facts and friends, which at least refuse loudly as unresolved v1_rt symbols) nothing anywhere reports this one. + +WHAT MAKES THE RUST REALIZATION HONEST RATHER THAN A SHIM: extdeps.languages.rust.types already declares Symbol's target type as String, so on that target the interning table is the identity and both bridges ARE identity functions. That is a realization of the declared row, not a second opinion about it; a target where Symbol is NOT String would need a different realization and the registry is where it would say so. The interpreter's arms and the Rust registry rows now answer for the same two primitives, which is the agreement that was missing. + +THE RESIDUE IS NAMED, NOT CLOSED: a self-call body is a DECIDABLE structural marker of a host seam, so the compiler could refuse an unrealized one instead of emitting it. It does not yet, and until it does this roster is the only thing standing between a new v4_bridge declaration and another silently nonterminating emission. That check is this class's next-rung trigger." data primitive_projection_roster_note: String = "One row per declaration that is the modeled surface of a declared primitive. Every row was established by READING THE DECLARATION, not by matching its name: the HostRealizedSeam rows are declarations whose whole body is a self-call, and the ModeledProjection rows are declarations with a real body that the builtin arm intercepts ahead of. The single DivergentProjection row is v2.std.collection map_get, whose declared return type is Outcome> against the primitive's Optional; it is carried rather than omitted because omission and divergence are different answers -- omission means nobody has looked, divergence means someone looked and found two authorities. A consumer collecting call candidates must suppress the builtin co-candidate for the first two fidelities and must keep refusing on the third." @@ -68,6 +76,8 @@ fn primitive_projection_roster() -> List { primitive_projection_row(primitive: primitive_concept_decl_facts, module_path: "v2.std.concept_index", decl_name: "concept_decl_facts", fidelity: HostRealizedSeam), primitive_projection_row(primitive: primitive_concept_decl_facts_live, module_path: "v2.std.concept_index", decl_name: "concept_decl_facts_live", fidelity: HostRealizedSeam), primitive_projection_row(primitive: primitive_empty_map, module_path: "v2.std.collection", decl_name: "empty_map_primitive_delegate", fidelity: HostRealizedSeam), + primitive_projection_row(primitive: primitive_symbol_lexeme, module_path: "v2.std.compilers.lexing", decl_name: "symbol_lexeme", fidelity: HostRealizedSeam), + primitive_projection_row(primitive: primitive_symbol_intern_lexeme, module_path: "v2.std.compilers.lexing", decl_name: "symbol_intern_lexeme", fidelity: HostRealizedSeam), primitive_projection_row(primitive: primitive_length, module_path: "v2.std.algebra", decl_name: "length", fidelity: ModeledProjection), primitive_projection_row(primitive: primitive_map_insert, module_path: "v2.std.collection", decl_name: "map_insert", fidelity: ModeledProjection), primitive_projection_row(primitive: primitive_empty_map, module_path: "v2.std.collection", decl_name: "empty_map", fidelity: ModeledProjection), diff --git a/src/v1/runtime_rust.dag b/src/v1/runtime_rust.dag index db4279d885b..ce5622ce922 100644 --- a/src/v1/runtime_rust.dag +++ b/src/v1/runtime_rust.dag @@ -117,6 +117,18 @@ fn rt_string_ops() -> String { "pub fn string_length(s: &str) -> i64 {\n", " if s.is_ascii() { s.len() as i64 } else { s.chars().count() as i64 }\n", "}\n\n", + "/// The two symbol bridges. `Symbol` is declared to realize as `String` on this target\n", + "/// (extdeps.languages.rust.types), so interning and its inverse are both the identity\n", + "/// HERE and nowhere else: a target whose Symbol is a table index needs a real table, and\n", + "/// its registry rows would say so. These exist because the .dag declarations are\n", + "/// self-calls -- host seams -- and emitting a self-call produces a function that compiles\n", + "/// and never returns (std.primitive_projection symbol_lexeme_seam_disposition_note).\n", + "pub fn symbol_lexeme(sym: String) -> String {\n", + " sym\n", + "}\n\n", + "pub fn symbol_intern_lexeme(lexeme: String) -> String {\n", + " lexeme\n", + "}\n\n", "/// See `char_at`: the ASCII fast path is bounded by `end`, not by the whole string.\n", "pub fn substring(s: &str, start: i64, end: i64) -> String {\n", " let start = start.max(0) as usize;\n", From f17c17b43d2cedd6ea9f21fe7378a340b2957043 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 29 Aug 2026 05:24:46 +0000 Subject: [PATCH 05/75] Regenerate the stage0 mirror for the emitter repairs (fixed point at round 2) Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01GXfYKNQTD3VfYyQcnJpxNU --- src/v1/stage0/src/v1_compiler_compile.rs | 5 +- src/v1/stage0/src/v1_compiler_emit_rust.rs | 68 +++++++++++++++---- src/v1/stage0/src/v1_compiler_infer.rs | 6 ++ src/v1/stage0/src/v1_compiler_infer_lookup.rs | 24 ++++--- src/v1/stage0/src/v1_compiler_infer_sigs.rs | 9 +-- src/v1/stage0/src/v1_std_core.rs | 7 ++ 6 files changed, 86 insertions(+), 33 deletions(-) diff --git a/src/v1/stage0/src/v1_compiler_compile.rs b/src/v1/stage0/src/v1_compiler_compile.rs index 14f64102b59..ed809719284 100644 --- a/src/v1/stage0/src/v1_compiler_compile.rs +++ b/src/v1/stage0/src/v1_compiler_compile.rs @@ -752,10 +752,7 @@ pub fn var_binding_kind_name(value: Rc) -> String { pub fn serialize_call_target_identity(value: Rc) -> String { match (*value.clone()).clone() { - CallTargetIdentity::RuntimePrimitiveCall { - primitive_name: primitive_name, - .. - } => v1_rt::concat( + CallTargetIdentity::RuntimePrimitiveCall { primitive_name, .. } => v1_rt::concat( v1_rt::concat( "{\"kind\": \"RuntimePrimitiveCall\", \"primitive_name\": ".to_string(), crate::v1_compiler_dag_collect_support::json_quote(primitive_name.clone()), diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index 63b56370a23..8fb74c5ea3f 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -221,9 +221,10 @@ pub use crate::v1_std_core::{ transport_stdin, transport_tls_posture, tuple_type_name, with_required_cardinality, }; pub use crate::v1_std_core::{ - CallSemantics, CallTargetIdentity, Cardinality, CompilerDiagnostic, Connective, ErrorNode, - ExprData, FieldAccessStyle, FieldSummary, FieldValueShape, InferredNode, MatchPattern, - MethodSemantics, NewlineIndex, Node, StringPart, TextFile, UnaryOpKind, VarBindingKind, + CallSemantics, CallTargetIdentity, Cardinality, CompilerDiagnostic, Connective, + DeclaredCallableIdentity, ErrorNode, ExprData, FieldAccessStyle, FieldSummary, FieldValueShape, + InferredNode, MatchPattern, MethodSemantics, NewlineIndex, Node, StringPart, TextFile, + UnaryOpKind, VarBindingKind, }; use crate::NonEmptyBTreeSet; use crate::NonEmptyVec; @@ -20684,10 +20685,9 @@ pub fn call_semantics_target(cs: Option>) -> Rc) -> Option { match (*target.clone()).clone() { - CallTargetIdentity::RuntimePrimitiveCall { - primitive_name: primitive_name, - .. - } => Some(primitive_name.clone()), + CallTargetIdentity::RuntimePrimitiveCall { primitive_name, .. } => { + Some(primitive_name.clone()) + } CallTargetIdentity::SourceDeclarationCall { .. } => None, CallTargetIdentity::CallableTargetUndetermined => None, } @@ -20697,6 +20697,23 @@ pub fn call_target_is_runtime_primitive(target: Rc) -> bool (call_target_runtime_primitive_name(target.clone()) != None) } +pub fn call_target_projected_declaration( + target: Rc, +) -> Option> { + match (*target.clone()).clone() { + CallTargetIdentity::RuntimePrimitiveCall { projected_from, .. } => projected_from.clone(), + CallTargetIdentity::SourceDeclarationCall { .. } => None, + CallTargetIdentity::CallableTargetUndetermined => None, + } +} + +pub fn rust_runtime_primitive_has_bridge(primitive_name: String) -> bool { + v1_rt::map_contains_key( + &crate::extdeps_languages_rust_emit::rt_functions(), + primitive_name.clone(), + ) +} + pub fn emit_rust_expr_call( expr: Rc, registry: Rc>>, @@ -22242,7 +22259,8 @@ pub fn emit_typed_call( Some(primitive_name) => primitive_name.clone(), None => "".to_string(), }; - let is_rt = ((callee_is_function_value.clone() == false) && target_is_runtime.clone()); + let is_rt = (((callee_is_function_value.clone() == false) && target_is_runtime.clone()) + && rust_runtime_primitive_has_bridge(runtime_primitive_name.clone())); let is_rt_ref_map = (is_rt.clone() && v1_rt::map_contains_key( &crate::extdeps_languages_rust_emit::rt_ref_map_functions(), @@ -22406,11 +22424,33 @@ pub fn emit_typed_call( ) } CallTargetIdentity::RuntimePrimitiveCall { - primitive_name: _, .. - } => crate::v1_compiler_emit::emit_error_expr( - "runtime call target lost its bridge identity".to_string(), - RenderTarget::Rust, - ), + primitive_name: unbridged_primitive, + projected_from, + .. + } => { + match projected_from.clone() { + Some(declared) => { + if (declared.owner_module_path.clone() == scope.module_name.clone()) { + crate::v1_compiler_emit::emit_ident( + declared.decl_name.clone(), + RenderTarget::Rust, + ) + } else { + v1_rt::concat(v1_rt::concat(v1_rt::concat("crate::".to_string(), crate::v1_compiler_emit_core_support::module_to_filename(declared.owner_module_path.clone())), "::".to_string()), crate::v1_compiler_emit::emit_ident(declared.decl_name.clone(), RenderTarget::Rust)) + } + } + None => crate::v1_compiler_emit::emit_error_expr( + v1_rt::concat( + v1_rt::concat( + "primitive ".to_string(), + unbridged_primitive.clone(), + ), + " has no v1_rt realization and no declaration to emit".to_string(), + ), + RenderTarget::Rust, + ), + } + } } }; let func_name = if callee_self_capture.clone() { @@ -25091,7 +25131,7 @@ if rust_method_template_result_wraps_in_rc(method_name.clone()) { raw.clone() } }, - None => emit_rust_generic_method_call(method_name.clone(), receiver.clone(), args.clone(), result_type.clone(), true, registry.clone(), scope.clone(), depth.clone(), shared_types.clone(), emit_info.clone()), + None => emit_rust_generic_method_call(method_name.clone(), receiver.clone(), args.clone(), result_type.clone(), rust_runtime_primitive_has_bridge(method_name.clone()), registry.clone(), scope.clone(), depth.clone(), shared_types.clone(), emit_info.clone()), } } } diff --git a/src/v1/stage0/src/v1_compiler_infer.rs b/src/v1/stage0/src/v1_compiler_infer.rs index 7031b6e1a70..79504f5b9fa 100644 --- a/src/v1/stage0/src/v1_compiler_infer.rs +++ b/src/v1/stage0/src/v1_compiler_infer.rs @@ -8411,6 +8411,7 @@ crate::v1_compiler_infer_types::resolve_type_variables_from_template(t.clone(), call_semantics: Some(Rc::new(CallSemantics::PlainCallSemantics { target: Rc::new(CallTargetIdentity::RuntimePrimitiveCall { primitive_name: "empty_map".to_string(), + projected_from: None, }), })), descent_evidence: None, @@ -8428,6 +8429,7 @@ match bare_m.clone() { call_semantics: Some(Rc::new(CallSemantics::PlainCallSemantics { target: Rc::new(CallTargetIdentity::RuntimePrimitiveCall { primitive_name: "empty_map".to_string(), + projected_from: None, }), })), descent_evidence: None, @@ -8441,6 +8443,7 @@ match bare_m.clone() { call_semantics: Some(Rc::new(CallSemantics::PlainCallSemantics { target: Rc::new(CallTargetIdentity::RuntimePrimitiveCall { primitive_name: "empty_map".to_string(), + projected_from: None, }), })), descent_evidence: None, @@ -8459,6 +8462,7 @@ match bare_m.clone() { call_semantics: Some(Rc::new(CallSemantics::PlainCallSemantics { target: Rc::new(CallTargetIdentity::RuntimePrimitiveCall { primitive_name: "empty_map".to_string(), + projected_from: None, }), })), descent_evidence: None, @@ -8472,6 +8476,7 @@ match bare_m.clone() { call_semantics: Some(Rc::new(CallSemantics::PlainCallSemantics { target: Rc::new(CallTargetIdentity::RuntimePrimitiveCall { primitive_name: "empty_map".to_string(), + projected_from: None, }), })), descent_evidence: None, @@ -8569,6 +8574,7 @@ let call_semantics = if (func_name.clone() == "lookup".to_string()) { Some(Rc::new(CallSemantics::LookupCallSemantics { target: Rc::new(CallTargetIdentity::RuntimePrimitiveCall { primitive_name: func_name.clone(), + projected_from: None, }), })) } else { diff --git a/src/v1/stage0/src/v1_compiler_infer_lookup.rs b/src/v1/stage0/src/v1_compiler_infer_lookup.rs index 6d37b016ff2..714d8300bf7 100644 --- a/src/v1/stage0/src/v1_compiler_infer_lookup.rs +++ b/src/v1/stage0/src/v1_compiler_infer_lookup.rs @@ -53,8 +53,7 @@ pub use crate::v1_compiler_infer_sigs::{ decide_callable_candidates, lookup_resolved_sig, parent_closure_callable_candidates, }; pub use crate::v1_compiler_infer_sigs::{ - CallableCandidate, CallableIdentity, DeclaredCallableIdentity, FuncSigLookup, ResolvedFuncEnv, - ResolvedFuncSig, + CallableCandidate, CallableIdentity, FuncSigLookup, ResolvedFuncEnv, ResolvedFuncSig, }; pub use crate::v1_compiler_infer_types::{ child_type_node, emit_map_has, enrich_kernel_type, instantiate_algebra_type, @@ -81,8 +80,9 @@ pub use crate::v1_std_core::{ with_required_cardinality, }; pub use crate::v1_std_core::{ - CallTargetIdentity, Cardinality, Connective, ErrorNode, FieldAccessStyle, FieldSummary, - FieldValueShape, InferredNode, MethodSemantics, NewlineIndex, Node, + CallTargetIdentity, Cardinality, Connective, DeclaredCallableIdentity, ErrorNode, + FieldAccessStyle, FieldSummary, FieldValueShape, InferredNode, MethodSemantics, NewlineIndex, + Node, }; use crate::NonEmptyBTreeSet; use crate::NonEmptyVec; @@ -209,6 +209,7 @@ pub fn resolved_declaration_call_target( crate::std_primitive_projection::primitive_identity_runtime_name( row.primitive.clone(), ), + projected_from: None, }) } ProjectionFidelity::ModeledProjection => { @@ -217,6 +218,7 @@ pub fn resolved_declaration_call_target( crate::std_primitive_projection::primitive_identity_runtime_name( row.primitive.clone(), ), + projected_from: Some(declared.clone()), }) } ProjectionFidelity::DivergentProjection { divergence: _, .. } => { @@ -252,6 +254,7 @@ pub fn builtin_call_target_or_undetermined(func_name: String) -> Rc Rc::new(CallTargetIdentity::RuntimePrimitiveCall { primitive_name: func_name.clone(), + projected_from: None, }), None => Rc::new(CallTargetIdentity::CallableTargetUndetermined), } @@ -267,7 +270,7 @@ pub fn callable_lookup_over_candidates( sig: sig.clone(), declared: Rc::new(DeclaredCallableIdentity { owner_module_path: func_env.name.clone(), - decl_name: name.clone(), + decl_name: crate::v1_std_core::qualified_last_segment(name.clone()), }), }), None => { @@ -616,7 +619,7 @@ pub fn borrowed_census_callable_candidate( identity: Rc::new(CallableIdentity::DeclaredCallable { identity: Rc::new(DeclaredCallableIdentity { owner_module_path: candidate.module_path.clone(), - decl_name: name.clone(), + decl_name: crate::v1_std_core::qualified_last_segment(name.clone()), }), }), sig: Rc::new(ResolvedFuncSig { @@ -699,7 +702,9 @@ pub fn func_sig_from_global_bare(type_env: Rc, name: String) -> Rc, name: String) -> Rc, } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] -pub struct DeclaredCallableIdentity { - pub owner_module_path: String, - pub decl_name: String, -} - #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum CallableIdentity { diff --git a/src/v1/stage0/src/v1_std_core.rs b/src/v1/stage0/src/v1_std_core.rs index d2c7bac19b7..cb83f6cf7c0 100644 --- a/src/v1/stage0/src/v1_std_core.rs +++ b/src/v1/stage0/src/v1_std_core.rs @@ -229,11 +229,18 @@ impl VarBindingKind { } } +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct DeclaredCallableIdentity { + pub owner_module_path: String, + pub decl_name: String, +} + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum CallTargetIdentity { RuntimePrimitiveCall { primitive_name: String, + projected_from: Option>, }, SourceDeclarationCall { owner_module_path: String, From c5de5aae6cbd6adf67230048f99a36f938abffd8 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 29 Aug 2026 05:39:04 +0000 Subject: [PATCH 06/75] test.claim fixtures: one discriminating RED per closed emission class, with boundary controls Six rows over the three emitter defects plus the two symbol bridges. Each class's positive and negative assertion differ only in the fact the repair added, so no single edit satisfies both directions, and each repair carries a boundary control that would go red had it over-reached the other way (empty_map for the registry gate, a registered bridge method for the class-B gate). The symbol-bridge row is deliberately not an error-count assertion: that class COMPILED throughout the defect and diverged by not terminating, so a row asserting 'no error' would have been green the whole time. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01GXfYKNQTD3VfYyQcnJpxNU --- ...d_call_target_realization_witness_test.dag | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 dag/test/claim/emitted_call_target_realization_witness_test.dag diff --git a/dag/test/claim/emitted_call_target_realization_witness_test.dag b/dag/test/claim/emitted_call_target_realization_witness_test.dag new file mode 100644 index 00000000000..2a69a859d6d --- /dev/null +++ b/dag/test/claim/emitted_call_target_realization_witness_test.dag @@ -0,0 +1,91 @@ +module test.claim.emitted_call_target_realization_witness_test + +import v2.std.live_tree { LiveTreeDisposition, SubstrateInputsOnly } + +data live_tree_disposition: LiveTreeDisposition = SubstrateInputsOnly + +data emitted_call_target_realization_witness_note: String = "PERMANENT REGRESSION CONTROLS for the three emission defects that stood between the v2 compiler closure and a Rust crate rustc would accept (gunbc#9664 milestones 1 and 2). All three are one family -- emission ASSERTING a realization it had not established -- and each row here is the discriminating RED for one of them, paired with a boundary control that would go red if the repair had over-reached in the opposite direction.\n\nMEASURED POPULATIONS on the emitted closure at main 6447dd4, by `gunbc compile --entry src/v2/compiler/00_compile.dag --target rust` then `cargo check`: 260 coded errors, 254 of them E0425. Class C 102 (98 `v2` + 4 `std`), length 73, class B 65 (member 11, apply 11, is_empty 5, allocate_literal 4, step 3, init 3, and a tail of ones and twos).\n\nWHY THESE ARE NOT A SNAPSHOT. Each class's positive and negative assertion differ only in the fact the repair added, so no single edit satisfies both directions. The C rows would flip if decl_name reverted to the authored spelling; the length rows would flip if the registry membership gate were removed OR if the declaration fallback were extended to seams; the B rows would flip if runtime_bridge went back to a literal. The boundary controls (empty_map, a real bridge method) would flip if any of the three repairs had instead stopped emission reaching v1_rt at all.\n\nDISSOLVE-ON: never. Emission may change target SPELLING, but it may never again name a runtime symbol it has not established exists."; + +// CLASS C, THE DISCRIMINATING RED. A qualified call carried the whole dotted path as its +// declaration name, so emission produced `crate::v2_std_collection::v2.std.collection.map_get(..)` +// -- the module prefix correct and the identifier a dotted path Rust reads as field access on an +// undefined value `v2`. map_get is the specimen because it is also DivergentProjection, so this +// row proves the qualified path reaches the DECLARATION and not the bridge. +test fn w_qualified_call_emits_only_the_declaration_last_segment() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.qualified_call_probe\nimport std.types { Int, String, Map }\nimport std.occurrence_identity { OccurrenceId }\nimport v2.std.diagnostic { Outcome }\nimport v2.std.optional { Optional }\nfn probe(m: Map) -> Outcome> { v2.std.collection.map_get(m: m, key: \"key\") }\n", + "src/test_claim_qualified_call_probe.rs", + ["crate::v2_std_collection::map_get("], + ["::v2.std.collection", "v2.std.collection.map_get("] + ) +} + +// LENGTH, THE DISCRIMINATING RED. v2.std.algebra length is a ModeledProjection of the `length` +// primitive and rt_function_registry has no `length` row, so emission took the identity arm of +// rust_runtime_bridge_name and wrote `v1_rt::length` -- a symbol the seed does not define -- at +// 73 sites. The declaration has a real fold body, so it is what a call must reach. +test fn w_unbridged_modeled_primitive_emits_its_declaration() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.length_projection_probe\nimport std.types { Int }\nimport std.occurrence_identity { OccurrenceId }\nimport v2.std.algebra { FreeMonoid, length }\nfn probe(xs: FreeMonoid) -> Int { length(xs: xs) }\n", + "src/test_claim_length_projection_probe.rs", + ["crate::v2_std_algebra::length("], + ["v1_rt::length("] + ) +} + +// THE BOUNDARY CONTROL FOR THE LENGTH REPAIR, AND THE ONE THAT PROVES THE GATE IS REGISTRY +// MEMBERSHIP RATHER THAN "ROSTER ROW MEANS DECLARATION". empty_map has a roster row AND a +// registry row, so it must still lower to the bridge. A repair that had simply routed every +// ModeledProjection to its declaration would go red here -- and would also emit +// v2.std.collection map_insert's `Map { lookup: fn .. }` body against an Rc carrier. +test fn w_bridged_modeled_primitive_still_lowers_to_the_bridge() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.bridged_empty_map_probe\nimport std.types { Int, String, Map }\nimport std.occurrence_identity { OccurrenceId }\nimport v2.std.collection { empty_map }\nfn probe() -> Map { empty_map() }\n", + "src/test_claim_bridged_empty_map_probe.rs", + ["v1_rt::rc_empty_map"], + ["crate::v2_std_collection::empty_map("] + ) +} + +// CLASS B, THE DISCRIMINATING RED. tier0 method resolution resolves an ordinary fn-typed RECORD +// FIELD through lookup_field_in_product, so a field call arrived as AlgebraMethodSemantics and the +// fallback at the end of that arm passed runtime_bridge: true unconditionally -- emitting +// `v1_rt::step`, and leaving emit_rust_generic_method_call's own callable-field arm, guarded on +// runtime_bridge == false, unreachable for the exact receiver it was written for. +test fn w_callable_record_field_lowers_as_a_field_not_a_bridge() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.callable_field_probe\nimport std.types { Int }\ntype Stepper { step: fn(Int) -> Int }\nfn probe(s: Stepper, n: Int) -> Int { s.step(n) }\n", + "src/test_claim_callable_field_probe.rs", + [".step)("], + ["v1_rt::step("] + ) +} + +// THE BOUNDARY CONTROL FOR THE B REPAIR. `count` IS in rt_function_registry, so method-form calls +// that genuinely name a bridge must still reach one. A repair that had stopped the algebra +// fallback reaching v1_rt at all -- rather than asking whether this particular name is realized -- +// goes red here. +test fn w_registered_bridge_method_still_reaches_the_bridge() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.bridge_method_probe\nimport std.types { Int, List }\nfn probe(xs: List) -> Int { xs |> count }\n", + "src/test_claim_bridge_method_probe.rs", + ["v1_rt::count("], + ["compile_error"] + ) +} + +// THE SYMBOL BRIDGES, AND THIS ONE'S RED IS NOT AN ERROR COUNT. symbol_lexeme and +// symbol_intern_lexeme have self-call bodies -- host seams -- but carried no projection roster +// row, so the resolver saw ordinary declarations and emission emitted the declaration. The result +// COMPILES: `pub fn symbol_lexeme(sym: String) -> String { symbol_lexeme(sym) }` type-checks and +// never returns. That is why these two are absent from the E0425 census this file's other rows +// are measured against -- they were silent, not absent. A row asserting "no error" would have +// been green throughout the defect; this asserts the call reaches the realization. +test fn w_symbol_lexeme_reaches_its_host_realization_not_its_self_call() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.symbol_lexeme_probe\nimport std.types { String }\nimport v2.std.node { Symbol }\nimport v2.std.compilers.lexing { symbol_lexeme }\nfn probe(sym: Symbol) -> String { symbol_lexeme(sym: sym) }\n", + "src/test_claim_symbol_lexeme_probe.rs", + ["v1_rt::symbol_lexeme("], + ["crate::v2_std_compilers_lexing::symbol_lexeme("] + ) +} From f8ea19f649299fd0010ada856466623f798fbfd8 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 29 Aug 2026 05:40:04 +0000 Subject: [PATCH 07/75] Fix the class-B boundary control: count has a method template, so it never reaches the seam under repair count is answered by rust_simple_method_specs before the algebra fallback, so the row would have gone red while executing none of the code the repair touched. trim is in rt_function_registry and has no template, so it is one of the few names that actually reaches that fallback. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01GXfYKNQTD3VfYyQcnJpxNU --- ...ed_call_target_realization_witness_test.dag | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/dag/test/claim/emitted_call_target_realization_witness_test.dag b/dag/test/claim/emitted_call_target_realization_witness_test.dag index 2a69a859d6d..4b0848cd60a 100644 --- a/dag/test/claim/emitted_call_target_realization_witness_test.dag +++ b/dag/test/claim/emitted_call_target_realization_witness_test.dag @@ -61,15 +61,21 @@ test fn w_callable_record_field_lowers_as_a_field_not_a_bridge() -> Bool { ) } -// THE BOUNDARY CONTROL FOR THE B REPAIR. `count` IS in rt_function_registry, so method-form calls -// that genuinely name a bridge must still reach one. A repair that had stopped the algebra -// fallback reaching v1_rt at all -- rather than asking whether this particular name is realized -- -// goes red here. +// THE BOUNDARY CONTROL FOR THE B REPAIR. `trim` is in rt_function_registry and, unlike count / +// join / first and the rest of rust_simple_method_specs, has NO method template -- so it is one of +// the few names that actually REACHES the algebra fallback this repair changed. A repair that had +// stopped that fallback reaching v1_rt at all, rather than asking whether this particular name is +// realized, goes red here. +// +// count was the first choice for this row and is wrong, which is worth recording: it has a +// template (`(\{recv\}.len() as i64)`), so it is answered before the fallback and would have gone +// red while testing nothing about the seam under repair -- a control passing through a codepath +// its subject never executes. test fn w_registered_bridge_method_still_reaches_the_bridge() -> Bool { compile_dag_rust_emit_check( - "module test.claim.bridge_method_probe\nimport std.types { Int, List }\nfn probe(xs: List) -> Int { xs |> count }\n", + "module test.claim.bridge_method_probe\nimport std.types { String }\nfn probe(s: String) -> String { s |> trim }\n", "src/test_claim_bridge_method_probe.rs", - ["v1_rt::count("], + ["v1_rt::trim("], ["compile_error"] ) } From 73a1aa495bdd6651cab88e0ed380eeec9f8eae98 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 29 Aug 2026 05:52:54 +0000 Subject: [PATCH 08/75] Unbreak the fixture parse: a trailing semicolon on the note declaration The module index refused the file outright, so none of the six witnesses were discovered. .dag item declarations carry no terminator. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01GXfYKNQTD3VfYyQcnJpxNU --- .../emitted_call_target_realization_witness_test.dag | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dag/test/claim/emitted_call_target_realization_witness_test.dag b/dag/test/claim/emitted_call_target_realization_witness_test.dag index 4b0848cd60a..0fc160439b2 100644 --- a/dag/test/claim/emitted_call_target_realization_witness_test.dag +++ b/dag/test/claim/emitted_call_target_realization_witness_test.dag @@ -4,7 +4,7 @@ import v2.std.live_tree { LiveTreeDisposition, SubstrateInputsOnly } data live_tree_disposition: LiveTreeDisposition = SubstrateInputsOnly -data emitted_call_target_realization_witness_note: String = "PERMANENT REGRESSION CONTROLS for the three emission defects that stood between the v2 compiler closure and a Rust crate rustc would accept (gunbc#9664 milestones 1 and 2). All three are one family -- emission ASSERTING a realization it had not established -- and each row here is the discriminating RED for one of them, paired with a boundary control that would go red if the repair had over-reached in the opposite direction.\n\nMEASURED POPULATIONS on the emitted closure at main 6447dd4, by `gunbc compile --entry src/v2/compiler/00_compile.dag --target rust` then `cargo check`: 260 coded errors, 254 of them E0425. Class C 102 (98 `v2` + 4 `std`), length 73, class B 65 (member 11, apply 11, is_empty 5, allocate_literal 4, step 3, init 3, and a tail of ones and twos).\n\nWHY THESE ARE NOT A SNAPSHOT. Each class's positive and negative assertion differ only in the fact the repair added, so no single edit satisfies both directions. The C rows would flip if decl_name reverted to the authored spelling; the length rows would flip if the registry membership gate were removed OR if the declaration fallback were extended to seams; the B rows would flip if runtime_bridge went back to a literal. The boundary controls (empty_map, a real bridge method) would flip if any of the three repairs had instead stopped emission reaching v1_rt at all.\n\nDISSOLVE-ON: never. Emission may change target SPELLING, but it may never again name a runtime symbol it has not established exists."; +data emitted_call_target_realization_witness_note: String = "PERMANENT REGRESSION CONTROLS for the three emission defects that stood between the v2 compiler closure and a Rust crate rustc would accept (gunbc#9664 milestones 1 and 2). All three are one family -- emission ASSERTING a realization it had not established -- and each row here is the discriminating RED for one of them, paired with a boundary control that would go red if the repair had over-reached in the opposite direction.\n\nMEASURED POPULATIONS on the emitted closure at main 6447dd4, by `gunbc compile --entry src/v2/compiler/00_compile.dag --target rust` then `cargo check`: 260 coded errors, 254 of them E0425. Class C 102 (98 `v2` + 4 `std`), length 73, class B 65 (member 11, apply 11, is_empty 5, allocate_literal 4, step 3, init 3, and a tail of ones and twos).\n\nWHY THESE ARE NOT A SNAPSHOT. Each class's positive and negative assertion differ only in the fact the repair added, so no single edit satisfies both directions. The C rows would flip if decl_name reverted to the authored spelling; the length rows would flip if the registry membership gate were removed OR if the declaration fallback were extended to seams; the B rows would flip if runtime_bridge went back to a literal. The boundary controls (empty_map, a real bridge method) would flip if any of the three repairs had instead stopped emission reaching v1_rt at all.\n\nDISSOLVE-ON: never. Emission may change target SPELLING, but it may never again name a runtime symbol it has not established exists." // CLASS C, THE DISCRIMINATING RED. A qualified call carried the whole dotted path as its // declaration name, so emission produced `crate::v2_std_collection::v2.std.collection.map_get(..)` @@ -68,9 +68,9 @@ test fn w_callable_record_field_lowers_as_a_field_not_a_bridge() -> Bool { // realized, goes red here. // // count was the first choice for this row and is wrong, which is worth recording: it has a -// template (`(\{recv\}.len() as i64)`), so it is answered before the fallback and would have gone -// red while testing nothing about the seam under repair -- a control passing through a codepath -// its subject never executes. +// simple-method template, so it is answered before the fallback and would have gone red while +// testing nothing about the seam under repair -- a control passing through a codepath its +// subject never executes. test fn w_registered_bridge_method_still_reaches_the_bridge() -> Bool { compile_dag_rust_emit_check( "module test.claim.bridge_method_probe\nimport std.types { String }\nfn probe(s: String) -> String { s |> trim }\n", From c92b6702d87c08db04c27f60aed773eae9bfbec4 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 29 Aug 2026 06:07:20 +0000 Subject: [PATCH 09/75] The self-call seam wall: an unrealized host seam refuses instead of emitting compiling recursion A whole-body self-call is the decidable structural marker of a host seam. In the interpreter the shape is safe -- reaching it recurses to the evaluation-budget refusal -- but emitted to Rust the same shape COMPILES and returns to no caller. Nothing reported it: not the module index, not the compile-clean gate, not cargo check. That is why the two symbol bridges were invisible until someone read the emitted bytes. emit_fn_def now asks the realization registry -- the same authority the call sites ask, so the two cannot drift -- and suppresses the declaration when the seam is realized, refuses with a located message when it is not. Suppression rather than delegation is deliberate: a forwarding body would make this seam reconstruct signatures in target types, which is the cementing the existing suppressed-seam precedent avoids, and a realized primitive's calls all route to the bridge anyway. The predicate is whole-body identity, not 'contains a self-call'. Ordinary recursion has a match, an if or a let between the head and the call, so it never matches; expr_has_self_call walks children and would have refused most of the compiler. Both directions carry a fixture. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01GXfYKNQTD3VfYyQcnJpxNU --- ...d_call_target_realization_witness_test.dag | 30 +++++++++++ src/v1/05_emit_rust.dag | 54 +++++++++++++++++++ 2 files changed, 84 insertions(+) diff --git a/dag/test/claim/emitted_call_target_realization_witness_test.dag b/dag/test/claim/emitted_call_target_realization_witness_test.dag index 0fc160439b2..277f757c0ce 100644 --- a/dag/test/claim/emitted_call_target_realization_witness_test.dag +++ b/dag/test/claim/emitted_call_target_realization_witness_test.dag @@ -95,3 +95,33 @@ test fn w_symbol_lexeme_reaches_its_host_realization_not_its_self_call() -> Bool ["crate::v2_std_compilers_lexing::symbol_lexeme("] ) } + +// THE SELF-CALL SEAM WALL, AND THIS IS THE ROW THAT MAKES THE CLASS STRUCTURAL RATHER THAN +// ROSTERED. Adding a self-calling declaration with no target realization used to emit it verbatim: +// `pub fn f(x) { f(x) }` compiles, and returns to no caller. Nothing reported it -- not the module +// index, not the compile-clean gate, not cargo check -- which is why the two symbol bridges were +// invisible until someone read the emitted bytes. The refusal now fires on the STRUCTURE, so a new +// seam cannot be added silently even if nobody remembers to roster it. +// +// The discriminating pair is the declaration itself: pre-wall the emitted module carries +// `pub fn declared_seam_without_realization`, post-wall it carries the refusal instead. +test fn w_unrealized_self_call_seam_refuses_instead_of_emitting_recursion() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.unrealized_seam_probe\nimport std.types { String }\nfn declared_seam_without_realization(x: String) -> String { declared_seam_without_realization(x: x) }\nfn probe(x: String) -> String { declared_seam_without_realization(x: x) }\n", + "src/test_claim_unrealized_seam_probe.rs", + ["has no realization for this target"], + ["pub fn declared_seam_without_realization"] + ) +} + +// ORDINARY RECURSION IS NOT A SEAM, and this is the control that keeps the wall from refusing most +// of the compiler. The predicate is whole-body identity, not "contains a self-call": a match, an if +// or a let between the head and the recursive call means the body is not the call. +test fn w_ordinary_recursion_is_not_read_as_a_host_seam() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.ordinary_recursion_probe\nimport std.types { Int }\nfn countdown(n: Int) -> Int { if n <= 0 { 0 } else { countdown(n: n - 1) } }\n", + "src/test_claim_ordinary_recursion_probe.rs", + ["pub fn countdown"], + ["has no realization for this target"] + ) +} diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index fdcd70afe2d..b89fe080a5a 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -7201,6 +7201,53 @@ fn v1_call_site_equality_forwarded_param_names( } } +// A WHOLE-BODY SELF-CALL IS THE STRUCTURAL MARKER OF A HOST SEAM, AND IT IS DECIDABLE. +// +// `fn decl_facts(pool_roots) { decl_facts(pool_roots: pool_roots) }` is not recursion that happens +// to be unbounded -- it is a declaration saying "my body lives in the host", and reaching it in the +// interpreter recurses to the evaluation-budget refusal, which is why the shape is safe there. In +// EMITTED RUST it is not safe: the same shape compiles, and the resulting function returns to no +// caller. That is DESIGN section 5 silent wrongness, and it is strictly worse than the unresolved +// symbol a missing bridge produces, because nothing anywhere reports it. The two symbol bridges sat +// in exactly this state and were absent from every error census precisely because they were silent. +// +// THE TEST IS THE WHOLE BODY, NOT A CONTAINED CALL. Ordinary recursion has a match, an if, or a let +// between the head and the self-call, so it never matches; expr_has_self_call, which walks children, +// is the wrong predicate here and would refuse most of the compiler. This asks only whether the body +// IS the self-call. +fn rust_body_is_bare_self_call(name: String, body: Node, source_indices: Map) -> Bool { + match body.expr_data { + ExprCall { call_semantics: _, descent_evidence: _ } => + qualified_last_segment(name: expr_call_func_at(texpr: body, source_indices: source_indices)) == name + _ => false + } +} + +// THE SEAM'S DISPOSITION AT THIS TARGET, ASKED OF THE REALIZATION REGISTRY RATHER THAN A NAME +// LITERAL. rust_host_string_seam_fn_emit above answers for two seams by spelling their Rust bodies +// out in the emitter, which is both hand-written target code in a compiler stage and a bare-name +// key. This asks the same registry the CALL SITES ask, so a seam's declaration is suppressed here +// exactly when a call to it lowers to a bridge, and the two answers cannot drift. +// +// SUPPRESSION, NOT DELEGATION, IS THE REALIZED ARM. Emitting a forwarding body would require this +// seam to reconstruct the signature in target types, which is the cementing the suppressed +// precedent avoids; and the declaration has no honest caller anyway, because every call to a +// realized primitive routes to the bridge. If some path ever misses that routing, the result is an +// unresolved symbol -- loud, located, and fixable -- rather than a silent nonterminating call. +fn rust_host_seam_declaration_emit(name: String, body: Node, source_indices: Map) -> String? { + if rust_body_is_bare_self_call(name: name, body: body, source_indices: source_indices) == false { + none + } else if rust_runtime_primitive_has_bridge(primitive_name: name) { + Present { value: "" } + } else { + Present { value: concat( + "compile_error!(\"host seam '", name, "' has no realization for this target: its whole body is a self-call, ", + "so emitting it would produce a compiling, nonterminating function. Give it a row in ", + "extdeps.languages.rust.emit rt_function_registry and a body in v1.runtime_rust.\");\n" + ) } + } +} + fn emit_fn_def(name: String, params: List, inferred: Node, body: Node, registry: Map, scope: InferScope, shared_types: Set, emit_info: EmitGraphInfo) -> String { let si = scope.type_env.source_indices let host_text_op = rust_host_string_op_fn_emit(name: name) @@ -7210,6 +7257,13 @@ fn emit_fn_def(name: String, params: List, inferred: Node, body: Node, reg Absent => "" } } + let host_seam_emit = rust_host_seam_declaration_emit(name: name, body: body, source_indices: si) + if host_seam_emit != none { + return match host_seam_emit { + Present { value: seam_emit } => seam_emit + Absent => "" + } + } match rust_host_string_seam_fn_emit(name: name) { Present { value: seam_fn } => { let _unused = seam_fn "" } From 7a0577cd1f6153c6f71c8b85f227f03f42a76545 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 29 Aug 2026 07:37:03 +0000 Subject: [PATCH 10/75] The seam wall must resolve realization through the roster's primitive, not the declaration name Measured, not predicted: the wall refused six seams in the emitted closure and one of them -- v2.std.collection empty_map_primitive_delegate -- is realized. Its roster row names the empty_map primitive, whose bridge is rc_empty_map, but rt_function_registry holds 'empty_map' and the wall looked up 'empty_map_primitive_delegate'. A declaration's name and the primitive it realizes are two facts; the roster is the authority that joins them, and the declaration name is only the fallback for a seam nobody has rostered. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01GXfYKNQTD3VfYyQcnJpxNU --- ...d_call_target_realization_witness_test.dag | 19 +++++++++++++++ src/v1/05_emit_rust.dag | 24 ++++++++++++++++--- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/dag/test/claim/emitted_call_target_realization_witness_test.dag b/dag/test/claim/emitted_call_target_realization_witness_test.dag index 277f757c0ce..7e94f844812 100644 --- a/dag/test/claim/emitted_call_target_realization_witness_test.dag +++ b/dag/test/claim/emitted_call_target_realization_witness_test.dag @@ -125,3 +125,22 @@ test fn w_ordinary_recursion_is_not_read_as_a_host_seam() -> Bool { ["has no realization for this target"] ) } + +// A SEAM'S DECLARATION NAME IS NOT THE PRIMITIVE IT REALIZES, and this row is the one that caught +// it. v2.std.collection empty_map_primitive_delegate is a self-call body -- so the wall sees a seam +// -- and it IS realized, because its roster row names the `empty_map` primitive whose bridge is +// rc_empty_map. Keying the realization lookup on the DECLARATION name missed, because the registry +// holds `empty_map`, and the wall refused a seam that had a perfectly good realization. Measured, +// not predicted: it appeared as one of six refusals in the emitted closure. +// +// The discriminating direction is that this seam must NOT refuse while decl_facts, which genuinely +// has no realization, must. A wall that reverted to decl-name keying flips this row red and leaves +// the decl_facts row green, so the two cannot be satisfied by one edit. +test fn w_rostered_seam_resolves_realization_through_its_primitive_not_its_decl_name() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.delegate_seam_probe\nimport std.types { Int, String, Map }\nimport std.occurrence_identity { OccurrenceId }\nimport v2.std.collection { empty_map }\nfn probe() -> Map { empty_map() }\n", + "src/test_claim_delegate_seam_probe.rs", + ["v1_rt::rc_empty_map"], + ["has no realization for this target"] + ) +} diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index b89fe080a5a..cecb593efd1 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -1,6 +1,10 @@ module v1.compiler.emit_rust import std.occurrence_identity { OccurrenceSynthetic } +import std.decl_ref { decl_ref } +import std.primitive_projection { + primitive_identity_runtime_name, primitive_projection_row_for_declaration +} import extdeps.languages.rust.capabilities { phantom_opaque_carrier_derive_traits } @@ -7234,10 +7238,24 @@ fn rust_body_is_bare_self_call(name: String, body: Node, source_indices: Map) -> String? { +// THE PRIMITIVE A DECLARATION PROJECTS, WHICH IS NOT ITS OWN NAME. A seam's declaration name and +// the primitive it realizes are different facts, and keying realization on the declaration name +// was a defect measured rather than reasoned: v2.std.collection empty_map_primitive_delegate is +// rostered to the `empty_map` primitive, whose bridge is rc_empty_map, so it IS realized -- but the +// registry holds `empty_map`, not `empty_map_primitive_delegate`, so a decl-name lookup missed and +// the wall refused a seam that had a perfectly good realization. The roster is the authority that +// joins the two; the declaration name is only the fallback for a seam nobody has rostered. +fn rust_seam_primitive_name(module_path: String, name: String) -> String { + match primitive_projection_row_for_declaration(declaration: decl_ref(module_path: module_path, decl_name: name)) { + Present { value: row } => primitive_identity_runtime_name(identity: row.primitive) + Absent => name + } +} + +fn rust_host_seam_declaration_emit(module_path: String, name: String, body: Node, source_indices: Map) -> String? { if rust_body_is_bare_self_call(name: name, body: body, source_indices: source_indices) == false { none - } else if rust_runtime_primitive_has_bridge(primitive_name: name) { + } else if rust_runtime_primitive_has_bridge(primitive_name: rust_seam_primitive_name(module_path: module_path, name: name)) { Present { value: "" } } else { Present { value: concat( @@ -7257,7 +7275,7 @@ fn emit_fn_def(name: String, params: List, inferred: Node, body: Node, reg Absent => "" } } - let host_seam_emit = rust_host_seam_declaration_emit(name: name, body: body, source_indices: si) + let host_seam_emit = rust_host_seam_declaration_emit(module_path: scope.module_name, name: name, body: body, source_indices: si) if host_seam_emit != none { return match host_seam_emit { Present { value: seam_emit } => seam_emit From 50b10e4f64195d9b45ff1664eb46d93c859ceb1f Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 29 Aug 2026 08:46:26 +0000 Subject: [PATCH 11/75] The seam wall's realized arm must not suppress the declaration: suppression created 10 dangling imports Measured on the emitted closure with the wall finally in the mirror: removing a realized seam's item left 10 unresolved imports (E0432) for symbol_lexeme, symbol_intern_lexeme and resolve_type_node. Other modules import these declarations; the suppression created that breakage rather than finding it. And the reasoning that made suppression look safe is what makes it unnecessary. A realized seam's body IS a call to itself, and resolution already routes that call through the roster to the bridge -- so ordinary emission writes v1_rt::symbol_lexeme(sym) as the body without help. The wall's whole job is the UNREALIZED arm. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01GXfYKNQTD3VfYyQcnJpxNU --- ...ted_call_target_realization_witness_test.dag | 16 ++++++++++++++++ src/v1/05_emit_rust.dag | 17 +++++++++++------ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/dag/test/claim/emitted_call_target_realization_witness_test.dag b/dag/test/claim/emitted_call_target_realization_witness_test.dag index 7e94f844812..a85db8c276d 100644 --- a/dag/test/claim/emitted_call_target_realization_witness_test.dag +++ b/dag/test/claim/emitted_call_target_realization_witness_test.dag @@ -144,3 +144,19 @@ test fn w_rostered_seam_resolves_realization_through_its_primitive_not_its_decl_ ["has no realization for this target"] ) } + +// A REALIZED SEAM KEEPS ITS DECLARATION, and this row exists because removing it was a defect I +// shipped. The wall first suppressed a realized seam's item, reasoning that every call to a +// realized primitive routes to the bridge so nothing calls the declaration. Other modules still +// IMPORT it, so 10 unresolved imports (E0432) appeared in the emitted closure -- created by the +// suppression, not found by it. The same reasoning that made suppression look safe is what makes +// it unnecessary: the seam's body is a self-call, resolution routes it through the roster to the +// bridge, and ordinary emission writes the delegation by itself. +test fn w_realized_seam_keeps_its_declaration_and_delegates_to_the_bridge() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.realized_seam_probe\nimport std.types { String }\nimport v2.std.node { Symbol }\nimport v2.std.compilers.lexing { symbol_lexeme }\nfn probe(sym: Symbol) -> String { symbol_lexeme(sym: sym) }\n", + "src/test_claim_realized_seam_probe.rs", + ["v1_rt::symbol_lexeme("], + ["has no realization for this target"] + ) +} diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index cecb593efd1..41a64519b5a 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -7233,11 +7233,16 @@ fn rust_body_is_bare_self_call(name: String, body: Node, source_indices: Map Date: Sat, 29 Aug 2026 08:49:23 +0000 Subject: [PATCH 12/75] The seam refusal is a generated body, not a crate-wide compile_error!: rustc's denominator is larger than the demand denominator compile_error! fails the WHOLE crate, and that form silently assumes every seam it refuses is one somebody calls. It is not. rustc type-checks the entire emitted crate including declarations imported but never invoked, so the refusal denominator is strictly larger than the entry-reachable execution closure -- five unreachable seams took the crate down. The refusal is now a panic body with the declaration's real signature: dependent modules resolve, the crate compiles, and only an actual invocation fails loudly. That moves the refusal from the crate to the one declaration that earned it, and leaves reachability to a separate instrument. An entry-rooted pruner can replace the body later without revisiting this. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01GXfYKNQTD3VfYyQcnJpxNU --- ...d_call_target_realization_witness_test.dag | 20 ++++++++- src/v1/05_emit_rust.dag | 41 ++++++++++--------- 2 files changed, 40 insertions(+), 21 deletions(-) diff --git a/dag/test/claim/emitted_call_target_realization_witness_test.dag b/dag/test/claim/emitted_call_target_realization_witness_test.dag index a85db8c276d..5ea0b3fe224 100644 --- a/dag/test/claim/emitted_call_target_realization_witness_test.dag +++ b/dag/test/claim/emitted_call_target_realization_witness_test.dag @@ -109,8 +109,24 @@ test fn w_unrealized_self_call_seam_refuses_instead_of_emitting_recursion() -> B compile_dag_rust_emit_check( "module test.claim.unrealized_seam_probe\nimport std.types { String }\nfn declared_seam_without_realization(x: String) -> String { declared_seam_without_realization(x: x) }\nfn probe(x: String) -> String { declared_seam_without_realization(x: x) }\n", "src/test_claim_unrealized_seam_probe.rs", - ["has no realization for this target"], - ["pub fn declared_seam_without_realization"] + ["unrealized host seam", "panic!"], + ["declared_seam_without_realization(x)"] + ) +} + +// THE REFUSAL KEEPS THE SIGNATURE AND THE CRATE KEEPS COMPILING. This is the row that separates the +// two refusal FORMS, and it is the whole point of the correction: compile_error! fails the entire +// crate, which is wrong for a seam nobody calls, because rustc's denominator is the whole emitted +// crate while the demand denominator is the entry-reachable closure. Five unreachable seams took +// the crate down under the old form. The declaration must therefore still be emitted, with its +// parameters and return type intact, so that dependent modules resolve and only an actual call +// fails. +test fn w_unrealized_seam_refusal_preserves_the_declaration_signature() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.unrealized_seam_shape_probe\nimport std.types { String }\nfn seam_with_no_realization(x: String) -> String { seam_with_no_realization(x: x) }\n", + "src/test_claim_unrealized_seam_shape_probe.rs", + ["pub fn seam_with_no_realization", "-> String", "panic!"], + ["compile_error!"] ) } diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index 41a64519b5a..e866e2f3baf 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -7233,6 +7233,16 @@ fn rust_body_is_bare_self_call(name: String, body: Node, source_indices: Map String { } } -fn rust_host_seam_declaration_emit(module_path: String, name: String, body: Node, source_indices: Map) -> String? { - if rust_body_is_bare_self_call(name: name, body: body, source_indices: source_indices) == false { - none - } else if rust_runtime_primitive_has_bridge(primitive_name: rust_seam_primitive_name(module_path: module_path, name: name)) { - none - } else { - Present { value: concat( - "compile_error!(\"host seam '", name, "' has no realization for this target: its whole body is a self-call, ", - "so emitting it would produce a compiling, nonterminating function. Give it a row in ", - "extdeps.languages.rust.emit rt_function_registry and a body in v1.runtime_rust.\");\n" - ) } - } +fn rust_host_seam_is_unrealized(module_path: String, name: String, body: Node, source_indices: Map) -> Bool { + rust_body_is_bare_self_call(name: name, body: body, source_indices: source_indices) + && rust_runtime_primitive_has_bridge(primitive_name: rust_seam_primitive_name(module_path: module_path, name: name)) == false } fn emit_fn_def(name: String, params: List, inferred: Node, body: Node, registry: Map, scope: InferScope, shared_types: Set, emit_info: EmitGraphInfo) -> String { @@ -7280,13 +7281,6 @@ fn emit_fn_def(name: String, params: List, inferred: Node, body: Node, reg Absent => "" } } - let host_seam_emit = rust_host_seam_declaration_emit(module_path: scope.module_name, name: name, body: body, source_indices: si) - if host_seam_emit != none { - return match host_seam_emit { - Present { value: seam_emit } => seam_emit - Absent => "" - } - } match rust_host_string_seam_fn_emit(name: name) { Present { value: seam_fn } => { let _unused = seam_fn "" } @@ -7365,6 +7359,15 @@ fn emit_fn_def(name: String, params: List, inferred: Node, body: Node, reg let depth = 0 let use_tco = is_tco_eligible(name: name, body: body, registry: registry, source_indices: si) let needs_stacker = is_self_recursive(name: name, body: body, registry: registry, source_indices: si) && use_tco == false + if rust_host_seam_is_unrealized(module_path: scope.module_name, name: name, body: body, source_indices: si) { + let kw = rust_items().func_keyword + return concat(rust_visibility_prefix(), kw, " ", emit_ident(name: name, target: Rust), type_params_str, "(", params_str, ")", ret_str, " {\n", + make_indent(level: 1), + "panic!(\"unrealized host seam '", name, "' in ", scope.module_name, + ": this declaration's whole body is a self-call, so it has no behaviour on this target. ", + "It compiles as a refusal rather than as recursion. Give it a row in ", + "extdeps.languages.rust.emit rt_function_registry and a body in v1.runtime_rust, or delete its consumers.\")\n}") + } if use_tco { let tco_params_str = emit_tco_params(params: value_params, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: si, variant_to_enum: emit_info.variant_to_enum, env: scope.type_env) let body_str = emit_typed_tco_body(texpr: body, fn_name: name, params: value_params, registry: registry, scope: body_scope, depth: depth + 1, shared_types: shared_types, emit_info: body_emit_info) From bd7dac664fbebe5ad810168feb904a7494fb1380 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 29 Aug 2026 09:34:23 +0000 Subject: [PATCH 13/75] Two obligations the required floor found, both real consequences of this change DETERMINISM DENOMINATOR (9 reach_witness rows red, including determinism_denominator_is_closed_on_declared_primitives, whose entire job is to notice this). v2.lens.determinism closes its denominator over primitive_declared_definitions, so adding two canonical names without traversal facts made the closure false. Both bridges are scalar -- symbol_lexeme maps one Symbol to its text and symbol_intern_lexeme is its inverse -- so there is no collection to walk and OrderFreeResult is the honest arm. HostUnspecifiedOrder would claim a real traversal whose order the host does not pin, fabricating a leak the primitive cannot have. NAMESPACE WAVE ADMISSION (6 unadjudicated deltas). Four are TargetChanged for DeclaredCallableIdentity moving v1.compiler.infer_sigs -> v1.std.core, which is what lets CallTargetIdentity carry the declaration a runtime target was projected from. infer_sigs imports v1.std.core, so the type could not stay put without a cycle. Four enumerated rows, one per binding site; the two membership deltas auto-admit as ExplicitlyEvaluatedZeroDelta. Dissolve-on: this PR merging, by the same trigger the three prior shrinks record. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01GXfYKNQTD3VfYyQcnJpxNU --- dag/std/primitive_identity.dag | 18 ++++++ src/v1/stage0/src/namespace_wave_admission.rs | 61 ++++++++++++++++++- 2 files changed, 78 insertions(+), 1 deletion(-) diff --git a/dag/std/primitive_identity.dag b/dag/std/primitive_identity.dag index 157368375c9..0430947387c 100644 --- a/dag/std/primitive_identity.dag +++ b/dag/std/primitive_identity.dag @@ -31,6 +31,7 @@ import std.primitive_projection { primitive_length, primitive_map_insert, primitive_map_get, primitive_empty_map, primitive_decl_facts, primitive_export_signature_facts, primitive_data_decl_type_facts, primitive_concept_decl_facts, primitive_concept_decl_facts_live, + primitive_symbol_lexeme, primitive_symbol_intern_lexeme, } data primitive_identity_d0_scope_note: String = "D0 is NOT terminal acceptance and does NOT close the subject universe. Landed and executing: join mechanism across five carriers, five refusal variants typed, three refusal detectors executing with witnesses (see primitive_d0_refusal_execution_note), derived census across all five surfaces including InterpreterDispatch from gunbc.v1_interpreter_primitive_surface. D1 (interpreter-primitive-roster consumption): measurement scaffold deleted; primitive_surface_census_derived reads the roster authority. Population-wide identity join closure remains the terminal acceptance bar." @@ -1316,6 +1317,21 @@ data primitive_concept_decl_facts_traversal: PrimitiveTraversalOrderFact = Primi data primitive_concept_decl_facts_live_traversal: PrimitiveTraversalOrderFact = PrimitiveTraversalOrderFact { primitive: primitive_concept_decl_facts_live, order: SourcePreservingOrder } +// THE TWO SYMBOL BRIDGES TRAVERSE NOTHING, and OrderFreeResult is the honest arm rather than the +// convenient one. Both are scalar: symbol_lexeme maps one Symbol to its text and +// symbol_intern_lexeme is its inverse, so there is no collection to walk and the result is a +// function of the input alone -- it cannot depend on an order because no order is consulted. That +// is a different statement from HostUnspecifiedOrder, which would claim a real traversal whose +// order the host does not pin, and asserting it here would fabricate a leak the primitive cannot +// have. Adding these rows is an OBLIGATION of declaring the primitives, not bookkeeping beside it: +// v2.lens.determinism closes its denominator over primitive_declared_definitions, so a primitive +// with no traversal fact makes the closure false. That is how this was found -- nine reach_witness +// rows went red, including determinism_denominator_is_closed_on_declared_primitives, the row whose +// entire job is to notice exactly this. +data primitive_symbol_lexeme_traversal: PrimitiveTraversalOrderFact = PrimitiveTraversalOrderFact { primitive: primitive_symbol_lexeme, order: OrderFreeResult } + +data primitive_symbol_intern_lexeme_traversal: PrimitiveTraversalOrderFact = PrimitiveTraversalOrderFact { primitive: primitive_symbol_intern_lexeme, order: OrderFreeResult } + data primitive_projection_traversal_facts: List = [ primitive_length_traversal, primitive_map_insert_traversal, @@ -1326,6 +1342,8 @@ data primitive_projection_traversal_facts: List = [ primitive_data_decl_type_facts_traversal, primitive_concept_decl_facts_traversal, primitive_concept_decl_facts_live_traversal, + primitive_symbol_lexeme_traversal, + primitive_symbol_intern_lexeme_traversal, ] fn primitive_declared_traversal_facts() -> List { diff --git a/src/v1/stage0/src/namespace_wave_admission.rs b/src/v1/stage0/src/namespace_wave_admission.rs index 4fa2876b39a..fb106ff51bb 100644 --- a/src/v1/stage0/src/namespace_wave_admission.rs +++ b/src/v1/stage0/src/namespace_wave_admission.rs @@ -367,7 +367,66 @@ pub struct TransitionAdmission { /// the shape the paragraph above records for the first 53. Removed by the trigger they were /// authored with. The roster is EMPTY and empty is not permissive: a run carrying a real /// namespace delta still refuses it as UNADJUDICATED until its author adds a row here. -pub const NAMESPACE_TRANSITION_ADMISSIONS: &[TransitionAdmission] = &[]; +/// FOURTH TRANSITION (2026-08-29, gunbc#9665 / issue #9664). `DeclaredCallableIdentity` moved +/// from `v1.compiler.infer_sigs` to `v1.std.core`, so every binding of that spelling inside +/// `v1.compiler.infer_lookup` reports `TargetChanged`. The move is not cosmetic and not +/// avoidable by re-spelling: `v1.std.core`'s own `CallTargetIdentity` now CARRIES a +/// `DeclaredCallableIdentity` on its `RuntimePrimitiveCall` arm -- the declaration a runtime +/// target was projected from, which is what lets Rust emission fall back to the declaration +/// when its registry has no bridge for the primitive instead of inventing `v1_rt::length`. +/// `v1.compiler.infer_sigs` imports `v1.std.core`, so the type could not stay where it was +/// without a cycle, and re-declaring the pair in `v1.std.core` beside the original is the +/// second-representation defect DESIGN §3 forbids -- the type's own note already says so, and +/// that note travelled with the declaration. +/// +/// FOUR ROWS, ONE PER BINDING SITE, and they are enumerated rather than matched by a module +/// pattern because the roster's own rule is that its population is an enumeration and never a +/// predicate. The two `membership` deltas this change also produces +/// (`v1.compiler.emit_rust -> std.decl_ref` and `-> std.primitive_projection`) are +/// `ExplicitlyEvaluatedZeroDelta` and auto-admit, so they are deliberately absent here. +/// +/// DISSOLVE-ON: this PR merging. Once `DeclaredCallableIdentity` is declared in `v1.std.core` +/// on main, the merge base and head both carry it, no run can produce these deltas, and all +/// four report stale -- which refuses every unrelated PR in the repository, exactly the shape +/// the three shrinks above record. Remove them by that trigger, not by reinterpreting it. +pub const NAMESPACE_TRANSITION_ADMISSIONS: &[TransitionAdmission] = &[ + TransitionAdmission { + label: "DeclaredCallableIdentity hoist to v1.std.core 2026-08-29", + subject: AdmissionSubject::Binding { + module: "v1.compiler.infer_lookup", + in_declaration: "borrowed_census_callable_candidate", + spelling: "DeclaredCallableIdentity", + }, + disposition: NamespaceDeltaDisposition::TargetChanged, + }, + TransitionAdmission { + label: "DeclaredCallableIdentity hoist to v1.std.core 2026-08-29", + subject: AdmissionSubject::Binding { + module: "v1.compiler.infer_lookup", + in_declaration: "callable_lookup_over_candidates", + spelling: "DeclaredCallableIdentity", + }, + disposition: NamespaceDeltaDisposition::TargetChanged, + }, + TransitionAdmission { + label: "DeclaredCallableIdentity hoist to v1.std.core 2026-08-29", + subject: AdmissionSubject::Binding { + module: "v1.compiler.infer_lookup", + in_declaration: "func_sig_from_global_bare", + spelling: "DeclaredCallableIdentity", + }, + disposition: NamespaceDeltaDisposition::TargetChanged, + }, + TransitionAdmission { + label: "DeclaredCallableIdentity hoist to v1.std.core 2026-08-29", + subject: AdmissionSubject::Binding { + module: "v1.compiler.infer_lookup", + in_declaration: "resolved_declaration_call_target", + spelling: "DeclaredCallableIdentity", + }, + disposition: NamespaceDeltaDisposition::TargetChanged, + }, +]; /// The denominators a green must name (DESIGN §5). A run that cannot say what it covered is /// an instrument failure wearing coverage's clothes. From d0de2a4dd3e5707e00484dbd648549ddd402e2e1 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 29 Aug 2026 10:04:22 +0000 Subject: [PATCH 14/75] Class-C fixture was broken, not the repair: the witness pool is smaller than the corpus The row FAILED while the mechanism was green. The probe used the qualified spelling without importing v2.std.collection, which resolves against the real 4261-module corpus but not against compile_dag_rust_emit_check's 2973-module witness pool. Measured both ways: emitted against the corpus the same probe produces crate::v2_std_collection::map_get(m.clone(), "key".to_string()), exactly what the row asserts. The import restores module presence and does not answer the call -- decl_name comes from the authored spelling at the call site regardless of imports -- so the negative assertion still discriminates. Falsifier 2 is what proves that rather than argues it. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01GXfYKNQTD3VfYyQcnJpxNU --- ...emitted_call_target_realization_witness_test.dag | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/dag/test/claim/emitted_call_target_realization_witness_test.dag b/dag/test/claim/emitted_call_target_realization_witness_test.dag index 5ea0b3fe224..cd91aa1ecd4 100644 --- a/dag/test/claim/emitted_call_target_realization_witness_test.dag +++ b/dag/test/claim/emitted_call_target_realization_witness_test.dag @@ -6,6 +6,17 @@ data live_tree_disposition: LiveTreeDisposition = SubstrateInputsOnly data emitted_call_target_realization_witness_note: String = "PERMANENT REGRESSION CONTROLS for the three emission defects that stood between the v2 compiler closure and a Rust crate rustc would accept (gunbc#9664 milestones 1 and 2). All three are one family -- emission ASSERTING a realization it had not established -- and each row here is the discriminating RED for one of them, paired with a boundary control that would go red if the repair had over-reached in the opposite direction.\n\nMEASURED POPULATIONS on the emitted closure at main 6447dd4, by `gunbc compile --entry src/v2/compiler/00_compile.dag --target rust` then `cargo check`: 260 coded errors, 254 of them E0425. Class C 102 (98 `v2` + 4 `std`), length 73, class B 65 (member 11, apply 11, is_empty 5, allocate_literal 4, step 3, init 3, and a tail of ones and twos).\n\nWHY THESE ARE NOT A SNAPSHOT. Each class's positive and negative assertion differ only in the fact the repair added, so no single edit satisfies both directions. The C rows would flip if decl_name reverted to the authored spelling; the length rows would flip if the registry membership gate were removed OR if the declaration fallback were extended to seams; the B rows would flip if runtime_bridge went back to a literal. The boundary controls (empty_map, a real bridge method) would flip if any of the three repairs had instead stopped emission reaching v1_rt at all.\n\nDISSOLVE-ON: never. Emission may change target SPELLING, but it may never again name a runtime symbol it has not established exists." +// THE PROBE IMPORTS v2.std.collection AND THEN CALLS IT BY ITS QUALIFIED NAME, which looks +// redundant and is not. compile_dag_rust_emit_check compiles through the witness harness's +// restricted pool (2973 modules against the corpus's 4261), and a qualified spelling alone does not +// put the target module in it -- so without the import this row FAILED while the repair was green, +// which is how it was found. Measured both ways: the same probe emitted against the real corpus +// produces `crate::v2_std_collection::map_get(m.clone(), "key".to_string())` exactly as asserted. +// The import restores module presence; it does not answer the call, because decl_name is taken from +// the authored spelling at the CALL SITE regardless of what is imported -- which is why the +// negative assertion below still discriminates, and why falsifier 2 (restore the dotted spelling) +// must red this row. +// // CLASS C, THE DISCRIMINATING RED. A qualified call carried the whole dotted path as its // declaration name, so emission produced `crate::v2_std_collection::v2.std.collection.map_get(..)` // -- the module prefix correct and the identifier a dotted path Rust reads as field access on an @@ -13,7 +24,7 @@ data emitted_call_target_realization_witness_note: String = "PERMANENT REGRESSIO // row proves the qualified path reaches the DECLARATION and not the bridge. test fn w_qualified_call_emits_only_the_declaration_last_segment() -> Bool { compile_dag_rust_emit_check( - "module test.claim.qualified_call_probe\nimport std.types { Int, String, Map }\nimport std.occurrence_identity { OccurrenceId }\nimport v2.std.diagnostic { Outcome }\nimport v2.std.optional { Optional }\nfn probe(m: Map) -> Outcome> { v2.std.collection.map_get(m: m, key: \"key\") }\n", + "module test.claim.qualified_call_probe\nimport std.types { Int, String, Map }\nimport std.occurrence_identity { OccurrenceId }\nimport v2.std.collection { map_get }\nimport v2.std.diagnostic { Outcome }\nimport v2.std.optional { Optional }\nfn probe(m: Map) -> Outcome> { v2.std.collection.map_get(m: m, key: \"key\") }\n", "src/test_claim_qualified_call_probe.rs", ["crate::v2_std_collection::map_get("], ["::v2.std.collection", "v2.std.collection.map_get("] From 51fb9111c3d81a238bf31dc7fd11eee08c253f26 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 29 Aug 2026 10:05:39 +0000 Subject: [PATCH 15/75] is_empty: a conversion is not a repair -- give it the Rust realization it never had Before the class-B change, xs |> is_empty emitted v1_rt::is_empty, a symbol the seed does not define: 5 x E0425. After it, the same 5 sites became typed refusals -- correct in kind, still 5 errors. The class-B repair made the gap visible; it did not close it. is_empty is an algebra template over FreeMonoid whose Rust realization is Vec::is_empty, exactly as count's is Vec::len, so the fix is one row in rust_simple_method_specs beside count. Nothing in 05_emit_rust learns a new name: realization is a target fact and lives in the target's registry. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01GXfYKNQTD3VfYyQcnJpxNU --- dag/extdeps/languages/rust/emit.dag | 3 ++- ...d_call_target_realization_witness_test.dag | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/dag/extdeps/languages/rust/emit.dag b/dag/extdeps/languages/rust/emit.dag index bc6be0952ec..906424fb1be 100644 --- a/dag/extdeps/languages/rust/emit.dag +++ b/dag/extdeps/languages/rust/emit.dag @@ -76,7 +76,8 @@ data rust_simple_method_specs: List = [ { method_name: "enumerate", template: "\{recv\}.iter().cloned().enumerate().map(|(i, v)| (i as i64, v)).collect::>()", wraps_result: true }, { method_name: "chars", template: "\{recv\}.chars().map(|c| c as i64).collect::>()", wraps_result: true }, { method_name: "skip", template: "\{recv\}.iter().cloned().skip(\{arg\} as usize).collect::>()", wraps_result: true }, - { method_name: "take", template: "\{recv\}.iter().cloned().take(\{arg\} as usize).collect::>()", wraps_result: true } + { method_name: "take", template: "\{recv\}.iter().cloned().take(\{arg\} as usize).collect::>()", wraps_result: true }, + { method_name: "is_empty", template: "\{recv\}.is_empty()", wraps_result: false } ] fn rust_method_templates() -> Map { diff --git a/dag/test/claim/emitted_call_target_realization_witness_test.dag b/dag/test/claim/emitted_call_target_realization_witness_test.dag index cd91aa1ecd4..036c4425a68 100644 --- a/dag/test/claim/emitted_call_target_realization_witness_test.dag +++ b/dag/test/claim/emitted_call_target_realization_witness_test.dag @@ -187,3 +187,22 @@ test fn w_realized_seam_keeps_its_declaration_and_delegates_to_the_bridge() -> B ["has no realization for this target"] ) } + +// is_empty HAD NO RUST REALIZATION AT ALL, and the class-B repair is what made that visible rather +// than what caused it. Before it, `xs |> is_empty` emitted `v1_rt::is_empty(..)` -- a symbol the +// seed does not define -- and appeared in the census as 5 x E0425. After it, the same 5 sites +// became typed refusals: correct in KIND, and still 5 errors. A conversion is not a repair, so this +// row exists to pin the actual realization. +// +// THE ROW IS A TARGET FACT, NOT EMITTER CODE. is_empty is an algebra template over FreeMonoid whose +// Rust realization is Vec::is_empty, exactly as count's is Vec::len -- so it belongs in +// rust_simple_method_specs beside count, and nothing in 05_emit_rust learns a new name. The +// negative assertion is the refusal message, because that is precisely the state this row leaves. +test fn w_is_empty_lowers_to_its_rust_realization_not_a_refusal() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.is_empty_probe\nimport std.types { Int, Bool }\nimport std.occurrence_identity { OccurrenceId }\nimport v2.std.algebra { FreeMonoid, is_empty }\nfn probe(xs: FreeMonoid) -> Bool { xs |> is_empty }\n", + "src/test_claim_is_empty_probe.rs", + [".is_empty()"], + ["v1_rt::is_empty(", "neither a resolved callable receiver field"] + ) +} From a715f1c5edb89e009960fe6ce26efd78ab54c3a2 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 29 Aug 2026 10:14:23 +0000 Subject: [PATCH 16/75] A receiver's own callable field outranks every name-keyed table: class B survived one layer up The requested is_empty negative control found a live hole rather than confirming a safe one. Both rust_method_templates lookups are keyed on the bare method spelling with no receiver check, so a fn-typed record field named is_empty was captured by the target template and emitted as recv.is_empty() instead of (recv.is_empty)(..). The class-B repair fixed the algebra FALLBACK and left the two tables sitting in front of it. The hole is not new and is not specific to is_empty: count, first, join, split, take, skip, last, chars and enumerate have carried it for as long as they have had templates. Adding is_empty made it urgent by putting the spelling most likely to name a predicate field in front of that table. One helper, consulted at the top of both arms before every name-keyed special case, so the two cannot drift. Two controls: the new spelling and a pre-existing one. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01GXfYKNQTD3VfYyQcnJpxNU --- ...d_call_target_realization_witness_test.dag | 31 +++++++++++++++++ src/v1/05_emit_rust.dag | 34 +++++++++++++++++-- 2 files changed, 63 insertions(+), 2 deletions(-) diff --git a/dag/test/claim/emitted_call_target_realization_witness_test.dag b/dag/test/claim/emitted_call_target_realization_witness_test.dag index 036c4425a68..2e620669f3f 100644 --- a/dag/test/claim/emitted_call_target_realization_witness_test.dag +++ b/dag/test/claim/emitted_call_target_realization_witness_test.dag @@ -206,3 +206,34 @@ test fn w_is_empty_lowers_to_its_rust_realization_not_a_refusal() -> Bool { ["v1_rt::is_empty(", "neither a resolved callable receiver field"] ) } + +// THE NEGATIVE IDENTITY CONTROL FOR THE is_empty ROW, and it caught a live hole rather than +// confirming a safe one. Adding is_empty to rust_simple_method_specs put a new spelling in front of +// the two rust_method_templates lookups -- and those lookups are keyed on the bare name with no +// receiver check, so a fn-typed record field named is_empty was captured by the target template and +// emitted as `recv.is_empty()` instead of `(recv.is_empty)(..)`. That is class B surviving one +// layer up: the class-B repair fixed the algebra FALLBACK and left the tables in front of it. +// +// The same hole existed for count, first, join, split, take, skip, last, chars and enumerate before +// is_empty was ever added; this row is the one that made it executable. +test fn w_callable_field_named_is_empty_is_not_captured_by_the_target_template() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.is_empty_field_probe\nimport std.types { Bool, Int }\ntype Probe { is_empty: fn(Int) -> Bool }\nfn probe(p: Probe, n: Int) -> Bool { p.is_empty(n) }\n", + "src/test_claim_is_empty_field_probe.rs", + [".is_empty)("], + ["p.is_empty()"] + ) +} + +// THE SAME CONTROL FOR A SPELLING THAT WAS ALREADY IN THE TABLE. count has had a template since +// before this change, so if the hole were specific to is_empty this row would be green on main and +// green here. It is not: it is the pre-existing instance of the class, and it is enrolled so the +// repair is measured against the whole table rather than the row that exposed it. +test fn w_callable_field_named_count_is_not_captured_by_the_target_template() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.count_field_probe\nimport std.types { Int }\ntype Counter { count: fn(Int) -> Int }\nfn probe(c: Counter, n: Int) -> Int { c.count(n) }\n", + "src/test_claim_count_field_probe.rs", + [".count)("], + ["c.count()"] + ) +} diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index e866e2f3baf..18307efce60 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -10402,7 +10402,10 @@ fn emit_typed_method_call(method_call_node: Node, receiver: Node, method: String let method_name = if method_name_raw == "length" { if is_string_typed_expr(e: receiver, source_indices: scope.type_env.source_indices) { "string_length" } else { "count" } } else { method_name_raw } - if method_name == "fold" { + let algebra_field_call = rust_callable_field_method_call(method_name: method_name, receiver: receiver, args: args, registry: registry, scope: scope, depth: depth, shared_types: shared_types, emit_info: emit_info) + if algebra_field_call != none { + match algebra_field_call { Present { value: field_call } => field_call Absent => "" } + } else if method_name == "fold" { emit_rust_fold_method_call(method_call_node: method_call_node, fold_accumulator_type: fold_accumulator_type, result_type: result_type, receiver: receiver, args: args, registry: registry, scope: scope, depth: depth, shared_types: shared_types, emit_info: emit_info) } else if method_name == "sort_by" { emit_rust_sort_by_method_call(receiver: receiver, args: args, registry: registry, scope: scope, depth: depth, shared_types: shared_types, emit_info: emit_info) @@ -10448,7 +10451,12 @@ fn emit_typed_method_call(method_call_node: Node, receiver: Node, method: String } } PlainMethodSemantics => - if method == "get" && is_collection_typed_expr(texpr: receiver, source_indices: scope.type_env.source_indices) { + if rust_callable_field_method_call(method_name: method, receiver: receiver, args: args, registry: registry, scope: scope, depth: depth, shared_types: shared_types, emit_info: emit_info) != none { + match rust_callable_field_method_call(method_name: method, receiver: receiver, args: args, registry: registry, scope: scope, depth: depth, shared_types: shared_types, emit_info: emit_info) { + Present { value: field_call } => field_call + Absent => "" + } + } else if method == "get" && is_collection_typed_expr(texpr: receiver, source_indices: scope.type_env.source_indices) { emit_rust_get_method_call(receiver: receiver, args: args, registry: registry, scope: scope, depth: depth, shared_types: shared_types, emit_info: emit_info) } else { let recv_str = emit_typed_expr(texpr: receiver, registry: registry, scope: scope, depth: depth, shared_types: shared_types, emit_info: emit_info, fuel: 1024) @@ -10987,6 +10995,28 @@ fn rust_record_field_needs_fn_rc(scope: InferScope, struct_name: String, field_n // The rt_functions() name guard that stood here is gone: the ONE caller now passes // `runtime_bridge` from the resolution that decided it, so this answers only the question it is // named for -- does the receiver have a callable field by this name. +// THE RECEIVER'S OWN CALLABLE FIELD OUTRANKS EVERY NAME-KEYED TABLE, and this is the same class as +// class B one layer up. That repair stopped the algebra FALLBACK from asserting a v1_rt bridge for +// a fn-typed record field, but left the two rust_method_templates lookups in front of it keyed on +// the bare spelling -- so a field named count, first, join, split, take, skip, last, chars, +// enumerate or is_empty was still captured by a target template and emitted as `recv.count()` +// rather than `(recv.count)(..)`. Adding the is_empty row to rust_simple_method_specs is what made +// this urgent: it put a brand-new spelling in front of that table, and the spelling most likely to +// name a predicate field. +// +// A receiver that genuinely has a fn-typed field of this name is answering with its OWN structure, +// which no global roster can outrank -- so the check goes before the tables rather than after them, +// and one helper serves both arms so the two cannot drift. +fn rust_callable_field_method_call(method_name: String, receiver: Node, args: List, registry: Map, scope: InferScope, depth: Int, shared_types: Set, emit_info: EmitGraphInfo) -> String? { + if rust_receiver_has_callable_method_field(receiver: receiver, method_name: method_name, scope: scope) { + let recv_str = emit_typed_expr_base(texpr: receiver, registry: registry, scope: scope, depth: depth, shared_types: shared_types, emit_info: emit_info) + let arg_strs = args |> map(a => emit_cloned_arg(texpr: arg_value(n: a), registry: registry, scope: scope, depth: depth, shared_types: shared_types, emit_info: emit_info)) + Present { value: concat("(", recv_str, ".", emit_ident(name: method_name, target: Rust), ")(", arg_strs |> join(separator: ", "), ")") } + } else { + none + } +} + fn rust_receiver_has_callable_method_field(receiver: Node, method_name: String, scope: InferScope) -> Bool { let receiver_type = resolved_type(n: receiver) let receiver_type_name = authored_name_at(source_indices: scope.type_env.source_indices, node: receiver_type) From 54a1bbe12a20fdc6aed10565894b98e0069b8419 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 29 Aug 2026 10:32:23 +0000 Subject: [PATCH 17/75] Two more wave admissions: the declaring module rebinds too v1.compiler.infer_sigs used to DECLARE DeclaredCallableIdentity, so its own two construction sites resolved locally and produced no delta. Now that the declaration lives in v1.std.core and infer_sigs imports it, those sites rebind exactly like the consumers in infer_lookup. An enumeration error on my part, not a second transition: same subject, same trigger, same dissolve. Floor is now green on this branch (passed=2754 failed=0) -- the OrderFreeResult traversal facts closed all nine determinism rows. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01GXfYKNQTD3VfYyQcnJpxNU --- src/v1/stage0/src/namespace_wave_admission.rs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/v1/stage0/src/namespace_wave_admission.rs b/src/v1/stage0/src/namespace_wave_admission.rs index fb106ff51bb..cd17b796a93 100644 --- a/src/v1/stage0/src/namespace_wave_admission.rs +++ b/src/v1/stage0/src/namespace_wave_admission.rs @@ -426,6 +426,30 @@ pub const NAMESPACE_TRANSITION_ADMISSIONS: &[TransitionAdmission] = &[ }, disposition: NamespaceDeltaDisposition::TargetChanged, }, + // THE DECLARING MODULE REBINDS TOO, which the first four rows missed. `v1.compiler.infer_sigs` + // used to DECLARE `DeclaredCallableIdentity`, so its own two construction sites resolved + // locally and produced no delta; now that the declaration lives in `v1.std.core` and this + // module imports it, those sites rebind exactly like the consumers in `infer_lookup`. Missing + // them was an enumeration error on my part, not a second transition: same subject, same + // trigger, same dissolve. + TransitionAdmission { + label: "DeclaredCallableIdentity hoist to v1.std.core 2026-08-29", + subject: AdmissionSubject::Binding { + module: "v1.compiler.infer_sigs", + in_declaration: "lookup_resolved_sig", + spelling: "DeclaredCallableIdentity", + }, + disposition: NamespaceDeltaDisposition::TargetChanged, + }, + TransitionAdmission { + label: "DeclaredCallableIdentity hoist to v1.std.core 2026-08-29", + subject: AdmissionSubject::Binding { + module: "v1.compiler.infer_sigs", + in_declaration: "parent_closure_callable_candidates", + spelling: "DeclaredCallableIdentity", + }, + disposition: NamespaceDeltaDisposition::TargetChanged, + }, ]; /// The denominators a green must name (DESIGN §5). A run that cannot say what it covered is From 952ffa6ef49fdd11774a788d1d9769b59dc41a5e Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 29 Aug 2026 11:55:25 +0000 Subject: [PATCH 18/75] The callable-field tier was consuming the algebra profile's identity domain, not the receiver's: 202 refusals on the first compile of the converged seed rust_receiver_has_callable_method_field asked rust_record_field_needs_fn_rc, which sweeps rust_struct_field_lookup_candidates -- and that list deliberately widens a receiver's name to its container template algebra. An algebra declares its operations as arrow-typed members, so under that widening every Map receiver "has a callable field" named map_keys, map_values, lookup or get, and the tier captured the very bridge calls it sits in front of. Measured at the first compile of the round-3 converged mirror: 202 rustc refusals, one class -- 164 E0609 (no field `map_keys` on Rc>> and friends), 48 E0282, 4 E0615 on `get`. It is the same defect the tier was built to close, one level up: a name-keyed lookup consuming an identity domain that is not its own. The predicate now consults only the receiver's own declared record. w_map_receiver_operation_is_not_read_as_a_callable_field is the discriminating red: restore the candidate sweep and its must_not_contain clause fires. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01GXfYKNQTD3VfYyQcnJpxNU --- ...ed_call_target_realization_witness_test.dag | 18 ++++++++++++++++++ src/v1/05_emit_rust.dag | 16 +++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/dag/test/claim/emitted_call_target_realization_witness_test.dag b/dag/test/claim/emitted_call_target_realization_witness_test.dag index 2e620669f3f..c119cfcdccc 100644 --- a/dag/test/claim/emitted_call_target_realization_witness_test.dag +++ b/dag/test/claim/emitted_call_target_realization_witness_test.dag @@ -237,3 +237,21 @@ test fn w_callable_field_named_count_is_not_captured_by_the_target_template() -> ["c.count()"] ) } + +// THE ALGEBRA-PROFILE CONTROL FOR THE CALLABLE-FIELD TIER, and the direct regression control for +// the 202-refusal class it caused. The tier asked rust_record_field_needs_fn_rc, whose candidate +// list widens a receiver's name to its CONTAINER TEMPLATE ALGEBRA -- and an algebra declares its +// operations as arrow-typed members, so a Map receiver read as having a callable field named +// map_keys, and the tier emitted `(m.map_keys)(..)` for a call rustc then refused with E0609 no +// field `map_keys` on Rc>. The receiver here is a genuine Map, so the tier must +// decline it and the ordinary bridge lowering must survive. This is the discriminating red for +// narrowing the predicate to the receiver's OWN declared record: restore the candidate sweep and +// the must_not_contain clause fires. +test fn w_map_receiver_operation_is_not_read_as_a_callable_field() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.map_receiver_probe\nimport std.types { Int, String }\nfn probe(m: Map) -> List { map_keys(m) }\n", + "src/test_claim_map_receiver_probe.rs", + ["map_keys"], + [".map_keys)("] + ) +} diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index 7ad4a7aa490..dc7dfff8dd1 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -11036,10 +11036,24 @@ fn rust_callable_field_method_call(method_name: String, receiver: Node, args: Li } } +// THE RECEIVER'S OWN DECLARED RECORD, NEVER ITS ALGEBRA PROFILE. This asked +// rust_record_field_needs_fn_rc, which sweeps rust_struct_field_lookup_candidates -- and that +// candidate list deliberately widens a receiver's name to its container template algebra so +// FIELD-TYPE questions can be answered through the profile. An algebra declares its OPERATIONS as +// arrow-typed members, so under that widening every Map receiver "has a callable field" named +// map_keys, map_values, lookup or get, and the callable-field tier captured the very bridge calls +// it sits in front of: 202 rustc refusals on the regenerated seed (E0609 no field `map_keys` on +// Rc>, E0615 on `get`), one class, measured at the first compile of the converged +// mirror. That is the SAME defect this tier was built to close, one level up -- a name-keyed +// lookup consuming an identity domain that is not its own -- so the fix is to consume only the +// domain this question is about: a field declared on the receiver's own record. fn rust_receiver_has_callable_method_field(receiver: Node, method_name: String, scope: InferScope) -> Bool { let receiver_type = resolved_type(n: receiver) let receiver_type_name = authored_name_at(source_indices: scope.type_env.source_indices, node: receiver_type) - rust_record_field_needs_fn_rc(scope: scope, struct_name: receiver_type_name, field_name: method_name) + match rust_struct_field_type_node(scope: scope, struct_name: receiver_type_name, field_name: method_name) { + Present { value: field_type } => field_type.connective == Arrow + Absent => false + } } fn rust_struct_field_type_node_variant_aware(scope: InferScope, emit_info: EmitGraphInfo, struct_name: String, field_name: String) -> Node? { From 443f3de208b886d50623b0235181f7f6fb9c479a Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 29 Aug 2026 13:56:38 +0000 Subject: [PATCH 19/75] Regenerate the stage0 mirror at the merge-equivalent tree: byte fixed point at round 3, six paths, each explained by an authority change Convergence transaction on srv1 (/tmp/xl0c.sh -> /tmp/xl0g.log), on 952ffa6 = main b726547 merged with the branch. Criterion is BYTE equality (sha256 over the whole candidate tree vs the whole installed tree), never first_generation_equal and never the changed-path list; the full workspace is rebuilt inside every round so a non-compiling mirror stops the line. round 1 cand e212fe74 inst 6f55cf3e installed, compiles round 2 cand 932b0543 inst e212fe74 drift = v1_rt.rs only (the two-hop: v1_rt.rs is rendered by the previously compiled rt_hash_ops) round 3 cand 932b0543 inst 932b0543 BYTE FIXED POINT -- produced by a compiler rebuilt from the round-2 installed tree Changed paths and their authority: extdeps_languages_rust_emit.rs <- rt_function_registry / rust_simple_method_specs rows std_primitive_projection.rs <- symbol_lexeme / symbol_intern_lexeme roster rows v1_compiler_emit_rust.rs <- 05_emit_rust.dag (seam wall, callable-field tier, class B/C) v1_compiler_infer.rs <- 04_infer.dag projected_from on RuntimePrimitiveCall v1_compiler_runtime_rust.rs <- runtime_rust.dag symbol bridges v1_rt.rs <- same, one hop later On these bytes: function_value_named_application_controls_witness PASSES (the d805243 / 952ffa6 rust-unit-tests red was the merge-driver-refused stale v1_compiler_infer.rs, not a semantic regression); emit 175 files; cargo check 15 errors: 9 E0425 (filesystem 2, V 2, K 2, Determinism 2, T 1), 2 E0728, 2 E0107, 1 E0391, 1 UNRESOLVED_CompilerError. No hand edit to any generated file. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01GXfYKNQTD3VfYyQcnJpxNU --- .../stage0/src/extdeps_languages_rust_emit.rs | 4 +- src/v1/stage0/src/std_primitive_projection.rs | 39 ++ src/v1/stage0/src/v1_compiler_emit_rust.rs | 581 +++++++++++------- src/v1/stage0/src/v1_compiler_infer.rs | 30 +- src/v1/stage0/src/v1_compiler_runtime_rust.rs | 2 +- src/v1/stage0/src/v1_rt.rs | 14 + 6 files changed, 439 insertions(+), 231 deletions(-) diff --git a/src/v1/stage0/src/extdeps_languages_rust_emit.rs b/src/v1/stage0/src/extdeps_languages_rust_emit.rs index 455431df768..fd50682ac44 100644 --- a/src/v1/stage0/src/extdeps_languages_rust_emit.rs +++ b/src/v1/stage0/src/extdeps_languages_rust_emit.rs @@ -89,7 +89,7 @@ pub fn rust_container_templates() -> Rc> { pub fn rust_simple_method_specs() -> Rc>> { thread_local! { static CACHED: Rc>> = { - serde_json::from_value(serde_json::json!([{"method_name": "count", "template": "({recv}.len() as i64)", "wraps_result": false}, {"method_name": "join", "template": "{recv}.join(&{arg})", "wraps_result": false}, {"method_name": "split", "template": "{recv}.split(&{arg}).map(|s| s.to_string()).collect::>()", "wraps_result": true}, {"method_name": "last", "template": "{recv}.last().cloned()", "wraps_result": false}, {"method_name": "first", "template": "{recv}.first().cloned()", "wraps_result": false}, {"method_name": "enumerate", "template": "{recv}.iter().cloned().enumerate().map(|(i, v)| (i as i64, v)).collect::>()", "wraps_result": true}, {"method_name": "chars", "template": "{recv}.chars().map(|c| c as i64).collect::>()", "wraps_result": true}, {"method_name": "skip", "template": "{recv}.iter().cloned().skip({arg} as usize).collect::>()", "wraps_result": true}, {"method_name": "take", "template": "{recv}.iter().cloned().take({arg} as usize).collect::>()", "wraps_result": true}])) + serde_json::from_value(serde_json::json!([{"method_name": "count", "template": "({recv}.len() as i64)", "wraps_result": false}, {"method_name": "join", "template": "{recv}.join(&{arg})", "wraps_result": false}, {"method_name": "split", "template": "{recv}.split(&{arg}).map(|s| s.to_string()).collect::>()", "wraps_result": true}, {"method_name": "last", "template": "{recv}.last().cloned()", "wraps_result": false}, {"method_name": "first", "template": "{recv}.first().cloned()", "wraps_result": false}, {"method_name": "enumerate", "template": "{recv}.iter().cloned().enumerate().map(|(i, v)| (i as i64, v)).collect::>()", "wraps_result": true}, {"method_name": "chars", "template": "{recv}.chars().map(|c| c as i64).collect::>()", "wraps_result": true}, {"method_name": "skip", "template": "{recv}.iter().cloned().skip({arg} as usize).collect::>()", "wraps_result": true}, {"method_name": "take", "template": "{recv}.iter().cloned().take({arg} as usize).collect::>()", "wraps_result": true}, {"method_name": "is_empty", "template": "{recv}.is_empty()", "wraps_result": false}])) .expect("valid data definition") }; } @@ -525,7 +525,7 @@ pub struct RuntimeFunction { pub fn rt_function_registry() -> Rc>> { thread_local! { static CACHED: Rc>> = { - serde_json::from_value(serde_json::json!([{"name": "concat", "bridge_name": "concat", "passes_by_ref": false, "wraps_result": false}, {"name": "char_at", "bridge_name": "char_at", "passes_by_ref": true, "wraps_result": false}, {"name": "string_length", "bridge_name": "string_length", "passes_by_ref": true, "wraps_result": false}, {"name": "substring", "bridge_name": "substring", "passes_by_ref": true, "wraps_result": false}, {"name": "string_contains", "bridge_name": "string_contains", "passes_by_ref": true, "wraps_result": false}, {"name": "scan_while", "bridge_name": "scan_while", "passes_by_ref": true, "wraps_result": false}, {"name": "skip_horizontal_ws", "bridge_name": "skip_horizontal_ws", "passes_by_ref": true, "wraps_result": false}, {"name": "scan_to_eol", "bridge_name": "scan_to_eol", "passes_by_ref": true, "wraps_result": false}, {"name": "scan_string_end", "bridge_name": "scan_string_end", "passes_by_ref": true, "wraps_result": false}, {"name": "code_point", "bridge_name": "code_point", "passes_by_ref": false, "wraps_result": false}, {"name": "from_code_point", "bridge_name": "from_code_point", "passes_by_ref": false, "wraps_result": false}, {"name": "lookup", "bridge_name": "lookup", "passes_by_ref": true, "wraps_result": false}, {"name": "index_by", "bridge_name": "rc_index_by", "passes_by_ref": false, "wraps_result": false}, {"name": "empty_map", "bridge_name": "rc_empty_map", "passes_by_ref": false, "wraps_result": false}, {"name": "empty_set", "bridge_name": "rc_empty_set", "passes_by_ref": false, "wraps_result": false}, {"name": "set_insert", "bridge_name": "rc_set_insert", "passes_by_ref": false, "wraps_result": false}, {"name": "set_union", "bridge_name": "rc_set_union", "passes_by_ref": false, "wraps_result": false}, {"name": "set_contains", "bridge_name": "set_contains", "passes_by_ref": true, "wraps_result": false}, {"name": "map_insert", "bridge_name": "rc_map_insert", "passes_by_ref": false, "wraps_result": false}, {"name": "map_merge", "bridge_name": "rc_map_merge", "passes_by_ref": false, "wraps_result": false}, {"name": "list_concat", "bridge_name": "rc_list_concat", "passes_by_ref": false, "wraps_result": false}, {"name": "str_eq", "bridge_name": "str_eq", "passes_by_ref": false, "wraps_result": false}, {"name": "filesystem_read", "bridge_name": "filesystem_read", "passes_by_ref": false, "wraps_result": false}, {"name": "list_push", "bridge_name": "rc_list_push", "passes_by_ref": false, "wraps_result": false}, {"name": "map_get", "bridge_name": "map_get", "passes_by_ref": true, "wraps_result": false}, {"name": "map_keys", "bridge_name": "map_keys", "passes_by_ref": true, "wraps_result": true}, {"name": "sorted_map_keys", "bridge_name": "sorted_map_keys", "passes_by_ref": true, "wraps_result": true}, {"name": "map_values", "bridge_name": "map_values", "passes_by_ref": true, "wraps_result": true}, {"name": "parse_int", "bridge_name": "parse_int", "passes_by_ref": false, "wraps_result": false}, {"name": "map_contains_key", "bridge_name": "map_contains_key", "passes_by_ref": true, "wraps_result": false}, {"name": "map_has", "bridge_name": "map_has", "passes_by_ref": true, "wraps_result": false}, {"name": "map_is_empty", "bridge_name": "map_is_empty", "passes_by_ref": true, "wraps_result": false}, {"name": "reverse", "bridge_name": "reverse", "passes_by_ref": false, "wraps_result": false}, {"name": "replace", "bridge_name": "replace", "passes_by_ref": false, "wraps_result": false}, {"name": "chars_to_string", "bridge_name": "chars_to_string", "passes_by_ref": true, "wraps_result": false}, {"name": "record_source_chars_index_lookup", "bridge_name": "record_source_chars_index_lookup", "passes_by_ref": false, "wraps_result": false}, {"name": "resolution_silent_pick_is_enabled", "bridge_name": "resolution_silent_pick_is_enabled", "passes_by_ref": false, "wraps_result": false}, {"name": "name_resolution_policy_is_namespace_only", "bridge_name": "name_resolution_policy_is_namespace_only", "passes_by_ref": false, "wraps_result": false}, {"name": "type_ref_hit_ne_bind_measure_active", "bridge_name": "type_ref_hit_ne_bind_measure_active", "passes_by_ref": false, "wraps_result": false}, {"name": "resolution_silent_pick_record_global_bare_lcp_pick", "bridge_name": "resolution_silent_pick_record_global_bare_lcp_pick", "passes_by_ref": false, "wraps_result": false}, {"name": "resolution_silent_pick_record_global_bare_lcp_tie", "bridge_name": "resolution_silent_pick_record_global_bare_lcp_tie", "passes_by_ref": false, "wraps_result": false}, {"name": "resolution_silent_pick_record_fn_parent_first_hit", "bridge_name": "resolution_silent_pick_record_fn_parent_first_hit", "passes_by_ref": false, "wraps_result": false}, {"name": "append", "bridge_name": "append", "passes_by_ref": false, "wraps_result": true}, {"name": "contains", "bridge_name": "contains", "passes_by_ref": false, "wraps_result": false}, {"name": "starts_with", "bridge_name": "starts_with", "passes_by_ref": false, "wraps_result": false}, {"name": "ends_with", "bridge_name": "ends_with", "passes_by_ref": false, "wraps_result": false}, {"name": "trim", "bridge_name": "trim", "passes_by_ref": false, "wraps_result": false}, {"name": "count", "bridge_name": "count", "passes_by_ref": false, "wraps_result": false}, {"name": "clamp", "bridge_name": "clamp", "passes_by_ref": false, "wraps_result": false}, {"name": "atom_identity_hash", "bridge_name": "atom_identity_hash", "passes_by_ref": false, "wraps_result": false}, {"name": "hash_combine", "bridge_name": "hash_combine", "passes_by_ref": false, "wraps_result": false}, {"name": "trace_mark", "bridge_name": "trace_mark", "passes_by_ref": false, "wraps_result": false}, {"name": "rc_ptr_eq", "bridge_name": "rc_ptr_eq", "passes_by_ref": false, "wraps_result": false}, {"name": "rc_vec_ptr_eq", "bridge_name": "rc_vec_ptr_eq", "passes_by_ref": false, "wraps_result": false}, {"name": "is_xid_start", "bridge_name": "is_xid_start", "passes_by_ref": false, "wraps_result": false}, {"name": "is_xid_continue", "bridge_name": "is_xid_continue", "passes_by_ref": false, "wraps_result": false}, {"name": "is_emoji_ident", "bridge_name": "is_emoji_ident", "passes_by_ref": false, "wraps_result": false}])) + serde_json::from_value(serde_json::json!([{"name": "concat", "bridge_name": "concat", "passes_by_ref": false, "wraps_result": false}, {"name": "char_at", "bridge_name": "char_at", "passes_by_ref": true, "wraps_result": false}, {"name": "string_length", "bridge_name": "string_length", "passes_by_ref": true, "wraps_result": false}, {"name": "substring", "bridge_name": "substring", "passes_by_ref": true, "wraps_result": false}, {"name": "string_contains", "bridge_name": "string_contains", "passes_by_ref": true, "wraps_result": false}, {"name": "scan_while", "bridge_name": "scan_while", "passes_by_ref": true, "wraps_result": false}, {"name": "skip_horizontal_ws", "bridge_name": "skip_horizontal_ws", "passes_by_ref": true, "wraps_result": false}, {"name": "scan_to_eol", "bridge_name": "scan_to_eol", "passes_by_ref": true, "wraps_result": false}, {"name": "scan_string_end", "bridge_name": "scan_string_end", "passes_by_ref": true, "wraps_result": false}, {"name": "code_point", "bridge_name": "code_point", "passes_by_ref": false, "wraps_result": false}, {"name": "from_code_point", "bridge_name": "from_code_point", "passes_by_ref": false, "wraps_result": false}, {"name": "lookup", "bridge_name": "lookup", "passes_by_ref": true, "wraps_result": false}, {"name": "index_by", "bridge_name": "rc_index_by", "passes_by_ref": false, "wraps_result": false}, {"name": "empty_map", "bridge_name": "rc_empty_map", "passes_by_ref": false, "wraps_result": false}, {"name": "empty_set", "bridge_name": "rc_empty_set", "passes_by_ref": false, "wraps_result": false}, {"name": "set_insert", "bridge_name": "rc_set_insert", "passes_by_ref": false, "wraps_result": false}, {"name": "set_union", "bridge_name": "rc_set_union", "passes_by_ref": false, "wraps_result": false}, {"name": "set_contains", "bridge_name": "set_contains", "passes_by_ref": true, "wraps_result": false}, {"name": "map_insert", "bridge_name": "rc_map_insert", "passes_by_ref": false, "wraps_result": false}, {"name": "map_merge", "bridge_name": "rc_map_merge", "passes_by_ref": false, "wraps_result": false}, {"name": "list_concat", "bridge_name": "rc_list_concat", "passes_by_ref": false, "wraps_result": false}, {"name": "str_eq", "bridge_name": "str_eq", "passes_by_ref": false, "wraps_result": false}, {"name": "filesystem_read", "bridge_name": "filesystem_read", "passes_by_ref": false, "wraps_result": false}, {"name": "list_push", "bridge_name": "rc_list_push", "passes_by_ref": false, "wraps_result": false}, {"name": "map_get", "bridge_name": "map_get", "passes_by_ref": true, "wraps_result": false}, {"name": "map_keys", "bridge_name": "map_keys", "passes_by_ref": true, "wraps_result": true}, {"name": "sorted_map_keys", "bridge_name": "sorted_map_keys", "passes_by_ref": true, "wraps_result": true}, {"name": "map_values", "bridge_name": "map_values", "passes_by_ref": true, "wraps_result": true}, {"name": "parse_int", "bridge_name": "parse_int", "passes_by_ref": false, "wraps_result": false}, {"name": "map_contains_key", "bridge_name": "map_contains_key", "passes_by_ref": true, "wraps_result": false}, {"name": "map_has", "bridge_name": "map_has", "passes_by_ref": true, "wraps_result": false}, {"name": "map_is_empty", "bridge_name": "map_is_empty", "passes_by_ref": true, "wraps_result": false}, {"name": "reverse", "bridge_name": "reverse", "passes_by_ref": false, "wraps_result": false}, {"name": "replace", "bridge_name": "replace", "passes_by_ref": false, "wraps_result": false}, {"name": "chars_to_string", "bridge_name": "chars_to_string", "passes_by_ref": true, "wraps_result": false}, {"name": "record_source_chars_index_lookup", "bridge_name": "record_source_chars_index_lookup", "passes_by_ref": false, "wraps_result": false}, {"name": "resolution_silent_pick_is_enabled", "bridge_name": "resolution_silent_pick_is_enabled", "passes_by_ref": false, "wraps_result": false}, {"name": "name_resolution_policy_is_namespace_only", "bridge_name": "name_resolution_policy_is_namespace_only", "passes_by_ref": false, "wraps_result": false}, {"name": "type_ref_hit_ne_bind_measure_active", "bridge_name": "type_ref_hit_ne_bind_measure_active", "passes_by_ref": false, "wraps_result": false}, {"name": "resolution_silent_pick_record_global_bare_lcp_pick", "bridge_name": "resolution_silent_pick_record_global_bare_lcp_pick", "passes_by_ref": false, "wraps_result": false}, {"name": "resolution_silent_pick_record_global_bare_lcp_tie", "bridge_name": "resolution_silent_pick_record_global_bare_lcp_tie", "passes_by_ref": false, "wraps_result": false}, {"name": "resolution_silent_pick_record_fn_parent_first_hit", "bridge_name": "resolution_silent_pick_record_fn_parent_first_hit", "passes_by_ref": false, "wraps_result": false}, {"name": "append", "bridge_name": "append", "passes_by_ref": false, "wraps_result": true}, {"name": "contains", "bridge_name": "contains", "passes_by_ref": false, "wraps_result": false}, {"name": "starts_with", "bridge_name": "starts_with", "passes_by_ref": false, "wraps_result": false}, {"name": "ends_with", "bridge_name": "ends_with", "passes_by_ref": false, "wraps_result": false}, {"name": "trim", "bridge_name": "trim", "passes_by_ref": false, "wraps_result": false}, {"name": "count", "bridge_name": "count", "passes_by_ref": false, "wraps_result": false}, {"name": "clamp", "bridge_name": "clamp", "passes_by_ref": false, "wraps_result": false}, {"name": "atom_identity_hash", "bridge_name": "atom_identity_hash", "passes_by_ref": false, "wraps_result": false}, {"name": "hash_combine", "bridge_name": "hash_combine", "passes_by_ref": false, "wraps_result": false}, {"name": "trace_mark", "bridge_name": "trace_mark", "passes_by_ref": false, "wraps_result": false}, {"name": "rc_ptr_eq", "bridge_name": "rc_ptr_eq", "passes_by_ref": false, "wraps_result": false}, {"name": "rc_vec_ptr_eq", "bridge_name": "rc_vec_ptr_eq", "passes_by_ref": false, "wraps_result": false}, {"name": "is_xid_start", "bridge_name": "is_xid_start", "passes_by_ref": false, "wraps_result": false}, {"name": "is_xid_continue", "bridge_name": "is_xid_continue", "passes_by_ref": false, "wraps_result": false}, {"name": "is_emoji_ident", "bridge_name": "is_emoji_ident", "passes_by_ref": false, "wraps_result": false}, {"name": "symbol_lexeme", "bridge_name": "symbol_lexeme", "passes_by_ref": false, "wraps_result": false}, {"name": "symbol_intern_lexeme", "bridge_name": "symbol_intern_lexeme", "passes_by_ref": false, "wraps_result": false}])) .expect("valid data definition") }; } diff --git a/src/v1/stage0/src/std_primitive_projection.rs b/src/v1/stage0/src/std_primitive_projection.rs index dbc97abfbea..ecf7cc5961e 100644 --- a/src/v1/stage0/src/std_primitive_projection.rs +++ b/src/v1/stage0/src/std_primitive_projection.rs @@ -191,6 +191,33 @@ pub fn primitive_concept_decl_facts_live() -> Rc { CACHED.with(|c: &Rc| c.clone()) } +pub fn primitive_symbol_lexeme() -> Rc { + thread_local! { + static CACHED: Rc = { + primitive_identity_slug("symbol_lexeme".to_string()) + }; + } + CACHED.with(|c: &Rc| c.clone()) +} + +pub fn primitive_symbol_intern_lexeme() -> Rc { + thread_local! { + static CACHED: Rc = { + primitive_identity_slug("symbol_intern_lexeme".to_string()) + }; + } + CACHED.with(|c: &Rc| c.clone()) +} + +pub fn symbol_lexeme_seam_disposition_note() -> String { + thread_local! { + static CACHED: String = { + "THE TWO SYMBOL BRIDGES WERE HOST SEAMS THAT NOTHING SAID WERE HOST SEAMS, and the cost of that silence is why they are rostered here rather than left alone. v2.std.compilers.lexing symbol_lexeme and symbol_intern_lexeme have self-call bodies -- the HostRealizedSeam shape exactly, correct by construction because reaching one recurses to the evaluation-budget refusal -- and the interpreter has carried real arms for both since they were written (gunbc.v1_interpreter_primitive_surface v4_bridge.symbol_lexeme, v4_bridge.symbol_intern_lexeme). But with no roster row the RESOLVER saw an ordinary declaration, so Rust emission emitted the declaration, and `pub fn symbol_lexeme(sym: String) -> String { symbol_lexeme(sym) }` COMPILES. The emitted v2 compiler closure therefore carried two functions that type-check, pass every gate we own, and diverge from the interpreter by not terminating -- the DESIGN section 5 fabricated-plausible-output failure in its quietest form, since unlike the sibling seams (decl_facts and friends, which at least refuse loudly as unresolved v1_rt symbols) nothing anywhere reports this one.\n\nWHAT MAKES THE RUST REALIZATION HONEST RATHER THAN A SHIM: extdeps.languages.rust.types already declares Symbol's target type as String, so on that target the interning table is the identity and both bridges ARE identity functions. That is a realization of the declared row, not a second opinion about it; a target where Symbol is NOT String would need a different realization and the registry is where it would say so. The interpreter's arms and the Rust registry rows now answer for the same two primitives, which is the agreement that was missing.\n\nTHE RESIDUE IS NAMED, NOT CLOSED: a self-call body is a DECIDABLE structural marker of a host seam, so the compiler could refuse an unrealized one instead of emitting it. It does not yet, and until it does this roster is the only thing standing between a new v4_bridge declaration and another silently nonterminating emission. That check is this class's next-rung trigger.".to_string() + }; + } + CACHED.with(|c: &String| c.clone()) +} + pub fn primitive_projection_roster_note() -> String { thread_local! { static CACHED: String = { @@ -251,6 +278,18 @@ pub fn primitive_projection_roster() -> Rc>> { "empty_map_primitive_delegate".to_string(), Rc::new(ProjectionFidelity::HostRealizedSeam), ), + primitive_projection_row( + primitive_symbol_lexeme(), + "v2.std.compilers.lexing".to_string(), + "symbol_lexeme".to_string(), + Rc::new(ProjectionFidelity::HostRealizedSeam), + ), + primitive_projection_row( + primitive_symbol_intern_lexeme(), + "v2.std.compilers.lexing".to_string(), + "symbol_intern_lexeme".to_string(), + Rc::new(ProjectionFidelity::HostRealizedSeam), + ), primitive_projection_row( primitive_length(), "v2.std.algebra".to_string(), diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index 8fb74c5ea3f..9dcd2f15425 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -37,12 +37,17 @@ pub use crate::gunbc_stage0_emitted_population_manifest::{ pub use crate::std_algebra::trim; pub use crate::std_coercion::TypeCheckpoint; pub use crate::std_content_hash::Fnv1a64Structural; +pub use crate::std_decl_ref::decl_ref; +pub use crate::std_decl_ref::DeclarationRef; use crate::std_induction::SubValueRelation::SubValueUnknown; pub use crate::std_induction::{InductiveField, SubValueRelation}; pub use crate::std_measure::millisecond_count; pub use crate::std_nat::Nat; pub use crate::std_occurrence_identity::NodeOccurrenceIdentity; use crate::std_occurrence_identity::NodeOccurrenceIdentity::OccurrenceSynthetic; +pub use crate::std_primitive_projection::{ + primitive_identity_runtime_name, primitive_projection_row_for_declaration, +}; use crate::std_serialization::VariantEncoding::*; use crate::std_serialization::VariantNaming::*; pub use crate::std_serialization::{CoproductWireContract, VariantEncoding, VariantNaming}; @@ -6579,17 +6584,16 @@ pub fn collect_anonymous_record_lit_heads( } pub fn collect_items_field_import_surface_names( - items: Rc>>, + surface_names: Rc>, emit_info: Rc, - source_indices: Rc>>, ) -> Rc> { { let type_summaries = emit_info.type_summaries.clone(); let variant_to_enum = emit_info.variant_to_enum.clone(); crate::v1_compiler_emit_core_support::unique_strings(Rc::new({ let mut __result = Vec::new(); - for item in items.iter().cloned() { - __result.extend((*Rc::new({ let mut __result = Vec::new(); for type_name in collect_item_emit_surface_names(item.clone(), source_indices.clone(), emit_info.clone()).iter().cloned() { __result.extend((*{ + for type_name in surface_names.iter().cloned() { + __result.extend((*{ let summary_lookup = match v1_rt::map_get(&type_summaries, type_name.clone()) { Some(summary) => Some(summary.clone()), None => match v1_rt::map_get(&variant_to_enum, type_name.clone()) { @@ -6611,7 +6615,7 @@ match summary_lookup.clone() { }) { __result.push(field_type); } } __result }), None => Rc::new(vec![]), } -}).iter().cloned()); } __result })).iter().cloned()); +}).iter().cloned()); } __result })) @@ -8177,7 +8181,7 @@ pub fn reference_derived_use_line_plan( } __result })); - let type_surface_names = crate::v1_compiler_emit_core_support::unique_strings(Rc::new({ + let item_emit_surface_names = Rc::new({ let mut __result = Vec::new(); for item in items.iter().cloned() { __result.extend( @@ -8191,11 +8195,12 @@ pub fn reference_derived_use_line_plan( ); } __result - })); + }); + let type_surface_names = + crate::v1_compiler_emit_core_support::unique_strings(item_emit_surface_names.clone()); let field_surface_names = collect_items_field_import_surface_names( - items.clone(), + item_emit_surface_names.clone(), emit_info.clone(), - source_indices.clone(), ); let variant_payload_structs = expand_variant_payload_struct_imports( type_surface_names.clone(), @@ -8236,6 +8241,10 @@ pub fn reference_derived_use_line_plan( __result })); let emitted_source_tokens = rust_identifier_tokens(emitted_source.clone()); + let emitted_source_token_set = emitted_source_tokens.iter().cloned().fold( + v1_rt::rc_empty_map::(), + |acc: Rc>, t: String| v1_rt::rc_map_insert(acc, t.clone(), true), + ); let candidates = Rc::new({ let mut __result = Vec::new(); for name in Rc::new({ @@ -8272,16 +8281,10 @@ pub fn reference_derived_use_line_plan( } } __found - }) || { - let mut __found = false; - for t in emitted_source_tokens.iter().cloned() { - if (t.clone() == name.clone()) { - __found = true; - break; - } - } - __found - }) { + }) || crate::v1_compiler_infer_types::emit_map_has( + emitted_source_token_set.clone(), + name.clone(), + )) { __result.push(name); } } @@ -8299,16 +8302,10 @@ pub fn reference_derived_use_line_plan( .iter() .cloned() { - if { - let mut __found = false; - for token in emitted_source_tokens.iter().cloned() { - if (token.clone() == name.clone()) { - __found = true; - break; - } - } - __found - } { + if crate::v1_compiler_infer_types::emit_map_has( + emitted_source_token_set.clone(), + name.clone(), + ) { __result.push(name); } } @@ -16118,6 +16115,46 @@ pub fn v1_call_site_equality_forwarded_param_names( } } +pub fn rust_body_is_bare_self_call( + name: String, + body: Rc, + source_indices: Rc>>, +) -> bool { + match (*body.expr_data.clone()).clone() { + ExprData::ExprCall { .. } => { + (crate::v1_std_core::qualified_last_segment(crate::v1_std_core::expr_call_func_at( + body.clone(), + source_indices.clone(), + )) == name.clone()) + } + _ => false, + } +} + +pub fn rust_seam_primitive_name(module_path: String, name: String) -> String { + match crate::std_primitive_projection::primitive_projection_row_for_declaration( + crate::std_decl_ref::decl_ref(module_path.clone(), name.clone()), + ) { + Some(row) => { + crate::std_primitive_projection::primitive_identity_runtime_name(row.primitive.clone()) + } + None => name.clone(), + } +} + +pub fn rust_host_seam_is_unrealized( + module_path: String, + name: String, + body: Rc, + source_indices: Rc>>, +) -> bool { + (rust_body_is_bare_self_call(name.clone(), body.clone(), source_indices.clone()) + && (rust_runtime_primitive_has_bridge(rust_seam_primitive_name( + module_path.clone(), + name.clone(), + )) == false)) +} + pub fn emit_fn_def( name: String, params: Rc>>, @@ -16287,6 +16324,17 @@ pub fn emit_fn_def( registry.clone(), si.clone(), ) && (use_tco.clone() == false)); + if rust_host_seam_is_unrealized( + scope.module_name.clone(), + name.clone(), + body.clone(), + si.clone(), + ) { + { + let kw = rust_items().func_keyword.clone(); + return v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visibility_prefix(), kw.clone()), " ".to_string()), crate::v1_compiler_emit::emit_ident(name.clone(), RenderTarget::Rust)), type_params_str.clone()), "(".to_string()), params_str.clone()), ")".to_string()), ret_str.clone()), " {\n".to_string()), crate::v1_compiler_emit_core_support::make_indent(1)), "panic!(\"unrealized host seam '".to_string()), name.clone()), "' in ".to_string()), scope.module_name.clone()), ": this declaration's whole body is a self-call, so it has no behaviour on this target. ".to_string()), "It compiles as a refusal rather than as recursion. Give it a row in ".to_string()), "extdeps.languages.rust.emit rt_function_registry and a body in v1.runtime_rust, or delete its consumers.\")\n}".to_string()); + } + } if use_tco.clone() { { let tco_params_str = emit_tco_params( @@ -24947,22 +24995,27 @@ pub fn emit_typed_method_call( } else { method_name_raw.clone() }; - if (method_name.clone() == "fold".to_string()) { - emit_rust_fold_method_call( - method_call_node.clone(), - fold_accumulator_type.clone(), - result_type.clone(), - receiver.clone(), - args.clone(), - registry.clone(), - scope.clone(), - depth.clone(), - shared_types.clone(), - emit_info.clone(), - ) + let algebra_field_call = rust_callable_field_method_call( + method_name.clone(), + receiver.clone(), + args.clone(), + registry.clone(), + scope.clone(), + depth.clone(), + shared_types.clone(), + emit_info.clone(), + ); + if (algebra_field_call.clone() != None) { + match algebra_field_call.clone() { + Some(field_call) => field_call.clone(), + None => "".to_string(), + } } else { - if (method_name.clone() == "sort_by".to_string()) { - emit_rust_sort_by_method_call( + if (method_name.clone() == "fold".to_string()) { + emit_rust_fold_method_call( + method_call_node.clone(), + fold_accumulator_type.clone(), + result_type.clone(), receiver.clone(), args.clone(), registry.clone(), @@ -24972,8 +25025,8 @@ pub fn emit_typed_method_call( emit_info.clone(), ) } else { - if (method_name.clone() == "map".to_string()) { - emit_rust_map_method_call( + if (method_name.clone() == "sort_by".to_string()) { + emit_rust_sort_by_method_call( receiver.clone(), args.clone(), registry.clone(), @@ -24983,20 +25036,8 @@ pub fn emit_typed_method_call( emit_info.clone(), ) } else { - match Rc::new({ - let mut __result = Vec::new(); - for s in rust_higher_order_methods().iter().cloned() { - if (s.method_name.clone() == method_name.clone()) { - __result.push(s); - } - } - __result - }) - .first() - .cloned() - { - Some(ho_spec) => emit_rust_higher_order_method( - ho_spec.clone(), + if (method_name.clone() == "map".to_string()) { + emit_rust_map_method_call( receiver.clone(), args.clone(), registry.clone(), @@ -25004,21 +25045,33 @@ pub fn emit_typed_method_call( depth.clone(), shared_types.clone(), emit_info.clone(), - ), - None => { - if (method_name.clone() == "get".to_string()) { - emit_rust_get_method_call( - receiver.clone(), - args.clone(), - registry.clone(), - scope.clone(), - depth.clone(), - shared_types.clone(), - emit_info.clone(), - ) - } else { - if (method_name.clone() == "with".to_string()) { - emit_rust_with_method_call( + ) + } else { + match Rc::new({ + let mut __result = Vec::new(); + for s in rust_higher_order_methods().iter().cloned() { + if (s.method_name.clone() == method_name.clone()) { + __result.push(s); + } + } + __result + }) + .first() + .cloned() + { + Some(ho_spec) => emit_rust_higher_order_method( + ho_spec.clone(), + receiver.clone(), + args.clone(), + registry.clone(), + scope.clone(), + depth.clone(), + shared_types.clone(), + emit_info.clone(), + ), + None => { + if (method_name.clone() == "get".to_string()) { + emit_rust_get_method_call( receiver.clone(), args.clone(), registry.clone(), @@ -25028,15 +25081,10 @@ pub fn emit_typed_method_call( emit_info.clone(), ) } else { - if (method_name.clone() - == "string_contains".to_string()) - { - emit_rust_generic_method_call( - "string_contains".to_string(), + if (method_name.clone() == "with".to_string()) { + emit_rust_with_method_call( receiver.clone(), args.clone(), - result_type.clone(), - true, registry.clone(), scope.clone(), depth.clone(), @@ -25044,58 +25092,26 @@ pub fn emit_typed_method_call( emit_info.clone(), ) } else { - if (method_name.clone() == "concat".to_string()) { - { - let recv_str = emit_typed_expr( - receiver.clone(), - registry.clone(), - scope.clone(), - depth.clone(), - shared_types.clone(), - emit_info.clone(), - 1024, - ); - let arg_strs = Rc::new({ - let mut __result = Vec::new(); - for a in args.iter().cloned() { - __result.push(emit_typed_expr( - crate::v1_std_core::arg_value( - a.clone(), - ), - registry.clone(), - scope.clone(), - depth.clone(), - shared_types.clone(), - emit_info.clone(), - 1024, - )); - } - __result - }); - let all_arg_strs = v1_rt::concat( - Rc::new(vec![recv_str.clone()]), - arg_strs.clone(), - ); - emit_nested_rt_concat( - all_arg_strs.clone(), - "".to_string(), - shared_types.clone(), - ) - } + if (method_name.clone() + == "string_contains".to_string()) + { + emit_rust_generic_method_call( + "string_contains".to_string(), + receiver.clone(), + args.clone(), + result_type.clone(), + true, + registry.clone(), + scope.clone(), + depth.clone(), + shared_types.clone(), + emit_info.clone(), + ) } else { - if (method_name.clone() == "first".to_string()) + if (method_name.clone() == "concat".to_string()) { - emit_rust_first_method_call( - receiver.clone(), - registry.clone(), - scope.clone(), - depth.clone(), - shared_types.clone(), - emit_info.clone(), - ) - } else { { - let recv_str_raw = emit_typed_expr( + let recv_str = emit_typed_expr( receiver.clone(), registry.clone(), scope.clone(), @@ -25104,35 +25120,76 @@ pub fn emit_typed_method_call( emit_info.clone(), 1024, ); - let recv_is_optional = (crate::v1_compiler_infer_types::resolved_type(receiver.clone()).return_cardinality.clone() == Cardinality::CardOptional); - let recv_str = if recv_is_optional - .clone() + let arg_strs = Rc::new({ + let mut __result = Vec::new(); + for a in args.iter().cloned() { + __result.push(emit_typed_expr(crate::v1_std_core::arg_value(a.clone()), registry.clone(), scope.clone(), depth.clone(), shared_types.clone(), emit_info.clone(), 1024)); + } + __result + }); + let all_arg_strs = v1_rt::concat( + Rc::new(vec![recv_str.clone()]), + arg_strs.clone(), + ); + emit_nested_rt_concat( + all_arg_strs.clone(), + "".to_string(), + shared_types.clone(), + ) + } + } else { + if (method_name.clone() + == "first".to_string()) + { + emit_rust_first_method_call( + receiver.clone(), + registry.clone(), + scope.clone(), + depth.clone(), + shared_types.clone(), + emit_info.clone(), + ) + } else { { - v1_rt::concat(recv_str_raw.clone(), v1_rt::concat(".expect(\"fail-closed: Optional receiver for method ".to_string(), v1_rt::concat(method_name.clone(), " (empty Optional at runtime)\")".to_string()))) - } else { - recv_str_raw.clone() - }; - let first_arg_str = - emit_typed_first_arg( - args.clone(), + let recv_str_raw = emit_typed_expr( + receiver.clone(), registry.clone(), scope.clone(), depth.clone(), shared_types.clone(), emit_info.clone(), + 1024, ); - match v1_rt::map_get(&crate::extdeps_languages_rust_emit::rust_method_templates(), method_name.clone()) { + let recv_is_optional = (crate::v1_compiler_infer_types::resolved_type(receiver.clone()).return_cardinality.clone() == Cardinality::CardOptional); + let recv_str = if recv_is_optional + .clone() + { + v1_rt::concat(recv_str_raw.clone(), v1_rt::concat(".expect(\"fail-closed: Optional receiver for method ".to_string(), v1_rt::concat(method_name.clone(), " (empty Optional at runtime)\")".to_string()))) + } else { + recv_str_raw.clone() + }; + let first_arg_str = + emit_typed_first_arg( + args.clone(), + registry.clone(), + scope.clone(), + depth.clone(), + shared_types.clone(), + emit_info.clone(), + ); + match v1_rt::map_get(&crate::extdeps_languages_rust_emit::rust_method_templates(), method_name.clone()) { Some(tmpl) => { - let bindings = v1_rt::rc_map_insert(crate::v1_compiler_emit::seed_bindings("recv".to_string(), recv_str.clone()), "arg".to_string(), first_arg_str.clone()); + let bindings = v1_rt::rc_map_insert(crate::v1_compiler_emit::seed_bindings("recv".to_string(), recv_str.clone()), "arg".to_string(), first_arg_str.clone()); let raw = crate::v1_compiler_emit_core_support::apply_named_template(tmpl.clone(), bindings.clone()); if rust_method_template_result_wraps_in_rc(method_name.clone()) { - rust_shared_wrap_ctor(raw.clone()) - } else { - raw.clone() - } + rust_shared_wrap_ctor(raw.clone()) + } else { + raw.clone() + } }, None => emit_rust_generic_method_call(method_name.clone(), receiver.clone(), args.clone(), result_type.clone(), rust_runtime_primitive_has_bridge(method_name.clone()), registry.clone(), scope.clone(), depth.clone(), shared_types.clone(), emit_info.clone()), } + } } } } @@ -25146,13 +25203,19 @@ if rust_method_template_result_wraps_in_rc(method_name.clone()) { } } MethodSemantics::PlainMethodSemantics => { - if ((method.clone() == "get".to_string()) - && is_collection_typed_expr( - receiver.clone(), - scope.type_env.clone().source_indices.clone(), - )) + if (rust_callable_field_method_call( + method.clone(), + receiver.clone(), + args.clone(), + registry.clone(), + scope.clone(), + depth.clone(), + shared_types.clone(), + emit_info.clone(), + ) != None) { - emit_rust_get_method_call( + match rust_callable_field_method_call( + method.clone(), receiver.clone(), args.clone(), registry.clone(), @@ -25160,83 +25223,106 @@ if rust_method_template_result_wraps_in_rc(method_name.clone()) { depth.clone(), shared_types.clone(), emit_info.clone(), - ) + ) { + Some(field_call) => field_call.clone(), + None => "".to_string(), + } } else { + if ((method.clone() == "get".to_string()) + && is_collection_typed_expr( + receiver.clone(), + scope.type_env.clone().source_indices.clone(), + )) { - let recv_str = emit_typed_expr( + emit_rust_get_method_call( receiver.clone(), + args.clone(), registry.clone(), scope.clone(), depth.clone(), shared_types.clone(), emit_info.clone(), - 1024, - ); - match v1_rt::map_get( - &crate::extdeps_languages_rust_emit::rust_method_templates(), - method.clone(), - ) { - Some(tmpl) => { - let first_arg_str = emit_typed_first_arg( - args.clone(), - registry.clone(), - scope.clone(), - depth.clone(), - shared_types.clone(), - emit_info.clone(), - ); - let bindings = v1_rt::rc_map_insert( - crate::v1_compiler_emit::seed_bindings( - "recv".to_string(), - recv_str.clone(), - ), - "arg".to_string(), - first_arg_str.clone(), - ); - let raw = - crate::v1_compiler_emit_core_support::apply_named_template( - tmpl.clone(), - bindings.clone(), + ) + } else { + { + let recv_str = emit_typed_expr( + receiver.clone(), + registry.clone(), + scope.clone(), + depth.clone(), + shared_types.clone(), + emit_info.clone(), + 1024, + ); + match v1_rt::map_get( + &crate::extdeps_languages_rust_emit::rust_method_templates(), + method.clone(), + ) { + Some(tmpl) => { + let first_arg_str = emit_typed_first_arg( + args.clone(), + registry.clone(), + scope.clone(), + depth.clone(), + shared_types.clone(), + emit_info.clone(), ); - if rust_method_template_result_wraps_in_rc(method.clone()) { - rust_shared_wrap_ctor(raw.clone()) - } else { - raw.clone() - } - } - None => { - let arg_strs = Rc::new({ - let mut __result = Vec::new(); - for a in args.iter().cloned() { - __result.push(emit_typed_expr( - crate::v1_std_core::arg_value(a.clone()), - registry.clone(), - scope.clone(), - depth.clone(), - shared_types.clone(), - emit_info.clone(), - 1024, - )); + let bindings = v1_rt::rc_map_insert( + crate::v1_compiler_emit::seed_bindings( + "recv".to_string(), + recv_str.clone(), + ), + "arg".to_string(), + first_arg_str.clone(), + ); + let raw = + crate::v1_compiler_emit_core_support::apply_named_template( + tmpl.clone(), + bindings.clone(), + ); + if rust_method_template_result_wraps_in_rc(method.clone()) { + rust_shared_wrap_ctor(raw.clone()) + } else { + raw.clone() } - __result - }); - let args_str = arg_strs.clone().join(&", ".to_string()); - v1_rt::concat( + } + None => { + let arg_strs = Rc::new({ + let mut __result = Vec::new(); + for a in args.iter().cloned() { + __result.push(emit_typed_expr( + crate::v1_std_core::arg_value(a.clone()), + registry.clone(), + scope.clone(), + depth.clone(), + shared_types.clone(), + emit_info.clone(), + 1024, + )); + } + __result + }); + let args_str = arg_strs.clone().join(&", ".to_string()); v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat(recv_str.clone(), ".".to_string()), - crate::v1_compiler_emit::emit_ident( - method.clone(), - RenderTarget::Rust, + v1_rt::concat( + v1_rt::concat( + recv_str.clone(), + ".".to_string(), + ), + crate::v1_compiler_emit::emit_ident( + method.clone(), + RenderTarget::Rust, + ), ), + "(".to_string(), ), - "(".to_string(), + args_str.clone(), ), - args_str.clone(), - ), - ")".to_string(), - ) + ")".to_string(), + ) + } } } } @@ -26762,6 +26848,66 @@ pub fn rust_record_field_needs_fn_rc( } } +pub fn rust_callable_field_method_call( + method_name: String, + receiver: Rc, + args: Rc>>, + registry: Rc>>, + scope: Rc, + depth: i64, + shared_types: Rc>, + emit_info: Rc, +) -> Option { + if rust_receiver_has_callable_method_field(receiver.clone(), method_name.clone(), scope.clone()) + { + { + let recv_str = emit_typed_expr_base( + receiver.clone(), + registry.clone(), + scope.clone(), + depth.clone(), + shared_types.clone(), + emit_info.clone(), + ); + let arg_strs = Rc::new({ + let mut __result = Vec::new(); + for a in args.iter().cloned() { + __result.push(emit_cloned_arg( + crate::v1_std_core::arg_value(a.clone()), + registry.clone(), + scope.clone(), + depth.clone(), + shared_types.clone(), + emit_info.clone(), + )); + } + __result + }); + Some(v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat("(".to_string(), recv_str.clone()), + ".".to_string(), + ), + crate::v1_compiler_emit::emit_ident( + method_name.clone(), + RenderTarget::Rust, + ), + ), + ")(".to_string(), + ), + arg_strs.clone().join(&", ".to_string()), + ), + ")".to_string(), + )) + } + } else { + None + } +} + pub fn rust_receiver_has_callable_method_field( receiver: Rc, method_name: String, @@ -26773,11 +26919,14 @@ pub fn rust_receiver_has_callable_method_field( scope.type_env.clone().source_indices.clone(), receiver_type.clone(), ); - rust_record_field_needs_fn_rc( + match rust_struct_field_type_node( scope.clone(), receiver_type_name.clone(), method_name.clone(), - ) + ) { + Some(field_type) => (field_type.connective.clone() == Connective::Arrow), + None => false, + } } } diff --git a/src/v1/stage0/src/v1_compiler_infer.rs b/src/v1/stage0/src/v1_compiler_infer.rs index 79504f5b9fa..99b310179bc 100644 --- a/src/v1/stage0/src/v1_compiler_infer.rs +++ b/src/v1/stage0/src/v1_compiler_infer.rs @@ -4882,18 +4882,24 @@ pub fn direct_call_argument_inhabitance_diags( __result.extend( (*match app.matched_arg.clone() { Some(ta) => { - let actual_expr = crate::v1_std_core::arg_value(ta.clone()); - declared_type_obligation_diags( - Rc::new(DeclaredTypeObligation { - position: DeclaredTypePosition::PositionDirectCallArgument, - declared: app.formal_subst.clone(), - produced: crate::v1_compiler_infer_types::resolved_type( - actual_expr.clone(), - ), - span: actual_expr.span.clone(), - }), - scope.clone(), - ) + if type_node_is_callable(app.formal_subst.clone()) { + Rc::new(vec![]) + } else { + { + let actual_expr = crate::v1_std_core::arg_value(ta.clone()); + declared_type_obligation_diags( + Rc::new(DeclaredTypeObligation { + position: DeclaredTypePosition::PositionDirectCallArgument, + declared: app.formal_subst.clone(), + produced: crate::v1_compiler_infer_types::resolved_type( + actual_expr.clone(), + ), + span: actual_expr.span.clone(), + }), + scope.clone(), + ) + } + } } None => Rc::new(vec![]), }) diff --git a/src/v1/stage0/src/v1_compiler_runtime_rust.rs b/src/v1/stage0/src/v1_compiler_runtime_rust.rs index 7711aa64f38..a6e3c928605 100644 --- a/src/v1/stage0/src/v1_compiler_runtime_rust.rs +++ b/src/v1/stage0/src/v1_compiler_runtime_rust.rs @@ -36,7 +36,7 @@ pub fn rt_concat_trait() -> String { } pub fn rt_string_ops() -> String { - v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("/// Code-point indexing over UTF-8, with the ASCII fast path bounded by `pos`\n".to_string(), "/// rather than by the whole string. A leading run of ASCII bytes makes the byte\n".to_string()), "/// offset equal the code-point offset, so nothing past `pos` is examined and the\n".to_string()), "/// per-call whole-string `s.is_ascii()` rescan is gone (STRING-INDEX-0). Cost is\n".to_string()), "/// O(min(pos, n)) -- the fallback's own cost -- never O(n) unconditionally.\n".to_string()), "/// This is the entry point for a caller holding a bare `&str` and therefore no ASCII\n".to_string()), "/// fact: it must test, and O(min(pos, n)) is the cheapest honest test. A caller that\n".to_string()), "/// holds an `RcStr` carries the fact instead and calls `RcStr::char_at`, which is\n".to_string()), "/// O(1) on ASCII text; the interpreter routes every string index that way.\n".to_string()), "/// RESIDUAL: a left-to-right walk through THIS function is still O(n^2), and a walk\n".to_string()), "/// through the carrier is linear rather than constant per string -- a cursor surface\n".to_string()), "/// that does not re-index from zero is that residual's next rung.\n".to_string()), "pub fn char_at(s: &str, pos: i64) -> String {\n".to_string()), " let pos = pos.max(0) as usize;\n".to_string()), " let bytes = s.as_bytes();\n".to_string()), " if pos >= bytes.len() { return String::new(); }\n".to_string()), " if bytes[..=pos].is_ascii() { return String::from(bytes[pos] as char); }\n".to_string()), " s.chars().nth(pos).map(|ch| ch.to_string()).unwrap_or_default()\n".to_string()), "}\n\n".to_string()), "pub fn string_length(s: &str) -> i64 {\n".to_string()), " if s.is_ascii() { s.len() as i64 } else { s.chars().count() as i64 }\n".to_string()), "}\n\n".to_string()), "/// See `char_at`: the ASCII fast path is bounded by `end`, not by the whole string.\n".to_string()), "pub fn substring(s: &str, start: i64, end: i64) -> String {\n".to_string()), " let start = start.max(0) as usize;\n".to_string()), " let end = end.max(0) as usize;\n".to_string()), " if end <= start { return String::new(); }\n".to_string()), " let bytes = s.as_bytes();\n".to_string()), " if start >= bytes.len() { return String::new(); }\n".to_string()), " let out_end = end.min(bytes.len());\n".to_string()), " if bytes[..out_end].is_ascii() {\n".to_string()), " let take_len = out_end.saturating_sub(start);\n".to_string()), " record_substring_chars_walked(s, start, take_len);\n".to_string()), " return s[start..out_end].to_string();\n".to_string()), " }\n".to_string()), " let take_len = end.saturating_sub(start);\n".to_string()), " record_substring_chars_walked(s, start, take_len);\n".to_string()), " s.chars().skip(start).take(take_len).collect()\n".to_string()), "}\n\n".to_string()), "pub fn string_contains(s: &str, sub: String) -> bool {\n".to_string()), " s.contains(&*sub)\n".to_string()), "}\n\n".to_string()), "pub fn contains(s: String, sub: String) -> bool { string_contains(&s, sub) }\n\n".to_string()), "pub fn starts_with(s: String, prefix: String) -> bool { s.starts_with(&*prefix) }\n\n".to_string()), "pub fn ends_with(s: String, suffix: String) -> bool { s.ends_with(&*suffix) }\n\n".to_string()), "pub fn trim(s: String) -> String { s.trim().to_string() }\n\n".to_string()), "pub fn count(items: Rc>) -> i64 { items.len() as i64 }\n\n".to_string()), "pub fn str_eq(a: String, b: String) -> bool { a == b }\n\n".to_string()), "pub fn to_string(value: i64) -> String { value.to_string() }\n\n".to_string()), "/// RFC 3629 UTF-8 decode of a byte vector. Fail-closed on invalid UTF-8.\n".to_string()), "pub fn utf8_decode_bytes(bytes: &[u8]) -> Result {\n".to_string()), " String::from_utf8(bytes.to_vec()).map_err(|e| format!(\"invalid UTF-8 in access payload: {}\", e))\n".to_string()), "}\n\n".to_string()), "pub fn clamp(val: i64, min_val: i64, max_val: i64) -> i64 {\n".to_string()), " val.clamp(min_val, max_val)\n".to_string()), "}\n\n".to_string()) + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("/// Code-point indexing over UTF-8, with the ASCII fast path bounded by `pos`\n".to_string(), "/// rather than by the whole string. A leading run of ASCII bytes makes the byte\n".to_string()), "/// offset equal the code-point offset, so nothing past `pos` is examined and the\n".to_string()), "/// per-call whole-string `s.is_ascii()` rescan is gone (STRING-INDEX-0). Cost is\n".to_string()), "/// O(min(pos, n)) -- the fallback's own cost -- never O(n) unconditionally.\n".to_string()), "/// This is the entry point for a caller holding a bare `&str` and therefore no ASCII\n".to_string()), "/// fact: it must test, and O(min(pos, n)) is the cheapest honest test. A caller that\n".to_string()), "/// holds an `RcStr` carries the fact instead and calls `RcStr::char_at`, which is\n".to_string()), "/// O(1) on ASCII text; the interpreter routes every string index that way.\n".to_string()), "/// RESIDUAL: a left-to-right walk through THIS function is still O(n^2), and a walk\n".to_string()), "/// through the carrier is linear rather than constant per string -- a cursor surface\n".to_string()), "/// that does not re-index from zero is that residual's next rung.\n".to_string()), "pub fn char_at(s: &str, pos: i64) -> String {\n".to_string()), " let pos = pos.max(0) as usize;\n".to_string()), " let bytes = s.as_bytes();\n".to_string()), " if pos >= bytes.len() { return String::new(); }\n".to_string()), " if bytes[..=pos].is_ascii() { return String::from(bytes[pos] as char); }\n".to_string()), " s.chars().nth(pos).map(|ch| ch.to_string()).unwrap_or_default()\n".to_string()), "}\n\n".to_string()), "pub fn string_length(s: &str) -> i64 {\n".to_string()), " if s.is_ascii() { s.len() as i64 } else { s.chars().count() as i64 }\n".to_string()), "}\n\n".to_string()), "/// The two symbol bridges. `Symbol` is declared to realize as `String` on this target\n".to_string()), "/// (extdeps.languages.rust.types), so interning and its inverse are both the identity\n".to_string()), "/// HERE and nowhere else: a target whose Symbol is a table index needs a real table, and\n".to_string()), "/// its registry rows would say so. These exist because the .dag declarations are\n".to_string()), "/// self-calls -- host seams -- and emitting a self-call produces a function that compiles\n".to_string()), "/// and never returns (std.primitive_projection symbol_lexeme_seam_disposition_note).\n".to_string()), "pub fn symbol_lexeme(sym: String) -> String {\n".to_string()), " sym\n".to_string()), "}\n\n".to_string()), "pub fn symbol_intern_lexeme(lexeme: String) -> String {\n".to_string()), " lexeme\n".to_string()), "}\n\n".to_string()), "/// See `char_at`: the ASCII fast path is bounded by `end`, not by the whole string.\n".to_string()), "pub fn substring(s: &str, start: i64, end: i64) -> String {\n".to_string()), " let start = start.max(0) as usize;\n".to_string()), " let end = end.max(0) as usize;\n".to_string()), " if end <= start { return String::new(); }\n".to_string()), " let bytes = s.as_bytes();\n".to_string()), " if start >= bytes.len() { return String::new(); }\n".to_string()), " let out_end = end.min(bytes.len());\n".to_string()), " if bytes[..out_end].is_ascii() {\n".to_string()), " let take_len = out_end.saturating_sub(start);\n".to_string()), " record_substring_chars_walked(s, start, take_len);\n".to_string()), " return s[start..out_end].to_string();\n".to_string()), " }\n".to_string()), " let take_len = end.saturating_sub(start);\n".to_string()), " record_substring_chars_walked(s, start, take_len);\n".to_string()), " s.chars().skip(start).take(take_len).collect()\n".to_string()), "}\n\n".to_string()), "pub fn string_contains(s: &str, sub: String) -> bool {\n".to_string()), " s.contains(&*sub)\n".to_string()), "}\n\n".to_string()), "pub fn contains(s: String, sub: String) -> bool { string_contains(&s, sub) }\n\n".to_string()), "pub fn starts_with(s: String, prefix: String) -> bool { s.starts_with(&*prefix) }\n\n".to_string()), "pub fn ends_with(s: String, suffix: String) -> bool { s.ends_with(&*suffix) }\n\n".to_string()), "pub fn trim(s: String) -> String { s.trim().to_string() }\n\n".to_string()), "pub fn count(items: Rc>) -> i64 { items.len() as i64 }\n\n".to_string()), "pub fn str_eq(a: String, b: String) -> bool { a == b }\n\n".to_string()), "pub fn to_string(value: i64) -> String { value.to_string() }\n\n".to_string()), "/// RFC 3629 UTF-8 decode of a byte vector. Fail-closed on invalid UTF-8.\n".to_string()), "pub fn utf8_decode_bytes(bytes: &[u8]) -> Result {\n".to_string()), " String::from_utf8(bytes.to_vec()).map_err(|e| format!(\"invalid UTF-8 in access payload: {}\", e))\n".to_string()), "}\n\n".to_string()), "pub fn clamp(val: i64, min_val: i64, max_val: i64) -> i64 {\n".to_string()), " val.clamp(min_val, max_val)\n".to_string()), "}\n\n".to_string()) } pub fn rt_collection_ops() -> String { diff --git a/src/v1/stage0/src/v1_rt.rs b/src/v1/stage0/src/v1_rt.rs index 97af46d127e..30f3c637d47 100644 --- a/src/v1/stage0/src/v1_rt.rs +++ b/src/v1/stage0/src/v1_rt.rs @@ -309,6 +309,20 @@ pub fn string_length(s: &str) -> i64 { } } +/// The two symbol bridges. `Symbol` is declared to realize as `String` on this target +/// (extdeps.languages.rust.types), so interning and its inverse are both the identity +/// HERE and nowhere else: a target whose Symbol is a table index needs a real table, and +/// its registry rows would say so. These exist because the .dag declarations are +/// self-calls -- host seams -- and emitting a self-call produces a function that compiles +/// and never returns (std.primitive_projection symbol_lexeme_seam_disposition_note). +pub fn symbol_lexeme(sym: String) -> String { + sym +} + +pub fn symbol_intern_lexeme(lexeme: String) -> String { + lexeme +} + /// See `char_at`: the ASCII fast path is bounded by `end`, not by the whole string. pub fn substring(s: &str, start: i64, end: i64) -> String { let start = start.max(0) as usize; From aeded616fcf17a5476152fbc0f9f0a8c729fe9f3 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 29 Aug 2026 14:14:45 +0000 Subject: [PATCH 20/75] WIP tail classes --- ...d_call_target_realization_witness_test.dag | 99 +++++++++++++ src/v1/05_emit_rust.dag | 133 ++++++++++++++++-- 2 files changed, 224 insertions(+), 8 deletions(-) diff --git a/dag/test/claim/emitted_call_target_realization_witness_test.dag b/dag/test/claim/emitted_call_target_realization_witness_test.dag index c119cfcdccc..cc462a5376e 100644 --- a/dag/test/claim/emitted_call_target_realization_witness_test.dag +++ b/dag/test/claim/emitted_call_target_realization_witness_test.dag @@ -255,3 +255,102 @@ test fn w_map_receiver_operation_is_not_read_as_a_callable_field() -> Bool { [".map_keys)("] ) } + +// --------------------------------------------------------------------------------------------- +// THE TAIL CLASSES: the fifteen rustc refusals that remained on the 00_compile closure once the +// three families above were closed, one discriminating row per emitter defect. Each row's +// must_not_contain is the exact malformed spelling the emitter produced, so a revert of that one +// repair reddens exactly that row. +// --------------------------------------------------------------------------------------------- + +// WITNESS CARRIER, THE DISCRIMINATING RED. A Holds value bound through a NESTED record pattern can +// reach emission with its produced identity erased; the turbofish then rendered the erasure itself: +// `Witness::::Holds`. The enclosing fn's declared return +// is the carrier authority and must be what the arm falls back to. +test fn w_witness_carrier_falls_back_to_the_fn_return_when_the_value_identity_is_erased() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.witness_carrier_probe\nimport std.types { Int }\nimport std.algebra { Cons, Empty }\nimport v2.std.algebra { fold_list, list_snoc_item }\nimport v2.std.witness { Holds, Violates, Witness }\nimport v2.std.diagnostic { Diagnostic }\ntype Progress { edges: List, index: Int }\nfn step(p: Witness, x: Int) -> Witness { match p { Holds { value: Progress { edges: es, index: i } } => Holds { value: Progress { edges: list_snoc_item(xs: es, item: x), index: i + 1 } } Violates { diagnostic: d } => Violates { diagnostic: d } } }\nfn probe(xs: List) -> Witness> { match fold_list(xs: xs, empty: Holds { value: Progress { edges: Empty, index: 0 } }, cons: fn(p, x) { step(p: p, x: x) }) { Holds { value: Progress { edges: result, index: _ } } => Holds { value: result } Violates { diagnostic: d } => Violates { diagnostic: d } } }\n", + "src/test_claim_witness_carrier_probe.rs", + ["Witness::<"], + ["UNRESOLVED_CompilerError"] + ) +} + +// FOLD ACCUMULATOR, THE DISCRIMINATING RED. A fold whose init is empty_map() took the Map +// declaration's own formals as its accumulator and wrote them into the turbofish: +// `v1_rt::rc_empty_map::()`. The fn's declared Map return is the resolved +// accumulator and must be what the init renders from. +test fn w_fold_empty_map_init_renders_the_resolved_accumulator_not_the_declaration_formals() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.fold_accumulator_probe\nimport std.types { Int, String, Map }\nimport v2.std.node { Symbol }\nimport v2.std.collection { empty_map, map_insert }\ntype Row { field: Symbol, carrier: Symbol }\nfn rows() -> List { [Row { field: ^a, carrier: ^b }] }\nfn probe() -> Map { fold(rows(), init: empty_map(), f: fn(acc, row) { map_insert(m: acc, key: row.field, value: row.carrier) }) }\n", + "src/test_claim_fold_accumulator_probe.rs", + ["rc_empty_map::<"], + ["rc_empty_map::"] + ) +} + +// LAMBDA PARAMETER ANNOTATION, THE DISCRIMINATING RED. A closure parameter whose inferred type +// carries a formal no fn generic binds (`FreeMonoid`) was annotated with it verbatim, a type the +// closure cannot name. The annotation must decline exactly as the fold element annotation does. +test fn w_lambda_param_annotation_declines_a_spurious_generic() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.lambda_annotation_probe\nimport std.types { Bool }\nimport std.algebra { Cons, Empty }\nimport v2.std.node { Symbol }\nfn has(xs: List, s: Symbol) -> Bool { match xs { Empty => false Cons { head: h, tail: t } => if h == s { true } else { has(xs: t, s: s) } } }\nfn probe(hits: List, accepted: List) -> Bool { match hits { Empty => false Cons { head: first_hit, tail: rest_hits } => fold(Cons { head: first_hit, tail: rest_hits }, init: true, f: fn(acc, a) { acc && has(xs: accepted, s: a) }) } }\n", + "src/test_claim_lambda_annotation_probe.rs", + ["|acc: bool"], + ["FreeMonoid>|"] + ) +} + +// ZERO-PARAMETER ALIAS, THE DISCRIMINATING RED. An alias over a parameterized type, referenced as +// the return of an arrow type, rendered with the arguments of what it abbreviates: +// `Gate = Rc Outc>>>` (E0107, with the E0391 variance cycle rustc +// reports beside it). The alias is zero-parameter and must render bare. +test fn w_zero_param_alias_in_an_arrow_return_renders_without_its_rhs_arguments() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.alias_arrow_probe\nimport std.types { Int }\nimport v2.std.witness { Witness }\nimport v2.std.diagnostic { Outcome }\nimport v2.std.node { Node }\ntype Outc = Outcome>\ntype Gate = fn(Int) -> Outc\ntype Lens { gate: Gate }\n", + "src/test_claim_alias_arrow_probe.rs", + ["-> Outc>"], + ["Outc<"] + ) +} + +// ARROW RETURN BINDING, THE DISCRIMINATING RED. An arrow type's return rendered through the +// target-generic renderer, which never reads an applied-type binding, so `fn(Int) -> Outcome>` +// dropped the inner binding: `Rc>>` (E0107 missing generics). The Rust renderer +// honours the binding and must be what an arrow's positions render through. +test fn w_arrow_return_type_keeps_its_applied_binding() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.arrow_binding_probe\nimport std.types { Int, String }\nimport v2.std.diagnostic { Outcome }\ntype Box2 { v: T }\nfn probe() -> fn(Int) -> Outcome> { fn(n) { Outcome::Accepted { value: Box2 { v: \"x\" } } } }\n", + "src/test_claim_arrow_binding_probe.rs", + ["Box2"], + ["Rc>"] + ) +} + +// QUALIFIED TYPE REFERENCE, THE DISCRIMINATING RED. A field typed `std.determinism.Determinism` +// with no import renders as bare `Determinism`, and the use-line derivation collected the DOTTED +// spelling, which is never an emitted token, so the module referenced a name it never imported. +// The leaf must earn its use-line from the qualified registry row. +test fn w_qualified_type_reference_earns_the_leaf_use_line() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.qualified_type_ref_probe\nimport std.types { String }\ntype Fact { signature: String, classification: std.determinism.Determinism }\nfn probe(f: Fact) -> std.determinism.Determinism { f.classification }\n", + "src/test_claim_qualified_type_ref_probe.rs", + ["use crate::std_determinism::Determinism"], + ["std.determinism.Determinism"] + ) +} + +// SERVICE OP WITHOUT A REALIZATION, THE DISCRIMINATING RED. `Filesystem.Read(path:)` inside a fn +// the signature authority judged service-free emitted `filesystem.read(path).await?` -- an unbound +// name in a non-async fn, the only `.await?` in the whole closure. It is a host seam with no +// realization in this target and must emit the generated refusal body naming the seam. The realized +// arm has no positive control here because no source in the corpus spells a receiver the signature +// authority accepts; that absence is recorded in rust_unrealized_service_op_refusal's note. +test fn w_service_op_in_a_service_free_fn_refuses_instead_of_awaiting_an_unbound_binding() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.service_op_probe\nimport std.types { String }\nimport extdeps.filesystem.filesystem_io { Filesystem }\nfn probe(path: String) -> String { let read = Filesystem.Read(path: path)\n read.content }\n", + "src/test_claim_service_op_probe.rs", + ["unrealized host seam: service op Filesystem.Read"], + [".await?"] + ) +} diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index dc7dfff8dd1..e51f54fb110 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -41,7 +41,7 @@ import v1.std.core { match_scrutinee, match_arm_nodes, if_condition, if_then_branch, if_else_branch, index_base, index_expr, slice_base, slice_start, slice_end, cast_target, cast_expr, return_value, binop_left, binop_right, no_span, with_required_cardinality, Connective, Conj, Disj, - NoConnective, Cardinality, Required, CardOptional, is_rest_transport, + NoConnective, Arrow, Cardinality, Required, CardOptional, is_rest_transport, transport_base_path, empty_intern_table } @@ -88,7 +88,7 @@ import v1.compiler.closure_stub_v2_std_integer_rust { closure_stub_v2_std_intege import v1.compiler.closure_stub_v2_std_text_rust { closure_stub_v2_std_text_source } import v1.compiler.coercion { coerce_primitive_type, is_copy, lookup_checkpoint, type_reference_decl_file, - rust_seed_host_numeric_alias + rust_seed_host_numeric_alias, target_callable } import v1.compiler.trait_derive_emit { v1_emit_enum_derives, @@ -226,6 +226,33 @@ fn render_rust_type(n: Node, shared_types: Set, source_indices: Map Outcome>` came out as +// `Rc Rc>>>` -- the inner binding dropped (E0107 missing +// generics for struct `Medium`, v2.compiler.compile stage_translate). The callable template and the +// void arm are the same rows render_node_type consumes; only the per-position renderer changes. +fn render_rust_arrow_type(n: Node, shared_types: Set, source_indices: Map, emit_info: EmitGraphInfo) -> String { + let repr = target_callable(target: Rust) + let param_strs = n.params |> map(p => render_rust_type(n: param_node_type_expr(n: p), shared_types: shared_types, source_indices: source_indices, emit_info: emit_info)) + let param_str = param_strs |> join(separator: repr.param_separator) + let spec = language_spec(target: Rust) + let ret_str = match n.inferred { + Present { value: Resolved { node: rt } } => render_rust_type(n: rt, shared_types: shared_types, source_indices: source_indices, emit_info: emit_info) + _ => spec.void_type + } + match spec.callable_type_template { + Present { value: t } => replace(replace(t, "\{params\}", param_str), "\{return\}", ret_str) + Absent => + if ret_str == "" { + replace(replace(repr.template, concat(repr.return_separator, "\{return\}"), ""), "\{params\}", param_str) + } else { + replace(replace(repr.template, "\{params\}", param_str), "\{return\}", ret_str) + } + } +} + fn render_rust_type_without_applied_binding(n: Node, shared_types: Set, source_indices: Map, emit_info: EmitGraphInfo) -> String { if is_host_text_carrier_type(n: n, source_indices: source_indices) { return rust_carrier_optional_wrap(n: n, rendered: "String") } if is_host_optional_carrier_type(n: n, source_indices: source_indices) { @@ -234,7 +261,18 @@ fn render_rust_type_without_applied_binding(n: Node, shared_types: Set, if is_host_diagnostics_carrier_type(n: n, source_indices: source_indices) { return render_rust_diagnostics_carrier_applied(shared_types: shared_types) } - if n.connective == NoConnective && n.children |> count > 0 && !is_container_type(name: authored_name_at(source_indices: source_indices, node: n)) { + if n.connective == Arrow { + render_rust_arrow_type(n: n, shared_types: shared_types, source_indices: source_indices, emit_info: emit_info) + } else if n.connective == NoConnective && n.children |> count > 0 && !is_container_type(name: authored_name_at(source_indices: source_indices, node: n)) && closed_alias_peels_zero_param(env: emit_info.fn_type_env, n: n) { + // A ZERO-PARAMETER ALIAS NEVER TAKES THE ARGUMENTS OF WHAT IT ABBREVIATES. The resolver hands an + // alias reference back carrying its right-hand side's children, and rendering name-plus-children + // wrote `CompileLensOutcome>>>` for `type CompileLensOutcome = + // Outcome>` (E0107, and the E0391 variance cycle rustc reports beside it). The + // fn-signature renderer already answers this position bare via closed_alias_peels_zero_param; + // this is the same verdict asked at the expression-type position. + let leaf = qualified_last_segment(name: authored_name_at(source_indices: source_indices, node: n)) + render_rust_shared_type_with_optional(n: n, type_name: leaf, rendered: leaf, shared_types: shared_types) + } else if n.connective == NoConnective && n.children |> count > 0 && !is_container_type(name: authored_name_at(source_indices: source_indices, node: n)) { render_rust_applied_via_emit_info(n: n, shared_types: shared_types, source_indices: source_indices, emit_info: emit_info) } else if node_is_set_collection(n: n, source_indices: source_indices) { match n.children |> first { @@ -682,7 +720,18 @@ fn rust_witness_applied_type_arg_node(type_node: Node, source_indices: Map::Holds { .. }`, one site on the +// 00_compile closure (v2.std.grammar derive_grammar_relation_token_edges_recursive). The fn's return +// type `Witness>` was present the whole time and is the authority for the arm's carrier; +// an erased first source must DECLINE so the second is consulted, never render its own refusal. fn rust_witness_carrier_from_type_node(type_node: Node, shared_types: Set, emit_info: EmitGraphInfo, source_indices: Map) -> String? { + if type_node.inferred != none && is_compiler_error(inferred: type_node.inferred.value) { return none } if type_node_has_unbound_type_variable(n: type_node, generic_param_names: emit_info.fn_generic_param_names, source_indices: source_indices) { return none } let peeled = rust_peel_all_rc_type_node(type_node: type_node, source_indices: source_indices) if qualified_last_segment(name: peeled.name) == "Witness" { @@ -1425,7 +1474,10 @@ fn render_rust_alias_rhs_type(n: Node, generic_param_names: List, shared } } } else { - render_rust_type(n: n, shared_types: shared_types, source_indices: source_indices, emit_info: empty_emit_graph_info()) + // The env travels: an alias right-hand side that is an Arrow renders its return through + // render_rust_type, and the zero-param-alias verdict there is asked of emit_info.fn_type_env. An + // empty env answered ClosedAliasBindingAbsent for every alias and the arm could never fire. + render_rust_type(n: n, shared_types: shared_types, source_indices: source_indices, emit_info: emit_info_with_fn_type_context(emit_info: empty_emit_graph_info(), generic_param_names: generic_param_names, env: scope.type_env)) } } @@ -4095,6 +4147,7 @@ fn reference_derived_use_line_plan(items: List, unlisted_type_names: List< let value_names = unique_strings(items: items |> flat_map(item => collect_value_ref_names(n: item, source_indices: source_indices, type_summaries: emit_info.type_summaries, variant_to_enum: emit_info.variant_to_enum))) let item_emit_surface_names = items |> flat_map(item => collect_item_emit_surface_names(item: item, source_indices: source_indices, emit_info: emit_info)) let type_surface_names = unique_strings(items: item_emit_surface_names) + let qualified_surface_leaves = qualified_type_surface_leaf_candidates(names: type_surface_names, registry: registry) let field_surface_names = collect_items_field_import_surface_names(surface_names: item_emit_surface_names, emit_info: emit_info) let variant_payload_structs = expand_variant_payload_struct_imports(names: type_surface_names, type_summaries: emit_info.type_summaries, variant_to_enum: emit_info.variant_to_enum) let emitter_attested_anon_heads = unique_strings(items: items |> flat_map(item => collect_anonymous_record_lit_heads(n: item, source_indices: source_indices, type_summaries: emit_info.type_summaries))) @@ -4102,7 +4155,7 @@ fn reference_derived_use_line_plan(items: List, unlisted_type_names: List< let emitted_source_tokens = rust_identifier_tokens(s: emitted_source) let emitted_source_token_set = emitted_source_tokens |> fold(init: empty_map(), f: (acc, t) => map_insert(acc, t, true)) - let candidates = unique_strings(items: concat(concat(concat(concat(concat(unlisted_type_names, value_names), type_surface_names), field_surface_names), variant_payload_structs), realized_surface_names)) + let candidates = unique_strings(items: concat(concat(concat(concat(concat(concat(unlisted_type_names, value_names), type_surface_names), qualified_surface_leaves), field_surface_names), variant_payload_structs), realized_surface_names)) |> filter(name => reference_derived_candidate_authored(module_source: module_source, name: name, type_summaries: emit_info.type_summaries, variant_to_enum: emit_info.variant_to_enum) || emitter_attested_anon_heads |> any(h => h == name) @@ -4161,6 +4214,33 @@ fn reference_derived_use_line_plan(items: List, unlisted_type_names: List< } } +// A QUALIFIED TYPE REFERENCE REACHES EMISSION AS ITS LEAF AND NEEDS THE LEAF'S USE-LINE. The type +// renderers spell `std.determinism.Determinism` as bare `Determinism` (rust_fn_sig_leaf_name), and +// the surface walk collects the DOTTED spelling -- which is never an identifier token in the emitted +// source, so the candidate filter dropped it before any disposition was assigned and the module +// referenced a name it never imported (E0425 cannot find type `Determinism`, v2.std.determinism, +// two sites). The leaf is admitted as a candidate only when the qualified registry row resolves it +// AND the bare row names the SAME declaring module: the downstream lookups are bare-keyed and +// last-write-wins, and a leaf whose bare row points elsewhere would import a homonym from the wrong +// provider. That disagreement stays a loud unresolved name rather than a fabricated use-line. +fn qualified_type_surface_leaf_candidates(names: List, registry: Map) -> List { + names |> flat_map(name => + if !string_contains(s: name, pattern: ".") { [] } else { + let leaf = qualified_last_segment(name: name) + match map_get(registry, name) { + Present { value: qualified_info } => + if is_duplicate_qualified_item_registry_marker(info: qualified_info) { [] } else { + match map_get(registry, leaf) { + Present { value: bare_info } => if bare_info.module_name == qualified_info.module_name { [leaf] } else { [] } + Absent => [] + } + } + Absent => [] + } + } + ) +} + fn reference_derived_use_lines(items: List, unlisted_type_names: List, this_module_name: String, registry: Map, emit_info: EmitGraphInfo, local_type_names: List, already_imported_names: List, export_sets: Map>, typed_modules: List, source_indices: Map, module_index: ModuleIndex, shared_types: Set, emitted_source: String) -> List { let plan = reference_derived_use_line_plan(items: items, unlisted_type_names: unlisted_type_names, this_module_name: this_module_name, registry: registry, emit_info: emit_info, local_type_names: local_type_names, already_imported_names: already_imported_names, export_sets: export_sets, typed_modules: typed_modules, source_indices: source_indices, module_index: module_index, shared_types: shared_types, emitted_source: emitted_source) plan.lines @@ -9912,7 +9992,16 @@ fn lambda_param_type_strs(params: List, param_nodes: List, fallbac } else if type_node_has_closure_unbound_generic_atom(n: param_type, generic_param_names: emit_info.fn_generic_param_names, env: type_env, source_indices: source_indices) { none } else { - Present { value: render_rust_type(n: param_type, shared_types: shared_types, source_indices: source_indices, emit_info: emit_info) } + // The same admission the fold arm applies to its element annotation + // (fold_elem_type_str): a rendered `FreeMonoid` whose T is no fn generic names a + // type this closure cannot spell, and an annotation that names it is refused by rustc + // (E0425 cannot find type `T`, v2.lens.mandatory_tag on the 00_compile closure). The + // node-grain check above missed it because the formal's spelling resolves to SOME + // binding in the whole-pool env; the rendered-string check is the one authority both + // arms consult, so the two cannot disagree. + let rendered = render_rust_type(n: param_type, shared_types: shared_types, source_indices: source_indices, emit_info: emit_info) + if rust_fold_rendered_type_has_any_spurious_generic(type_str: rendered, generic_param_names: emit_info.fn_generic_param_names) { none } + else { Present { value: rendered } } } _ => none } @@ -10012,7 +10101,16 @@ fn emit_rust_fold_method_call(method_call_node: Node, fold_accumulator_type: Nod let is_under_resolved_list = node_is_element_collection(n: acc_type, source_indices: scope.type_env.source_indices) && !node_is_set_collection(n: acc_type, source_indices: scope.type_env.source_indices) && acc_type.children |> count == 0 let is_under_resolved_set = node_is_set_collection(n: acc_type, source_indices: scope.type_env.source_indices) && (acc_type.children |> count == 0 || acc_children_have_unit) let is_under_resolved_non_collection = !node_is_keyed_collection(n: acc_type, source_indices: scope.type_env.source_indices) && !node_is_element_collection(n: acc_type, source_indices: scope.type_env.source_indices) && !node_is_collection(n: acc_type, source_indices: scope.type_env.source_indices) - if is_under_resolved_map || is_under_resolved_list || is_under_resolved_set || is_under_resolved_non_collection { + // A DECLARATION'S OWN PARAMETER NAMES ARE NOT A RESOLVED ACCUMULATOR. fold_accumulator_type can + // arrive as the container declaration's parametric shape -- Map with K and V the + // declaration's formals, bound to nothing at this call -- and the four shape tests above all + // read that as resolved (two children, neither unit-like). The init arm then wrote the formals + // straight into a turbofish, `v1_rt::rc_empty_map::()`, four sites on the 00_compile + // closure (v2.lens.unit_modeling) while the lambda beside it had already fallen back to `_`. + // The contextual method result type IS the resolved accumulator here, so a shape whose atoms are + // unbound in the closure scope is under-resolved exactly like an empty one. + let is_under_resolved_generic = type_node_has_closure_unbound_generic_atom(n: acc_type, generic_param_names: emit_info.fn_generic_param_names, env: scope.type_env, source_indices: scope.type_env.source_indices) + if is_under_resolved_map || is_under_resolved_list || is_under_resolved_set || is_under_resolved_non_collection || is_under_resolved_generic { match contextual_acc_type { Present { value: concrete_type } => concrete_type Absent => acc_type @@ -10383,9 +10481,28 @@ fn emit_rust_generic_method_call(method_name: String, receiver: Node, args: List } } +// TWO AUTHORITIES DECIDED ONE SERVICE CALL, AND THE EMISSION FOLLOWED THE ONE THAT DOES NOT REALIZE. +// The Rust realization of a service op is the SIGNATURE fact: ItemInfo.service_names, computed by +// collect_typed_service_calls over is_typed_service_call_receiver, which makes the fn async, binds +// the service as a parameter, and puts `.await?` on every caller. The method-call arm keyed on +// ServiceMethodSemantics alone and wrote `filesystem.read(path).await?` into a fn the signature +// authority had judged service-free -- an unbound name inside a non-async fn (E0425 + E0728, two +// sites in v2.compiler.source_authority, and the ONLY `.await?` in the whole emitted closure). That +// is a fabricated realization. The arm now asks the same predicate the signature asks, so the two +// agree by construction; where it declines, the op is a host seam with no realization in this +// target and emits the generated refusal body the seam ruling prescribes -- a panic naming the seam, +// never a call into a binding that does not exist. The realized arm is currently UNINHABITED by +// the corpus (no `.dag` source in the seed or the closure spells a receiver the predicate accepts), +// so its positive control is not authorable today; that is recorded, not papered over. +fn rust_unrealized_service_op_refusal(service_name: String, method: String, module_name: String) -> String { + concat("panic!(\"unrealized host seam: service op ", service_name, ".", method, " in ", module_name, ": the Rust realization binds a service only through an async fn parameter, and this function declares none\")") +} + fn emit_typed_method_call(method_call_node: Node, receiver: Node, method: String, args: List, result_type: InferredNode?, method_semantics: MethodSemantics?, registry: Map, scope: InferScope, depth: Int, shared_types: Set, emit_info: EmitGraphInfo) -> String { if method_semantics != none { match method_semantics.value { - ServiceMethodSemantics { service_name: svc_name, op_params: op_params } => { + ServiceMethodSemantics { service_name: svc_name, op_params: op_params } => if !is_typed_service_call_receiver(receiver: receiver, source_indices: scope.type_env.source_indices) { + rust_unrealized_service_op_refusal(service_name: svc_name, method: method, module_name: scope.module_name) + } else { let var_name = service_var_name(service_name: svc_name) let si = scope.type_env.source_indices let filled_args = fill_op_default_args(ordered: args, op_params: op_params, registry: registry, scope: scope, depth: depth, shared_types: shared_types, emit_info: emit_info) From 4b57ad1cca56a3e57fe163a1177b737a1a7a3b20 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 29 Aug 2026 14:22:26 +0000 Subject: [PATCH 21/75] WIP: if-equals-variant parses as a record literal; name the predicate --- src/v1/05_emit_rust.dag | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index e51f54fb110..c3319c15bd3 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -233,6 +233,11 @@ fn render_rust_type(n: Node, shared_types: Set, source_indices: Map Rc>>>` -- the inner binding dropped (E0107 missing // generics for struct `Medium`, v2.compiler.compile stage_translate). The callable template and the // void arm are the same rows render_node_type consumes; only the per-position renderer changes. +// Named rather than inlined because `if x == Variant {` parses as a record literal in .dag. +fn rust_type_node_is_arrow(n: Node) -> Bool { + n.connective == Arrow +} + fn render_rust_arrow_type(n: Node, shared_types: Set, source_indices: Map, emit_info: EmitGraphInfo) -> String { let repr = target_callable(target: Rust) let param_strs = n.params |> map(p => render_rust_type(n: param_node_type_expr(n: p), shared_types: shared_types, source_indices: source_indices, emit_info: emit_info)) @@ -261,7 +266,7 @@ fn render_rust_type_without_applied_binding(n: Node, shared_types: Set, if is_host_diagnostics_carrier_type(n: n, source_indices: source_indices) { return render_rust_diagnostics_carrier_applied(shared_types: shared_types) } - if n.connective == Arrow { + if rust_type_node_is_arrow(n: n) { render_rust_arrow_type(n: n, shared_types: shared_types, source_indices: source_indices, emit_info: emit_info) } else if n.connective == NoConnective && n.children |> count > 0 && !is_container_type(name: authored_name_at(source_indices: source_indices, node: n)) && closed_alias_peels_zero_param(env: emit_info.fn_type_env, n: n) { // A ZERO-PARAMETER ALIAS NEVER TAKES THE ARGUMENTS OF WHAT IT ABBREVIATES. The resolver hands an From dc04b9d24453c7729cfc4db894cd370ff134ae82 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 29 Aug 2026 14:26:20 +0000 Subject: [PATCH 22/75] WIP: annotations at module-item grain --- src/v1/05_emit_rust.dag | 52 ++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index c3319c15bd3..7d529fff27b 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -258,6 +258,13 @@ fn render_rust_arrow_type(n: Node, shared_types: Set, source_indices: Ma } } +// ZERO-PARAMETER ALIAS AT THE EXPRESSION-TYPE POSITION (the closed_alias_peels_zero_param arm below): +// A ZERO-PARAMETER ALIAS NEVER TAKES THE ARGUMENTS OF WHAT IT ABBREVIATES. The resolver hands an +// alias reference back carrying its right-hand side's children, and rendering name-plus-children +// wrote `CompileLensOutcome>>>` for `type CompileLensOutcome = +// Outcome>` (E0107, and the E0391 variance cycle rustc reports beside it). The +// fn-signature renderer already answers this position bare via closed_alias_peels_zero_param; +// this is the same verdict asked at the expression-type position. fn render_rust_type_without_applied_binding(n: Node, shared_types: Set, source_indices: Map, emit_info: EmitGraphInfo) -> String { if is_host_text_carrier_type(n: n, source_indices: source_indices) { return rust_carrier_optional_wrap(n: n, rendered: "String") } if is_host_optional_carrier_type(n: n, source_indices: source_indices) { @@ -269,12 +276,6 @@ fn render_rust_type_without_applied_binding(n: Node, shared_types: Set, if rust_type_node_is_arrow(n: n) { render_rust_arrow_type(n: n, shared_types: shared_types, source_indices: source_indices, emit_info: emit_info) } else if n.connective == NoConnective && n.children |> count > 0 && !is_container_type(name: authored_name_at(source_indices: source_indices, node: n)) && closed_alias_peels_zero_param(env: emit_info.fn_type_env, n: n) { - // A ZERO-PARAMETER ALIAS NEVER TAKES THE ARGUMENTS OF WHAT IT ABBREVIATES. The resolver hands an - // alias reference back carrying its right-hand side's children, and rendering name-plus-children - // wrote `CompileLensOutcome>>>` for `type CompileLensOutcome = - // Outcome>` (E0107, and the E0391 variance cycle rustc reports beside it). The - // fn-signature renderer already answers this position bare via closed_alias_peels_zero_param; - // this is the same verdict asked at the expression-type position. let leaf = qualified_last_segment(name: authored_name_at(source_indices: source_indices, node: n)) render_rust_shared_type_with_optional(n: n, type_name: leaf, rendered: leaf, shared_types: shared_types) } else if n.connective == NoConnective && n.children |> count > 0 && !is_container_type(name: authored_name_at(source_indices: source_indices, node: n)) { @@ -1388,6 +1389,10 @@ Fix: route on the TERMINAL segment via qualified_last_segment (v1.std.core, the The v2 corpus authors qualified names in type position only rarely today, which is why one line carried this much weight; the point of fixing the renderer rather than editing that one declaration is that the next qualified name must not reintroduce it (DESIGN: do not cement the seed's accidents)." +// THE FINAL else ARM CARRIES THE MODULE ENV: +// The env travels: an alias right-hand side that is an Arrow renders its return through +// render_rust_type, and the zero-param-alias verdict there is asked of emit_info.fn_type_env. An +// empty env answered ClosedAliasBindingAbsent for every alias and the arm could never fire. fn render_rust_alias_rhs_type(n: Node, generic_param_names: List, shared_types: Set, source_indices: Map, scope: InferScope, imports: List, registry: Map, module_name: String, export_sets: Map>, typed_modules: List, module_index: ModuleIndex, variant_to_enum: Map) -> String { if is_where_refinement_type(ty: n) { match n.children |> first { @@ -1479,9 +1484,6 @@ fn render_rust_alias_rhs_type(n: Node, generic_param_names: List, shared } } } else { - // The env travels: an alias right-hand side that is an Arrow renders its return through - // render_rust_type, and the zero-param-alias verdict there is asked of emit_info.fn_type_env. An - // empty env answered ClosedAliasBindingAbsent for every alias and the arm could never fire. render_rust_type(n: n, shared_types: shared_types, source_indices: source_indices, emit_info: emit_info_with_fn_type_context(emit_info: empty_emit_graph_info(), generic_param_names: generic_param_names, env: scope.type_env)) } } @@ -9979,6 +9981,14 @@ fn lambda_scope_from_children(scope: InferScope, params: List, param_nod ) } +// THE RENDERED-STRING ADMISSION ON AN INFERRED PARAMETER TYPE: +// The same admission the fold arm applies to its element annotation +// (fold_elem_type_str): a rendered `FreeMonoid` whose T is no fn generic names a +// type this closure cannot spell, and an annotation that names it is refused by rustc +// (E0425 cannot find type `T`, v2.lens.mandatory_tag on the 00_compile closure). The +// node-grain check above missed it because the formal's spelling resolves to SOME +// binding in the whole-pool env; the rendered-string check is the one authority both +// arms consult, so the two cannot disagree. fn lambda_param_type_strs(params: List, param_nodes: List, fallback_types: List, shared_types: Set, source_indices: Map, emit_info: EmitGraphInfo, fold_acc_uses_fallback: Bool, type_env: TypeEnv) -> List { params |> enumerate |> map(pair => let idx = pair.first @@ -9997,13 +10007,6 @@ fn lambda_param_type_strs(params: List, param_nodes: List, fallbac } else if type_node_has_closure_unbound_generic_atom(n: param_type, generic_param_names: emit_info.fn_generic_param_names, env: type_env, source_indices: source_indices) { none } else { - // The same admission the fold arm applies to its element annotation - // (fold_elem_type_str): a rendered `FreeMonoid` whose T is no fn generic names a - // type this closure cannot spell, and an annotation that names it is refused by rustc - // (E0425 cannot find type `T`, v2.lens.mandatory_tag on the 00_compile closure). The - // node-grain check above missed it because the formal's spelling resolves to SOME - // binding in the whole-pool env; the rendered-string check is the one authority both - // arms consult, so the two cannot disagree. let rendered = render_rust_type(n: param_type, shared_types: shared_types, source_indices: source_indices, emit_info: emit_info) if rust_fold_rendered_type_has_any_spurious_generic(type_str: rendered, generic_param_names: emit_info.fn_generic_param_names) { none } else { Present { value: rendered } } @@ -10092,6 +10095,15 @@ fn emit_typed_fold_lambda(lambda_expr: Node, acc_type_str: String, elem_type_str // instead would restate it, and would then have to be kept in step with any future change to the strip // -- reintroducing the shape of this defect while fixing this instance of it. `_` is also the device // already used for elem_render_has_spurious_generic a few bindings earlier. +// THE UNDER-RESOLVED-GENERIC ACCUMULATOR ARM (is_under_resolved_generic below): +// A DECLARATION'S OWN PARAMETER NAMES ARE NOT A RESOLVED ACCUMULATOR. fold_accumulator_type can +// arrive as the container declaration's parametric shape -- Map with K and V the +// declaration's formals, bound to nothing at this call -- and the four shape tests above all +// read that as resolved (two children, neither unit-like). The init arm then wrote the formals +// straight into a turbofish, `v1_rt::rc_empty_map::()`, four sites on the 00_compile +// closure (v2.lens.unit_modeling) while the lambda beside it had already fallen back to `_`. +// The contextual method result type IS the resolved accumulator here, so a shape whose atoms are +// unbound in the closure scope is under-resolved exactly like an empty one. fn emit_rust_fold_method_call(method_call_node: Node, fold_accumulator_type: Node?, result_type: InferredNode?, receiver: Node, args: List, registry: Map, scope: InferScope, depth: Int, shared_types: Set, emit_info: EmitGraphInfo) -> String { let recv_str = emit_typed_iter_owned_receiver(receiver: receiver, downstream: args, registry: registry, scope: scope, depth: depth, shared_types: shared_types, emit_info: emit_info) let elem_type_str = collection_element_type(receiver_type: receiver.inferred, shared_types: shared_types, source_indices: scope.type_env.source_indices, emit_info: emit_info, type_env: scope.type_env) @@ -10106,14 +10118,6 @@ fn emit_rust_fold_method_call(method_call_node: Node, fold_accumulator_type: Nod let is_under_resolved_list = node_is_element_collection(n: acc_type, source_indices: scope.type_env.source_indices) && !node_is_set_collection(n: acc_type, source_indices: scope.type_env.source_indices) && acc_type.children |> count == 0 let is_under_resolved_set = node_is_set_collection(n: acc_type, source_indices: scope.type_env.source_indices) && (acc_type.children |> count == 0 || acc_children_have_unit) let is_under_resolved_non_collection = !node_is_keyed_collection(n: acc_type, source_indices: scope.type_env.source_indices) && !node_is_element_collection(n: acc_type, source_indices: scope.type_env.source_indices) && !node_is_collection(n: acc_type, source_indices: scope.type_env.source_indices) - // A DECLARATION'S OWN PARAMETER NAMES ARE NOT A RESOLVED ACCUMULATOR. fold_accumulator_type can - // arrive as the container declaration's parametric shape -- Map with K and V the - // declaration's formals, bound to nothing at this call -- and the four shape tests above all - // read that as resolved (two children, neither unit-like). The init arm then wrote the formals - // straight into a turbofish, `v1_rt::rc_empty_map::()`, four sites on the 00_compile - // closure (v2.lens.unit_modeling) while the lambda beside it had already fallen back to `_`. - // The contextual method result type IS the resolved accumulator here, so a shape whose atoms are - // unbound in the closure scope is under-resolved exactly like an empty one. let is_under_resolved_generic = type_node_has_closure_unbound_generic_atom(n: acc_type, generic_param_names: emit_info.fn_generic_param_names, env: scope.type_env, source_indices: scope.type_env.source_indices) if is_under_resolved_map || is_under_resolved_list || is_under_resolved_set || is_under_resolved_non_collection || is_under_resolved_generic { match contextual_acc_type { From 7f434917c619e0d5fbb02af290148aede2e4022b Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 29 Aug 2026 14:51:57 +0000 Subject: [PATCH 23/75] Regen round 1 (BuildBuddy invocation ebbdffc5, compiler gunbc=9830014a4e965ddb built from the committed mirror): v1_compiler_emit_rust.rs regenerated; candidate patch sha 05ce734c52890571 --- src/v1/stage0/src/v1_compiler_emit_rust.rs | 816 +++++++++++++-------- 1 file changed, 517 insertions(+), 299 deletions(-) diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index 9dcd2f15425..8e912f6ecc4 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -64,7 +64,7 @@ pub use crate::v1_compiler_closure_stub_v2_std_text_rust::closure_stub_v2_std_te pub use crate::v1_compiler_coercion::decl_identity_file; pub use crate::v1_compiler_coercion::{ coerce_primitive_type, is_copy, lookup_checkpoint, rust_seed_host_numeric_alias, - type_reference_decl_file, + target_callable, type_reference_decl_file, }; pub use crate::v1_compiler_compiler_tests_rust::compiler_tests_source; use crate::v1_compiler_emit::BoundOperation::{ @@ -184,7 +184,7 @@ use crate::v1_std_core::CompilerDiagnostic::{ InternalError, ParameterDefaultFormNotAdmitted, ReferenceDerivedImportExportUnproven, ReferenceDerivedImportProviderUnknown, UnlistedImportUse, }; -use crate::v1_std_core::Connective::{Conj, Disj, NoConnective}; +use crate::v1_std_core::Connective::{Arrow, Conj, Disj, NoConnective}; use crate::v1_std_core::ExprData::{ ExprBinOp, ExprBlock, ExprCall, ExprCast, ExprError, ExprFieldAccess, ExprForEach, ExprIf, ExprIndex, ExprLambda, ExprLet, ExprListLit, ExprLiteral, ExprMatch, ExprMethodCall, @@ -319,6 +319,74 @@ pub fn render_rust_type( } } +pub fn rust_type_node_is_arrow(n: Rc) -> bool { + (n.connective.clone() == Connective::Arrow) +} + +pub fn render_rust_arrow_type( + n: Rc, + shared_types: Rc>, + source_indices: Rc>>, + emit_info: Rc, +) -> String { + { + let repr = crate::v1_compiler_coercion::target_callable(RenderTarget::Rust); + let param_strs = Rc::new({ + let mut __result = Vec::new(); + for p in n.params.clone().iter().cloned() { + __result.push(render_rust_type( + crate::v1_std_core::param_node_type_expr(p.clone()), + shared_types.clone(), + source_indices.clone(), + emit_info.clone(), + )); + } + __result + }); + let param_str = param_strs.clone().join(&repr.param_separator.clone()); + let spec = crate::v1_compiler_emit_core_support::language_spec(RenderTarget::Rust); + let ret_str = match n.inferred.clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: rt, .. }) => render_rust_type( + rt.clone(), + shared_types.clone(), + source_indices.clone(), + emit_info.clone(), + ), + _ => spec.void_type.clone(), + }; + match spec.callable_type_template.clone() { + Some(t) => v1_rt::replace( + v1_rt::replace(t.clone(), "{params}".to_string(), param_str.clone()), + "{return}".to_string(), + ret_str.clone(), + ), + None => { + if (ret_str.clone() == "".to_string()) { + v1_rt::replace( + v1_rt::replace( + repr.template.clone(), + v1_rt::concat(repr.return_separator.clone(), "{return}".to_string()), + "".to_string(), + ), + "{params}".to_string(), + param_str.clone(), + ) + } else { + v1_rt::replace( + v1_rt::replace( + repr.template.clone(), + "{params}".to_string(), + param_str.clone(), + ), + "{return}".to_string(), + ret_str.clone(), + ) + } + } + } + } +} + pub fn render_rust_type_without_applied_binding( n: Rc, shared_types: Rc>, @@ -342,121 +410,49 @@ pub fn render_rust_type_without_applied_binding( if is_host_diagnostics_carrier_type(n.clone(), source_indices.clone()) { return render_rust_diagnostics_carrier_applied(shared_types.clone()); } - if (((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) > 0)) - && !crate::std_types::is_container_type(crate::v1_std_core::authored_name_at( - source_indices.clone(), - n.clone(), - ))) - { - render_rust_applied_via_emit_info( + if rust_type_node_is_arrow(n.clone()) { + render_rust_arrow_type( n.clone(), shared_types.clone(), source_indices.clone(), emit_info.clone(), ) } else { - if crate::v1_compiler_infer_types::node_is_set_collection( - n.clone(), - source_indices.clone(), - ) { - match n.children.clone().first().cloned() { - Some(elem_child) => { - let elem_node = - crate::v1_compiler_infer_types::child_type_node(elem_child.clone()); - let elem_is_type_var = if (elem_node.inferred.clone() != None) { - is_type_variable(elem_node.inferred.clone().clone().unwrap()) - } else { - false - }; - if elem_is_type_var.clone() { - emit_rust_compile_error_expr("Set element type unresolved".to_string()) - } else { - if !rust_btree_set_element_ord_eligible( - elem_node.clone(), - source_indices.clone(), - emit_info.clone(), - ) { - { - let elem_name = crate::v1_std_core::authored_name_at( - source_indices.clone(), - elem_node.clone(), - ); - emit_rust_compile_error_expr(v1_rt::concat( - v1_rt::concat( - "Set element type ".to_string(), - elem_name.clone(), - ), - " is not Ord-eligible for BTreeSet".to_string(), - )) - } - } else { - crate::v1_compiler_emit::render_node_type( - n.clone(), - RenderTarget::Rust, - shared_types.clone(), - source_indices.clone(), - ) - } - } - } - None => emit_rust_compile_error_expr("Set missing element type".to_string()), + if ((((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) > 0)) + && !crate::std_types::is_container_type(crate::v1_std_core::authored_name_at( + source_indices.clone(), + n.clone(), + ))) + && closed_alias_peels_zero_param(emit_info.fn_type_env.clone(), n.clone())) + { + { + let leaf = crate::v1_std_core::qualified_last_segment( + crate::v1_std_core::authored_name_at(source_indices.clone(), n.clone()), + ); + render_rust_shared_type_with_optional( + n.clone(), + leaf.clone(), + leaf.clone(), + shared_types.clone(), + ) } } else { - if crate::v1_compiler_infer_types::node_is_keyed_collection( - n.clone(), - source_indices.clone(), - ) { - match n.children.clone().first().cloned() { - Some(key_child) => { - let key_node = - crate::v1_compiler_infer_types::child_type_node(key_child.clone()); - let val_node = - match n.children.clone().iter().cloned().skip(1 as usize).next() { - Some(val_child) => { - crate::v1_compiler_infer_types::child_type_node( - val_child.clone(), - ) - } - None => type_variable_node("map_value".to_string()), - }; - let key_str = render_rust_type( - key_node.clone(), - shared_types.clone(), - source_indices.clone(), - emit_info.clone(), - ); - let val_str = render_rust_type( - val_node.clone(), - shared_types.clone(), - source_indices.clone(), - emit_info.clone(), - ); - let tn = crate::v1_std_core::authored_name_at( - source_indices.clone(), - n.clone(), - ); - let base = crate::v1_compiler_emit::emit_map_type( - key_str.clone(), - val_str.clone(), - RenderTarget::Rust, - ); - render_rust_shared_type_with_optional( - n.clone(), - tn.clone(), - base.clone(), - shared_types.clone(), - ) - } - None => crate::v1_compiler_emit::render_node_type( - n.clone(), - RenderTarget::Rust, - shared_types.clone(), - source_indices.clone(), - ), - } + if (((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) > 0)) + && !crate::std_types::is_container_type(crate::v1_std_core::authored_name_at( + source_indices.clone(), + n.clone(), + ))) + { + render_rust_applied_via_emit_info( + n.clone(), + shared_types.clone(), + source_indices.clone(), + emit_info.clone(), + ) } else { - if crate::v1_compiler_infer_types::node_is_element_collection( + if crate::v1_compiler_infer_types::node_is_set_collection( n.clone(), source_indices.clone(), ) { @@ -465,60 +461,178 @@ pub fn render_rust_type_without_applied_binding( let elem_node = crate::v1_compiler_infer_types::child_type_node( elem_child.clone(), ); - let inner_str = render_rust_type( - elem_node.clone(), - shared_types.clone(), - source_indices.clone(), - emit_info.clone(), - ); - let tn = crate::v1_std_core::authored_name_at( - source_indices.clone(), + let elem_is_type_var = if (elem_node.inferred.clone() != None) { + is_type_variable(elem_node.inferred.clone().clone().unwrap()) + } else { + false + }; + if elem_is_type_var.clone() { + emit_rust_compile_error_expr( + "Set element type unresolved".to_string(), + ) + } else { + if !rust_btree_set_element_ord_eligible( + elem_node.clone(), + source_indices.clone(), + emit_info.clone(), + ) { + { + let elem_name = crate::v1_std_core::authored_name_at( + source_indices.clone(), + elem_node.clone(), + ); + emit_rust_compile_error_expr(v1_rt::concat( + v1_rt::concat( + "Set element type ".to_string(), + elem_name.clone(), + ), + " is not Ord-eligible for BTreeSet".to_string(), + )) + } + } else { + crate::v1_compiler_emit::render_node_type( + n.clone(), + RenderTarget::Rust, + shared_types.clone(), + source_indices.clone(), + ) + } + } + } + None => { + emit_rust_compile_error_expr("Set missing element type".to_string()) + } + } + } else { + if crate::v1_compiler_infer_types::node_is_keyed_collection( + n.clone(), + source_indices.clone(), + ) { + match n.children.clone().first().cloned() { + Some(key_child) => { + let key_node = crate::v1_compiler_infer_types::child_type_node( + key_child.clone(), + ); + let val_node = match n + .children + .clone() + .iter() + .cloned() + .skip(1 as usize) + .next() + { + Some(val_child) => { + crate::v1_compiler_infer_types::child_type_node( + val_child.clone(), + ) + } + None => type_variable_node("map_value".to_string()), + }; + let key_str = render_rust_type( + key_node.clone(), + shared_types.clone(), + source_indices.clone(), + emit_info.clone(), + ); + let val_str = render_rust_type( + val_node.clone(), + shared_types.clone(), + source_indices.clone(), + emit_info.clone(), + ); + let tn = crate::v1_std_core::authored_name_at( + source_indices.clone(), + n.clone(), + ); + let base = crate::v1_compiler_emit::emit_map_type( + key_str.clone(), + val_str.clone(), + RenderTarget::Rust, + ); + render_rust_shared_type_with_optional( + n.clone(), + tn.clone(), + base.clone(), + shared_types.clone(), + ) + } + None => crate::v1_compiler_emit::render_node_type( n.clone(), - ); - let base = crate::v1_compiler_emit::emit_container( - tn.clone(), - inner_str.clone(), RenderTarget::Rust, - ); - render_rust_shared_type_with_optional( - n.clone(), - tn.clone(), - base.clone(), shared_types.clone(), - ) + source_indices.clone(), + ), } - None => crate::v1_compiler_emit::render_node_type( - n.clone(), - RenderTarget::Rust, - shared_types.clone(), - source_indices.clone(), - ), - } - } else { - { - let tn = crate::v1_std_core::authored_name_at( - source_indices.clone(), - n.clone(), - ); - if type_node_has_unbound_type_variable( + } else { + if crate::v1_compiler_infer_types::node_is_element_collection( n.clone(), - emit_info.fn_generic_param_names.clone(), source_indices.clone(), ) { - "_".to_string() - } else { - if is_host_text_carrier_type(n.clone(), source_indices.clone()) { - rust_carrier_optional_wrap( - n.clone(), - render_rust_text_carrier(shared_types.clone()), - ) - } else { - crate::v1_compiler_emit::render_node_type( + match n.children.clone().first().cloned() { + Some(elem_child) => { + let elem_node = + crate::v1_compiler_infer_types::child_type_node( + elem_child.clone(), + ); + let inner_str = render_rust_type( + elem_node.clone(), + shared_types.clone(), + source_indices.clone(), + emit_info.clone(), + ); + let tn = crate::v1_std_core::authored_name_at( + source_indices.clone(), + n.clone(), + ); + let base = crate::v1_compiler_emit::emit_container( + tn.clone(), + inner_str.clone(), + RenderTarget::Rust, + ); + render_rust_shared_type_with_optional( + n.clone(), + tn.clone(), + base.clone(), + shared_types.clone(), + ) + } + None => crate::v1_compiler_emit::render_node_type( n.clone(), RenderTarget::Rust, shared_types.clone(), source_indices.clone(), - ) + ), + } + } else { + { + let tn = crate::v1_std_core::authored_name_at( + source_indices.clone(), + n.clone(), + ); + if type_node_has_unbound_type_variable( + n.clone(), + emit_info.fn_generic_param_names.clone(), + source_indices.clone(), + ) { + "_".to_string() + } else { + if is_host_text_carrier_type( + n.clone(), + source_indices.clone(), + ) { + rust_carrier_optional_wrap( + n.clone(), + render_rust_text_carrier(shared_types.clone()), + ) + } else { + crate::v1_compiler_emit::render_node_type( + n.clone(), + RenderTarget::Rust, + shared_types.clone(), + source_indices.clone(), + ) + } + } } } } @@ -1120,6 +1234,11 @@ pub fn rust_witness_carrier_from_type_node( source_indices: Rc>>, ) -> Option { { + if ((type_node.inferred.clone() != None) + && crate::v1_std_core::is_compiler_error(type_node.inferred.clone().clone().unwrap())) + { + return None; + } if type_node_has_unbound_type_variable( type_node.clone(), emit_info.fn_generic_param_names.clone(), @@ -2857,7 +2976,11 @@ pub fn render_rust_alias_rhs_type( n.clone(), shared_types.clone(), source_indices.clone(), - crate::v1_compiler_infer_emit_info::empty_emit_graph_info(), + crate::v1_compiler_infer_emit_info::emit_info_with_fn_type_context( + crate::v1_compiler_infer_emit_info::empty_emit_graph_info(), + generic_param_names.clone(), + scope.type_env.clone(), + ), ) } } @@ -8198,6 +8321,8 @@ pub fn reference_derived_use_line_plan( }); let type_surface_names = crate::v1_compiler_emit_core_support::unique_strings(item_emit_surface_names.clone()); + let qualified_surface_leaves = + qualified_type_surface_leaf_candidates(type_surface_names.clone(), registry.clone()); let field_surface_names = collect_items_field_import_surface_names( item_emit_surface_names.clone(), emit_info.clone(), @@ -8255,8 +8380,14 @@ pub fn reference_derived_use_line_plan( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat(unlisted_type_names.clone(), value_names.clone()), - type_surface_names.clone(), + v1_rt::concat( + v1_rt::concat( + unlisted_type_names.clone(), + value_names.clone(), + ), + type_surface_names.clone(), + ), + qualified_surface_leaves.clone(), ), field_surface_names.clone(), ), @@ -8450,6 +8581,52 @@ v1_rt::concat(block_lines.clone(), fallback.clone()) } } +pub fn qualified_type_surface_leaf_candidates( + names: Rc>, + registry: Rc>>, +) -> Rc> { + Rc::new({ + let mut __result = Vec::new(); + for name in names.iter().cloned() { + __result.extend( + (*if !v1_rt::string_contains(&name, ".".to_string()) { + Rc::new(vec![]) + } else { + { + let leaf = crate::v1_std_core::qualified_last_segment(name.clone()); + match v1_rt::map_get(®istry, name.clone()) { + Some(qualified_info) => { + if is_duplicate_qualified_item_registry_marker( + qualified_info.clone(), + ) { + Rc::new(vec![]) + } else { + match v1_rt::map_get(®istry, leaf.clone()) { + Some(bare_info) => { + if (bare_info.module_name.clone() + == qualified_info.module_name.clone()) + { + Rc::new(vec![leaf.clone()]) + } else { + Rc::new(vec![]) + } + } + None => Rc::new(vec![]), + } + } + } + None => Rc::new(vec![]), + } + } + }) + .iter() + .cloned(), + ); + } + __result + }) +} + pub fn reference_derived_use_lines( items: Rc>>, unlisted_type_names: Rc>, @@ -23179,12 +23356,22 @@ pub fn lambda_param_type_strs( ) { None } else { - Some(render_rust_type( - param_type.clone(), - shared_types.clone(), - source_indices.clone(), - emit_info.clone(), - )) + { + let rendered = render_rust_type( + param_type.clone(), + shared_types.clone(), + source_indices.clone(), + emit_info.clone(), + ); + if rust_fold_rendered_type_has_any_spurious_generic( + rendered.clone(), + emit_info.fn_generic_param_names.clone(), + ) { + None + } else { + Some(rendered.clone()) + } + } } } } @@ -23549,9 +23736,16 @@ pub fn emit_rust_fold_method_call( acc_type.clone(), scope.type_env.clone().source_indices.clone(), )); - if (((is_under_resolved_map.clone() || is_under_resolved_list.clone()) + let is_under_resolved_generic = type_node_has_closure_unbound_generic_atom( + acc_type.clone(), + emit_info.fn_generic_param_names.clone(), + scope.type_env.clone(), + scope.type_env.clone().source_indices.clone(), + ); + if ((((is_under_resolved_map.clone() || is_under_resolved_list.clone()) || is_under_resolved_set.clone()) || is_under_resolved_non_collection.clone()) + || is_under_resolved_generic.clone()) { match contextual_acc_type.clone() { Some(concrete_type) => concrete_type.clone(), @@ -24807,6 +25001,14 @@ pub fn emit_rust_generic_method_call( } } +pub fn rust_unrealized_service_op_refusal( + service_name: String, + method: String, + module_name: String, +) -> String { + v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("panic!(\"unrealized host seam: service op ".to_string(), service_name.clone()), ".".to_string()), method.clone()), " in ".to_string()), module_name.clone()), ": the Rust realization binds a service only through an async fn parameter, and this function declares none\")".to_string()) +} + pub fn emit_typed_method_call( method_call_node: Rc, receiver: Rc, @@ -24827,152 +25029,168 @@ pub fn emit_typed_method_call( op_params, .. } => { - let var_name = - crate::v1_compiler_emit_core_support::service_var_name(svc_name.clone()); - let si = scope.type_env.clone().source_indices.clone(); - let filled_args = fill_op_default_args( - args.clone(), - op_params.clone(), - registry.clone(), - scope.clone(), - depth.clone(), - shared_types.clone(), - emit_info.clone(), - ); - let optional_param_set = Rc::new({ - let mut __result = Vec::new(); - for p in op_params.iter().cloned() { - if (crate::v1_std_core::param_node_type_expr(p.clone()) - .return_cardinality - .clone() - == Cardinality::CardOptional) - { - __result.push(p); - } - } - __result - }) - .iter() - .cloned() - .fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, p: Rc| { - v1_rt::rc_map_insert( - acc, - crate::v1_std_core::param_node_name_at(p.clone(), si.clone()), - true, - ) - }, - ); - let json_param_set = Rc::new({ - let mut __result = Vec::new(); - for p in op_params.iter().cloned() { - if (crate::v1_compiler_coercion::coerce_primitive_type( - RenderTarget::Rust, - crate::v1_std_core::authored_name_at( - si.clone(), - crate::v1_std_core::param_node_type_expr(p.clone()), - ), - crate::v1_compiler_coercion::type_reference_decl_file( - crate::v1_std_core::param_node_type_expr(p.clone()), - ), - ) == "serde_json::Value".to_string()) - { - __result.push(p); - } - } - __result - }) - .iter() - .cloned() - .fold( - v1_rt::rc_empty_map::(), - |acc: Rc>, p: Rc| { - v1_rt::rc_map_insert( - acc, - crate::v1_std_core::param_node_name_at(p.clone(), si.clone()), - true, - ) - }, - ); - let arg_strs = Rc::new({ - let mut __result = Vec::new(); - for a in filled_args.iter().cloned() { - __result.push({ - let arg_str = emit_typed_expr( - crate::v1_std_core::arg_value(a.clone()), - registry.clone(), - scope.clone(), - depth.clone(), - shared_types.clone(), - emit_info.clone(), - 1024, - ); - let aname = match crate::v1_std_core::arg_name_at(a.clone(), si.clone()) - { - Some(n) => n.clone(), - None => "".to_string(), - }; - let param_is_json = match v1_rt::map_get(&json_param_set, aname.clone()) - { - Some(_) => true, - None => false, - }; - let param_is_optional = - match v1_rt::map_get(&optional_param_set, aname.clone()) { - Some(_) => true, - None => false, - }; - let needs_optional = (param_is_optional.clone() - && (is_already_optional( - crate::v1_std_core::arg_value(a.clone()), - emit_info.clone(), - scope.clone(), - ) == false)); - let coerced = if (param_is_json.clone() - && is_string_typed_expr( - crate::v1_std_core::arg_value(a.clone()), - si.clone(), - )) { - v1_rt::concat( - v1_rt::concat( - "serde_json::from_str(&".to_string(), - arg_str.clone(), - ), - ").unwrap()".to_string(), + if !crate::v1_compiler_infer_service::is_typed_service_call_receiver( + receiver.clone(), + scope.type_env.clone().source_indices.clone(), + ) { + rust_unrealized_service_op_refusal( + svc_name.clone(), + method.clone(), + scope.module_name.clone(), + ) + } else { + { + let var_name = crate::v1_compiler_emit_core_support::service_var_name( + svc_name.clone(), + ); + let si = scope.type_env.clone().source_indices.clone(); + let filled_args = fill_op_default_args( + args.clone(), + op_params.clone(), + registry.clone(), + scope.clone(), + depth.clone(), + shared_types.clone(), + emit_info.clone(), + ); + let optional_param_set = Rc::new({ + let mut __result = Vec::new(); + for p in op_params.iter().cloned() { + if (crate::v1_std_core::param_node_type_expr(p.clone()) + .return_cardinality + .clone() + == Cardinality::CardOptional) + { + __result.push(p); + } + } + __result + }) + .iter() + .cloned() + .fold( + v1_rt::rc_empty_map::(), + |acc: Rc>, p: Rc| { + v1_rt::rc_map_insert( + acc, + crate::v1_std_core::param_node_name_at(p.clone(), si.clone()), + true, ) - } else { - arg_str.clone() - }; - if needs_optional.clone() { - v1_rt::concat( - v1_rt::concat("Some(".to_string(), coerced.clone()), - ")".to_string(), + }, + ); + let json_param_set = Rc::new({ + let mut __result = Vec::new(); + for p in op_params.iter().cloned() { + if (crate::v1_compiler_coercion::coerce_primitive_type( + RenderTarget::Rust, + crate::v1_std_core::authored_name_at( + si.clone(), + crate::v1_std_core::param_node_type_expr(p.clone()), + ), + crate::v1_compiler_coercion::type_reference_decl_file( + crate::v1_std_core::param_node_type_expr(p.clone()), + ), + ) == "serde_json::Value".to_string()) + { + __result.push(p); + } + } + __result + }) + .iter() + .cloned() + .fold( + v1_rt::rc_empty_map::(), + |acc: Rc>, p: Rc| { + v1_rt::rc_map_insert( + acc, + crate::v1_std_core::param_node_name_at(p.clone(), si.clone()), + true, ) - } else { - coerced.clone() + }, + ); + let arg_strs = Rc::new({ + let mut __result = Vec::new(); + for a in filled_args.iter().cloned() { + __result.push({ + let arg_str = emit_typed_expr( + crate::v1_std_core::arg_value(a.clone()), + registry.clone(), + scope.clone(), + depth.clone(), + shared_types.clone(), + emit_info.clone(), + 1024, + ); + let aname = match crate::v1_std_core::arg_name_at( + a.clone(), + si.clone(), + ) { + Some(n) => n.clone(), + None => "".to_string(), + }; + let param_is_json = + match v1_rt::map_get(&json_param_set, aname.clone()) { + Some(_) => true, + None => false, + }; + let param_is_optional = + match v1_rt::map_get(&optional_param_set, aname.clone()) { + Some(_) => true, + None => false, + }; + let needs_optional = (param_is_optional.clone() + && (is_already_optional( + crate::v1_std_core::arg_value(a.clone()), + emit_info.clone(), + scope.clone(), + ) == false)); + let coerced = if (param_is_json.clone() + && is_string_typed_expr( + crate::v1_std_core::arg_value(a.clone()), + si.clone(), + )) { + v1_rt::concat( + v1_rt::concat( + "serde_json::from_str(&".to_string(), + arg_str.clone(), + ), + ").unwrap()".to_string(), + ) + } else { + arg_str.clone() + }; + if needs_optional.clone() { + v1_rt::concat( + v1_rt::concat("Some(".to_string(), coerced.clone()), + ")".to_string(), + ) + } else { + coerced.clone() + } + }); } + __result }); - } - __result - }); - let args_str = arg_strs.clone().join(&", ".to_string()); - v1_rt::concat( - v1_rt::concat( + let args_str = arg_strs.clone().join(&", ".to_string()); v1_rt::concat( v1_rt::concat( - v1_rt::concat(var_name.clone(), ".".to_string()), - crate::v1_compiler_emit::emit_ident( - method.clone(), - RenderTarget::Rust, + v1_rt::concat( + v1_rt::concat( + v1_rt::concat(var_name.clone(), ".".to_string()), + crate::v1_compiler_emit::emit_ident( + method.clone(), + RenderTarget::Rust, + ), + ), + "(".to_string(), ), + args_str.clone(), ), - "(".to_string(), - ), - args_str.clone(), - ), - ").await?".to_string(), - ) + ").await?".to_string(), + ) + } + } } MethodSemantics::AlgebraMethodSemantics { method_def, From e9900e26fe4f5033c5fb899ddb49ea55dfba0b96 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 29 Aug 2026 15:07:18 +0000 Subject: [PATCH 24/75] Regen round 2 (BuildBuddy, compiler gunbc=75d74698aebcdb6e built from installed ce959e40604ffdd5): std_algebra.rs, std_nat.rs -- arrow returns now render through the Rust renderer (Rc> for List, Nat preserved); candidate patch sha b5b409aeebbeb6c4 --- src/v1/stage0/src/std_algebra.rs | 4 ++-- src/v1/stage0/src/std_nat.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/v1/stage0/src/std_algebra.rs b/src/v1/stage0/src/std_algebra.rs index a2b8c0e1f4c..03c8a17ad5e 100644 --- a/src/v1/stage0/src/std_algebra.rs +++ b/src/v1/stage0/src/std_algebra.rs @@ -281,8 +281,8 @@ pub struct FinitelySupportedFunction { pub insert: Rc Rc>>, pub merge: Rc>) -> Rc>>, - pub map_keys: Rc Rc>>, - pub map_values: Rc Rc>>, + pub map_keys: Rc Rc>>, + pub map_values: Rc Rc>>, pub map_has: Rc bool>, pub contains_key: Rc bool>, pub size: Rc i64>, diff --git a/src/v1/stage0/src/std_nat.rs b/src/v1/stage0/src/std_nat.rs index 19188c278f1..796b083f66c 100644 --- a/src/v1/stage0/src/std_nat.rs +++ b/src/v1/stage0/src/std_nat.rs @@ -42,11 +42,11 @@ pub fn nat_min(a: Nat, b: Nat) -> Nat { } } -pub fn nat_range_inclusive(lo: Nat, hi: Nat) -> Rc> { +pub fn nat_range_inclusive(lo: Nat, hi: Nat) -> Rc> { nat_range_accumulate(lo.clone(), hi.clone(), Rc::new(vec![])) } -pub fn nat_range_accumulate(mut lo: Nat, mut hi: Nat, mut acc: Rc>) -> Rc> { +pub fn nat_range_accumulate(mut lo: Nat, mut hi: Nat, mut acc: Rc>) -> Rc> { loop { if (lo.clone() > hi.clone()) { break acc; From 675d7ce78bad98139ab1dbb87be27ed538a61b84 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 29 Aug 2026 15:54:42 +0000 Subject: [PATCH 25/75] Arrow positions deviate from the generic renderer only for the two defect shapes: the unconditioned route emitted 2790 refusals where 15 stood; fix the arrow probe's variant spelling --- ...d_call_target_realization_witness_test.dag | 2 +- src/v1/05_emit_rust.dag | 32 +++++++++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/dag/test/claim/emitted_call_target_realization_witness_test.dag b/dag/test/claim/emitted_call_target_realization_witness_test.dag index cc462a5376e..f2a52bdcc57 100644 --- a/dag/test/claim/emitted_call_target_realization_witness_test.dag +++ b/dag/test/claim/emitted_call_target_realization_witness_test.dag @@ -320,7 +320,7 @@ test fn w_zero_param_alias_in_an_arrow_return_renders_without_its_rhs_arguments( // honours the binding and must be what an arrow's positions render through. test fn w_arrow_return_type_keeps_its_applied_binding() -> Bool { compile_dag_rust_emit_check( - "module test.claim.arrow_binding_probe\nimport std.types { Int, String }\nimport v2.std.diagnostic { Outcome }\ntype Box2 { v: T }\nfn probe() -> fn(Int) -> Outcome> { fn(n) { Outcome::Accepted { value: Box2 { v: \"x\" } } } }\n", + "module test.claim.arrow_binding_probe\nimport std.types { Int, String }\nimport v2.std.diagnostic { Outcome, Accepted }\ntype Box2 { v: T }\nfn probe() -> fn(Int) -> Outcome> { fn(n) { Accepted { value: Box2 { v: \"x\" } } } }\n", "src/test_claim_arrow_binding_probe.rs", ["Box2"], ["Rc>"] diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index 7d529fff27b..29d923c6ac8 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -233,6 +233,34 @@ fn render_rust_type(n: Node, shared_types: Set, source_indices: Map Rc>>>` -- the inner binding dropped (E0107 missing // generics for struct `Medium`, v2.compiler.compile stage_translate). The callable template and the // void arm are the same rows render_node_type consumes; only the per-position renderer changes. +// AN ARROW POSITION DEVIATES FROM THE TARGET-GENERIC RENDERER ONLY FOR THE TWO SHAPES THAT RENDERER +// CANNOT SPELL, AND THIS GATE IS MEASURED, NOT ASSUMED. The first cut routed EVERY arrow position +// through render_rust_type, and the regenerated seed then emitted 2790 rustc refusals on the +// 00_compile closure where the committed bytes had 15: the Rust renderer realizes a v2-declared +// Symbol/String structurally (Rc>, E0308 by the hundreds) and renders an out-of-scope +// type variable as `_` (E0121 inside fn signatures) -- spellings the generic renderer had been +// supplying at those positions, and which nothing in this change set out to alter. So a position +// takes the Rust renderer only when its subtree carries an applied-type binding the generic +// renderer would drop (the `Rc` E0107 class) or is itself a zero-parameter alias carrying +// its right-hand side's children (the `CompileLensOutcome<..>` E0107 class); every other position +// renders exactly as before this change. The deviation set is therefore the defect set. +fn render_rust_arrow_position(n: Node, shared_types: Set, source_indices: Map, emit_info: EmitGraphInfo) -> String { + let is_bare_zero_param_alias = n.connective == NoConnective && n.children |> count > 0 && closed_alias_peels_zero_param(env: emit_info.fn_type_env, n: n) + if type_node_carries_applied_binding(n: n, source_indices: source_indices) || is_bare_zero_param_alias { + render_rust_type(n: n, shared_types: shared_types, source_indices: source_indices, emit_info: emit_info) + } else { + render_node_type(n: n, target: Rust, shared_types: shared_types, source_indices: source_indices) + } +} + +fn type_node_carries_applied_binding(n: Node, source_indices: Map) -> Bool { + let own = match find_property(props: n.properties, prop_name: "__applied_type_args", source_indices: source_indices) { + Present { value: applied } => applied.children |> count > 0 + Absent => false + } + own || n.children |> any(c => type_node_carries_applied_binding(n: child_type_node(ch: c), source_indices: source_indices)) +} + // Named rather than inlined because `if x == Variant {` parses as a record literal in .dag. fn rust_type_node_is_arrow(n: Node) -> Bool { n.connective == Arrow @@ -240,11 +268,11 @@ fn rust_type_node_is_arrow(n: Node) -> Bool { fn render_rust_arrow_type(n: Node, shared_types: Set, source_indices: Map, emit_info: EmitGraphInfo) -> String { let repr = target_callable(target: Rust) - let param_strs = n.params |> map(p => render_rust_type(n: param_node_type_expr(n: p), shared_types: shared_types, source_indices: source_indices, emit_info: emit_info)) + let param_strs = n.params |> map(p => render_rust_arrow_position(n: param_node_type_expr(n: p), shared_types: shared_types, source_indices: source_indices, emit_info: emit_info)) let param_str = param_strs |> join(separator: repr.param_separator) let spec = language_spec(target: Rust) let ret_str = match n.inferred { - Present { value: Resolved { node: rt } } => render_rust_type(n: rt, shared_types: shared_types, source_indices: source_indices, emit_info: emit_info) + Present { value: Resolved { node: rt } } => render_rust_arrow_position(n: rt, shared_types: shared_types, source_indices: source_indices, emit_info: emit_info) _ => spec.void_type } match spec.callable_type_template { From 077318463ebd3c05f583b51ba564461cc3ee3ddd Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 29 Aug 2026 16:10:30 +0000 Subject: [PATCH 26/75] B: the init turbofish declines a declaration's own formals by the lambda's admission; F: a qualified type reference earns its use-line from the qualifier under export proof; both earlier cuts were measured non-events and are deleted --- ...d_call_target_realization_witness_test.dag | 11 +-- src/v1/05_emit_rust.dag | 70 +++++++++++-------- 2 files changed, 46 insertions(+), 35 deletions(-) diff --git a/dag/test/claim/emitted_call_target_realization_witness_test.dag b/dag/test/claim/emitted_call_target_realization_witness_test.dag index f2a52bdcc57..a5f78c03c3d 100644 --- a/dag/test/claim/emitted_call_target_realization_witness_test.dag +++ b/dag/test/claim/emitted_call_target_realization_witness_test.dag @@ -278,11 +278,14 @@ test fn w_witness_carrier_falls_back_to_the_fn_return_when_the_value_identity_is // FOLD ACCUMULATOR, THE DISCRIMINATING RED. A fold whose init is empty_map() took the Map // declaration's own formals as its accumulator and wrote them into the turbofish: -// `v1_rt::rc_empty_map::()`. The fn's declared Map return is the resolved -// accumulator and must be what the init renders from. +// `v1_rt::rc_empty_map::()`. THE PROBE IMPORTS NOTHING ON PURPOSE: it mirrors +// v2.lens.unit_modeling, which resolves Map, Symbol, empty_map and map_insert by namespace alone -- +// under an explicit `import std.types { Map }` the accumulator resolves to the kernel container and +// the defect never fires (measured: that probe emitted `rc_empty_map::` on the +// defective compiler). The init must decline the formals exactly as the lambda beside it does. test fn w_fold_empty_map_init_renders_the_resolved_accumulator_not_the_declaration_formals() -> Bool { compile_dag_rust_emit_check( - "module test.claim.fold_accumulator_probe\nimport std.types { Int, String, Map }\nimport v2.std.node { Symbol }\nimport v2.std.collection { empty_map, map_insert }\ntype Row { field: Symbol, carrier: Symbol }\nfn rows() -> List { [Row { field: ^a, carrier: ^b }] }\nfn probe() -> Map { fold(rows(), init: empty_map(), f: fn(acc, row) { map_insert(m: acc, key: row.field, value: row.carrier) }) }\n", + "module test.claim.fold_accumulator_probe\n\ntype Row {\n field: Symbol\n carrier: Symbol\n}\n\ndata rows: List = [\n Row { field: ^a, carrier: ^b }\n]\n\nfn probe() -> Map {\n fold(rows, init: empty_map(), f: fn(acc, row) {\n map_insert(m: acc, key: row.field, value: row.carrier)\n })\n}\n", "src/test_claim_fold_accumulator_probe.rs", ["rc_empty_map::<"], ["rc_empty_map::"] @@ -335,7 +338,7 @@ test fn w_qualified_type_reference_earns_the_leaf_use_line() -> Bool { compile_dag_rust_emit_check( "module test.claim.qualified_type_ref_probe\nimport std.types { String }\ntype Fact { signature: String, classification: std.determinism.Determinism }\nfn probe(f: Fact) -> std.determinism.Determinism { f.classification }\n", "src/test_claim_qualified_type_ref_probe.rs", - ["use crate::std_determinism::Determinism"], + ["use crate::std_determinism::Determinism;"], ["std.determinism.Determinism"] ) } diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index 29d923c6ac8..6dcc0945adc 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -4182,7 +4182,6 @@ fn reference_derived_use_line_plan(items: List, unlisted_type_names: List< let value_names = unique_strings(items: items |> flat_map(item => collect_value_ref_names(n: item, source_indices: source_indices, type_summaries: emit_info.type_summaries, variant_to_enum: emit_info.variant_to_enum))) let item_emit_surface_names = items |> flat_map(item => collect_item_emit_surface_names(item: item, source_indices: source_indices, emit_info: emit_info)) let type_surface_names = unique_strings(items: item_emit_surface_names) - let qualified_surface_leaves = qualified_type_surface_leaf_candidates(names: type_surface_names, registry: registry) let field_surface_names = collect_items_field_import_surface_names(surface_names: item_emit_surface_names, emit_info: emit_info) let variant_payload_structs = expand_variant_payload_struct_imports(names: type_surface_names, type_summaries: emit_info.type_summaries, variant_to_enum: emit_info.variant_to_enum) let emitter_attested_anon_heads = unique_strings(items: items |> flat_map(item => collect_anonymous_record_lit_heads(n: item, source_indices: source_indices, type_summaries: emit_info.type_summaries))) @@ -4190,7 +4189,7 @@ fn reference_derived_use_line_plan(items: List, unlisted_type_names: List< let emitted_source_tokens = rust_identifier_tokens(s: emitted_source) let emitted_source_token_set = emitted_source_tokens |> fold(init: empty_map(), f: (acc, t) => map_insert(acc, t, true)) - let candidates = unique_strings(items: concat(concat(concat(concat(concat(concat(unlisted_type_names, value_names), type_surface_names), qualified_surface_leaves), field_surface_names), variant_payload_structs), realized_surface_names)) + let candidates = unique_strings(items: concat(concat(concat(concat(concat(unlisted_type_names, value_names), type_surface_names), field_surface_names), variant_payload_structs), realized_surface_names)) |> filter(name => reference_derived_candidate_authored(module_source: module_source, name: name, type_summaries: emit_info.type_summaries, variant_to_enum: emit_info.variant_to_enum) || emitter_attested_anon_heads |> any(h => h == name) @@ -4245,7 +4244,9 @@ fn reference_derived_use_line_plan(items: List, unlisted_type_names: List< ) concat(block_lines, fallback) ) - ReferenceDerivedUseLinePlan { lines: lines, rows: rows } + let names_already_in_lines = lines |> flat_map(l => imported_names_in_use_line(line: l)) + let qualified_lines = qualified_type_reference_use_lines(names: type_surface_names, this_module_name: this_module_name, already: already, names_already_in_lines: names_already_in_lines, registry: registry, export_sets: export_sets, typed_modules: typed_modules, source_indices: source_indices, module_index: module_index) + ReferenceDerivedUseLinePlan { lines: concat(lines, qualified_lines), rows: rows } } } @@ -4254,26 +4255,28 @@ fn reference_derived_use_line_plan(items: List, unlisted_type_names: List< // the surface walk collects the DOTTED spelling -- which is never an identifier token in the emitted // source, so the candidate filter dropped it before any disposition was assigned and the module // referenced a name it never imported (E0425 cannot find type `Determinism`, v2.std.determinism, -// two sites). The leaf is admitted as a candidate only when the qualified registry row resolves it -// AND the bare row names the SAME declaring module: the downstream lookups are bare-keyed and -// last-write-wins, and a leaf whose bare row points elsewhere would import a homonym from the wrong -// provider. That disagreement stays a loud unresolved name rather than a fabricated use-line. -fn qualified_type_surface_leaf_candidates(names: List, registry: Map) -> List { - names |> flat_map(name => +// two sites). The qualifier IS the provider the author named, so the line is synthesized from it +// directly -- under the same construction wall every other synthesized use-line passes: +// provider_proven_exports_symbol must hold for the leaf on that module, or nothing is emitted and +// the name stays a loud unresolved symbol. A first cut keyed this on the qualified item-registry +// overlay instead; that overlay carries no row for the reference and the cut was a measured +// NON-EVENT (falsifier m12 reddened nothing; the two sites stayed), so it is replaced, not kept. +fn qualified_type_reference_use_lines(names: List, this_module_name: String, already: Map, names_already_in_lines: List, registry: Map, export_sets: Map>, typed_modules: List, source_indices: Map, module_index: ModuleIndex) -> List { + let leaves_done = names_already_in_lines |> fold(init: empty_map(), f: (acc, nm) => map_insert(acc, nm, true)) + unique_strings(items: names |> flat_map(name => if !string_contains(s: name, pattern: ".") { [] } else { let leaf = qualified_last_segment(name: name) - match map_get(registry, name) { - Present { value: qualified_info } => - if is_duplicate_qualified_item_registry_marker(info: qualified_info) { [] } else { - match map_get(registry, leaf) { - Present { value: bare_info } => if bare_info.module_name == qualified_info.module_name { [leaf] } else { [] } - Absent => [] - } - } - Absent => [] + let segments = name |> split(delimiter: ".") + let qualifier = segments |> take(n: (segments |> count) - 1) |> join(separator: ".") + if qualifier == this_module_name || emit_map_has(m: already, key: leaf) || emit_map_has(m: leaves_done, key: leaf) || is_kernel_type(name: leaf) { + [] + } else if provider_proven_exports_symbol(name: leaf, provider_module: qualifier, export_sets: export_sets, typed_modules: typed_modules, source_indices: source_indices, module_index: module_index) { + [concat(rust_visibility_prefix(), "use crate::", module_to_filename(name: qualifier), "::", emit_import_name(n: leaf, registry: registry), ";")] + } else { + [] } } - ) + )) } fn reference_derived_use_lines(items: List, unlisted_type_names: List, this_module_name: String, registry: Map, emit_info: EmitGraphInfo, local_type_names: List, already_imported_names: List, export_sets: Map>, typed_modules: List, source_indices: Map, module_index: ModuleIndex, shared_types: Set, emitted_source: String) -> List { @@ -10123,15 +10126,19 @@ fn emit_typed_fold_lambda(lambda_expr: Node, acc_type_str: String, elem_type_str // instead would restate it, and would then have to be kept in step with any future change to the strip // -- reintroducing the shape of this defect while fixing this instance of it. `_` is also the device // already used for elem_render_has_spurious_generic a few bindings earlier. -// THE UNDER-RESOLVED-GENERIC ACCUMULATOR ARM (is_under_resolved_generic below): -// A DECLARATION'S OWN PARAMETER NAMES ARE NOT A RESOLVED ACCUMULATOR. fold_accumulator_type can -// arrive as the container declaration's parametric shape -- Map with K and V the -// declaration's formals, bound to nothing at this call -- and the four shape tests above all -// read that as resolved (two children, neither unit-like). The init arm then wrote the formals -// straight into a turbofish, `v1_rt::rc_empty_map::()`, four sites on the 00_compile -// closure (v2.lens.unit_modeling) while the lambda beside it had already fallen back to `_`. -// The contextual method result type IS the resolved accumulator here, so a shape whose atoms are -// unbound in the closure scope is under-resolved exactly like an empty one. +// THE INIT TURBOFISH DECLINES A DECLARATION'S OWN FORMALS, BY THE SAME ADMISSION THE LAMBDA USES. +// In a module that resolves Map, Symbol, empty_map and map_insert by namespace alone +// (v2.lens.unit_modeling imports none of them), the fold's accumulator arrives as the v2 Map +// declaration's parametric shape -- Map with K and V the declaration's formals -- and so +// does the call's contextual result type, so no choice between the two helps. The lambda beside +// the init already renders such an accumulator as `_` (rust_fold_rendered_type_has_any_spurious_generic +// over the rendered string), while the init arm wrote the formals into a turbofish: +// `v1_rt::rc_empty_map::()`, four sites on the 00_compile closure. The init now asks the same +// rendered-string admission and, where the formals are unbound in this fn's generic scope, defers +// the key and value types to the target's own inference exactly as the lambda does -- rustc binds +// them from the fold body or refuses loudly. An earlier cut of this repair instead widened the +// "under-resolved accumulator" test to prefer the contextual type; that was a measured NON-EVENT +// (falsifier m09: removing it reddened nothing, and the four sites stayed) and is deleted. fn emit_rust_fold_method_call(method_call_node: Node, fold_accumulator_type: Node?, result_type: InferredNode?, receiver: Node, args: List, registry: Map, scope: InferScope, depth: Int, shared_types: Set, emit_info: EmitGraphInfo) -> String { let recv_str = emit_typed_iter_owned_receiver(receiver: receiver, downstream: args, registry: registry, scope: scope, depth: depth, shared_types: shared_types, emit_info: emit_info) let elem_type_str = collection_element_type(receiver_type: receiver.inferred, shared_types: shared_types, source_indices: scope.type_env.source_indices, emit_info: emit_info, type_env: scope.type_env) @@ -10146,8 +10153,7 @@ fn emit_rust_fold_method_call(method_call_node: Node, fold_accumulator_type: Nod let is_under_resolved_list = node_is_element_collection(n: acc_type, source_indices: scope.type_env.source_indices) && !node_is_set_collection(n: acc_type, source_indices: scope.type_env.source_indices) && acc_type.children |> count == 0 let is_under_resolved_set = node_is_set_collection(n: acc_type, source_indices: scope.type_env.source_indices) && (acc_type.children |> count == 0 || acc_children_have_unit) let is_under_resolved_non_collection = !node_is_keyed_collection(n: acc_type, source_indices: scope.type_env.source_indices) && !node_is_element_collection(n: acc_type, source_indices: scope.type_env.source_indices) && !node_is_collection(n: acc_type, source_indices: scope.type_env.source_indices) - let is_under_resolved_generic = type_node_has_closure_unbound_generic_atom(n: acc_type, generic_param_names: emit_info.fn_generic_param_names, env: scope.type_env, source_indices: scope.type_env.source_indices) - if is_under_resolved_map || is_under_resolved_list || is_under_resolved_set || is_under_resolved_non_collection || is_under_resolved_generic { + if is_under_resolved_map || is_under_resolved_list || is_under_resolved_set || is_under_resolved_non_collection { match contextual_acc_type { Present { value: concrete_type } => concrete_type Absent => acc_type @@ -10263,7 +10269,9 @@ fn emit_rust_fold_method_call(method_call_node: Node, fold_accumulator_type: Nod let init_func = expr_call_func_at(texpr: arg_value(n: init_arg), source_indices: scope.type_env.source_indices) if init_func == "empty_map" && acc_type_str != "_" && acc_type_str != "" && !acc_has_unit_child { let kv_type_str = rust_empty_map_kv_type_str(map_type: acc_type_node, shared_types: shared_types, source_indices: scope.type_env.source_indices) - if kv_type_str != "" { + if kv_type_str != "" && rust_fold_rendered_type_has_any_spurious_generic(type_str: concat("<", kv_type_str, ">"), generic_param_names: emit_info.fn_generic_param_names) { + "v1_rt::rc_empty_map::<_, _>()" + } else if kv_type_str != "" { concat("v1_rt::rc_empty_map::<", kv_type_str, ">()") } else { rust_shared_wrap_ctor(inner_expr: "HashMap::new() /* BRIDGE: fold empty_map value type unresolved */") From a5120f16b74fdcaf72c7357b0d74446bb0991c61 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 29 Aug 2026 17:16:02 +0000 Subject: [PATCH 27/75] Regenerate the stage0 mirror at the 0773184 freeze: byte fixed point at round 3, three paths, each explained by an authority change srv1 (/tmp/xl0e.sh -> /tmp/xl0j.log), criterion = every regen-population file byte-equal to installed; full workspace rebuilt as the gate each round. round 1 gunbc=1dc61ba198c6750b from installed 0479b0df9fc5598e -> v1_compiler_emit_rust.rs round 2 gunbc=909aa212f353bd03 from installed 8ebedc7445fadbaa -> std_algebra.rs, v1_compiler_trait_derive_emit.rs round 3 gunbc=0d0cd70ec5b20db9 from installed 8713cb43f8ad848c -> BYTE FIXED POINT v1_compiler_emit_rust.rs <- 05_emit_rust.dag (gated arrow position, init turbofish admission, qualified-type use-lines) std_algebra.rs <- the gated arrow route restores the pre-e9900e2 spelling of the two arrow-typed fields v1_compiler_trait_derive_emit.rs <- one use-line synthesized for a qualified std.types.List reference under export proof Final installed tree 8713cb43f8ad848c. No hand edit to any generated file. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01GXfYKNQTD3VfYyQcnJpxNU --- src/v1/stage0/src/std_algebra.rs | 4 +- src/v1/stage0/src/v1_compiler_emit_rust.rs | 205 ++++++++++++------ .../src/v1_compiler_trait_derive_emit.rs | 1 + 3 files changed, 142 insertions(+), 68 deletions(-) diff --git a/src/v1/stage0/src/std_algebra.rs b/src/v1/stage0/src/std_algebra.rs index 03c8a17ad5e..a2b8c0e1f4c 100644 --- a/src/v1/stage0/src/std_algebra.rs +++ b/src/v1/stage0/src/std_algebra.rs @@ -281,8 +281,8 @@ pub struct FinitelySupportedFunction { pub insert: Rc Rc>>, pub merge: Rc>) -> Rc>>, - pub map_keys: Rc Rc>>, - pub map_values: Rc Rc>>, + pub map_keys: Rc Rc>>, + pub map_values: Rc Rc>>, pub map_has: Rc bool>, pub contains_key: Rc bool>, pub size: Rc i64>, diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index 8e912f6ecc4..9f85f01ae36 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -319,6 +319,65 @@ pub fn render_rust_type( } } +pub fn render_rust_arrow_position( + n: Rc, + shared_types: Rc>, + source_indices: Rc>>, + emit_info: Rc, +) -> String { + { + let is_bare_zero_param_alias = (((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) > 0)) + && closed_alias_peels_zero_param(emit_info.fn_type_env.clone(), n.clone())); + if (type_node_carries_applied_binding(n.clone(), source_indices.clone()) + || is_bare_zero_param_alias.clone()) + { + render_rust_type( + n.clone(), + shared_types.clone(), + source_indices.clone(), + emit_info.clone(), + ) + } else { + crate::v1_compiler_emit::render_node_type( + n.clone(), + RenderTarget::Rust, + shared_types.clone(), + source_indices.clone(), + ) + } + } +} + +pub fn type_node_carries_applied_binding( + n: Rc, + source_indices: Rc>>, +) -> bool { + stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { + let own = match crate::v1_std_core::find_property( + n.properties.clone(), + "__applied_type_args".to_string(), + source_indices.clone(), + ) { + Some(applied) => ((applied.children.clone().len() as i64) > 0), + None => false, + }; + (own.clone() || { + let mut __found = false; + for c in n.children.clone().iter().cloned() { + if type_node_carries_applied_binding( + crate::v1_compiler_infer_types::child_type_node(c.clone()), + source_indices.clone(), + ) { + __found = true; + break; + } + } + __found + }) + }) +} + pub fn rust_type_node_is_arrow(n: Rc) -> bool { (n.connective.clone() == Connective::Arrow) } @@ -334,7 +393,7 @@ pub fn render_rust_arrow_type( let param_strs = Rc::new({ let mut __result = Vec::new(); for p in n.params.clone().iter().cloned() { - __result.push(render_rust_type( + __result.push(render_rust_arrow_position( crate::v1_std_core::param_node_type_expr(p.clone()), shared_types.clone(), source_indices.clone(), @@ -346,7 +405,7 @@ pub fn render_rust_arrow_type( let param_str = param_strs.clone().join(&repr.param_separator.clone()); let spec = crate::v1_compiler_emit_core_support::language_spec(RenderTarget::Rust); let ret_str = match n.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: rt, .. }) => render_rust_type( + Some(InferredNode::Resolved { node: rt, .. }) => render_rust_arrow_position( rt.clone(), shared_types.clone(), source_indices.clone(), @@ -8321,8 +8380,6 @@ pub fn reference_derived_use_line_plan( }); let type_surface_names = crate::v1_compiler_emit_core_support::unique_strings(item_emit_surface_names.clone()); - let qualified_surface_leaves = - qualified_type_surface_leaf_candidates(type_surface_names.clone(), registry.clone()); let field_surface_names = collect_items_field_import_surface_names( item_emit_surface_names.clone(), emit_info.clone(), @@ -8380,14 +8437,8 @@ pub fn reference_derived_use_line_plan( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - unlisted_type_names.clone(), - value_names.clone(), - ), - type_surface_names.clone(), - ), - qualified_surface_leaves.clone(), + v1_rt::concat(unlisted_type_names.clone(), value_names.clone()), + type_surface_names.clone(), ), field_surface_names.clone(), ), @@ -8574,57 +8625,74 @@ v1_rt::concat(block_lines.clone(), fallback.clone()) } __result }); + let names_already_in_lines = Rc::new({ + let mut __result = Vec::new(); + for l in lines.iter().cloned() { + __result.extend((*imported_names_in_use_line(l.clone())).iter().cloned()); + } + __result + }); + let qualified_lines = qualified_type_reference_use_lines( + type_surface_names.clone(), + this_module_name.clone(), + already.clone(), + names_already_in_lines.clone(), + registry.clone(), + export_sets.clone(), + typed_modules.clone(), + source_indices.clone(), + module_index.clone(), + ); Rc::new(ReferenceDerivedUseLinePlan { - lines: lines.clone(), + lines: v1_rt::concat(lines.clone(), qualified_lines.clone()), rows: rows.clone(), }) } } -pub fn qualified_type_surface_leaf_candidates( +pub fn qualified_type_reference_use_lines( names: Rc>, + this_module_name: String, + already: Rc>, + names_already_in_lines: Rc>, registry: Rc>>, + export_sets: Rc>>>, + typed_modules: Rc>>, + source_indices: Rc>>, + module_index: Rc, ) -> Rc> { - Rc::new({ - let mut __result = Vec::new(); - for name in names.iter().cloned() { - __result.extend( - (*if !v1_rt::string_contains(&name, ".".to_string()) { + { + let leaves_done = names_already_in_lines.iter().cloned().fold( + v1_rt::rc_empty_map::(), + |acc: Rc>, nm: String| { + v1_rt::rc_map_insert(acc, nm.clone(), true) + }, + ); + crate::v1_compiler_emit_core_support::unique_strings(Rc::new({ + let mut __result = Vec::new(); + for name in names.iter().cloned() { + __result.extend((*if !v1_rt::string_contains(&name, ".".to_string()) { + Rc::new(vec![]) + } else { + { + let leaf = crate::v1_std_core::qualified_last_segment(name.clone()); +let segments = Rc::new(name.clone().split(&".".to_string()).map(|s| s.to_string()).collect::>()); +let qualifier = Rc::new(segments.clone().iter().cloned().take(((segments.clone().len() as i64) - 1) as usize).collect::>()).join(&".".to_string()); +if ((((qualifier.clone() == this_module_name.clone()) || crate::v1_compiler_infer_types::emit_map_has(already.clone(), leaf.clone())) || crate::v1_compiler_infer_types::emit_map_has(leaves_done.clone(), leaf.clone())) || crate::std_types::is_kernel_type(leaf.clone())) { Rc::new(vec![]) } else { - { - let leaf = crate::v1_std_core::qualified_last_segment(name.clone()); - match v1_rt::map_get(®istry, name.clone()) { - Some(qualified_info) => { - if is_duplicate_qualified_item_registry_marker( - qualified_info.clone(), - ) { - Rc::new(vec![]) - } else { - match v1_rt::map_get(®istry, leaf.clone()) { - Some(bare_info) => { - if (bare_info.module_name.clone() - == qualified_info.module_name.clone()) - { - Rc::new(vec![leaf.clone()]) - } else { - Rc::new(vec![]) - } - } - None => Rc::new(vec![]), - } - } - } - None => Rc::new(vec![]), - } + if provider_proven_exports_symbol(leaf.clone(), qualifier.clone(), export_sets.clone(), typed_modules.clone(), source_indices.clone(), module_index.clone()) { + Rc::new(vec![v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visibility_prefix(), "use crate::".to_string()), crate::v1_compiler_emit_core_support::module_to_filename(qualifier.clone())), "::".to_string()), emit_import_name(leaf.clone(), registry.clone())), ";".to_string())]) + } else { + Rc::new(vec![]) } - }) - .iter() - .cloned(), - ); - } - __result - }) + } +} + }).iter().cloned()); + } + __result + })) + } } pub fn reference_derived_use_lines( @@ -23736,16 +23804,9 @@ pub fn emit_rust_fold_method_call( acc_type.clone(), scope.type_env.clone().source_indices.clone(), )); - let is_under_resolved_generic = type_node_has_closure_unbound_generic_atom( - acc_type.clone(), - emit_info.fn_generic_param_names.clone(), - scope.type_env.clone(), - scope.type_env.clone().source_indices.clone(), - ); - if ((((is_under_resolved_map.clone() || is_under_resolved_list.clone()) + if (((is_under_resolved_map.clone() || is_under_resolved_list.clone()) || is_under_resolved_set.clone()) || is_under_resolved_non_collection.clone()) - || is_under_resolved_generic.clone()) { match contextual_acc_type.clone() { Some(concrete_type) => concrete_type.clone(), @@ -24012,16 +24073,28 @@ pub fn emit_rust_fold_method_call( shared_types.clone(), scope.type_env.clone().source_indices.clone(), ); - if (kv_type_str.clone() != "".to_string()) { - v1_rt::concat( + if ((kv_type_str.clone() != "".to_string()) + && rust_fold_rendered_type_has_any_spurious_generic( v1_rt::concat( - "v1_rt::rc_empty_map::<".to_string(), - kv_type_str.clone(), + v1_rt::concat("<".to_string(), kv_type_str.clone()), + ">".to_string(), ), - ">()".to_string(), - ) + emit_info.fn_generic_param_names.clone(), + )) + { + "v1_rt::rc_empty_map::<_, _>()".to_string() } else { - rust_shared_wrap_ctor("HashMap::new() /* BRIDGE: fold empty_map value type unresolved */".to_string()) + if (kv_type_str.clone() != "".to_string()) { + v1_rt::concat( + v1_rt::concat( + "v1_rt::rc_empty_map::<".to_string(), + kv_type_str.clone(), + ), + ">()".to_string(), + ) + } else { + rust_shared_wrap_ctor("HashMap::new() /* BRIDGE: fold empty_map value type unresolved */".to_string()) + } } } } else { diff --git a/src/v1/stage0/src/v1_compiler_trait_derive_emit.rs b/src/v1/stage0/src/v1_compiler_trait_derive_emit.rs index cec8ebda4e1..9427918702f 100644 --- a/src/v1/stage0/src/v1_compiler_trait_derive_emit.rs +++ b/src/v1/stage0/src/v1_compiler_trait_derive_emit.rs @@ -37,6 +37,7 @@ pub use crate::std_trait_derive_shape::{ repr_grounding_derive_completeness_predicate, repr_grounding_group_completion_carrier, repr_grounding_supplemental_bool_host_bridge_target, }; +pub use crate::std_types::List; pub use crate::std_types::{container_template_algebra, is_container_type}; pub use crate::v1_compiler_artifact::RenderTarget; use crate::v1_compiler_artifact::RenderTarget::Rust; From b0e4ad377634a4f08f9389ae6b9e784ed0223716 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 29 Aug 2026 19:52:16 +0000 Subject: [PATCH 28/75] One renderer for every arrow position; a type position never takes the variant arm; the qualified route synthesizes use-lines only for types the emitted source names Four regressions the 0773184 fixed point put on the closure, each with its discriminating row: - E0603 x16: the qualified-type route synthesized `pub use crate::v2_std_nat::Succ;` for every `v2.std.nat.Succ { prev: .. }` record literal. A qualified name reaches the surface walk in the same dotted spelling whether it is a type or a variant head; the route now asks the registry whether the leaf is a TYPE declared in the named qualifier, records each decision as a census row, and considers only leaves the emitted source actually names (it had also synthesized an unused `DeclarationRef` import from a variant payload). w_qualified_variant_head_earns_no_type_use_line. - `Outcome` x3 and `Rc` E0107: two cuts had each introduced a second per-position renderer for arrow types beside the one fn parameters use. An arrow's return is not a different kind of type from its parameter: both positions now render through render_rust_fn_sig_type, and render_rust_type_with_applied_binding -- which rebuilt its EmitGraphInfo with an empty generic scope, so a fn-scope `C` rendered `_` (E0121) -- carries the fn's generic names through that hop. The measured gate over the second renderer is deleted. w_generic_arrow_return_renders_the_fn_scope_generic; w_arrow_return_type_keeps_its_applied_binding (its fixture was an invalid program: Accepted lacked `diagnostics`). - v2.std.determinism E0425 x2: traced to the bare-name disposition, not the qualified route -- `Determinism` is a type in std.determinism and a variant of v2.lens.registry LensIdV0, and is_known_variant is corpus-wide by spelling, so a TYPE-position reference was delegated to an enum it never named. A name in one of the module's type positions never takes the variant arm. a_known_variant_spelling_in_a_type_position_takes_the_registry_arm (red by construction on the old arm); the harness row is a positive control and says so, because the witness harness refuses any pool carrying the colliding variant with NoSuchVariable. Verified on a test binary built from the self-emitted emitter (not a regeneration): witnesses 23/24 -> 24/24 after the harness row was reshaped; closure instrument 2799 -> 2779. The regeneration that binds these to the mirror follows as its own commit after the freeze merge. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01GXfYKNQTD3VfYyQcnJpxNU --- ...d_call_target_realization_witness_test.dag | 50 ++++++- src/v1/05_emit_rust.dag | 137 +++++++++++------- ...erived_disposition_census_witness_test.dag | 33 ++++- 3 files changed, 156 insertions(+), 64 deletions(-) diff --git a/dag/test/claim/emitted_call_target_realization_witness_test.dag b/dag/test/claim/emitted_call_target_realization_witness_test.dag index a5f78c03c3d..a42610a4669 100644 --- a/dag/test/claim/emitted_call_target_realization_witness_test.dag +++ b/dag/test/claim/emitted_call_target_realization_witness_test.dag @@ -278,14 +278,15 @@ test fn w_witness_carrier_falls_back_to_the_fn_return_when_the_value_identity_is // FOLD ACCUMULATOR, THE DISCRIMINATING RED. A fold whose init is empty_map() took the Map // declaration's own formals as its accumulator and wrote them into the turbofish: -// `v1_rt::rc_empty_map::()`. THE PROBE IMPORTS NOTHING ON PURPOSE: it mirrors +// `v1_rt::rc_empty_map::()`. THE PROBE IMPORTS ONLY `Symbol` (the harness pool is the probe's +// import closure, so an unimported `Symbol` refuses there while the whole corpus binds it): it mirrors // v2.lens.unit_modeling, which resolves Map, Symbol, empty_map and map_insert by namespace alone -- // under an explicit `import std.types { Map }` the accumulator resolves to the kernel container and // the defect never fires (measured: that probe emitted `rc_empty_map::` on the // defective compiler). The init must decline the formals exactly as the lambda beside it does. test fn w_fold_empty_map_init_renders_the_resolved_accumulator_not_the_declaration_formals() -> Bool { compile_dag_rust_emit_check( - "module test.claim.fold_accumulator_probe\n\ntype Row {\n field: Symbol\n carrier: Symbol\n}\n\ndata rows: List = [\n Row { field: ^a, carrier: ^b }\n]\n\nfn probe() -> Map {\n fold(rows, init: empty_map(), f: fn(acc, row) {\n map_insert(m: acc, key: row.field, value: row.carrier)\n })\n}\n", + "module test.claim.fold_accumulator_probe\nimport v2.std.node { Symbol }\n\ntype Row {\n field: Symbol\n carrier: Symbol\n}\n\ndata rows: List = [\n Row { field: ^a, carrier: ^b }\n]\n\nfn probe() -> Map {\n fold(rows, init: empty_map(), f: fn(acc, row) {\n map_insert(m: acc, key: row.field, value: row.carrier)\n })\n}\n", "src/test_claim_fold_accumulator_probe.rs", ["rc_empty_map::<"], ["rc_empty_map::"] @@ -323,26 +324,59 @@ test fn w_zero_param_alias_in_an_arrow_return_renders_without_its_rhs_arguments( // honours the binding and must be what an arrow's positions render through. test fn w_arrow_return_type_keeps_its_applied_binding() -> Bool { compile_dag_rust_emit_check( - "module test.claim.arrow_binding_probe\nimport std.types { Int, String }\nimport v2.std.diagnostic { Outcome, Accepted }\ntype Box2 { v: T }\nfn probe() -> fn(Int) -> Outcome> { fn(n) { Accepted { value: Box2 { v: \"x\" } } } }\n", + "module test.claim.arrow_binding_probe\nimport std.types { Int, String }\nimport v2.std.diagnostic { Outcome, Accepted }\ntype Box2 { v: T }\nfn probe() -> fn(Int) -> Outcome> { fn(n) { Accepted { value: Box2 { v: \"x\" }, diagnostics: None } } }\n", "src/test_claim_arrow_binding_probe.rs", ["Box2"], ["Rc>"] ) } -// QUALIFIED TYPE REFERENCE, THE DISCRIMINATING RED. A field typed `std.determinism.Determinism` -// with no import renders as bare `Determinism`, and the use-line derivation collected the DOTTED -// spelling, which is never an emitted token, so the module referenced a name it never imported. -// The leaf must earn its use-line from the qualified registry row. +// QUALIFIED TYPE REFERENCE, POSITIVE CONTROL ONLY. A field typed `std.determinism.Determinism` with +// no import renders as bare `Determinism` and must earn `use crate::std_determinism::{Determinism};`. +// The defect that opened this class (v2.std.determinism, E0425 x2 on the whole closure) fires only +// when the pool also carries a coproduct with a VARIANT spelled `Determinism` (v2.lens.registry +// LensIdV0): the bare-name disposition classified the type-position leaf as that variant. This +// harness cannot carry that pool -- it refuses any probe whose closure includes such a module with +// NoSuchVariable (reproduced with a data-free fixture coproduct; the same probe compiles and earns +// the line from the CLI), so this row is satisfied by the unfixed emitter too and is NOT the class's +// discriminating red. That red is a_known_variant_spelling_in_a_type_position_takes_the_registry_arm +// in src/v1/tests/claim/reference_derived_disposition_census_witness_test.dag (the disposition at +// function grain, red by construction on the variant arm) together with the closure count of the +// use-line in v2_std_determinism.rs. test fn w_qualified_type_reference_earns_the_leaf_use_line() -> Bool { compile_dag_rust_emit_check( "module test.claim.qualified_type_ref_probe\nimport std.types { String }\ntype Fact { signature: String, classification: std.determinism.Determinism }\nfn probe(f: Fact) -> std.determinism.Determinism { f.classification }\n", "src/test_claim_qualified_type_ref_probe.rs", - ["use crate::std_determinism::Determinism;"], + ["use crate::std_determinism::{Determinism};"], ["std.determinism.Determinism"] ) } +// QUALIFIED VALUE HEAD, THE OTHER DIRECTION. `v2.std.nat.Succ { prev: .. }` is a variant record +// literal; the value route imports it through its parent enum, and this route must synthesize +// nothing for it (E0603 `variant import is private`, sixteen sites on the first regeneration). +test fn w_qualified_variant_head_earns_no_type_use_line() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.qualified_variant_head_probe\nimport v2.std.nat { Nat, Zero }\nfn probe() -> Nat { v2.std.nat.Succ { prev: Zero } }\n", + "src/test_claim_qualified_variant_head_probe.rs", + ["Succ"], + ["use crate::v2_std_nat::Succ;"] + ) +} + +// GENERIC ARROW RETURN. A fn-scope generic inside an arrow return position rendered by its erased +// inference -- `Rc>` (v2.std.staging +// then_outcome, three sites) -- while the same shape in a parameter position rendered `C`. Both +// positions now ask the fn-signature renderer. +test fn w_generic_arrow_return_renders_the_fn_scope_generic() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.generic_arrow_probe\nimport v2.std.diagnostic { Outcome, Accepted, Rejected }\nfn then2(f: fn(A) -> Outcome, g: fn(B) -> Outcome) -> fn(A) -> Outcome {\n fn(a) { match f(a) { Accepted { value: b, diagnostics: _ } => g(b) Rejected { diagnostics: d } => Rejected { diagnostics: d } } }\n}\n", + "src/test_claim_generic_arrow_probe.rs", + ["-> Rc Rc>>"], + ["UNRESOLVED_"] + ) +} + // SERVICE OP WITHOUT A REALIZATION, THE DISCRIMINATING RED. `Filesystem.Read(path:)` inside a fn // the signature authority judged service-free emitted `filesystem.read(path).await?` -- an unbound // name in a non-async fn, the only `.await?` in the whole closure. It is a host seam with no diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index 6dcc0945adc..6705b8f3d8f 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -226,39 +226,23 @@ fn render_rust_type(n: Node, shared_types: Set, source_indices: Map Outcome>` came out as -// `Rc Rc>>>` -- the inner binding dropped (E0107 missing -// generics for struct `Medium`, v2.compiler.compile stage_translate). The callable template and the -// void arm are the same rows render_node_type consumes; only the per-position renderer changes. -// AN ARROW POSITION DEVIATES FROM THE TARGET-GENERIC RENDERER ONLY FOR THE TWO SHAPES THAT RENDERER -// CANNOT SPELL, AND THIS GATE IS MEASURED, NOT ASSUMED. The first cut routed EVERY arrow position -// through render_rust_type, and the regenerated seed then emitted 2790 rustc refusals on the -// 00_compile closure where the committed bytes had 15: the Rust renderer realizes a v2-declared -// Symbol/String structurally (Rc>, E0308 by the hundreds) and renders an out-of-scope -// type variable as `_` (E0121 inside fn signatures) -- spellings the generic renderer had been -// supplying at those positions, and which nothing in this change set out to alter. So a position -// takes the Rust renderer only when its subtree carries an applied-type binding the generic -// renderer would drop (the `Rc` E0107 class) or is itself a zero-parameter alias carrying -// its right-hand side's children (the `CompileLensOutcome<..>` E0107 class); every other position -// renders exactly as before this change. The deviation set is therefore the defect set. +// the Rust renderers exist to honour: `fn(ResolvedTree) -> Outcome>` came out as +// `Rc Rc>>>` (E0107, v2.compiler.compile stage_translate). +// Two earlier cuts each introduced a SECOND per-position renderer beside the parameter side's: +// routing every position through render_rust_type rendered a fn-scope generic by its erased +// inference (`Outcome`, v2.std.staging then_outcome), +// and a gate that admitted only applied-binding subtrees kept that defect for exactly those +// subtrees while re-opening `Rc` for the rest. The parameter side of the same arrow -- +// emit_rust_param_type's `impl Fn(A) -> Rc>` -- had rendered both shapes correctly all +// along, through render_rust_fn_sig_type in the fn's generic scope. An arrow's return is not a +// different kind of type from an arrow's parameter, so both positions ask that renderer, and the +// defect set is whatever that renderer gets wrong, which the parameter side already measures. +// The callable template and the void arm are the same rows render_node_type consumes. fn render_rust_arrow_position(n: Node, shared_types: Set, source_indices: Map, emit_info: EmitGraphInfo) -> String { - let is_bare_zero_param_alias = n.connective == NoConnective && n.children |> count > 0 && closed_alias_peels_zero_param(env: emit_info.fn_type_env, n: n) - if type_node_carries_applied_binding(n: n, source_indices: source_indices) || is_bare_zero_param_alias { - render_rust_type(n: n, shared_types: shared_types, source_indices: source_indices, emit_info: emit_info) - } else { - render_node_type(n: n, target: Rust, shared_types: shared_types, source_indices: source_indices) - } -} - -fn type_node_carries_applied_binding(n: Node, source_indices: Map) -> Bool { - let own = match find_property(props: n.properties, prop_name: "__applied_type_args", source_indices: source_indices) { - Present { value: applied } => applied.children |> count > 0 - Absent => false - } - own || n.children |> any(c => type_node_carries_applied_binding(n: child_type_node(ch: c), source_indices: source_indices)) + render_rust_fn_sig_type(n: n, generic_param_names: emit_info.fn_generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: emit_info.variant_to_enum, env: emit_info.fn_type_env) } // Named rather than inlined because `if x == Variant {` parses as a record literal in .dag. @@ -1284,7 +1268,7 @@ fn render_rust_decl_type(n: Node, generic_param_names: List, shared_type } else if type_node_has_unbound_type_variable(n: n, generic_param_names: generic_param_names, source_indices: source_indices) { "_" } else { - render_rust_type_with_applied_binding(n: n, shared_types: shared_types, source_indices: source_indices, env: env) + render_rust_type_with_applied_binding_in_scope(n: n, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, env: env) } } } @@ -3858,6 +3842,12 @@ fn local_coproduct_variant_names(items: List, source_indices: Map, export_sets: Map>, typed_modules: List, source_indices: Map, module_index: ModuleIndex, type_summaries: Map, variant_to_enum: Map) -> ReferenceDerivedCandidateDisposition { - if is_known_variant(type_summaries: type_summaries, name: name) { +fn reference_derived_candidate_disposition(name: String, this_module_name: String, registry: Map, export_sets: Map>, typed_modules: List, source_indices: Map, module_index: ModuleIndex, type_summaries: Map, variant_to_enum: Map, in_type_position: Bool) -> ReferenceDerivedCandidateDisposition { + if is_known_variant(type_summaries: type_summaries, name: name) && !in_type_position { match map_get(variant_to_enum, name) { Present { value: parent } => if parent == "" { CandidateVariantParentUnresolved } @@ -4182,6 +4172,7 @@ fn reference_derived_use_line_plan(items: List, unlisted_type_names: List< let value_names = unique_strings(items: items |> flat_map(item => collect_value_ref_names(n: item, source_indices: source_indices, type_summaries: emit_info.type_summaries, variant_to_enum: emit_info.variant_to_enum))) let item_emit_surface_names = items |> flat_map(item => collect_item_emit_surface_names(item: item, source_indices: source_indices, emit_info: emit_info)) let type_surface_names = unique_strings(items: item_emit_surface_names) + let type_position_set = type_surface_names |> fold(init: empty_map(), f: (acc, nm) => map_insert(acc, nm, true)) let field_surface_names = collect_items_field_import_surface_names(surface_names: item_emit_surface_names, emit_info: emit_info) let variant_payload_structs = expand_variant_payload_struct_imports(names: type_surface_names, type_summaries: emit_info.type_summaries, variant_to_enum: emit_info.variant_to_enum) let emitter_attested_anon_heads = unique_strings(items: items |> flat_map(item => collect_anonymous_record_lit_heads(n: item, source_indices: source_indices, type_summaries: emit_info.type_summaries))) @@ -4210,7 +4201,7 @@ fn reference_derived_use_line_plan(items: List, unlisted_type_names: List< [ReferenceDerivedCandidateRow { module_name: this_module_name, name: name, - disposition: reference_derived_candidate_disposition(name: name, this_module_name: this_module_name, registry: registry, export_sets: export_sets, typed_modules: typed_modules, source_indices: source_indices, module_index: module_index, type_summaries: emit_info.type_summaries, variant_to_enum: emit_info.variant_to_enum) + disposition: reference_derived_candidate_disposition(name: name, this_module_name: this_module_name, registry: registry, export_sets: export_sets, typed_modules: typed_modules, source_indices: source_indices, module_index: module_index, type_summaries: emit_info.type_summaries, variant_to_enum: emit_info.variant_to_enum, in_type_position: emit_map_has(m: type_position_set, key: name)) }] } ) @@ -4234,7 +4225,7 @@ fn reference_derived_use_line_plan(items: List, unlisted_type_names: List< let block_lines = if block == "" { [] } else { block |> split(delimiter: "\n") } let emitted_here = block_lines |> flat_map(l => imported_names_in_use_line(line: l)) let fallback = names |> flat_map(nm => - if (emitted_here |> any(e => e == nm)) || is_known_variant(type_summaries: emit_info.type_summaries, name: nm) { + if (emitted_here |> any(e => e == nm)) || (is_known_variant(type_summaries: emit_info.type_summaries, name: nm) && !emit_map_has(m: type_position_set, key: nm)) { [] } else if provider_proven_exports_symbol(name: nm, provider_module: provider, export_sets: export_sets, typed_modules: typed_modules, source_indices: source_indices, module_index: module_index) { [concat(rust_visibility_prefix(), concat("use crate::", concat(module_to_filename(name: provider), concat("::", concat(emit_import_name(n: nm, registry: registry), ";")))))] @@ -4245,37 +4236,72 @@ fn reference_derived_use_line_plan(items: List, unlisted_type_names: List< concat(block_lines, fallback) ) let names_already_in_lines = lines |> flat_map(l => imported_names_in_use_line(line: l)) - let qualified_lines = qualified_type_reference_use_lines(names: type_surface_names, this_module_name: this_module_name, already: already, names_already_in_lines: names_already_in_lines, registry: registry, export_sets: export_sets, typed_modules: typed_modules, source_indices: source_indices, module_index: module_index) - ReferenceDerivedUseLinePlan { lines: concat(lines, qualified_lines), rows: rows } + let qualified_rows = qualified_type_reference_rows(names: type_surface_names |> filter(nm => emit_map_has(m: emitted_source_token_set, key: qualified_last_segment(name: nm))), this_module_name: this_module_name, already: already, names_already_in_lines: names_already_in_lines, registry: registry, export_sets: export_sets, typed_modules: typed_modules, source_indices: source_indices, module_index: module_index) + let qualified_lines = qualified_type_reference_use_lines(rows: qualified_rows, registry: registry) + ReferenceDerivedUseLinePlan { lines: concat(lines, qualified_lines), rows: concat(rows, qualified_rows) } } } // A QUALIFIED TYPE REFERENCE REACHES EMISSION AS ITS LEAF AND NEEDS THE LEAF'S USE-LINE. The type -// renderers spell `std.determinism.Determinism` as bare `Determinism` (rust_fn_sig_leaf_name), and -// the surface walk collects the DOTTED spelling -- which is never an identifier token in the emitted -// source, so the candidate filter dropped it before any disposition was assigned and the module -// referenced a name it never imported (E0425 cannot find type `Determinism`, v2.std.determinism, -// two sites). The qualifier IS the provider the author named, so the line is synthesized from it +// renderers spell `std.determinism.Determinism` as bare `Determinism` (rust_fn_sig_leaf_name). A +// reference the resolver binds reaches the surface walk as that leaf and is decided by the +// bare-name route above; a reference the resolver leaves authored reaches it in its DOTTED spelling +// -- never an identifier token in the emitted source, so the candidate filter dropped it before any +// disposition was assigned. This route decides the dotted ones. (The v2.std.determinism E0425 that +// motivated it was the OTHER case, measured by tracing this route's inputs: the leaf arrived bare +// and the bare-name route classified it as the v2.lens.registry VARIANT of the same spelling; that +// is the type-position exemption in reference_derived_candidate_disposition, not this route.) The qualifier IS the provider the author named, so the line is synthesized from it // directly -- under the same construction wall every other synthesized use-line passes: // provider_proven_exports_symbol must hold for the leaf on that module, or nothing is emitted and // the name stays a loud unresolved symbol. A first cut keyed this on the qualified item-registry // overlay instead; that overlay carries no row for the reference and the cut was a measured // NON-EVENT (falsifier m12 reddened nothing; the two sites stayed), so it is replaced, not kept. -fn qualified_type_reference_use_lines(names: List, this_module_name: String, already: Map, names_already_in_lines: List, registry: Map, export_sets: Map>, typed_modules: List, source_indices: Map, module_index: ModuleIndex) -> List { +// THE SURFACE WALK ALSO COLLECTS QUALIFIED VALUE HEADS, AND THOSE ARE NOT THIS ROUTE'S. The first +// regeneration of this function synthesized `pub use crate::v2_std_nat::Succ;` for every +// `v2.std.nat.Succ { prev: .. }` record literal (E0603, sixteen sites): a variant reaches the surface +// walk in the same dotted spelling as a type, and Rust admits a variant only through its parent +// enum, which the value route already imports. So the leaf must be a TYPE the registry declares in +// the named qualifier before any line is synthesized; every other qualified name is the value +// route's, and this route says nothing about it. Each decision this route does take is a census row +// beside the bare-name rows -- the qualified spelling is the row's name, so the two never collide. +fn qualified_type_reference_rows(names: List, this_module_name: String, already: Map, names_already_in_lines: List, registry: Map, export_sets: Map>, typed_modules: List, source_indices: Map, module_index: ModuleIndex) -> List { let leaves_done = names_already_in_lines |> fold(init: empty_map(), f: (acc, nm) => map_insert(acc, nm, true)) - unique_strings(items: names |> flat_map(name => + names |> flat_map(name => if !string_contains(s: name, pattern: ".") { [] } else { let leaf = qualified_last_segment(name: name) let segments = name |> split(delimiter: ".") let qualifier = segments |> take(n: (segments |> count) - 1) |> join(separator: ".") if qualifier == this_module_name || emit_map_has(m: already, key: leaf) || emit_map_has(m: leaves_done, key: leaf) || is_kernel_type(name: leaf) { [] - } else if provider_proven_exports_symbol(name: leaf, provider_module: qualifier, export_sets: export_sets, typed_modules: typed_modules, source_indices: source_indices, module_index: module_index) { - [concat(rust_visibility_prefix(), "use crate::", module_to_filename(name: qualifier), "::", emit_import_name(n: leaf, registry: registry), ";")] } else { - [] + match map_get(registry, leaf) { + Absent => [ReferenceDerivedCandidateRow { module_name: this_module_name, name: name, disposition: CandidateRegistryAbsent }] + Present { value: info } => + if !(registry_row_is_type_declared_in(info: info, module_name: qualifier)) { + [] + } else if provider_proven_exports_symbol(name: leaf, provider_module: qualifier, export_sets: export_sets, typed_modules: typed_modules, source_indices: source_indices, module_index: module_index) { + [ReferenceDerivedCandidateRow { module_name: this_module_name, name: name, disposition: CandidateSurvived { provider_module: qualifier } }] + } else { + [ReferenceDerivedCandidateRow { module_name: this_module_name, name: name, disposition: CandidateExportProofFailed { provider_module: qualifier } }] + } + } } } + ) +} + +// Named because `info.kind == TypeItem` is a comparison the .dag surface reads as a record literal. +fn registry_row_is_type_declared_in(info: ItemInfo, module_name: String) -> Bool { + if info.module_name != module_name { false } else { match info.kind { TypeItem => true _ => false } } +} + +fn qualified_type_reference_use_lines(rows: List, registry: Map) -> List { + unique_strings(items: rows |> flat_map(r => + match r.disposition { + CandidateSurvived { provider_module: provider } => + [concat(rust_visibility_prefix(), "use crate::", module_to_filename(name: provider), "::", emit_import_name(n: qualified_last_segment(name: r.name), registry: registry), ";")] + _ => [] + } )) } @@ -6574,7 +6600,16 @@ fn emit_struct_from_children(name: String, type_params: String, generic_param_na data render_rust_type_applied_binding_env_note: String = "Construction wall for the zero-parameter-alias applied-argument class (E0107 'type alias takes 0 generic arguments but N were supplied'). A reference to a closed alias arrives at the emitter carrying the RESOLVED DEFINITION's type arguments as its children while its authored spelling is still the alias name, so a renderer that prints name-plus-children emits ClosedCarrierAlias for a Rust alias declared with no parameters. Four renderers already refuse that shape by asking the single peel authority closed_alias_peel_verdict: render_rust_applied_type, render_rust_decl_type, render_rust_fn_sig_type and render_rust_alias_rhs_type. This function is the fifth path, and it did NOT lack the guard -- it reached render_rust_applied_type, which asked, and was answered with an EMPTY TypeEnv this function constructed inline plus an empty_emit_graph_info() it passed to render_rust_type. An empty env resolves no binding, and the peel predicate renders 'I could not look this up' identically to 'this declaration has parameters' -- the state-space conflation DESIGN section 5 names, failing open into the widened applied form rather than refusing. Every one of this function's callers already holds the TypeEnv it was discarding, so the fix is to stop discarding it: the peel authority stays the single authority and is simply answered truthfully. Measured on the src/v2/compiler/03_ingest.dag closure. The next rung is upstream and not taken here: an alias reference that preserved its AUTHORED arity would make the bad shape unwritable rather than merely refused, at which point no renderer would need to ask at all." +// THE FN'S GENERIC SCOPE MUST SURVIVE THIS HOP. render_rust_decl_type reaches here from a fn +// signature carrying generic_param_names, and the EmitGraphInfo rebuilt below used to carry an +// empty scope, so a fn-scope generic inside an arrow return (`fn(A) -> Outcome`) rendered as +// `_` (E0121) or by its erased inference; the parameter side of the same arrow rendered `C`. +// The scope-free spelling stays for the callers that have no fn scope (fields, data, wire rows). fn render_rust_type_with_applied_binding(n: Node, shared_types: Set, source_indices: Map, env: TypeEnv) -> String { + render_rust_type_with_applied_binding_in_scope(n: n, generic_param_names: [], shared_types: shared_types, source_indices: source_indices, env: env) +} + +fn render_rust_type_with_applied_binding_in_scope(n: Node, generic_param_names: List, shared_types: Set, source_indices: Map, env: TypeEnv) -> String { if is_host_text_carrier_type(n: n, source_indices: source_indices) { return rust_carrier_optional_wrap(n: n, rendered: "String") } match find_property(props: n.properties, prop_name: "__applied_type_args", source_indices: source_indices) { Present { value: applied } => @@ -6585,15 +6620,15 @@ fn render_rust_type_with_applied_binding(n: Node, shared_types: Set, sou if outer_name != applied_name { render_rust_shared_type_with_optional(n: n, type_name: outer_name, rendered: outer_name, shared_types: shared_types) } else { - render_rust_applied_type_shared(n: applied, generic_param_names: [], shared_types: shared_types, source_indices: source_indices, variant_to_enum: empty_map(), env: env) + render_rust_applied_type_shared(n: applied, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: empty_map(), env: env) } } else { - render_rust_applied_type_shared(n: applied, generic_param_names: [], shared_types: shared_types, source_indices: source_indices, variant_to_enum: empty_map(), env: env) + render_rust_applied_type_shared(n: applied, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: empty_map(), env: env) } } else { - render_rust_type(n: n, shared_types: shared_types, source_indices: source_indices, emit_info: emit_info_with_fn_type_context(emit_info: empty_emit_graph_info(), generic_param_names: [], env: env)) + render_rust_type(n: n, shared_types: shared_types, source_indices: source_indices, emit_info: emit_info_with_fn_type_context(emit_info: empty_emit_graph_info(), generic_param_names: generic_param_names, env: env)) } - Absent => render_rust_type(n: n, shared_types: shared_types, source_indices: source_indices, emit_info: emit_info_with_fn_type_context(emit_info: empty_emit_graph_info(), generic_param_names: [], env: env)) + Absent => render_rust_type(n: n, shared_types: shared_types, source_indices: source_indices, emit_info: emit_info_with_fn_type_context(emit_info: empty_emit_graph_info(), generic_param_names: generic_param_names, env: env)) } } diff --git a/src/v1/tests/claim/reference_derived_disposition_census_witness_test.dag b/src/v1/tests/claim/reference_derived_disposition_census_witness_test.dag index 895e408187d..3949fcf8f4a 100644 --- a/src/v1/tests/claim/reference_derived_disposition_census_witness_test.dag +++ b/src/v1/tests/claim/reference_derived_disposition_census_witness_test.dag @@ -58,7 +58,8 @@ fn fixture_disposition(registry: Map, export_sets: Map Bool { source_indices: empty_map(), module_index: build_module_index(modules: []), type_summaries: empty_map(), - variant_to_enum: empty_map() + variant_to_enum: empty_map(), + in_type_position: false ) == CandidateSurvived { provider_module: "fixture.provider" } } @@ -136,7 +138,8 @@ test fn known_variant_is_delegated_to_its_parent_not_registry_absent() -> Bool { source_indices: empty_map(), module_index: build_module_index(modules: []), type_summaries: fixture_variant_type_summaries(), - variant_to_enum: map_insert(empty_map(), "V", "E") + variant_to_enum: map_insert(empty_map(), "V", "E"), + in_type_position: false ) == CandidateVariantDelegatedToParent { parent_enum: "E" } } @@ -165,10 +168,29 @@ test fn a_variant_whose_parent_is_ambiguous_is_not_delegated_to_nothing() -> Boo source_indices: empty_map(), module_index: build_module_index(modules: []), type_summaries: fixture_colliding_variant_type_summaries(), - variant_to_enum: map_insert(empty_map(), "V", "") + variant_to_enum: map_insert(empty_map(), "V", ""), + in_type_position: false ) == CandidateVariantParentUnresolved } +// A TYPE POSITION CANNOT HOLD A VARIANT. The same spelling `V` that the whole-corpus type summaries +// know as a variant, referenced from one of the module's type positions, is decided by the registry +// arm -- here registry-absent, never delegated to an enum the position could not name. +test fn a_known_variant_spelling_in_a_type_position_takes_the_registry_arm() -> Bool { + reference_derived_disposition_name(disposition: reference_derived_candidate_disposition( + name: "V", + this_module_name: "fixture.consumer", + registry: empty_map(), + export_sets: empty_map(), + typed_modules: [], + source_indices: empty_map(), + module_index: build_module_index(modules: []), + type_summaries: fixture_variant_type_summaries(), + variant_to_enum: map_insert(empty_map(), "V", "E"), + in_type_position: true + )) == "registry-absent" +} + test fn an_unresolved_parent_is_not_reported_as_registry_absent() -> Bool { reference_derived_disposition_name(disposition: CandidateVariantParentUnresolved) != "registry-absent" } @@ -183,7 +205,8 @@ test fn non_variant_name_still_answers_registry_absent() -> Bool { source_indices: empty_map(), module_index: build_module_index(modules: []), type_summaries: fixture_variant_type_summaries(), - variant_to_enum: map_insert(empty_map(), "V", "E") + variant_to_enum: map_insert(empty_map(), "V", "E"), + in_type_position: false )) == "registry-absent" } From c2dadc85dd441f514a0222a780c93c88ffc0697b Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 29 Aug 2026 20:38:06 +0000 Subject: [PATCH 29/75] Regenerate the stage0 mirror at the 49482b0 freeze: byte fixed point at round 3, three paths, each explained by an authority change srv1 (/tmp/xl0e2.sh -> /tmp/xl0j2.log, launched 2026-08-29T19:52:56Z), criterion = every regen-population file byte-equal to installed; the full workspace rebuilt as the gate each round. round 1 gunbc=14967ca810cb6609 from installed db46176cc5cf5861 -> v1_compiler_emit_rust.rs, v1_tests_claim_reference_derived_disposition_census_witness_test.rs round 2 gunbc=5378a516528a6e0c from installed efa440bc86734f53 -> v1_compiler_trait_derive_emit.rs round 3 gunbc=974aafe864f743f6 from installed b1a0409ce9fc79d4 -> BYTE FIXED POINT v1_compiler_emit_rust.rs <- 05_emit_rust.dag (arrow positions via the fn-signature renderer, generic scope through the applied-binding hop, type-position exemption, qualified rows with the registry type gate and token filter) v1_tests_claim_reference_derived_disposition_census_witness_test.rs <- its .dag (in_type_position at 5 callers + the type-position control) v1_compiler_trait_derive_emit.rs <- retracts the unused `pub use crate::std_types::List;` the earlier qualified route synthesized (token filter) Final installed tree b1a0409ce9fc79d4; merged tree 89c55a0e7e8d949047b5d92864dfc9fe306aebc0 at the freeze; main parent 5e80671. No hand edit to any generated file. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01GXfYKNQTD3VfYyQcnJpxNU --- src/v1/stage0/src/v1_compiler_emit_rust.rs | 280 +++++++++++++----- .../src/v1_compiler_trait_derive_emit.rs | 1 - ...derived_disposition_census_witness_test.rs | 26 ++ 3 files changed, 224 insertions(+), 83 deletions(-) diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index 9f85f01ae36..d94b5921a40 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -325,57 +325,14 @@ pub fn render_rust_arrow_position( source_indices: Rc>>, emit_info: Rc, ) -> String { - { - let is_bare_zero_param_alias = (((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) > 0)) - && closed_alias_peels_zero_param(emit_info.fn_type_env.clone(), n.clone())); - if (type_node_carries_applied_binding(n.clone(), source_indices.clone()) - || is_bare_zero_param_alias.clone()) - { - render_rust_type( - n.clone(), - shared_types.clone(), - source_indices.clone(), - emit_info.clone(), - ) - } else { - crate::v1_compiler_emit::render_node_type( - n.clone(), - RenderTarget::Rust, - shared_types.clone(), - source_indices.clone(), - ) - } - } -} - -pub fn type_node_carries_applied_binding( - n: Rc, - source_indices: Rc>>, -) -> bool { - stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let own = match crate::v1_std_core::find_property( - n.properties.clone(), - "__applied_type_args".to_string(), - source_indices.clone(), - ) { - Some(applied) => ((applied.children.clone().len() as i64) > 0), - None => false, - }; - (own.clone() || { - let mut __found = false; - for c in n.children.clone().iter().cloned() { - if type_node_carries_applied_binding( - crate::v1_compiler_infer_types::child_type_node(c.clone()), - source_indices.clone(), - ) { - __found = true; - break; - } - } - __found - }) - }) + render_rust_fn_sig_type( + n.clone(), + emit_info.fn_generic_param_names.clone(), + shared_types.clone(), + source_indices.clone(), + emit_info.variant_to_enum.clone(), + emit_info.fn_type_env.clone(), + ) } pub fn rust_type_node_is_arrow(n: Rc) -> bool { @@ -2382,8 +2339,9 @@ if peel.clone() { ) { "_".to_string() } else { - render_rust_type_with_applied_binding( + render_rust_type_with_applied_binding_in_scope( n.clone(), + generic_param_names.clone(), shared_types.clone(), source_indices.clone(), env.clone(), @@ -8081,8 +8039,11 @@ pub fn reference_derived_candidate_disposition( module_index: Rc, type_summaries: Rc>>, variant_to_enum: Rc>, + in_type_position: bool, ) -> Rc { - if crate::v1_compiler_infer_emit_info::is_known_variant(type_summaries.clone(), name.clone()) { + if (crate::v1_compiler_infer_emit_info::is_known_variant(type_summaries.clone(), name.clone()) + && !in_type_position.clone()) + { match v1_rt::map_get(&variant_to_enum, name.clone()) { Some(parent) => { if (parent.clone() == "".to_string()) { @@ -8380,6 +8341,12 @@ pub fn reference_derived_use_line_plan( }); let type_surface_names = crate::v1_compiler_emit_core_support::unique_strings(item_emit_surface_names.clone()); + let type_position_set = type_surface_names.iter().cloned().fold( + v1_rt::rc_empty_map::(), + |acc: Rc>, nm: String| { + v1_rt::rc_map_insert(acc, nm.clone(), true) + }, + ); let field_surface_names = collect_items_field_import_surface_names( item_emit_surface_names.clone(), emit_info.clone(), @@ -8555,6 +8522,10 @@ pub fn reference_derived_use_line_plan( module_index.clone(), emit_info.type_summaries.clone(), emit_info.variant_to_enum.clone(), + crate::v1_compiler_infer_types::emit_map_has( + type_position_set.clone(), + name.clone(), + ), ), })]) }) @@ -8611,7 +8582,7 @@ let block_lines = if (block.clone() == "".to_string()) { Rc::new(block.clone().split(&"\n".to_string()).map(|s| s.to_string()).collect::>()) }; let emitted_here = Rc::new({ let mut __result = Vec::new(); for l in block_lines.iter().cloned() { __result.extend((*imported_names_in_use_line(l.clone())).iter().cloned()); } __result }); -let fallback = Rc::new({ let mut __result = Vec::new(); for nm in names.iter().cloned() { __result.extend((*if ({ let mut __found = false; for e in emitted_here.iter().cloned() { if (e.clone() == nm.clone()) { __found = true; break; } } __found } || crate::v1_compiler_infer_emit_info::is_known_variant(emit_info.type_summaries.clone(), nm.clone())) { +let fallback = Rc::new({ let mut __result = Vec::new(); for nm in names.iter().cloned() { __result.extend((*if ({ let mut __found = false; for e in emitted_here.iter().cloned() { if (e.clone() == nm.clone()) { __found = true; break; } } __found } || (crate::v1_compiler_infer_emit_info::is_known_variant(emit_info.type_summaries.clone(), nm.clone()) && !crate::v1_compiler_infer_types::emit_map_has(type_position_set.clone(), nm.clone()))) { Rc::new(vec![]) } else { if provider_proven_exports_symbol(nm.clone(), provider.clone(), export_sets.clone(), typed_modules.clone(), source_indices.clone(), module_index.clone()) { @@ -8632,8 +8603,19 @@ v1_rt::concat(block_lines.clone(), fallback.clone()) } __result }); - let qualified_lines = qualified_type_reference_use_lines( - type_surface_names.clone(), + let qualified_rows = qualified_type_reference_rows( + Rc::new({ + let mut __result = Vec::new(); + for nm in type_surface_names.iter().cloned() { + if crate::v1_compiler_infer_types::emit_map_has( + emitted_source_token_set.clone(), + crate::v1_std_core::qualified_last_segment(nm.clone()), + ) { + __result.push(nm); + } + } + __result + }), this_module_name.clone(), already.clone(), names_already_in_lines.clone(), @@ -8643,14 +8625,16 @@ v1_rt::concat(block_lines.clone(), fallback.clone()) source_indices.clone(), module_index.clone(), ); + let qualified_lines = + qualified_type_reference_use_lines(qualified_rows.clone(), registry.clone()); Rc::new(ReferenceDerivedUseLinePlan { lines: v1_rt::concat(lines.clone(), qualified_lines.clone()), - rows: rows.clone(), + rows: v1_rt::concat(rows.clone(), qualified_rows.clone()), }) } } -pub fn qualified_type_reference_use_lines( +pub fn qualified_type_reference_rows( names: Rc>, this_module_name: String, already: Rc>, @@ -8660,7 +8644,7 @@ pub fn qualified_type_reference_use_lines( typed_modules: Rc>>, source_indices: Rc>>, module_index: Rc, -) -> Rc> { +) -> Rc>> { { let leaves_done = names_already_in_lines.iter().cloned().fold( v1_rt::rc_empty_map::(), @@ -8668,33 +8652,149 @@ pub fn qualified_type_reference_use_lines( v1_rt::rc_map_insert(acc, nm.clone(), true) }, ); - crate::v1_compiler_emit_core_support::unique_strings(Rc::new({ + Rc::new({ let mut __result = Vec::new(); for name in names.iter().cloned() { - __result.extend((*if !v1_rt::string_contains(&name, ".".to_string()) { - Rc::new(vec![]) - } else { - { - let leaf = crate::v1_std_core::qualified_last_segment(name.clone()); -let segments = Rc::new(name.clone().split(&".".to_string()).map(|s| s.to_string()).collect::>()); -let qualifier = Rc::new(segments.clone().iter().cloned().take(((segments.clone().len() as i64) - 1) as usize).collect::>()).join(&".".to_string()); -if ((((qualifier.clone() == this_module_name.clone()) || crate::v1_compiler_infer_types::emit_map_has(already.clone(), leaf.clone())) || crate::v1_compiler_infer_types::emit_map_has(leaves_done.clone(), leaf.clone())) || crate::std_types::is_kernel_type(leaf.clone())) { - Rc::new(vec![]) - } else { - if provider_proven_exports_symbol(leaf.clone(), qualifier.clone(), export_sets.clone(), typed_modules.clone(), source_indices.clone(), module_index.clone()) { - Rc::new(vec![v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(rust_visibility_prefix(), "use crate::".to_string()), crate::v1_compiler_emit_core_support::module_to_filename(qualifier.clone())), "::".to_string()), emit_import_name(leaf.clone(), registry.clone())), ";".to_string())]) - } else { + __result.extend( + (*if !v1_rt::string_contains(&name, ".".to_string()) { Rc::new(vec![]) - } - } -} - }).iter().cloned()); + } else { + { + let leaf = crate::v1_std_core::qualified_last_segment(name.clone()); + let segments = Rc::new( + name.clone() + .split(&".".to_string()) + .map(|s| s.to_string()) + .collect::>(), + ); + let qualifier = Rc::new( + segments + .clone() + .iter() + .cloned() + .take(((segments.clone().len() as i64) - 1) as usize) + .collect::>(), + ) + .join(&".".to_string()); + if ((((qualifier.clone() == this_module_name.clone()) + || crate::v1_compiler_infer_types::emit_map_has( + already.clone(), + leaf.clone(), + )) + || crate::v1_compiler_infer_types::emit_map_has( + leaves_done.clone(), + leaf.clone(), + )) + || crate::std_types::is_kernel_type(leaf.clone())) + { + Rc::new(vec![]) + } else { + match v1_rt::map_get(®istry, leaf.clone()) { + None => Rc::new(vec![Rc::new(ReferenceDerivedCandidateRow { + module_name: this_module_name.clone(), + name: name.clone(), + disposition: Rc::new(ReferenceDerivedCandidateDisposition::CandidateRegistryAbsent), +})]), + Some(info) => { + if !registry_row_is_type_declared_in( + info.clone(), + qualifier.clone(), + ) { + Rc::new(vec![]) + } else { + if provider_proven_exports_symbol( + leaf.clone(), + qualifier.clone(), + export_sets.clone(), + typed_modules.clone(), + source_indices.clone(), + module_index.clone(), + ) { + Rc::new(vec![Rc::new(ReferenceDerivedCandidateRow { + module_name: this_module_name.clone(), + name: name.clone(), + disposition: Rc::new(ReferenceDerivedCandidateDisposition::CandidateSurvived { + provider_module: qualifier.clone(), +}), +})]) + } else { + Rc::new(vec![Rc::new(ReferenceDerivedCandidateRow { + module_name: this_module_name.clone(), + name: name.clone(), + disposition: Rc::new(ReferenceDerivedCandidateDisposition::CandidateExportProofFailed { + provider_module: qualifier.clone(), +}), +})]) + } + } + } + } + } + } + }) + .iter() + .cloned(), + ); } __result - })) + }) } } +pub fn registry_row_is_type_declared_in(info: Rc, module_name: String) -> bool { + if (info.module_name.clone() != module_name.clone()) { + false + } else { + match info.kind.clone() { + ItemKind::TypeItem => true, + _ => false, + } + } +} + +pub fn qualified_type_reference_use_lines( + rows: Rc>>, + registry: Rc>>, +) -> Rc> { + crate::v1_compiler_emit_core_support::unique_strings(Rc::new({ + let mut __result = Vec::new(); + for r in rows.iter().cloned() { + __result.extend( + (*match (*r.disposition.clone()).clone() { + ReferenceDerivedCandidateDisposition::CandidateSurvived { + provider_module: provider, + .. + } => Rc::new(vec![v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + rust_visibility_prefix(), + "use crate::".to_string(), + ), + crate::v1_compiler_emit_core_support::module_to_filename( + provider.clone(), + ), + ), + "::".to_string(), + ), + emit_import_name( + crate::v1_std_core::qualified_last_segment(r.name.clone()), + registry.clone(), + ), + ), + ";".to_string(), + )]), + _ => Rc::new(vec![]), + }) + .iter() + .cloned(), + ); + } + __result + })) +} + pub fn reference_derived_use_lines( items: Rc>>, unlisted_type_names: Rc>, @@ -14604,6 +14704,22 @@ pub fn render_rust_type_with_applied_binding( shared_types: Rc>, source_indices: Rc>>, env: Rc, +) -> String { + render_rust_type_with_applied_binding_in_scope( + n.clone(), + Rc::new(vec![]), + shared_types.clone(), + source_indices.clone(), + env.clone(), + ) +} + +pub fn render_rust_type_with_applied_binding_in_scope( + n: Rc, + generic_param_names: Rc>, + shared_types: Rc>, + source_indices: Rc>>, + env: Rc, ) -> String { { if is_host_text_carrier_type(n.clone(), source_indices.clone()) { @@ -14637,7 +14753,7 @@ pub fn render_rust_type_with_applied_binding( } else { render_rust_applied_type_shared( applied.clone(), - Rc::new(vec![]), + generic_param_names.clone(), shared_types.clone(), source_indices.clone(), v1_rt::rc_empty_map::(), @@ -14647,7 +14763,7 @@ pub fn render_rust_type_with_applied_binding( } else { render_rust_applied_type_shared( applied.clone(), - Rc::new(vec![]), + generic_param_names.clone(), shared_types.clone(), source_indices.clone(), v1_rt::rc_empty_map::(), @@ -14662,7 +14778,7 @@ pub fn render_rust_type_with_applied_binding( source_indices.clone(), crate::v1_compiler_infer_emit_info::emit_info_with_fn_type_context( crate::v1_compiler_infer_emit_info::empty_emit_graph_info(), - Rc::new(vec![]), + generic_param_names.clone(), env.clone(), ), ) @@ -14674,7 +14790,7 @@ pub fn render_rust_type_with_applied_binding( source_indices.clone(), crate::v1_compiler_infer_emit_info::emit_info_with_fn_type_context( crate::v1_compiler_infer_emit_info::empty_emit_graph_info(), - Rc::new(vec![]), + generic_param_names.clone(), env.clone(), ), ), diff --git a/src/v1/stage0/src/v1_compiler_trait_derive_emit.rs b/src/v1/stage0/src/v1_compiler_trait_derive_emit.rs index 9427918702f..cec8ebda4e1 100644 --- a/src/v1/stage0/src/v1_compiler_trait_derive_emit.rs +++ b/src/v1/stage0/src/v1_compiler_trait_derive_emit.rs @@ -37,7 +37,6 @@ pub use crate::std_trait_derive_shape::{ repr_grounding_derive_completeness_predicate, repr_grounding_group_completion_carrier, repr_grounding_supplemental_bool_host_bridge_target, }; -pub use crate::std_types::List; pub use crate::std_types::{container_template_algebra, is_container_type}; pub use crate::v1_compiler_artifact::RenderTarget; use crate::v1_compiler_artifact::RenderTarget::Rust; diff --git a/src/v1/stage0/src/v1_tests_claim_reference_derived_disposition_census_witness_test.rs b/src/v1/stage0/src/v1_tests_claim_reference_derived_disposition_census_witness_test.rs index 7525f8971a6..c2455448796 100644 --- a/src/v1/stage0/src/v1_tests_claim_reference_derived_disposition_census_witness_test.rs +++ b/src/v1/stage0/src/v1_tests_claim_reference_derived_disposition_census_witness_test.rs @@ -86,6 +86,7 @@ pub fn fixture_disposition( crate::v1_compiler_emit_rust::build_module_index(Rc::new(vec![])), v1_rt::rc_empty_map::>(), v1_rt::rc_empty_map::(), + false, ), ) } @@ -122,6 +123,7 @@ pub fn cross_module_candidate_with_export_proof_survives() -> bool { crate::v1_compiler_emit_rust::build_module_index(Rc::new(vec![])), v1_rt::rc_empty_map::>(), v1_rt::rc_empty_map::(), + false, ) == Rc::new(ReferenceDerivedCandidateDisposition::CandidateSurvived { provider_module: "fixture.provider".to_string(), })) @@ -234,6 +236,7 @@ pub fn known_variant_is_delegated_to_its_parent_not_registry_absent() -> bool { "V".to_string(), "E".to_string(), ), + false, ) == Rc::new( ReferenceDerivedCandidateDisposition::CandidateVariantDelegatedToParent { parent_enum: "E".to_string(), @@ -286,9 +289,31 @@ pub fn a_variant_whose_parent_is_ambiguous_is_not_delegated_to_nothing() -> bool "V".to_string(), "".to_string(), ), + false, ) == Rc::new(ReferenceDerivedCandidateDisposition::CandidateVariantParentUnresolved)) } +pub fn a_known_variant_spelling_in_a_type_position_takes_the_registry_arm() -> bool { + (crate::v1_compiler_emit_rust::reference_derived_disposition_name( + crate::v1_compiler_emit_rust::reference_derived_candidate_disposition( + "V".to_string(), + "fixture.consumer".to_string(), + v1_rt::rc_empty_map::>(), + v1_rt::rc_empty_map::>>(), + Rc::new(vec![]), + v1_rt::rc_empty_map::>(), + crate::v1_compiler_emit_rust::build_module_index(Rc::new(vec![])), + fixture_variant_type_summaries(), + v1_rt::rc_map_insert( + v1_rt::rc_empty_map::(), + "V".to_string(), + "E".to_string(), + ), + true, + ), + ) == "registry-absent".to_string()) +} + pub fn an_unresolved_parent_is_not_reported_as_registry_absent() -> bool { (crate::v1_compiler_emit_rust::reference_derived_disposition_name(Rc::new( ReferenceDerivedCandidateDisposition::CandidateVariantParentUnresolved, @@ -311,6 +336,7 @@ pub fn non_variant_name_still_answers_registry_absent() -> bool { "V".to_string(), "E".to_string(), ), + false, ), ) == "registry-absent".to_string()) } From 466811e7a98c0b5e820cb9faa3d55ca4e19fc98c Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 29 Aug 2026 21:00:39 +0000 Subject: [PATCH 30/75] Witness fixture only: the qualified-type positive control moves to a provider the harness pool can carry Post-freeze, fixture-only (dag/test/claim is not a regen-population path; a no-drift regen run on this head is recorded in the PR). Two harness facts, both measured on the fixed-point artifact gunbc=974aafe864f743f6: a `{Determinism}` inside a .dag string literal is read as an interpolation of that name (the row failed in the interpreter before any compile ran), and the harness pool is the probe's DECLARED import closure, so a provider referenced only by a dotted name is absent -- and std.determinism cannot enter it because its own body references std.perturbation the same way. The row now uses std.decl_ref with a sibling import and says plainly that it is a positive control; the class's discriminating red stays at the disposition grain (a_known_variant_spelling_in_a_type_position_takes_the_registry_arm) and in the closure count. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01GXfYKNQTD3VfYyQcnJpxNU --- ...d_call_target_realization_witness_test.dag | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/dag/test/claim/emitted_call_target_realization_witness_test.dag b/dag/test/claim/emitted_call_target_realization_witness_test.dag index a42610a4669..b849d70e533 100644 --- a/dag/test/claim/emitted_call_target_realization_witness_test.dag +++ b/dag/test/claim/emitted_call_target_realization_witness_test.dag @@ -331,24 +331,27 @@ test fn w_arrow_return_type_keeps_its_applied_binding() -> Bool { ) } -// QUALIFIED TYPE REFERENCE, POSITIVE CONTROL ONLY. A field typed `std.determinism.Determinism` with -// no import renders as bare `Determinism` and must earn `use crate::std_determinism::{Determinism};`. -// The defect that opened this class (v2.std.determinism, E0425 x2 on the whole closure) fires only -// when the pool also carries a coproduct with a VARIANT spelled `Determinism` (v2.lens.registry -// LensIdV0): the bare-name disposition classified the type-position leaf as that variant. This -// harness cannot carry that pool -- it refuses any probe whose closure includes such a module with -// NoSuchVariable (reproduced with a data-free fixture coproduct; the same probe compiles and earns -// the line from the CLI), so this row is satisfied by the unfixed emitter too and is NOT the class's -// discriminating red. That red is a_known_variant_spelling_in_a_type_position_takes_the_registry_arm -// in src/v1/tests/claim/reference_derived_disposition_census_witness_test.dag (the disposition at +// QUALIFIED TYPE REFERENCE, POSITIVE CONTROL ONLY. A field typed by a dotted, unimported provider +// name renders as its bare leaf and must earn the leaf's use-line from the provider the author +// named. The defect that opened this class (v2.std.determinism, E0425 x2 on the whole closure) +// fires only when the pool also carries a coproduct with a VARIANT spelled `Determinism` +// (v2.lens.registry LensIdV0): the bare-name disposition classified the type-position leaf as that +// variant. This harness cannot carry that specimen at all -- its pool is the probe's DECLARED +// import closure, so a provider referenced only by a dotted name is absent (hard diagnostic), and +// std.determinism itself references std.perturbation the same way -- so this row uses std.decl_ref +// with a sibling import to bring the provider into the pool, and is satisfied by the unfixed +// emitter too. The class's discriminating red is +// a_known_variant_spelling_in_a_type_position_takes_the_registry_arm in +// src/v1/tests/claim/reference_derived_disposition_census_witness_test.dag (the disposition at // function grain, red by construction on the variant arm) together with the closure count of the -// use-line in v2_std_determinism.rs. +// use-line in v2_std_determinism.rs. The expected line is spelled as two substrings because a +// `{Name}` inside a .dag string literal is read as an interpolation of that name. test fn w_qualified_type_reference_earns_the_leaf_use_line() -> Bool { compile_dag_rust_emit_check( - "module test.claim.qualified_type_ref_probe\nimport std.types { String }\ntype Fact { signature: String, classification: std.determinism.Determinism }\nfn probe(f: Fact) -> std.determinism.Determinism { f.classification }\n", + "module test.claim.qualified_type_ref_probe\nimport std.types { String }\nimport std.decl_ref { DeclField }\ntype Fact { signature: String, r: std.decl_ref.DeclarationRef }\nfn probe(f: Fact) -> std.decl_ref.DeclarationRef { f.r }\n", "src/test_claim_qualified_type_ref_probe.rs", - ["use crate::std_determinism::{Determinism};"], - ["std.determinism.Determinism"] + ["use crate::std_decl_ref::{", "DeclarationRef};"], + ["std.decl_ref.DeclarationRef"] ) } From a5af51eb95f3e04aeb7483fd4850e194547e2052 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 03:00:16 +0000 Subject: [PATCH 31/75] WIP XL-0B commit 1: thread DeclarationRef into the checkpoint-spelling callers; exact binding first; delete the redundant expression-position alias arm --- ...d_call_target_realization_witness_test.dag | 16 ++ src/v1/05_emit_rust.dag | 137 +++++++++++++++--- 2 files changed, 129 insertions(+), 24 deletions(-) diff --git a/dag/test/claim/emitted_call_target_realization_witness_test.dag b/dag/test/claim/emitted_call_target_realization_witness_test.dag index b849d70e533..f1c55a0a8e5 100644 --- a/dag/test/claim/emitted_call_target_realization_witness_test.dag +++ b/dag/test/claim/emitted_call_target_realization_witness_test.dag @@ -355,6 +355,22 @@ test fn w_qualified_type_reference_earns_the_leaf_use_line() -> Bool { ) } +// THE SYMBOL IMPORT COLLISION, the byte-level falsifier test.claim.symbol_identity_binding specifies +// for the exact path (symbol_import_collision_fixture_source there is this source). v2.std.node +// `type Symbol` is opaque and bound by declaration to RustStdString; v2.std.text `String` is the +// structural text carrier, and this module imports both. Under the spelling-keyed path Symbol +// rendered the bare token `String`, which the v2_std_text use-line captured (the XL-0A E0308 +// population); under the exact path the declaration-keyed spelling is fully qualified and no +// use-line can shadow it. +test fn w_symbol_reference_renders_the_exact_qualified_spelling() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.symbol_import_collision\nimport v2.std.node { Symbol }\nimport v2.std.text { String }\n\nfn takes_symbol(identity: Symbol) -> Symbol {\n identity\n}\n\nfn takes_text(text: String) -> String {\n text\n}\n", + "src/test_claim_symbol_import_collision.rs", + ["identity: std::string::String) -> std::string::String"], + ["identity: String", "identity: Symbol"] + ) +} + // QUALIFIED VALUE HEAD, THE OTHER DIRECTION. `v2.std.nat.Succ { prev: .. }` is a variant record // literal; the value route imports it through its parent enum, and this route must synthesize // nothing for it (E0603 `variant import is private`, sixteen sites on the first regeneration). diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index 6705b8f3d8f..839f05904be 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -1,7 +1,9 @@ module v1.compiler.emit_rust import std.occurrence_identity { OccurrenceSynthetic } -import std.decl_ref { decl_ref } +import std.decl_ref { decl_ref, DeclarationRef } +import std.target_representation { ResolvedExactBinding, ExactBindingAbsent, ExactBindingAmbiguous, ExactSourceIdentityUnavailable } +import extdeps.languages.rust.representation { rust_exact_type_checkpoint } import std.primitive_projection { primitive_identity_runtime_name, primitive_projection_row_for_declaration } @@ -88,7 +90,7 @@ import v1.compiler.closure_stub_v2_std_integer_rust { closure_stub_v2_std_intege import v1.compiler.closure_stub_v2_std_text_rust { closure_stub_v2_std_text_source } import v1.compiler.coercion { coerce_primitive_type, is_copy, lookup_checkpoint, type_reference_decl_file, - rust_seed_host_numeric_alias, target_callable + rust_seed_host_numeric_alias, target_callable, rust_lookup_exact_binding } import v1.compiler.trait_derive_emit { v1_emit_enum_derives, @@ -111,7 +113,7 @@ import v1.compiler.trait_bound_witness { import std.types { is_container_type, is_kernel_type, container_template_algebra } import std.serialization { CoproductWireContract, VariantEncoding, VariantNaming } -import v1.compiler.infer_env { TypeEnv, TypeBinding, authored_name, lookup_type_by_name, lookup_type_for, GlobalBareLookupState, empty_symbol_index } +import v1.compiler.infer_env { TypeEnv, TypeBinding, authored_name, lookup_type_by_name, lookup_type_for, GlobalBareLookupState, GlobalBareUniqueBinding, GlobalBareAmbiguousBinding, empty_symbol_index } import v1.compiler.infer_types { resolved_type, normalize_access_type_node, for_each_element_type_node, child_type_node, emit_map_has, @@ -270,13 +272,11 @@ fn render_rust_arrow_type(n: Node, shared_types: Set, source_indices: Ma } } -// ZERO-PARAMETER ALIAS AT THE EXPRESSION-TYPE POSITION (the closed_alias_peels_zero_param arm below): -// A ZERO-PARAMETER ALIAS NEVER TAKES THE ARGUMENTS OF WHAT IT ABBREVIATES. The resolver hands an -// alias reference back carrying its right-hand side's children, and rendering name-plus-children -// wrote `CompileLensOutcome>>>` for `type CompileLensOutcome = -// Outcome>` (E0107, and the E0391 variance cycle rustc reports beside it). The -// fn-signature renderer already answers this position bare via closed_alias_peels_zero_param; -// this is the same verdict asked at the expression-type position. +// ZERO-PARAMETER ALIAS AT THE EXPRESSION-TYPE POSITION has no arm of its own here: the applied +// route below reaches render_rust_applied_type, whose closed_alias_peel_verdict answers the alias +// bare, so a second peel arm ahead of it answered nothing the route did not (measured on the XL-0A +// falsifier batch: deleting it changed no emitted byte of the compiler closure, and +// w_zero_param_alias_in_an_arrow_return_renders_without_its_rhs_arguments stayed green). fn render_rust_type_without_applied_binding(n: Node, shared_types: Set, source_indices: Map, emit_info: EmitGraphInfo) -> String { if is_host_text_carrier_type(n: n, source_indices: source_indices) { return rust_carrier_optional_wrap(n: n, rendered: "String") } if is_host_optional_carrier_type(n: n, source_indices: source_indices) { @@ -287,9 +287,6 @@ fn render_rust_type_without_applied_binding(n: Node, shared_types: Set, } if rust_type_node_is_arrow(n: n) { render_rust_arrow_type(n: n, shared_types: shared_types, source_indices: source_indices, emit_info: emit_info) - } else if n.connective == NoConnective && n.children |> count > 0 && !is_container_type(name: authored_name_at(source_indices: source_indices, node: n)) && closed_alias_peels_zero_param(env: emit_info.fn_type_env, n: n) { - let leaf = qualified_last_segment(name: authored_name_at(source_indices: source_indices, node: n)) - render_rust_shared_type_with_optional(n: n, type_name: leaf, rendered: leaf, shared_types: shared_types) } else if n.connective == NoConnective && n.children |> count > 0 && !is_container_type(name: authored_name_at(source_indices: source_indices, node: n)) { render_rust_applied_via_emit_info(n: n, shared_types: shared_types, source_indices: source_indices, emit_info: emit_info) } else if node_is_set_collection(n: n, source_indices: source_indices) { @@ -520,8 +517,11 @@ fn rust_opaque_kernel_alias_carrier(name: String) -> String? { } } -fn rust_opaque_kernel_alias_type_decl(name: String) -> String { - let carrier = coerce_primitive_type(target: Rust, dag_name: name, decl_file: "") +fn rust_opaque_kernel_alias_type_decl(name: String, module_path: String) -> String { + let carrier = match rust_exact_binding_spelling(source: Present { value: decl_ref(module_path: module_path, decl_name: name) }, grounding: true) { + Present { value: exact } => exact + Absent => coerce_primitive_type(target: Rust, dag_name: name, decl_file: "") + } concat(rust_visibility_prefix(), rust_items().type_alias_keyword, " ", name, " = ", carrier, ";") } @@ -607,11 +607,14 @@ data rust_checkpoint_scalar_phantom_params_note: String = "Construction wall for // authority suppresses the wrap. rust_scalar_checkpoint_reference_base also answers for // lookup_checkpoint rows that are NOT machine scalars (String is the live one), and those may // legitimately be shared, so widening this to every checkpoint row is a separate cut. -fn rust_render_checkpoint_scalar_bare(n: Node, source_indices: Map, shared_types: Set) -> String? { +fn rust_render_checkpoint_scalar_bare(n: Node, source_indices: Map, shared_types: Set, env: TypeEnv) -> String? { if n.children |> count == 0 { none } else { let leaf = rust_fn_sig_leaf_name(source_indices: source_indices, n: n) if is_container_type(name: leaf) { return none } + match rust_exact_reference_spelling(n: n, source_indices: source_indices, env: env) { + Present { value: exact } => Present { value: exact } + Absent => match rust_seed_host_numeric_alias(name: leaf, decl_file: type_reference_decl_file(n: n)) { Present { value: numeric } => Present { value: numeric } Absent => @@ -625,6 +628,88 @@ fn rust_render_checkpoint_scalar_bare(n: Node, source_indices: Map none } } + } + } +} + +// THE EXACT PATH, AT THE RENDERER. A type reference carries its resolved declaration +// (`inferred: Resolved { node }`); the declaration's module is the containment fact the corpus-wide +// bare-name census already holds (v1.compiler.infer_env SymbolIndex.global_bare, one row per declared +// name with its module_path and the declaration node), so the DeclarationRef is read from that +// census by identity -- the candidate whose declaration node IS the resolved node, by ident_span -- +// and never minted from a spelling. A second file->module map beside the census would be the +// parallel representation DESIGN section 3 forbids. Identity that the census cannot supply (a +// kernel mint, a variant alias, an unresolved reference) is absent, and absent identity is the +// ExactSourceIdentityUnavailable arm of the resolver: the spelling-keyed path answers or refuses +// for it exactly as before, which is the residue v1.compiler.coercion type_realization_decision declares for an empty decl_file. +fn binding_declares_span(binding: TypeBinding, sp: SourceSpan) -> Bool { + match binding.resolved.ident_span { + Present { value: s } => s.file == sp.file && s.start == sp.start + Absent => false + } +} + +fn type_reference_declaration_ref(n: Node, source_indices: Map, env: TypeEnv) -> DeclarationRef? { + let rt = match n.inferred { + Present { value: Resolved { node: r } } => r + _ => n + } + let decl_name = qualified_last_segment(name: authored_name_at(source_indices: source_indices, node: rt)) + if decl_name == "" { return none } + match rt.ident_span { + Absent => none + Present { value: sp } => + match map_get(env.symbol_index.global_bare, decl_name) { + Present { value: GlobalBareUniqueBinding { module_path: mp, binding: b } } => + if binding_declares_span(binding: b, sp: sp) { Present { value: decl_ref(module_path: mp, decl_name: decl_name) } } else { none } + Present { value: GlobalBareAmbiguousBinding { candidates: cands } } => + match cands |> filter(c => binding_declares_span(binding: c.binding, sp: sp)) |> first { + Present { value: c } => Present { value: decl_ref(module_path: c.module_path, decl_name: decl_name) } + Absent => none + } + Absent => none + } + } +} + +// The four arms of the exact resolver, rendered. Two answer a spelling; two are LOUD in the emitted +// bytes -- a declaration bound to a representation with no realization row, and two rows for one +// declaration -- because both are authoring defects a silent fall-through would hide behind the +// structural rendering. Absent and identity-unavailable answer none so the caller's spelling-keyed +// path runs, which for a Migrated name refuses (v1.compiler.coercion type_realization_decision). +fn rust_exact_binding_spelling(source: DeclarationRef?, grounding: Bool) -> String? { + match rust_lookup_exact_binding(source: source) { + ResolvedExactBinding { binding: b } => + match rust_exact_type_checkpoint(binding: b) { + Present { value: cp } => Present { value: if grounding { cp.grounding_type } else { cp.target_type } } + Absent => Present { value: emit_rust_compile_error_expr(message: concat("declaration '", b.source.decl_name as String, "' is bound to a Rust representation with no realization row")) } + } + ExactBindingAmbiguous { candidate_count: k } => + Present { value: emit_rust_compile_error_expr(message: concat("ambiguous exact Rust binding: ", to_string(value: k), " rows for one declaration")) } + ExactBindingAbsent => none + ExactSourceIdentityUnavailable { cause: _ } => none + } +} + +fn rust_exact_reference_spelling(n: Node, source_indices: Map, env: TypeEnv) -> String? { + rust_exact_binding_spelling(source: type_reference_declaration_ref(n: n, source_indices: source_indices, env: env), grounding: false) +} + +// REFERENCE position, node-bearing: exact first, then the spelling-keyed reference base. +fn rust_reference_checkpoint_spelling_at(n: Node, source_indices: Map, env: TypeEnv) -> String? { + match rust_exact_reference_spelling(n: n, source_indices: source_indices, env: env) { + Present { value: exact } => Present { value: exact } + Absent => rust_scalar_checkpoint_reference_base(dag_name: rust_fn_sig_leaf_name(source_indices: source_indices, n: n), decl_file: type_reference_decl_file(n: n)) + } +} + +// DECLARATION right-hand side, declaration-keyed: the declaring module is the env's own, so the +// DeclarationRef is constructed rather than looked up. Exact first, then the spelling-keyed +// grounding base. +fn rust_declaration_checkpoint_grounding_at(module_path: String, decl_name: String, decl_file: String) -> String? { + match rust_exact_binding_spelling(source: Present { value: decl_ref(module_path: module_path, decl_name: decl_name) }, grounding: true) { + Present { value: exact } => Present { value: exact } + Absent => rust_scalar_checkpoint_grounding_base(dag_name: decl_name, decl_file: decl_file) } } @@ -986,7 +1071,7 @@ fn render_rust_applied_type_arg(n: Node, generic_param_names: List, shar Present { value: TypeVariable { id: tv } } => if type_var_in_fn_generic_scope(id: tv, generic_param_names: generic_param_names) { to_pascal(name: tv) } else { "_" } _ => - match rust_render_checkpoint_scalar_bare(n: n, source_indices: source_indices, shared_types: shared_types) { + match rust_render_checkpoint_scalar_bare(n: n, source_indices: source_indices, shared_types: shared_types, env: env) { Present { value: scalar } => scalar Absent => render_rust_decl_type(n: n, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) } @@ -1011,7 +1096,7 @@ fn render_rust_applied_type(n: Node, generic_param_names: List, shared_t } } else { - match rust_scalar_checkpoint_reference_base(dag_name: base_name, decl_file: type_reference_decl_file(n: n)) { + match rust_reference_checkpoint_spelling_at(n: n, source_indices: source_indices, env: env) { Present { value: scalar } => scalar Absent => match closed_alias_peel_verdict(env: env, n: n) { @@ -1223,7 +1308,7 @@ fn render_rust_decl_type(n: Node, generic_param_names: List, shared_type let rendered = rust_render_type_leaf_name(name: name, variant_to_enum: variant_to_enum) render_rust_shared_type_with_optional(n: n, type_name: name, rendered: rendered, shared_types: shared_types) } else if n.connective == NoConnective && n.children |> count > 0 { - match rust_render_checkpoint_scalar_bare(n: n, source_indices: source_indices, shared_types: shared_types) { + match rust_render_checkpoint_scalar_bare(n: n, source_indices: source_indices, shared_types: shared_types, env: env) { Present { value: scalar } => render_rust_shared_type_with_optional(n: n, type_name: rust_fn_sig_leaf_name(source_indices: source_indices, n: n), rendered: scalar, shared_types: shared_types) Absent => if !is_container_type(name: name) && closed_alias_peels_zero_param(env: env, n: n) { @@ -1238,7 +1323,7 @@ fn render_rust_decl_type(n: Node, generic_param_names: List, shared_type } else if rust_type_arg_renders_as_unit(n: typed_arg, generic_param_names: generic_param_names, variant_to_enum: variant_to_enum, source_indices: source_indices) { "()" } else { - match rust_render_checkpoint_scalar_bare(n: typed_arg, source_indices: source_indices, shared_types: shared_types) { + match rust_render_checkpoint_scalar_bare(n: typed_arg, source_indices: source_indices, shared_types: shared_types, env: env) { Present { value: scalar } => scalar Absent => render_rust_decl_type(n: typed_arg, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) } @@ -1417,6 +1502,9 @@ fn render_rust_alias_rhs_type(n: Node, generic_param_names: List, shared if n.connective == NoConnective && n.children |> count == 0 && (generic_param_names |> any(g => g == name)) { to_pascal(name: name) } else if n.connective == NoConnective && n.children |> count == 0 { + match rust_exact_reference_spelling(n: n, source_indices: source_indices, env: env) { + Present { value: exact } => exact + Absent => match rust_seed_host_numeric_alias(name: name, decl_file: type_reference_decl_file(n: n)) { Present { value: host } => host Absent => @@ -1434,9 +1522,10 @@ fn render_rust_alias_rhs_type(n: Node, generic_param_names: List, shared } } } + } } else if n.connective == NoConnective && n.children |> count > 0 { let leaf = qualified_last_segment(name: name) - let numeric_host_alias = match rust_scalar_checkpoint_reference_base(dag_name: leaf, decl_file: type_reference_decl_file(n: n)) { + let numeric_host_alias = match rust_reference_checkpoint_spelling_at(n: n, source_indices: source_indices, env: scope.type_env) { Present { value: scalar } => Present { value: scalar } Absent => rust_seed_host_numeric_alias(name: leaf, decl_file: type_reference_decl_file(n: n)) } @@ -6003,11 +6092,11 @@ fn emit_typed_item(item: Node, module_name: String, registry: Map count) == 0 && rust_opaque_kernel_alias_type_eligible(name: item_text) { - rust_opaque_kernel_alias_type_decl(name: item_text) + rust_opaque_kernel_alias_type_decl(name: item_text, module_path: module_name) } else if is_zero_param_self_referential_opaque_decl(item: item, source_indices: env.source_indices) { emit_zero_param_phantom_opaque_struct(item: item, map_key_required: set_contains(emit_info.map_key_required_type_names, item_text), source_indices: env.source_indices) } else { - match rust_scalar_checkpoint_grounding_base(dag_name: item_text, decl_file: decl_identity_file(item: item)) { + match rust_declaration_checkpoint_grounding_at(module_path: module_name, decl_name: item_text, decl_file: decl_identity_file(item: item)) { Present { value: host } => concat(rust_visibility_prefix(), rust_items().type_alias_keyword, " ", item_text, " = ", host, ";") Absent => @@ -6028,7 +6117,7 @@ fn emit_typed_item(item: Node, module_name: String, registry: Map count) == 0 && rust_opaque_kernel_alias_type_eligible(name: item_text) { - rust_opaque_kernel_alias_type_decl(name: item_text) + rust_opaque_kernel_alias_type_decl(name: item_text, module_path: module_name) } else { match rust_seed_host_container_base(name: item_text) { From dbee0ebe9ebd8e3455c01941896e8049cd3fd455 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 03:14:19 +0000 Subject: [PATCH 32/75] Enroll the two emission batteries under the required-gate seed prefix (test.claim.self_host_*) --- dag/gunbc/rust_source_type_bindings.dag | 2 +- ...elf_host_emitted_call_target_realization_witness_test.dag} | 4 ++-- ...dag => self_host_symbol_identity_binding_witness_test.dag} | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) rename dag/test/claim/{emitted_call_target_realization_witness_test.dag => self_host_emitted_call_target_realization_witness_test.dag} (99%) rename dag/test/claim/{symbol_identity_binding_witness_test.dag => self_host_symbol_identity_binding_witness_test.dag} (99%) diff --git a/dag/gunbc/rust_source_type_bindings.dag b/dag/gunbc/rust_source_type_bindings.dag index a3216faa52f..c1d3a0eeedc 100644 --- a/dag/gunbc/rust_source_type_bindings.dag +++ b/dag/gunbc/rust_source_type_bindings.dag @@ -49,7 +49,7 @@ fn rust_bound_declaration_refs() -> List { } // THE VERDICT ON EVERY BARE-NAME ROW OF extdeps.languages.rust.types rust_type_checkpoints, one per -// name that table carried when this authority landed. The witness test.claim.symbol_identity_binding +// name that table carried when this authority landed. The witness test.claim.self_host_symbol_identity_binding // holds the roster and the table to each other: a Migrated name must be ABSENT from the bare table // (its deletion is the census), a Proven or Debt name must be PRESENT, and a table row with no // verdict is a refusal. So the spelling-keyed table can only shrink by a declared verdict. diff --git a/dag/test/claim/emitted_call_target_realization_witness_test.dag b/dag/test/claim/self_host_emitted_call_target_realization_witness_test.dag similarity index 99% rename from dag/test/claim/emitted_call_target_realization_witness_test.dag rename to dag/test/claim/self_host_emitted_call_target_realization_witness_test.dag index f1c55a0a8e5..9f079f6c20a 100644 --- a/dag/test/claim/emitted_call_target_realization_witness_test.dag +++ b/dag/test/claim/self_host_emitted_call_target_realization_witness_test.dag @@ -1,4 +1,4 @@ -module test.claim.emitted_call_target_realization_witness_test +module test.claim.self_host_emitted_call_target_realization_witness_test import v2.std.live_tree { LiveTreeDisposition, SubstrateInputsOnly } @@ -355,7 +355,7 @@ test fn w_qualified_type_reference_earns_the_leaf_use_line() -> Bool { ) } -// THE SYMBOL IMPORT COLLISION, the byte-level falsifier test.claim.symbol_identity_binding specifies +// THE SYMBOL IMPORT COLLISION, the byte-level falsifier test.claim.self_host_symbol_identity_binding specifies // for the exact path (symbol_import_collision_fixture_source there is this source). v2.std.node // `type Symbol` is opaque and bound by declaration to RustStdString; v2.std.text `String` is the // structural text carrier, and this module imports both. Under the spelling-keyed path Symbol diff --git a/dag/test/claim/symbol_identity_binding_witness_test.dag b/dag/test/claim/self_host_symbol_identity_binding_witness_test.dag similarity index 99% rename from dag/test/claim/symbol_identity_binding_witness_test.dag rename to dag/test/claim/self_host_symbol_identity_binding_witness_test.dag index 62d8caa3681..5c531987a98 100644 --- a/dag/test/claim/symbol_identity_binding_witness_test.dag +++ b/dag/test/claim/self_host_symbol_identity_binding_witness_test.dag @@ -1,4 +1,4 @@ -module test.claim.symbol_identity_binding_witness +module test.claim.self_host_symbol_identity_binding_witness import std.types { List, String, Bool, Int, NonEmptyStr } import std.decl_ref { DeclarationRef, decl_ref, declaration_ref_eq, declaration_ref_in_list } From 678e7363b6b8d99dfd7f36e9c0cbe7fafa681919 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 03:24:22 +0000 Subject: [PATCH 33/75] XL-0B commit 1: exact spelling at the fn-signature and declaration-type leaves; alias-rhs site reads scope.type_env --- src/v1/05_emit_rust.dag | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index 839f05904be..ae4f50f7d53 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -1300,6 +1300,10 @@ fn render_rust_decl_type(n: Node, generic_param_names: List, shared_type } Absent => let name = rust_fn_sig_leaf_name(source_indices: source_indices, n: n) + let exact_leaf = if n.connective == NoConnective && n.children |> count == 0 && !(generic_param_names |> any(g => g == name)) { rust_exact_reference_spelling(n: n, source_indices: source_indices, env: env) } else { none } + match exact_leaf { + Present { value: exact } => rust_carrier_optional_wrap(n: n, rendered: exact) + Absent => if n.connective == NoConnective && n.children |> count == 0 && (generic_param_names |> any(g => g == name)) { to_pascal(name: name) } else if n.connective == NoConnective && n.children |> count == 0 && applied_prop == none && is_host_text_carrier_type(n: n, source_indices: source_indices) { @@ -1355,6 +1359,7 @@ fn render_rust_decl_type(n: Node, generic_param_names: List, shared_type } else { render_rust_type_with_applied_binding_in_scope(n: n, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, env: env) } + } } } @@ -1391,6 +1396,10 @@ fn render_rust_fn_sig_type(n: Node, generic_param_names: List, shared_ty return render_rust_decl_type(n: n, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, variant_to_enum: variant_to_enum, env: env) } let name = rust_fn_sig_leaf_name(source_indices: source_indices, n: n) + let exact_leaf = if n.connective == NoConnective && n.children |> count == 0 && !(generic_param_names |> any(g => g == name)) { rust_exact_reference_spelling(n: n, source_indices: source_indices, env: env) } else { none } + match exact_leaf { + Present { value: exact } => rust_carrier_optional_wrap(n: n, rendered: exact) + Absent => if n.connective == NoConnective && n.children |> count == 0 && is_host_text_carrier_type(n: n, source_indices: source_indices) { rust_carrier_optional_wrap(n: n, rendered: render_rust_text_carrier(shared_types: shared_types)) } else if n.connective == NoConnective && n.children |> count == 0 && name != "" && name != "String" && !is_container_type(name: name) && closed_alias_peels_zero_param(env: env, n: n) && rust_fn_sig_preserves_authored_alias_leaf(name: name, decl_file: type_reference_decl_file(n: n)) { @@ -1402,6 +1411,7 @@ fn render_rust_fn_sig_type(n: Node, generic_param_names: List, shared_ty } else { render_rust_fn_sig_type_applied_binding(n: n, shared_types: shared_types, source_indices: source_indices, env: env) } + } } fn render_rust_fn_sig_type_applied_binding(n: Node, shared_types: Set, source_indices: Map, env: TypeEnv) -> String { From a1c9dde2105c0fd062d8d131a016af8a0e985c16 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 03:33:26 +0000 Subject: [PATCH 34/75] alias-rhs leaf site reads scope.type_env --- src/v1/05_emit_rust.dag | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index ae4f50f7d53..4b4f0664612 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -1512,7 +1512,7 @@ fn render_rust_alias_rhs_type(n: Node, generic_param_names: List, shared if n.connective == NoConnective && n.children |> count == 0 && (generic_param_names |> any(g => g == name)) { to_pascal(name: name) } else if n.connective == NoConnective && n.children |> count == 0 { - match rust_exact_reference_spelling(n: n, source_indices: source_indices, env: env) { + match rust_exact_reference_spelling(n: n, source_indices: source_indices, env: scope.type_env) { Present { value: exact } => exact Absent => match rust_seed_host_numeric_alias(name: name, decl_file: type_reference_decl_file(n: n)) { From c91d79de1137543043370d157efee36bdf86dcd3 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 04:32:37 +0000 Subject: [PATCH 35/75] Regenerate the stage0 mirror at the XL-0B commit-1 tree: byte fixed point at round 3 Cycle on srv1 over a1c9dde (authority tree bc2ae136138ac4aa), gate bins built each round: round 1: compiler e33c998203b59217 from installed df30d05facfa6307 -> drift v1_compiler_emit_rust.rs round 2: compiler ad9914da781db28d from installed c475b249666c3ba5 -> drift std_nat.rs, std_types.rs round 3: compiler c7ac6e91c1e07861 from installed be968e441d3a2a43 -> every regen-population file byte-equal CHANGED paths, each explained by the authority change: v1_compiler_emit_rust.rs (the threading); std_types.rs (Bytes/Secret/SecretValue declaration sites now spell the exact grounding std::vec::Vec / std::string::String); std_nat.rs (List in container-argument position renders the closed alias's resolved numeric realization i64 -- type-identical to Nat = i64). Unit tests on the converged bytes: 552 passed, 0 failed, 140 ignored. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01GXfYKNQTD3VfYyQcnJpxNU --- src/v1/stage0/src/std_nat.rs | 4 +- src/v1/stage0/src/std_types.rs | 6 +- src/v1/stage0/src/v1_compiler_emit_rust.rs | 926 +++++++++++++-------- 3 files changed, 571 insertions(+), 365 deletions(-) diff --git a/src/v1/stage0/src/std_nat.rs b/src/v1/stage0/src/std_nat.rs index 796b083f66c..19188c278f1 100644 --- a/src/v1/stage0/src/std_nat.rs +++ b/src/v1/stage0/src/std_nat.rs @@ -42,11 +42,11 @@ pub fn nat_min(a: Nat, b: Nat) -> Nat { } } -pub fn nat_range_inclusive(lo: Nat, hi: Nat) -> Rc> { +pub fn nat_range_inclusive(lo: Nat, hi: Nat) -> Rc> { nat_range_accumulate(lo.clone(), hi.clone(), Rc::new(vec![])) } -pub fn nat_range_accumulate(mut lo: Nat, mut hi: Nat, mut acc: Rc>) -> Rc> { +pub fn nat_range_accumulate(mut lo: Nat, mut hi: Nat, mut acc: Rc>) -> Rc> { loop { if (lo.clone() > hi.clone()) { break acc; diff --git a/src/v1/stage0/src/std_types.rs b/src/v1/stage0/src/std_types.rs index 18069b16576..46b60b226c8 100644 --- a/src/v1/stage0/src/std_types.rs +++ b/src/v1/stage0/src/std_types.rs @@ -185,7 +185,7 @@ impl From for bool { pub type Json = serde_json::Value; -pub type Bytes = Vec; +pub type Bytes = std::vec::Vec; pub type Char = i64; @@ -240,9 +240,9 @@ pub type Port = i64; pub type GistId = String; -pub type Secret = String; +pub type Secret = std::string::String; -pub type SecretValue = String; +pub type SecretValue = std::string::String; pub type SemVer = String; diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index d94b5921a40..dd0fefdadab 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -18,6 +18,7 @@ pub use crate::extdeps_languages_rust_emit::{ rust_method_wraps_result, rust_serde_rename_all_screaming_snake_case, rust_serde_rename_all_snake_case, rust_trait_derive_attr_from_traits, }; +pub use crate::extdeps_languages_rust_representation::rust_exact_type_checkpoint; use crate::gunbc_cli_dispatch_surface::CliOptionArity::{CliAtMostOne, CliRepeated, CliRequired}; use crate::gunbc_cli_dispatch_surface::CliOptionValue::{ CliMillisecondValue, CliPortValue, CliTextValue, CliToggleValue, @@ -55,6 +56,10 @@ use crate::std_syntax::AlgebraFieldKind::*; use crate::std_syntax::BinOp::*; use crate::std_syntax::LiteralValue::*; pub use crate::std_syntax::{AlgebraFieldKind, BinOp, LiteralValue}; +pub use crate::std_target_representation::ExactBindingResolution; +use crate::std_target_representation::ExactBindingResolution::{ + ExactBindingAbsent, ExactBindingAmbiguous, ExactSourceIdentityUnavailable, ResolvedExactBinding, +}; pub use crate::std_types::SourceSpan; pub use crate::std_types::{container_template_algebra, is_container_type, is_kernel_type}; pub use crate::v1_compiler_artifact::RenderTarget; @@ -63,8 +68,8 @@ pub use crate::v1_compiler_closure_stub_v2_std_integer_rust::closure_stub_v2_std pub use crate::v1_compiler_closure_stub_v2_std_text_rust::closure_stub_v2_std_text_source; pub use crate::v1_compiler_coercion::decl_identity_file; pub use crate::v1_compiler_coercion::{ - coerce_primitive_type, is_copy, lookup_checkpoint, rust_seed_host_numeric_alias, - target_callable, type_reference_decl_file, + coerce_primitive_type, is_copy, lookup_checkpoint, rust_lookup_exact_binding, + rust_seed_host_numeric_alias, target_callable, type_reference_decl_file, }; pub use crate::v1_compiler_compiler_tests_rust::compiler_tests_source; use crate::v1_compiler_emit::BoundOperation::{ @@ -120,7 +125,9 @@ pub use crate::v1_compiler_infer_emit_info::{ variant_belongs_to_enum, variant_summary_key, }; pub use crate::v1_compiler_infer_emit_info::{EmitGraphInfo, TypeRepr, TypeSummary}; -use crate::v1_compiler_infer_env::GlobalBareLookupState::*; +use crate::v1_compiler_infer_env::GlobalBareLookupState::{ + GlobalBareAmbiguousBinding, GlobalBareUniqueBinding, +}; pub use crate::v1_compiler_infer_env::{ authored_name, empty_symbol_index, lookup_type_by_name, lookup_type_for, }; @@ -434,124 +441,142 @@ pub fn render_rust_type_without_applied_binding( emit_info.clone(), ) } else { - if ((((n.connective.clone() == Connective::NoConnective) + if (((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) > 0)) && !crate::std_types::is_container_type(crate::v1_std_core::authored_name_at( source_indices.clone(), n.clone(), ))) - && closed_alias_peels_zero_param(emit_info.fn_type_env.clone(), n.clone())) { - { - let leaf = crate::v1_std_core::qualified_last_segment( - crate::v1_std_core::authored_name_at(source_indices.clone(), n.clone()), - ); - render_rust_shared_type_with_optional( - n.clone(), - leaf.clone(), - leaf.clone(), - shared_types.clone(), - ) - } + render_rust_applied_via_emit_info( + n.clone(), + shared_types.clone(), + source_indices.clone(), + emit_info.clone(), + ) } else { - if (((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) > 0)) - && !crate::std_types::is_container_type(crate::v1_std_core::authored_name_at( - source_indices.clone(), - n.clone(), - ))) - { - render_rust_applied_via_emit_info( - n.clone(), - shared_types.clone(), - source_indices.clone(), - emit_info.clone(), - ) + if crate::v1_compiler_infer_types::node_is_set_collection( + n.clone(), + source_indices.clone(), + ) { + match n.children.clone().first().cloned() { + Some(elem_child) => { + let elem_node = + crate::v1_compiler_infer_types::child_type_node(elem_child.clone()); + let elem_is_type_var = if (elem_node.inferred.clone() != None) { + is_type_variable(elem_node.inferred.clone().clone().unwrap()) + } else { + false + }; + if elem_is_type_var.clone() { + emit_rust_compile_error_expr( + "Set element type unresolved".to_string(), + ) + } else { + if !rust_btree_set_element_ord_eligible( + elem_node.clone(), + source_indices.clone(), + emit_info.clone(), + ) { + { + let elem_name = crate::v1_std_core::authored_name_at( + source_indices.clone(), + elem_node.clone(), + ); + emit_rust_compile_error_expr(v1_rt::concat( + v1_rt::concat( + "Set element type ".to_string(), + elem_name.clone(), + ), + " is not Ord-eligible for BTreeSet".to_string(), + )) + } + } else { + crate::v1_compiler_emit::render_node_type( + n.clone(), + RenderTarget::Rust, + shared_types.clone(), + source_indices.clone(), + ) + } + } + } + None => { + emit_rust_compile_error_expr("Set missing element type".to_string()) + } + } } else { - if crate::v1_compiler_infer_types::node_is_set_collection( + if crate::v1_compiler_infer_types::node_is_keyed_collection( n.clone(), source_indices.clone(), ) { match n.children.clone().first().cloned() { - Some(elem_child) => { - let elem_node = crate::v1_compiler_infer_types::child_type_node( - elem_child.clone(), + Some(key_child) => { + let key_node = crate::v1_compiler_infer_types::child_type_node( + key_child.clone(), ); - let elem_is_type_var = if (elem_node.inferred.clone() != None) { - is_type_variable(elem_node.inferred.clone().clone().unwrap()) - } else { - false - }; - if elem_is_type_var.clone() { - emit_rust_compile_error_expr( - "Set element type unresolved".to_string(), - ) - } else { - if !rust_btree_set_element_ord_eligible( - elem_node.clone(), - source_indices.clone(), - emit_info.clone(), - ) { - { - let elem_name = crate::v1_std_core::authored_name_at( - source_indices.clone(), - elem_node.clone(), - ); - emit_rust_compile_error_expr(v1_rt::concat( - v1_rt::concat( - "Set element type ".to_string(), - elem_name.clone(), - ), - " is not Ord-eligible for BTreeSet".to_string(), - )) - } - } else { - crate::v1_compiler_emit::render_node_type( - n.clone(), - RenderTarget::Rust, - shared_types.clone(), - source_indices.clone(), + let val_node = match n + .children + .clone() + .iter() + .cloned() + .skip(1 as usize) + .next() + { + Some(val_child) => { + crate::v1_compiler_infer_types::child_type_node( + val_child.clone(), ) } - } - } - None => { - emit_rust_compile_error_expr("Set missing element type".to_string()) + None => type_variable_node("map_value".to_string()), + }; + let key_str = render_rust_type( + key_node.clone(), + shared_types.clone(), + source_indices.clone(), + emit_info.clone(), + ); + let val_str = render_rust_type( + val_node.clone(), + shared_types.clone(), + source_indices.clone(), + emit_info.clone(), + ); + let tn = crate::v1_std_core::authored_name_at( + source_indices.clone(), + n.clone(), + ); + let base = crate::v1_compiler_emit::emit_map_type( + key_str.clone(), + val_str.clone(), + RenderTarget::Rust, + ); + render_rust_shared_type_with_optional( + n.clone(), + tn.clone(), + base.clone(), + shared_types.clone(), + ) } + None => crate::v1_compiler_emit::render_node_type( + n.clone(), + RenderTarget::Rust, + shared_types.clone(), + source_indices.clone(), + ), } } else { - if crate::v1_compiler_infer_types::node_is_keyed_collection( + if crate::v1_compiler_infer_types::node_is_element_collection( n.clone(), source_indices.clone(), ) { match n.children.clone().first().cloned() { - Some(key_child) => { - let key_node = crate::v1_compiler_infer_types::child_type_node( - key_child.clone(), + Some(elem_child) => { + let elem_node = crate::v1_compiler_infer_types::child_type_node( + elem_child.clone(), ); - let val_node = match n - .children - .clone() - .iter() - .cloned() - .skip(1 as usize) - .next() - { - Some(val_child) => { - crate::v1_compiler_infer_types::child_type_node( - val_child.clone(), - ) - } - None => type_variable_node("map_value".to_string()), - }; - let key_str = render_rust_type( - key_node.clone(), - shared_types.clone(), - source_indices.clone(), - emit_info.clone(), - ); - let val_str = render_rust_type( - val_node.clone(), + let inner_str = render_rust_type( + elem_node.clone(), shared_types.clone(), source_indices.clone(), emit_info.clone(), @@ -560,9 +585,9 @@ pub fn render_rust_type_without_applied_binding( source_indices.clone(), n.clone(), ); - let base = crate::v1_compiler_emit::emit_map_type( - key_str.clone(), - val_str.clone(), + let base = crate::v1_compiler_emit::emit_container( + tn.clone(), + inner_str.clone(), RenderTarget::Rust, ); render_rust_shared_type_with_optional( @@ -580,74 +605,31 @@ pub fn render_rust_type_without_applied_binding( ), } } else { - if crate::v1_compiler_infer_types::node_is_element_collection( - n.clone(), - source_indices.clone(), - ) { - match n.children.clone().first().cloned() { - Some(elem_child) => { - let elem_node = - crate::v1_compiler_infer_types::child_type_node( - elem_child.clone(), - ); - let inner_str = render_rust_type( - elem_node.clone(), - shared_types.clone(), - source_indices.clone(), - emit_info.clone(), - ); - let tn = crate::v1_std_core::authored_name_at( - source_indices.clone(), - n.clone(), - ); - let base = crate::v1_compiler_emit::emit_container( - tn.clone(), - inner_str.clone(), - RenderTarget::Rust, - ); - render_rust_shared_type_with_optional( + { + let tn = crate::v1_std_core::authored_name_at( + source_indices.clone(), + n.clone(), + ); + if type_node_has_unbound_type_variable( + n.clone(), + emit_info.fn_generic_param_names.clone(), + source_indices.clone(), + ) { + "_".to_string() + } else { + if is_host_text_carrier_type(n.clone(), source_indices.clone()) + { + rust_carrier_optional_wrap( n.clone(), - tn.clone(), - base.clone(), - shared_types.clone(), + render_rust_text_carrier(shared_types.clone()), ) - } - None => crate::v1_compiler_emit::render_node_type( - n.clone(), - RenderTarget::Rust, - shared_types.clone(), - source_indices.clone(), - ), - } - } else { - { - let tn = crate::v1_std_core::authored_name_at( - source_indices.clone(), - n.clone(), - ); - if type_node_has_unbound_type_variable( - n.clone(), - emit_info.fn_generic_param_names.clone(), - source_indices.clone(), - ) { - "_".to_string() } else { - if is_host_text_carrier_type( + crate::v1_compiler_emit::render_node_type( n.clone(), + RenderTarget::Rust, + shared_types.clone(), source_indices.clone(), - ) { - rust_carrier_optional_wrap( - n.clone(), - render_rust_text_carrier(shared_types.clone()), - ) - } else { - crate::v1_compiler_emit::render_node_type( - n.clone(), - RenderTarget::Rust, - shared_types.clone(), - source_indices.clone(), - ) - } + ) } } } @@ -905,13 +887,22 @@ pub fn rust_opaque_kernel_alias_carrier(name: String) -> Option { } } -pub fn rust_opaque_kernel_alias_type_decl(name: String) -> String { +pub fn rust_opaque_kernel_alias_type_decl(name: String, module_path: String) -> String { { - let carrier = crate::v1_compiler_coercion::coerce_primitive_type( - RenderTarget::Rust, - name.clone(), - "".to_string(), - ); + let carrier = match rust_exact_binding_spelling( + Some(crate::std_decl_ref::decl_ref( + module_path.clone(), + name.clone(), + )), + true, + ) { + Some(exact) => exact.clone(), + None => crate::v1_compiler_coercion::coerce_primitive_type( + RenderTarget::Rust, + name.clone(), + "".to_string(), + ), + }; v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -1029,6 +1020,7 @@ pub fn rust_render_checkpoint_scalar_bare( n: Rc, source_indices: Rc>>, shared_types: Rc>, + env: Rc, ) -> Option { if ((n.children.clone().len() as i64) == 0) { None @@ -1038,31 +1030,183 @@ pub fn rust_render_checkpoint_scalar_bare( if crate::std_types::is_container_type(leaf.clone()) { return None; } - match crate::v1_compiler_coercion::rust_seed_host_numeric_alias( - leaf.clone(), - crate::v1_compiler_coercion::type_reference_decl_file(n.clone()), - ) { - Some(numeric) => Some(numeric.clone()), - None => match rust_scalar_checkpoint_reference_base( + match rust_exact_reference_spelling(n.clone(), source_indices.clone(), env.clone()) { + Some(exact) => Some(exact.clone()), + None => match crate::v1_compiler_coercion::rust_seed_host_numeric_alias( leaf.clone(), crate::v1_compiler_coercion::type_reference_decl_file(n.clone()), ) { - Some(scalar) => { - if (v1_rt::set_contains(&shared_types, leaf.clone()) - && !rust_type_is_rc_wrapped(scalar.clone())) - { - Some(crate::v1_compiler_languages::wrap_shared_type( - RenderTarget::Rust, - scalar.clone(), - )) - } else { - Some(scalar.clone()) + Some(numeric) => Some(numeric.clone()), + None => match rust_scalar_checkpoint_reference_base( + leaf.clone(), + crate::v1_compiler_coercion::type_reference_decl_file(n.clone()), + ) { + Some(scalar) => { + if (v1_rt::set_contains(&shared_types, leaf.clone()) + && !rust_type_is_rc_wrapped(scalar.clone())) + { + Some(crate::v1_compiler_languages::wrap_shared_type( + RenderTarget::Rust, + scalar.clone(), + )) + } else { + Some(scalar.clone()) + } + } + None => None, + }, + }, + } + } + } +} + +pub fn binding_declares_span(binding: Rc, sp: Rc) -> bool { + match binding.resolved.clone().ident_span.clone() { + Some(s) => ((s.file.clone() == sp.file.clone()) && (s.start.clone() == sp.start.clone())), + None => false, + } +} + +pub fn type_reference_declaration_ref( + n: Rc, + source_indices: Rc>>, + env: Rc, +) -> Option> { + { + let rt = match n.inferred.clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: r, .. }) => r.clone(), + _ => n.clone(), + }; + let decl_name = crate::v1_std_core::qualified_last_segment( + crate::v1_std_core::authored_name_at(source_indices.clone(), rt.clone()), + ); + if (decl_name.clone() == "".to_string()) { + return None; + } + match rt.ident_span.clone() { + None => None, + Some(sp) => match v1_rt::map_get( + &env.symbol_index.clone().global_bare.clone(), + decl_name.clone(), + ) + .as_deref() + .cloned() + { + Some(GlobalBareLookupState::GlobalBareUniqueBinding { + module_path: mp, + binding: b, + .. + }) => { + if binding_declares_span(b.clone(), sp.clone()) { + Some(crate::std_decl_ref::decl_ref(mp.clone(), decl_name.clone())) + } else { + None + } + } + Some(GlobalBareLookupState::GlobalBareAmbiguousBinding { + candidates: cands, + .. + }) => match Rc::new({ + let mut __result = Vec::new(); + for c in cands.iter().cloned() { + if binding_declares_span(c.binding.clone(), sp.clone()) { + __result.push(c); } } + __result + }) + .first() + .cloned() + { + Some(c) => Some(crate::std_decl_ref::decl_ref( + c.module_path.clone(), + decl_name.clone(), + )), None => None, }, + None => None, + }, + } + } +} + +pub fn rust_exact_binding_spelling( + source: Option>, + grounding: bool, +) -> Option { + match (*crate::v1_compiler_coercion::rust_lookup_exact_binding(source.clone())).clone() { + ExactBindingResolution::ResolvedExactBinding { binding: b, .. } => { + match crate::extdeps_languages_rust_representation::rust_exact_type_checkpoint( + b.clone(), + ) { + Some(cp) => Some(if grounding.clone() { + cp.grounding_type.clone() + } else { + cp.target_type.clone() + }), + None => Some(emit_rust_compile_error_expr(v1_rt::concat( + v1_rt::concat( + "declaration '".to_string(), + b.source.clone().decl_name.clone(), + ), + "' is bound to a Rust representation with no realization row".to_string(), + ))), } } + ExactBindingResolution::ExactBindingAmbiguous { + candidate_count: k, .. + } => Some(emit_rust_compile_error_expr(v1_rt::concat( + v1_rt::concat( + "ambiguous exact Rust binding: ".to_string(), + crate::v1_compiler_emit_core_support::to_string(k.clone()), + ), + " rows for one declaration".to_string(), + ))), + ExactBindingResolution::ExactBindingAbsent => None, + ExactBindingResolution::ExactSourceIdentityUnavailable { cause: _, .. } => None, + } +} + +pub fn rust_exact_reference_spelling( + n: Rc, + source_indices: Rc>>, + env: Rc, +) -> Option { + rust_exact_binding_spelling( + type_reference_declaration_ref(n.clone(), source_indices.clone(), env.clone()), + false, + ) +} + +pub fn rust_reference_checkpoint_spelling_at( + n: Rc, + source_indices: Rc>>, + env: Rc, +) -> Option { + match rust_exact_reference_spelling(n.clone(), source_indices.clone(), env.clone()) { + Some(exact) => Some(exact.clone()), + None => rust_scalar_checkpoint_reference_base( + rust_fn_sig_leaf_name(source_indices.clone(), n.clone()), + crate::v1_compiler_coercion::type_reference_decl_file(n.clone()), + ), + } +} + +pub fn rust_declaration_checkpoint_grounding_at( + module_path: String, + decl_name: String, + decl_file: String, +) -> Option { + match rust_exact_binding_spelling( + Some(crate::std_decl_ref::decl_ref( + module_path.clone(), + decl_name.clone(), + )), + true, + ) { + Some(exact) => Some(exact.clone()), + None => rust_scalar_checkpoint_grounding_base(decl_name.clone(), decl_file.clone()), } } @@ -1839,6 +1983,7 @@ pub fn render_rust_applied_type_arg( n.clone(), source_indices.clone(), shared_types.clone(), + env.clone(), ) { Some(scalar) => scalar.clone(), None => render_rust_decl_type( @@ -1890,9 +2035,10 @@ pub fn render_rust_applied_type( ), } } else { - match rust_scalar_checkpoint_reference_base( - base_name.clone(), - crate::v1_compiler_coercion::type_reference_decl_file(n.clone()), + match rust_reference_checkpoint_spelling_at( + n.clone(), + source_indices.clone(), + env.clone(), ) { Some(scalar) => scalar.clone(), None => match closed_alias_peel_verdict(env.clone(), n.clone()) { @@ -2196,9 +2342,9 @@ pub fn render_rust_decl_type( } None => { let name = rust_fn_sig_leaf_name(source_indices.clone(), n.clone()); - if (((n.connective.clone() == Connective::NoConnective) + let exact_leaf = if (((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) == 0)) - && { + && !{ let mut __found = false; for g in generic_param_names.iter().cloned() { if (g.clone() == name.clone()) { @@ -2207,76 +2353,102 @@ pub fn render_rust_decl_type( } } __found - }) - { - crate::v1_compiler_emit_core_support::to_pascal(name.clone()) + }) { + rust_exact_reference_spelling(n.clone(), source_indices.clone(), env.clone()) } else { - if ((((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) == 0)) - && (applied_prop.clone() == None)) - && is_host_text_carrier_type(n.clone(), source_indices.clone())) - { - rust_carrier_optional_wrap( - n.clone(), - render_rust_text_carrier(shared_types.clone()), - ) - } else { - if ((((n.connective.clone() == Connective::NoConnective) + None + }; + match exact_leaf.clone() { + Some(exact) => rust_carrier_optional_wrap(n.clone(), exact.clone()), + None => { + if (((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) == 0)) - && (applied_prop.clone() == None)) - && v1_rt::set_contains(&shared_types, name.clone())) + && { + let mut __found = false; + for g in generic_param_names.iter().cloned() { + if (g.clone() == name.clone()) { + __found = true; + break; + } + } + __found + }) { - { - let rendered = rust_render_type_leaf_name( - name.clone(), - variant_to_enum.clone(), - ); - render_rust_shared_type_with_optional( - n.clone(), - name.clone(), - rendered.clone(), - shared_types.clone(), - ) - } + crate::v1_compiler_emit_core_support::to_pascal(name.clone()) } else { - if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) > 0)) + if ((((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) == 0)) + && (applied_prop.clone() == None)) + && is_host_text_carrier_type(n.clone(), source_indices.clone())) { - match rust_render_checkpoint_scalar_bare( + rust_carrier_optional_wrap( n.clone(), - source_indices.clone(), - shared_types.clone(), - ) { - Some(scalar) => render_rust_shared_type_with_optional( - n.clone(), - rust_fn_sig_leaf_name(source_indices.clone(), n.clone()), - scalar.clone(), - shared_types.clone(), - ), - None => { - if (!crate::std_types::is_container_type(name.clone()) - && closed_alias_peels_zero_param( - env.clone(), - n.clone(), - )) - { - render_rust_shared_type_with_optional( + render_rust_text_carrier(shared_types.clone()), + ) + } else { + if ((((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) == 0)) + && (applied_prop.clone() == None)) + && v1_rt::set_contains(&shared_types, name.clone())) + { + { + let rendered = rust_render_type_leaf_name( + name.clone(), + variant_to_enum.clone(), + ); + render_rust_shared_type_with_optional( + n.clone(), + name.clone(), + rendered.clone(), + shared_types.clone(), + ) + } + } else { + if ((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) > 0)) + { + match rust_render_checkpoint_scalar_bare( + n.clone(), + source_indices.clone(), + shared_types.clone(), + env.clone(), + ) { + Some(scalar) => render_rust_shared_type_with_optional( n.clone(), - name.clone(), - name.clone(), + rust_fn_sig_leaf_name( + source_indices.clone(), + n.clone(), + ), + scalar.clone(), shared_types.clone(), - ) - } else { - { - let base = rust_applied_type_base(name.clone(), crate::v1_compiler_coercion::type_reference_decl_file(n.clone())); - let peel = is_parametric_opaque_type_by_name( - env.clone(), + ), + None => { + if (!crate::std_types::is_container_type( name.clone(), - ); - let arg_list = Rc::new({ - let mut __result = Vec::new(); - for arg in n.children.clone().iter().cloned() { - __result.push({ + ) && closed_alias_peels_zero_param( + env.clone(), + n.clone(), + )) { + render_rust_shared_type_with_optional( + n.clone(), + name.clone(), + name.clone(), + shared_types.clone(), + ) + } else { + { + let base = rust_applied_type_base(name.clone(), crate::v1_compiler_coercion::type_reference_decl_file(n.clone())); + let peel = + is_parametric_opaque_type_by_name( + env.clone(), + name.clone(), + ); + let arg_list = Rc::new({ + let mut __result = Vec::new(); + for arg in + n.children.clone().iter().cloned() + { + __result.push({ let typed_arg = render_rust_decl_type_container_arg(arg.clone(), source_indices.clone(), env.clone()); if peel.clone() { render_rust_phantom_opaque_applied_decl_arg(typed_arg.clone(), generic_param_names.clone(), shared_types.clone(), source_indices.clone(), variant_to_enum.clone(), env.clone()) @@ -2284,25 +2456,22 @@ if peel.clone() { if rust_type_arg_renders_as_unit(typed_arg.clone(), generic_param_names.clone(), variant_to_enum.clone(), source_indices.clone()) { "()".to_string() } else { - match rust_render_checkpoint_scalar_bare(typed_arg.clone(), source_indices.clone(), shared_types.clone()) { + match rust_render_checkpoint_scalar_bare(typed_arg.clone(), source_indices.clone(), shared_types.clone(), env.clone()) { Some(scalar) => scalar.clone(), None => render_rust_decl_type(typed_arg.clone(), generic_param_names.clone(), shared_types.clone(), source_indices.clone(), variant_to_enum.clone(), env.clone()), } } } }); - } - __result - }); - let applied_ty = if (name.clone() - == tuple_type_name()) - { - crate::v1_compiler_emit::render_tuple_parts( - arg_list.clone(), - RenderTarget::Rust, - ) - } else { - if crate::v1_compiler_infer_types::node_is_keyed_collection(n.clone(), source_indices.clone()) { + } + __result + }); + let applied_ty = if (name.clone() + == tuple_type_name()) + { + crate::v1_compiler_emit::render_tuple_parts(arg_list.clone(), RenderTarget::Rust) + } else { + if crate::v1_compiler_infer_types::node_is_keyed_collection(n.clone(), source_indices.clone()) { match arg_list.clone().first().cloned() { Some(k) => match arg_list.clone().iter().cloned().skip(1 as usize).next() { Some(v) => crate::v1_compiler_emit::emit_map_type(k.clone(), v.clone(), RenderTarget::Rust), @@ -2320,33 +2489,35 @@ if peel.clone() { v1_rt::concat(v1_rt::concat(v1_rt::concat(base.clone(), "<".to_string()), arg_list.clone().join(&", ".to_string())), ">".to_string()) } } - }; - render_rust_shared_type_with_optional( - n.clone(), - name.clone(), - applied_ty.clone(), - shared_types.clone(), - ) + }; + render_rust_shared_type_with_optional( + n.clone(), + name.clone(), + applied_ty.clone(), + shared_types.clone(), + ) + } + } } } + } else { + if type_node_has_unbound_type_variable( + n.clone(), + generic_param_names.clone(), + source_indices.clone(), + ) { + "_".to_string() + } else { + render_rust_type_with_applied_binding_in_scope( + n.clone(), + generic_param_names.clone(), + shared_types.clone(), + source_indices.clone(), + env.clone(), + ) + } } } - } else { - if type_node_has_unbound_type_variable( - n.clone(), - generic_param_names.clone(), - source_indices.clone(), - ) { - "_".to_string() - } else { - render_rust_type_with_applied_binding_in_scope( - n.clone(), - generic_param_names.clone(), - shared_types.clone(), - source_indices.clone(), - env.clone(), - ) - } } } } @@ -2430,58 +2601,82 @@ pub fn render_rust_fn_sig_type( ); } let name = rust_fn_sig_leaf_name(source_indices.clone(), n.clone()); - if (((n.connective.clone() == Connective::NoConnective) + let exact_leaf = if (((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) == 0)) - && is_host_text_carrier_type(n.clone(), source_indices.clone())) - { - rust_carrier_optional_wrap(n.clone(), render_rust_text_carrier(shared_types.clone())) + && !{ + let mut __found = false; + for g in generic_param_names.iter().cloned() { + if (g.clone() == name.clone()) { + __found = true; + break; + } + } + __found + }) { + rust_exact_reference_spelling(n.clone(), source_indices.clone(), env.clone()) } else { - if (((((((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) == 0)) - && (name.clone() != "".to_string())) - && (name.clone() != "String".to_string())) - && !crate::std_types::is_container_type(name.clone())) - && closed_alias_peels_zero_param(env.clone(), n.clone())) - && rust_fn_sig_preserves_authored_alias_leaf( - name.clone(), - crate::v1_compiler_coercion::type_reference_decl_file(n.clone()), - )) - { - render_rust_shared_type_with_optional( - n.clone(), - name.clone(), - name.clone(), - shared_types.clone(), - ) - } else { - if ((((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) > 0)) - && !crate::std_types::is_container_type(name.clone())) - && closed_alias_peels_zero_param(env.clone(), n.clone())) + None + }; + match exact_leaf.clone() { + Some(exact) => rust_carrier_optional_wrap(n.clone(), exact.clone()), + None => { + if (((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) == 0)) + && is_host_text_carrier_type(n.clone(), source_indices.clone())) { - render_rust_shared_type_with_optional( + rust_carrier_optional_wrap( n.clone(), - name.clone(), - name.clone(), - shared_types.clone(), + render_rust_text_carrier(shared_types.clone()), ) } else { - if ((generic_param_names.clone().len() as i64) > 0) { - render_rust_decl_type( + if (((((((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) == 0)) + && (name.clone() != "".to_string())) + && (name.clone() != "String".to_string())) + && !crate::std_types::is_container_type(name.clone())) + && closed_alias_peels_zero_param(env.clone(), n.clone())) + && rust_fn_sig_preserves_authored_alias_leaf( + name.clone(), + crate::v1_compiler_coercion::type_reference_decl_file(n.clone()), + )) + { + render_rust_shared_type_with_optional( n.clone(), - generic_param_names.clone(), + name.clone(), + name.clone(), shared_types.clone(), - source_indices.clone(), - variant_to_enum.clone(), - env.clone(), ) } else { - render_rust_fn_sig_type_applied_binding( - n.clone(), - shared_types.clone(), - source_indices.clone(), - env.clone(), - ) + if ((((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) > 0)) + && !crate::std_types::is_container_type(name.clone())) + && closed_alias_peels_zero_param(env.clone(), n.clone())) + { + render_rust_shared_type_with_optional( + n.clone(), + name.clone(), + name.clone(), + shared_types.clone(), + ) + } else { + if ((generic_param_names.clone().len() as i64) > 0) { + render_rust_decl_type( + n.clone(), + generic_param_names.clone(), + shared_types.clone(), + source_indices.clone(), + variant_to_enum.clone(), + env.clone(), + ) + } else { + render_rust_fn_sig_type_applied_binding( + n.clone(), + shared_types.clone(), + source_indices.clone(), + env.clone(), + ) + } + } } } } @@ -2732,33 +2927,42 @@ pub fn render_rust_alias_rhs_type( if ((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) == 0)) { - match crate::v1_compiler_coercion::rust_seed_host_numeric_alias( - name.clone(), - crate::v1_compiler_coercion::type_reference_decl_file(n.clone()), + match rust_exact_reference_spelling( + n.clone(), + source_indices.clone(), + scope.type_env.clone(), ) { - Some(host) => host.clone(), - None => match rust_opaque_kernel_alias_carrier(name.clone()) { - Some(carrier) => carrier.clone(), - None => { - let leaf = crate::v1_std_core::qualified_last_segment(name.clone()); - match rust_scalar_checkpoint_reference_base( - leaf.clone(), - crate::v1_compiler_coercion::type_reference_decl_file(n.clone()), - ) { - Some(scalar) => scalar.clone(), - None => { - let rendered = rust_render_type_leaf_name( - leaf.clone(), - variant_to_enum.clone(), - ); - render_rust_shared_type_if_needed( - leaf.clone(), - rendered.clone(), - shared_types.clone(), - ) + Some(exact) => exact.clone(), + None => match crate::v1_compiler_coercion::rust_seed_host_numeric_alias( + name.clone(), + crate::v1_compiler_coercion::type_reference_decl_file(n.clone()), + ) { + Some(host) => host.clone(), + None => match rust_opaque_kernel_alias_carrier(name.clone()) { + Some(carrier) => carrier.clone(), + None => { + let leaf = crate::v1_std_core::qualified_last_segment(name.clone()); + match rust_scalar_checkpoint_reference_base( + leaf.clone(), + crate::v1_compiler_coercion::type_reference_decl_file( + n.clone(), + ), + ) { + Some(scalar) => scalar.clone(), + None => { + let rendered = rust_render_type_leaf_name( + leaf.clone(), + variant_to_enum.clone(), + ); + render_rust_shared_type_if_needed( + leaf.clone(), + rendered.clone(), + shared_types.clone(), + ) + } } } - } + }, }, } } else { @@ -2767,9 +2971,10 @@ pub fn render_rust_alias_rhs_type( { { let leaf = crate::v1_std_core::qualified_last_segment(name.clone()); - let numeric_host_alias = match rust_scalar_checkpoint_reference_base( - leaf.clone(), - crate::v1_compiler_coercion::type_reference_decl_file(n.clone()), + let numeric_host_alias = match rust_reference_checkpoint_spelling_at( + n.clone(), + source_indices.clone(), + scope.type_env.clone(), ) { Some(scalar) => Some(scalar.clone()), None => crate::v1_compiler_coercion::rust_seed_host_numeric_alias( @@ -13319,7 +13524,7 @@ pub fn emit_typed_item( if (((item.params.clone().len() as i64) == 0) && rust_opaque_kernel_alias_type_eligible(item_text.clone())) { - rust_opaque_kernel_alias_type_decl(item_text.clone()) + rust_opaque_kernel_alias_type_decl(item_text.clone(), module_name.clone()) } else { if is_zero_param_self_referential_opaque_decl( item.clone(), @@ -13334,7 +13539,8 @@ pub fn emit_typed_item( env.source_indices.clone(), ) } else { - match rust_scalar_checkpoint_grounding_base( + match rust_declaration_checkpoint_grounding_at( + module_name.clone(), item_text.clone(), decl_identity_file(item.clone()), ) { @@ -13400,7 +13606,7 @@ pub fn emit_typed_item( if (((item.params.clone().len() as i64) == 0) && rust_opaque_kernel_alias_type_eligible(item_text.clone())) { - rust_opaque_kernel_alias_type_decl(item_text.clone()) + rust_opaque_kernel_alias_type_decl(item_text.clone(), module_name.clone()) } else { match rust_seed_host_container_base(item_text.clone()) { Some(host) => { From 8781269ebfccf05428bb21ff93cd1d5e150167b2 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 04:55:16 +0000 Subject: [PATCH 36/75] XL-0B commit 2 (source): declared callees imported over builtin capture; dead RebuildEmittedFail variant; Accepted diagnostics bound and threaded; WallNow carries its fields; evaluator binding-miss answers the PartialFunction codomain; Optional-nested variant qualified by its own enum; Clone for generics forwarded by a returned closure --- ...d_call_target_realization_witness_test.dag | 27 ++++++++++++++++ src/v1/05_emit_rust.dag | 2 +- src/v1/trait_derive_emit.dag | 32 +++++++++++++++++++ src/v2/compiler/06_translate.dag | 1 + src/v2/extdeps/runtimes/v2_effect_io_pure.dag | 4 +-- src/v2/extdeps/runtimes/v2_evaluator.dag | 16 +++------- src/v2/lens/coverage.dag | 2 ++ src/v2/lens/enforcement/vocab.dag | 2 ++ src/v2/lens/mandatory_tag.dag | 7 +++- src/v2/lens/reference_deps.dag | 5 +-- src/v2/std/compilers/target_model.dag | 26 +++++++++------ src/v2/std/grammar.dag | 1 - 12 files changed, 97 insertions(+), 28 deletions(-) diff --git a/dag/test/claim/self_host_emitted_call_target_realization_witness_test.dag b/dag/test/claim/self_host_emitted_call_target_realization_witness_test.dag index 9f079f6c20a..937cdf48b31 100644 --- a/dag/test/claim/self_host_emitted_call_target_realization_witness_test.dag +++ b/dag/test/claim/self_host_emitted_call_target_realization_witness_test.dag @@ -396,6 +396,33 @@ test fn w_generic_arrow_return_renders_the_fn_scope_generic() -> Bool { ) } +// A VARIANT NESTED INSIDE AN OPTIONAL PATTERN IS QUALIFIED BY ITS OWN ENUM. `Present { value: U { .. } }` +// rendered `Some(Optional::U { .. })` (four sites in v2.std.symbol_index, E0599 no variant named U in +// Option): the Some payload inherited the OUTER scrutinee's enum. The payload's parent is the +// enum that declares the variant, never the Optional around it. +test fn w_variant_nested_in_an_optional_pattern_is_qualified_by_its_own_enum() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.optional_nested_variant_probe\nimport std.types { Int, Bool }\ntype State = Unique { n: Int } | Ambiguous\nfn probe(s: State?) -> Bool {\n match s {\n Present { value: Unique { n: k } } => k == 0\n Present { value: Ambiguous } => false\n Absent => false\n }\n}\n", + "src/test_claim_optional_nested_variant_probe.rs", + ["Some(State::Unique {", "Some(State::Ambiguous)"], + ["Optional::Unique", "Option::Unique"] + ) +} + +// A GENERIC PARAMETER FORWARDED BY THE RETURNED CLOSURE CARRIES CLONE. An arrow-returning fn +// realizes as `Rc::new(move |x| f(x.clone()))`, so a generic that reaches an arrow-typed parameter +// needs `Clone` (E0277 `A: Clone` not satisfied, v2.std.staging then_outcome and +// v2.compiler.materialization_carriers cached_stage_governed). The structural rules read what a +// value is; this obligation comes from what the realization does with it. +test fn w_generic_forwarded_by_a_returned_closure_carries_clone() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.returned_closure_clone_probe\nfn compose(f: fn(A) -> B, g: fn(B) -> C) -> fn(A) -> C {\n fn(x) { g(f(x)) }\n}\n", + "src/test_claim_returned_closure_clone_probe.rs", + ["pub fn compose("], + ["pub fn compose qualified diff --git a/src/v1/trait_derive_emit.dag b/src/v1/trait_derive_emit.dag index 61b81ab16b4..2fba80ae8b7 100644 --- a/src/v1/trait_derive_emit.dag +++ b/src/v1/trait_derive_emit.dag @@ -18,6 +18,7 @@ import extdeps.languages.rust.derive_contracts { import v1.std.core { Node, NewlineIndex, + Resolved, authored_name_at, qualified_last_segment, generic_param_name_at, @@ -1442,6 +1443,7 @@ fn v1_generic_params_needing_clone_bound( type_decl_items: type_decl_items, source_indices: source_indices ) + || v1_generic_param_cloned_by_returned_closure(param_name: g, value_params: value_params, ret: ret, source_indices: source_indices) || ( !v1_phantom_only_param_names_contains(names: phantom_only, param_name: g) && ( @@ -1467,6 +1469,36 @@ fn v1_generic_params_needing_clone_bound( ) } +// A function that RETURNS an arrow realizes as `Rc::new(move |x| ..)` over its arrow-typed +// parameters, and that closure clones what it forwards (`f(x.clone())`, `g.clone()`), so every +// generic parameter mentioned in an arrow-typed value parameter -- its domain or its codomain's +// type arguments -- carries a `Clone` obligation the structural rules above cannot see: they read +// what a value IS, and here the obligation comes from what the realization DOES with it. Gated on +// the return being an arrow for the same reason the `'static` gate in v1.compiler.emit_rust +// emit_rust_param_type is: the closure that creates the obligation exists exactly there. +fn v1_generic_param_cloned_by_returned_closure(param_name: String, value_params: List, ret: Node, source_indices: Map) -> Bool { + (ret.params |> count) > 0 + && value_params |> any(vp => v1_arrow_type_expr_mentions_param(param_name: param_name, type_expr: param_node_type_expr(n: vp), source_indices: source_indices)) +} + +fn v1_arrow_type_expr_mentions_param(param_name: String, type_expr: Node, source_indices: Map) -> Bool { + if (type_expr.params |> count) == 0 { false } + else { + let in_domain = type_expr.params |> any(p => + let pt = param_node_type_expr(n: p) + v1_type_expr_is_bare_param(param_name: param_name, type_expr: pt, source_indices: source_indices) + || pt.children |> any(c => v1_type_expr_is_bare_param(param_name: param_name, type_expr: c, source_indices: source_indices)) + ) + let in_codomain = match type_expr.inferred { + Present { value: Resolved { node: r } } => + v1_type_expr_is_bare_param(param_name: param_name, type_expr: r, source_indices: source_indices) + || r.children |> any(c => v1_type_expr_is_bare_param(param_name: param_name, type_expr: c, source_indices: source_indices)) + _ => false + } + in_domain || in_codomain + } +} + fn v1_field_type_expr_needs_clone_bound_for_param_narrow( param_name: String, type_expr: Node, diff --git a/src/v2/compiler/06_translate.dag b/src/v2/compiler/06_translate.dag index e64b5d3b448..55884fd6980 100644 --- a/src/v2/compiler/06_translate.dag +++ b/src/v2/compiler/06_translate.dag @@ -121,6 +121,7 @@ import v2.std.compilers.target_model { target_collection_select_choice, target_collection_realization_lookup_in_catalog, target_carrier_free_monoid_node, + target_collection_set_carrier_node, target_collection_set_element_type_node, target_collection_free_monoid_element_type_node, target_collection_type_node_is_set_carrier, diff --git a/src/v2/extdeps/runtimes/v2_effect_io_pure.dag b/src/v2/extdeps/runtimes/v2_effect_io_pure.dag index ed7af4da604..aae02a87048 100644 --- a/src/v2/extdeps/runtimes/v2_effect_io_pure.dag +++ b/src/v2/extdeps/runtimes/v2_effect_io_pure.dag @@ -204,10 +204,10 @@ fn effect_io_pure_store_lookup( ) -> Outcome { if effect_io_pure_backends_match(left: locator.backend, right: store.backend) { match map_get(m: store.entries, key: locator.identity) { - Accepted { value: opt, diagnostics: None } => + Accepted { value: opt, diagnostics: d } => match opt { Present { value: payload } => - Accepted { value: payload, diagnostics: None } + Accepted { value: payload, diagnostics: d } Absent => outcome_rejected( d: Diagnostic { diff --git a/src/v2/extdeps/runtimes/v2_evaluator.dag b/src/v2/extdeps/runtimes/v2_evaluator.dag index 65d3276e999..96b5bdeee19 100644 --- a/src/v2/extdeps/runtimes/v2_evaluator.dag +++ b/src/v2/extdeps/runtimes/v2_evaluator.dag @@ -33,12 +33,10 @@ import v2.std.diagnostic { outcome_accepted, outcome_rejected, node_locus, - invariant_port_locus, Diagnostic, ExternalContractUnknown, Unavailable, - None, - AmbiguousIntent + None } import v2.std.logic { Bool } import v2.std.machine { Byte } @@ -91,7 +89,7 @@ import v2.std.runtime { runtime_reject_match_arm, runtime_value_resolved_type } -import v2.std.witness { Violates, Witness } +import v2.std.optional { Optional, optional_absent } type V4EvaluatorRuntime { runtime_identity: Symbol core: ModelCore @@ -161,14 +159,8 @@ fn v2_eval_runtime_diagnostic(node: Node) -> Diagnostic { } } -fn v2_eval_binding_lookup_miss(_key: EnvironmentBindingKey) -> Witness { - Violates { - diagnostic: Diagnostic { - reason: ^v2_eval_binding_miss, - at: invariant_port_locus(port: ^v2_eval_binding_lookup_port, invariant: ^v2_eval_binding_miss), - correction: Unavailable { reason: AmbiguousIntent } - } - } +fn v2_eval_binding_lookup_miss(_key: EnvironmentBindingKey) -> Optional { + optional_absent() } fn v2_eval_empty_bindings() -> PartialFunction { diff --git a/src/v2/lens/coverage.dag b/src/v2/lens/coverage.dag index 65c683ce420..3b70c5f5745 100644 --- a/src/v2/lens/coverage.dag +++ b/src/v2/lens/coverage.dag @@ -1,5 +1,7 @@ module v2.lens.coverage +import v2.std.algebra { contains } + type Coverage { concern: C diff --git a/src/v2/lens/enforcement/vocab.dag b/src/v2/lens/enforcement/vocab.dag index 7c5366aa417..afa56ed34d0 100644 --- a/src/v2/lens/enforcement/vocab.dag +++ b/src/v2/lens/enforcement/vocab.dag @@ -1,5 +1,7 @@ module v2.lens.enforcement.vocab +import v2.std.algebra { contains } + type SubjectRoster { entries: List diff --git a/src/v2/lens/mandatory_tag.dag b/src/v2/lens/mandatory_tag.dag index b70d93ad467..498ead655b8 100644 --- a/src/v2/lens/mandatory_tag.dag +++ b/src/v2/lens/mandatory_tag.dag @@ -1,6 +1,8 @@ module v2.lens.mandatory_tag import v2.lens.common.construction_justification { ConstructionJustification, WallNow } +import std.disposition { SubstrateMandatoryTag } +import std.decl_ref { decl_ref } import std.algebra { Cons, Empty } import v2.std.algebra { length } import v2.std.integer { Int } @@ -455,5 +457,8 @@ fn mandatory_tag_compile_gate(node: Node) -> Outcome> { } data construction_justification: ConstructionJustification = ConstructionJustification { - class: WallNow + class: WallNow { + mechanism: SubstrateMandatoryTag, + authority: decl_ref(module_path: "v2.lens.mandatory_tag", decl_name: "mandatory_tag_compile_gate") + } } diff --git a/src/v2/lens/reference_deps.dag b/src/v2/lens/reference_deps.dag index 6a3d4774b08..d7b9a7a08af 100644 --- a/src/v2/lens/reference_deps.dag +++ b/src/v2/lens/reference_deps.dag @@ -3,8 +3,9 @@ module v2.lens.reference_deps import std.dissolution { DissolutionCondition, unbound_dissolution } import std.measure { ClockBasis, WallClock, Millisecond, millisecond } -import v2.extdeps.languages.dag { qualified_name_from_module_node } -import v2.lens.module_graph { no_paths, module_graph_exclude_substrings } +import v2.extdeps.languages.dag { dag_language_model, qualified_name_from_module_node } +import v2.lens.module_graph { map_lookup_where_rejected_unreachable, no_paths, module_graph_exclude_substrings } +import v2.std.algebra { contains } type ReferenceResolutionFact { diff --git a/src/v2/std/compilers/target_model.dag b/src/v2/std/compilers/target_model.dag index 00ec2f6d896..8ebc0442fd4 100644 --- a/src/v2/std/compilers/target_model.dag +++ b/src/v2/std/compilers/target_model.dag @@ -9232,9 +9232,9 @@ fn target_type_expr_emitted_validate_positional_arity( } TargetTypeExprArrow => match target_type_expr_arrow_wire_shape(node: node) { - Accepted { value: TargetTypeExprArrowPositionalWire, diagnostics: None } => - Accepted { value: true, diagnostics: None } - Accepted { value: TargetTypeExprArrowLabeledWire, diagnostics: None } => + Accepted { value: TargetTypeExprArrowPositionalWire, diagnostics: d } => + Accepted { value: true, diagnostics: d } + Accepted { value: TargetTypeExprArrowLabeledWire, diagnostics: _ } => outcome_rejected(target_type_expr_emitted_shape_malformed_diagnostic(node: node)) Rejected { diagnostics: r } => Rejected { diagnostics: r } } @@ -9261,6 +9261,8 @@ fn target_type_expr_emitted_validate_positional_wire( match target_type_expr_emitted_validate_positional_arity(node: node, kind: kind) { Accepted { value: true, diagnostics: d2 } => Accepted { value: true, diagnostics: diagnostics_merge(outer: d, inner: d2) } + Accepted { value: false, diagnostics: _ } => + outcome_rejected(target_type_expr_emitted_shape_malformed_diagnostic(node: node)) Rejected { diagnostics: r } => Rejected { diagnostics: r } } } else { @@ -9335,18 +9337,24 @@ fn target_type_expr_emitted_validate_wire_shape( ) TargetTypeExprArrow => match target_type_expr_arrow_wire_shape(node: node) { - Accepted { value: TargetTypeExprArrowLabeledWire, diagnostics: None } => - target_type_expr_emitted_validate_labeled_wire( + Accepted { value: TargetTypeExprArrowLabeledWire, diagnostics: d } => + match target_type_expr_emitted_validate_labeled_wire( node: node, kind: kind, projection: projection - ) - Accepted { value: TargetTypeExprArrowPositionalWire, diagnostics: None } => - target_type_expr_emitted_validate_positional_wire( + ) { + Accepted { value: v, diagnostics: d2 } => Accepted { value: v, diagnostics: diagnostics_merge(outer: d, inner: d2) } + Rejected { diagnostics: r } => Rejected { diagnostics: r } + } + Accepted { value: TargetTypeExprArrowPositionalWire, diagnostics: d } => + match target_type_expr_emitted_validate_positional_wire( node: node, kind: kind, projection: projection - ) + ) { + Accepted { value: v, diagnostics: d2 } => Accepted { value: v, diagnostics: diagnostics_merge(outer: d, inner: d2) } + Rejected { diagnostics: r } => Rejected { diagnostics: r } + } Rejected { diagnostics: r } => Rejected { diagnostics: r } } _ => diff --git a/src/v2/std/grammar.dag b/src/v2/std/grammar.dag index d54b124038e..a636c5f975e 100644 --- a/src/v2/std/grammar.dag +++ b/src/v2/std/grammar.dag @@ -1877,7 +1877,6 @@ type RebuildRhsWalkState type RebuildEmittedResult = RebuildEmittedOk { emitted: Node, token_index: Int } - | RebuildEmittedFail type RebuildProductionMatchFold = RebuildProductionMatchNone From e97322e1624b2227a650d9f316ba77ee13207855 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 05:58:14 +0000 Subject: [PATCH 37/75] Regenerate the stage0 mirror for commit 2 (mechanical residue): byte fixed point at round 2 Cycle on 8781269 (main parent d35cda54): round 1 drift on v1_compiler_emit_rust.rs and v1_compiler_trait_derive_emit.rs (the two files commit 2 edits), round 2 byte fixed point; installed tree 7fcf44b9f5c9df97, gunbc 2146d1f1844dea92. Unit 552/0. Emitted closure cargo check 420 -> 392; line-insensitive identity diff vs the merged-tree base: 28 removed, 0 added (E0061 x6 vocab arity, E0599 GlobalBare* x4, E0004 x7, E0533, E0271, E0618 x2, returned-closure Clone x7). Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01GXfYKNQTD3VfYyQcnJpxNU --- src/v1/stage0/src/v1_compiler_emit_rust.rs | 2 +- .../src/v1_compiler_trait_derive_emit.rs | 103 +++++++++++++++++- 2 files changed, 101 insertions(+), 4 deletions(-) diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index dd0fefdadab..fd55daa155c 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -18639,7 +18639,7 @@ pub fn emit_variant_pattern( fb_pat.clone(), v1_rt::rc_list_push(path_prefix.clone(), rust_name.clone()), shared_types.clone(), - scrut_type.clone(), + "".to_string(), source_indices.clone(), emit_info.clone(), ); diff --git a/src/v1/stage0/src/v1_compiler_trait_derive_emit.rs b/src/v1/stage0/src/v1_compiler_trait_derive_emit.rs index cec8ebda4e1..781fe50ba50 100644 --- a/src/v1/stage0/src/v1_compiler_trait_derive_emit.rs +++ b/src/v1/stage0/src/v1_compiler_trait_derive_emit.rs @@ -51,11 +51,14 @@ use crate::v1_std_core::Connective::{Arrow, NoConnective}; use crate::v1_std_core::ContainerSpellingVerdict::{ ContainerSpellingDeclared, ContainerSpellingUnknown, NotAContainerSpelling, }; +use crate::v1_std_core::InferredNode::Resolved; pub use crate::v1_std_core::{ authored_container_spelling_verdict, authored_name_at, generic_param_name_at, param_node_type_expr, qualified_last_segment, }; -pub use crate::v1_std_core::{Connective, ContainerSpellingVerdict, NewlineIndex, Node}; +pub use crate::v1_std_core::{ + Connective, ContainerSpellingVerdict, InferredNode, NewlineIndex, Node, +}; use crate::NonEmptyBTreeSet; use crate::NonEmptyVec; use im::{vector as vec, HashMap, OrdSet as BTreeSet, Vector as Vec}; @@ -2988,14 +2991,19 @@ pub fn v1_generic_params_needing_clone_bound( Rc::new({ let mut __result = Vec::new(); for g in generic_param_names.iter().cloned() { - if (v1_fn_param_wf_needs_clone( + if ((v1_fn_param_wf_needs_clone( g.clone(), value_params.clone(), ret.clone(), bounds.clone(), type_decl_items.clone(), source_indices.clone(), - ) || (!v1_phantom_only_param_names_contains(phantom_only.clone(), g.clone()) + ) || v1_generic_param_cloned_by_returned_closure( + g.clone(), + value_params.clone(), + ret.clone(), + source_indices.clone(), + )) || (!v1_phantom_only_param_names_contains(phantom_only.clone(), g.clone()) && (v1_type_param_needs_clone_bound( g.clone(), return_is_bare_generic.clone(), @@ -3021,6 +3029,95 @@ pub fn v1_generic_params_needing_clone_bound( } } +pub fn v1_generic_param_cloned_by_returned_closure( + param_name: String, + value_params: Rc>>, + ret: Rc, + source_indices: Rc>>, +) -> bool { + (((ret.params.clone().len() as i64) > 0) && { + let mut __found = false; + for vp in value_params.iter().cloned() { + if v1_arrow_type_expr_mentions_param( + param_name.clone(), + crate::v1_std_core::param_node_type_expr(vp.clone()), + source_indices.clone(), + ) { + __found = true; + break; + } + } + __found + }) +} + +pub fn v1_arrow_type_expr_mentions_param( + param_name: String, + type_expr: Rc, + source_indices: Rc>>, +) -> bool { + if ((type_expr.params.clone().len() as i64) == 0) { + false + } else { + { + let in_domain = { + let mut __found = false; + for p in type_expr.params.clone().iter().cloned() { + if { + let pt = crate::v1_std_core::param_node_type_expr(p.clone()); + (v1_type_expr_is_bare_param( + param_name.clone(), + pt.clone(), + source_indices.clone(), + ) || { + let mut __found = false; + for c in pt.children.clone().iter().cloned() { + if v1_type_expr_is_bare_param( + param_name.clone(), + c.clone(), + source_indices.clone(), + ) { + __found = true; + break; + } + } + __found + }) + } { + __found = true; + break; + } + } + __found + }; + let in_codomain = match type_expr.inferred.clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: r, .. }) => { + (v1_type_expr_is_bare_param( + param_name.clone(), + r.clone(), + source_indices.clone(), + ) || { + let mut __found = false; + for c in r.children.clone().iter().cloned() { + if v1_type_expr_is_bare_param( + param_name.clone(), + c.clone(), + source_indices.clone(), + ) { + __found = true; + break; + } + } + __found + }) + } + _ => false, + }; + (in_domain.clone() || in_codomain.clone()) + } + } +} + pub fn v1_field_type_expr_needs_clone_bound_for_param_narrow( param_name: String, type_expr: Rc, From 4da60592676d87518c96cb1a2ee24c5cd186b38e Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 05:59:04 +0000 Subject: [PATCH 38/75] A1: relocate the import-admission helpers to their consumer layer; C: one storage representation for Map at every position A1 (closure prune). Counting fully qualified code references as declared edges, the declared closure from v2.compiler.compile equals the emitted set: no module enters by bare-name binding. The carrier was 03_name_resolve importing v2.lens.reference_deps for admission_from_module_root / import_rows_from_parsed_module / collect_import_decl_nodes / ImportRowsState, consumed only by v2.workflow.compile_door_ledger and self_host.frontier_probe (both outside the closure, both already importing reference_deps). They now live in reference_deps; the two consumers import them there. Emitted closure drops 8 modules (lens.coverage, enforcement.{grammar_coverage,standing_intent,vocab}, registry, module_graph, reference_deps, std.decl_index) and all 6 host-primitive panic sites. C (Map). The six PartialFunction<..> positions (InferredTree.facts, EvaluationEnvironment.bindings, four signatures) are Map<..>; the four PartialFunction { lookup: .. } constructions are empty_map() or a first-wins map_insert fold; map_insert routes through a rostered map_insert_primitive_delegate (closure body deleted); slots.lookup -> map_lookup. Emitter: the alias RHS renders a keyed/element collection through the host template (type X = Map -> Rc>), and a generic in map-key position carries std::cmp::Eq + std::hash::Hash from the signature. Two witness rows added. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01GXfYKNQTD3VfYyQcnJpxNU --- dag/std/primitive_projection.dag | 1 + ...d_call_target_realization_witness_test.dag | 26 ++++++ src/v1/05_emit_rust.dag | 82 ++++++++++++++++--- src/v2/compiler/03_name_resolve.dag | 67 --------------- src/v2/compiler/04_infer.dag | 22 ++--- src/v2/compiler/05_eval.dag | 11 +-- src/v2/compiler/inferred_tree.dag | 3 +- src/v2/compiler/program_partition.dag | 2 +- src/v2/compiler/self_host/frontier_probe.dag | 3 +- src/v2/extdeps/runtimes/v2_evaluator.dag | 12 +-- src/v2/lens/reference_deps.dag | 71 +++++++++++++++- src/v2/std/collection.dag | 12 +-- src/v2/std/compilers/target_model.dag | 2 +- src/v2/std/runtime.dag | 2 +- src/v2/workflow/compile_door_ledger.dag | 6 +- 15 files changed, 196 insertions(+), 126 deletions(-) diff --git a/dag/std/primitive_projection.dag b/dag/std/primitive_projection.dag index 47a2caa21b9..da0a2e30cfe 100644 --- a/dag/std/primitive_projection.dag +++ b/dag/std/primitive_projection.dag @@ -76,6 +76,7 @@ fn primitive_projection_roster() -> List { primitive_projection_row(primitive: primitive_concept_decl_facts, module_path: "v2.std.concept_index", decl_name: "concept_decl_facts", fidelity: HostRealizedSeam), primitive_projection_row(primitive: primitive_concept_decl_facts_live, module_path: "v2.std.concept_index", decl_name: "concept_decl_facts_live", fidelity: HostRealizedSeam), primitive_projection_row(primitive: primitive_empty_map, module_path: "v2.std.collection", decl_name: "empty_map_primitive_delegate", fidelity: HostRealizedSeam), + primitive_projection_row(primitive: primitive_map_insert, module_path: "v2.std.collection", decl_name: "map_insert_primitive_delegate", fidelity: HostRealizedSeam), primitive_projection_row(primitive: primitive_symbol_lexeme, module_path: "v2.std.compilers.lexing", decl_name: "symbol_lexeme", fidelity: HostRealizedSeam), primitive_projection_row(primitive: primitive_symbol_intern_lexeme, module_path: "v2.std.compilers.lexing", decl_name: "symbol_intern_lexeme", fidelity: HostRealizedSeam), primitive_projection_row(primitive: primitive_length, module_path: "v2.std.algebra", decl_name: "length", fidelity: ModeledProjection), diff --git a/dag/test/claim/self_host_emitted_call_target_realization_witness_test.dag b/dag/test/claim/self_host_emitted_call_target_realization_witness_test.dag index 937cdf48b31..652c591a20d 100644 --- a/dag/test/claim/self_host_emitted_call_target_realization_witness_test.dag +++ b/dag/test/claim/self_host_emitted_call_target_realization_witness_test.dag @@ -423,6 +423,32 @@ test fn w_generic_forwarded_by_a_returned_closure_carries_clone() -> Bool { ) } +// ONE STORAGE REPRESENTATION FOR A KEYED COLLECTION, AT THE ALIAS POSITION. A `Map` field or +// parameter lowers to the host template `Rc>`; the alias RHS lowered the authored +// base instead, so `type Slots = Map` became `Rc>` -- the +// algebra struct, a second representation of the same carrier, refused by rustc wherever a Slots +// met a HashMap parameter. The positive control is the field position on the same fixture. +test fn w_alias_of_a_keyed_collection_renders_the_host_map_template() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.map_alias_probe\nimport v2.std.collection { Map }\ntype Slot\ntype Slots = Map\ntype Holder { slots: Slots, direct: Map }\n", + "src/test_claim_map_alias_probe.rs", + ["pub type Slots = Rc Bool { + compile_dag_rust_emit_check( + "module test.claim.map_key_bound_probe\nimport v2.std.collection { Map, map_lookup }\nimport v2.std.optional { Optional }\nfn probe(m: Map, key: K) -> Optional {\n map_lookup(m: m, key: key)\n}\n", + "src/test_claim_map_key_bound_probe.rs", + ["pub fn probe`, `Vec`); this branch rendered the authored base instead, so +// `type Map = FinitelySupportedFunction` became the algebra STRUCT and +// `type X = Map` became `Rc>` -- a second storage representation +// for one carrier, met by rustc wherever an X flowed into a HashMap parameter (E0308 +// `expected Rc>, found Rc>`; the derive rows on any struct holding an X). +// One template, consulted from the same predicate the field renderer uses. +fn rust_alias_rhs_applied_container_or_base(n: Node, leaf: String, base: String, arg_list: List, source_indices: Map) -> String { + if node_is_keyed_collection(n: n, source_indices: source_indices) { + match arg_list |> first { + Present { value: k } => match arg_list |> skip(1) |> first { + Present { value: v } => emit_map_type(key_type: k, val_type: v, target: Rust) + Absent => concat(base, "<", arg_list |> join(separator: ", "), ">") + } + Absent => concat(base, "<", arg_list |> join(separator: ", "), ">") + } + } else if node_is_collection(n: n, source_indices: source_indices) && (arg_list |> count) == 1 { + match arg_list |> first { + Present { value: inner } => emit_container(name: leaf, inner: inner, target: Rust) + Absent => concat(base, "<", arg_list |> join(separator: ", "), ">") + } + } else { + concat(base, "<", arg_list |> join(separator: ", "), ">") + } +} + fn render_rust_alias_rhs_type(n: Node, generic_param_names: List, shared_types: Set, source_indices: Map, scope: InferScope, imports: List, registry: Map, module_name: String, export_sets: Map>, typed_modules: List, module_index: ModuleIndex, variant_to_enum: Map) -> String { if is_where_refinement_type(ty: n) { match n.children |> first { @@ -1561,14 +1589,15 @@ fn render_rust_alias_rhs_type(n: Node, generic_param_names: List, shared if set_contains(shared_types, leaf) && !rust_type_is_rc_wrapped(type_name: base) { wrap_shared_type(target: Rust, inner: base) } else { base } AliasDeclArityHasParams => { let peel = is_parametric_opaque_type_base(type_name: leaf, def_mod_filename: def_mod, typed_modules: typed_modules, source_indices: source_indices, module_index: module_index) - let args = n.children |> map(arg => + let arg_list = n.children |> map(arg => if peel { render_rust_phantom_opaque_applied_type_arg(n: arg, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, scope: scope, imports: imports, registry: registry, module_name: module_name, export_sets: export_sets, typed_modules: typed_modules, module_index: module_index, variant_to_enum: variant_to_enum) } else { render_rust_alias_rhs_type(n: alias_rhs_container_arg(arg: arg, source_indices: source_indices), generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, scope: scope, imports: imports, registry: registry, module_name: module_name, export_sets: export_sets, typed_modules: typed_modules, module_index: module_index, variant_to_enum: variant_to_enum) } - ) |> join(separator: ", ") - let applied_ty = concat(base, "<", args, ">") + ) + let args = arg_list |> join(separator: ", ") + let applied_ty = rust_alias_rhs_applied_container_or_base(n: n, leaf: leaf, base: base, arg_list: arg_list, source_indices: source_indices) if set_contains(shared_types, leaf) && !rust_type_is_rc_wrapped(type_name: applied_ty) { wrap_shared_type(target: Rust, inner: applied_ty) } else { @@ -1579,14 +1608,15 @@ fn render_rust_alias_rhs_type(n: Node, generic_param_names: List, shared } ClosedAliasHasParams => { let peel = is_parametric_opaque_type_base(type_name: leaf, def_mod_filename: def_mod, typed_modules: typed_modules, source_indices: source_indices, module_index: module_index) - let args = n.children |> map(arg => + let arg_list = n.children |> map(arg => if peel { render_rust_phantom_opaque_applied_type_arg(n: arg, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, scope: scope, imports: imports, registry: registry, module_name: module_name, export_sets: export_sets, typed_modules: typed_modules, module_index: module_index, variant_to_enum: variant_to_enum) } else { render_rust_alias_rhs_type(n: alias_rhs_container_arg(arg: arg, source_indices: source_indices), generic_param_names: generic_param_names, shared_types: shared_types, source_indices: source_indices, scope: scope, imports: imports, registry: registry, module_name: module_name, export_sets: export_sets, typed_modules: typed_modules, module_index: module_index, variant_to_enum: variant_to_enum) } - ) |> join(separator: ", ") - let applied_ty = concat(base, "<", args, ">") + ) + let args = arg_list |> join(separator: ", ") + let applied_ty = rust_alias_rhs_applied_container_or_base(n: n, leaf: leaf, base: base, arg_list: arg_list, source_indices: source_indices) if set_contains(shared_types, leaf) && !rust_type_is_rc_wrapped(type_name: applied_ty) { wrap_shared_type(target: Rust, inner: applied_ty) } else { @@ -7199,15 +7229,40 @@ fn v1_fn_body_derived_clone_param_names(params: List, inferred: Node, body // oracle for "equality changed nothing that did not need changing". fn v1_fn_bounds_by_param( clone_param_names: List, - eq_param_names: List + eq_param_names: List, + map_key_param_names: List ) -> Map> { let with_clone = clone_param_names |> fold(init: empty_map(), f: (m, n) => map_insert(m, n, ["Clone"])) - eq_param_names |> fold(init: with_clone, f: (m, n) => + let with_eq = eq_param_names |> fold(init: with_clone, f: (m, n) => match map_get(m, n) { Present { value: traits } => map_insert(m, n, concat(traits, ["PartialEq"])) Absent => map_insert(m, n, ["PartialEq"]) } ) + map_key_param_names |> fold(init: with_eq, f: (m, n) => + match map_get(m, n) { + Present { value: traits } => map_insert(m, n, concat(traits, rust_map_key_bound_traits())) + Absent => map_insert(m, n, rust_map_key_bound_traits()) + } + ) +} + +// A GENERIC IN KEY POSITION OF A KEYED COLLECTION CARRIES THE HOST KEY BOUNDS. The Rust row for +// FinitelySupportedFunction / PartialFunction is `HashMap`, whose every bridge +// (v1_rt::lookup, rc_map_insert, rc_map_merge) declares `K: Eq + Hash`; a fn generic over the key +// that emitted only `K: Clone` refused at each bridge call (E0277 on map_insert / map_lookup / +// map_get in v2_std_collection, three sites, one class). The bound is read from the SIGNATURE -- +// parameters and return type -- through the same keyed-map walker the struct derive path uses +// (v1_map_key_head_names_in_type_expr), so a key generic is decided by the declared carrier, not +// by inspecting the body for a bridge call. +fn rust_map_key_bound_traits() -> List { + ["std::cmp::Eq", "std::hash::Hash"] +} + +fn v1_fn_signature_map_key_param_names(value_params: List, ret: Node, generic_param_names: List, source_indices: Map) -> List { + let from_params = value_params |> flat_map(p => v1_map_key_head_names_in_type_expr(type_expr: param_node_type_expr(n: p), source_indices: source_indices)) + let from_ret = v1_map_key_head_names_in_type_expr(type_expr: ret, source_indices: source_indices) + unique_strings(items: concat(from_params, from_ret) |> filter(n => generic_param_names |> any(g => g == n))) } // Node-consuming extraction for the equality bound, kept here rather than in @@ -7614,11 +7669,18 @@ fn emit_fn_def(name: String, params: List, inferred: Node, body: Node, reg base: self_eq_param_names, extra: call_forwarding_eq_param_names ) + let map_key_param_names = v1_fn_signature_map_key_param_names( + value_params: value_params, + ret: inferred, + generic_param_names: generic_param_names, + source_indices: si + ) let bounds_by_param = v1_fn_bounds_by_param( clone_param_names: clone_param_names, - eq_param_names: eq_param_names + eq_param_names: eq_param_names, + map_key_param_names: map_key_param_names ) - let needs_bound = (clone_param_names |> count) > 0 || (eq_param_names |> count) > 0 + let needs_bound = (clone_param_names |> count) > 0 || (eq_param_names |> count) > 0 || (map_key_param_names |> count) > 0 let type_params_str = if needs_bound { v1_emit_type_params_with_bounds(params: type_params, bounds_by_param: bounds_by_param, source_indices: si) } else { diff --git a/src/v2/compiler/03_name_resolve.dag b/src/v2/compiler/03_name_resolve.dag index 3303553e565..cfb729b3f76 100644 --- a/src/v2/compiler/03_name_resolve.dag +++ b/src/v2/compiler/03_name_resolve.dag @@ -49,7 +49,6 @@ import v2.std.diagnostic { textual_whole_file_diagnostic } import v2.std.compilers.lexing { symbol_intern_lexeme } -import v2.lens.reference_deps { reference_qn_from_import_decl_strict } import v2.extdeps.languages.dag { parse_production_emitted_identity_optional } import v2.std.qualified_name { qualified_name_to_dotted_string } import v2.std.node { @@ -62,7 +61,6 @@ import v2.std.node { fold_node_topdown, well_formed } -import v2.std.algebra { list_reverse } import v2.std.passing_candidate_fold { ManyPassingCandidates, NoPassingCandidate, @@ -160,71 +158,6 @@ fn resolve_module_not_found_diagnostic(name: QualifiedName) -> NonEmptyDiagnosti resolve_module_not_found_diagnostic_from_missing(requested: name) } -fn collect_import_decl_nodes(n: Node, acc: FreeMonoid) -> FreeMonoid { - let here = match parse_production_emitted_identity_optional(node: n) { - Present { value: id } => - if id == ^dag_surface_import_decl { - Cons { head: n, tail: acc } - } else { - acc - } - Absent => acc - } - fold(n.children, init: here, f: fn(a, e) { - collect_import_decl_nodes(n: e.target, acc: a) - }) -} - -type ImportRowsState - = ImportRowsFailed { reason: Symbol } - | ImportRowsOk { rows: List } - -fn import_rows_from_parsed_module(root: Node) -> ImportRowsState { - let gathered = fold_list( - xs: list_reverse(xs: collect_import_decl_nodes(n: root, acc: Empty)), - empty: ImportRowsOk { rows: Empty }, - cons: fn(state, import_node) { - match state { - ImportRowsFailed { reason: r } => ImportRowsFailed { reason: r } - ImportRowsOk { rows: prior } => - match reference_qn_from_import_decl_strict(node: import_node, module_root: root) { - Rejected { diagnostics: d } => ImportRowsFailed { reason: d.head.reason } - Accepted { value: target_qn, diagnostics: _ } => - ImportRowsOk { - rows: Cons { - head: Import { target: target_qn, visibility: ImportVisible }, - tail: prior - } - } - } - } - } - ) - match gathered { - ImportRowsFailed { reason: r } => ImportRowsFailed { reason: r } - ImportRowsOk { rows: rev } => ImportRowsOk { rows: list_reverse(xs: rev) } - } -} - -fn admission_from_module_root(root: Node) -> Outcome { - match qualified_name_from_module_node(root: root) { - Rejected { diagnostics: d } => Rejected { diagnostics: d } - Accepted { value: subject_qn, diagnostics: _ } => - match import_rows_from_parsed_module(root: root) { - ImportRowsFailed { reason: r } => - Rejected { diagnostics: resolve_diagnostics(reason: r) } - ImportRowsOk { rows: rows } => - Accepted { - value: Admission { - subject: ResolutionSubject { name: subject_qn }, - imports: rows - }, - diagnostics: None - } - } - } -} - fn admission_initial(base: Namespace) -> AdmissionState { AdmissionAccepted { bindings: base.bindings, diff --git a/src/v2/compiler/04_infer.dag b/src/v2/compiler/04_infer.dag index 918a0d68658..d1b691796f0 100644 --- a/src/v2/compiler/04_infer.dag +++ b/src/v2/compiler/04_infer.dag @@ -29,7 +29,10 @@ import v2.std.cardinality { TerminationProof, termination_proof_witness_for_node import v2.std.collection { List, Map, - list_at_optional + empty_map, + list_at_optional, + map_insert, + map_lookup } import v2.std.optional { Absent, @@ -175,11 +178,7 @@ data infer_emit_shape_frontier_note: String = "Test-only emit-shape frontier (re fn infer_emit_shape_frontier_inferred_tree(root: Node) -> InferredTree { InferredTree { root: root, - facts: PartialFunction { - lookup: fn(_key) { - Absent - } - } + facts: empty_map() } } @@ -486,7 +485,7 @@ fn lookup_inferred_facts_in_entries( ) } -fn facts_map_from_entries(entries: List) -> Outcome> { +fn facts_map_from_entries(entries: List) -> Outcome> { match fold(entries, init: Accepted { value: empty_inferred_facts_entry_list(), diagnostics: None }, f: fn(acc, entry) { match acc { Rejected { diagnostics: r } => Rejected { diagnostics: r } @@ -505,11 +504,12 @@ fn facts_map_from_entries(entries: List) -> Outcome Rejected { diagnostics: r } Accepted { value: admitted, diagnostics: d } => Accepted { - value: PartialFunction { - lookup: fn(key) { - lookup_inferred_facts_in_entries(entries: admitted, key: key) + value: fold(admitted, init: empty_map(), f: fn(acc, entry) { + match map_lookup(m: acc, key: entry.node) { + Present { value: _ } => acc + Absent => map_insert(m: acc, key: entry.node, value: entry.facts) } - }, + }), diagnostics: d } } diff --git a/src/v2/compiler/05_eval.dag b/src/v2/compiler/05_eval.dag index feee07937a0..e888a944b04 100644 --- a/src/v2/compiler/05_eval.dag +++ b/src/v2/compiler/05_eval.dag @@ -19,6 +19,7 @@ import v2.std.cardinality { RankingDimension, TerminationProof } import v2.std.collection { List, Map, + empty_map, list_at_optional, list_nth } @@ -955,14 +956,8 @@ fn eval_diagnostic(reason: Symbol, node: Node) -> Diagnostic { } } -fn runtime_binding_lookup_miss(key: EnvironmentBindingKey) -> Optional { - optional_absent() -} - -fn empty_runtime_bindings() -> PartialFunction { - PartialFunction { - lookup: runtime_binding_lookup_miss - } +fn empty_runtime_bindings() -> Map { + empty_map() } fn empty_evaluation_environment() -> EvaluationEnvironment { diff --git a/src/v2/compiler/inferred_tree.dag b/src/v2/compiler/inferred_tree.dag index 1a5f50b2c85..0e20caefc06 100644 --- a/src/v2/compiler/inferred_tree.dag +++ b/src/v2/compiler/inferred_tree.dag @@ -5,7 +5,6 @@ import v2.std.collection { Map } import v2.std.constraints { CanonicalGrounding } import v2.std.node { Node } import v2.std.witness { Witness } -import std.algebra { PartialFunction } // InferredFacts/InferredTree/InferredFactsEntry are the SHAPE infer's pass // produces and consumers hold -- not the pass itself. They lived inside @@ -32,7 +31,7 @@ type InferredFacts { type InferredTree { root: Node - facts: PartialFunction + facts: Map } type InferredFactsEntry { diff --git a/src/v2/compiler/program_partition.dag b/src/v2/compiler/program_partition.dag index b7db016e152..a8390c380eb 100644 --- a/src/v2/compiler/program_partition.dag +++ b/src/v2/compiler/program_partition.dag @@ -468,7 +468,7 @@ fn facts_closure_entries_fold( ) } -fn facts_closure_fold(partition: ProgramPartition) -> Outcome> { +fn facts_closure_fold(partition: ProgramPartition) -> Outcome> { match partition.boundary { AmbientContextAvailable => outcome_accepted(value: partition.ambient.facts) diff --git a/src/v2/compiler/self_host/frontier_probe.dag b/src/v2/compiler/self_host/frontier_probe.dag index eb8dd8b24f1..61b38773614 100644 --- a/src/v2/compiler/self_host/frontier_probe.dag +++ b/src/v2/compiler/self_host/frontier_probe.dag @@ -9,7 +9,6 @@ import v2.compiler.name_resolve { Import, ModuleRootMissing, ResolutionSubject, - admission_from_module_root, module_root_lookup, resolve_diagnostics, validate_module_roots @@ -76,7 +75,7 @@ import v2.compiler.source_authority { } import v2.extdeps.languages.dag { dag_language_model } import v2.extdeps.languages.rust { rust_target_model } -import v2.lens.reference_deps { reference_deps_ingest_source_text } +import v2.lens.reference_deps { admission_from_module_root, reference_deps_ingest_source_text } import std.algebra { Cons, Empty, FreeMonoid } import std.content_hash { ContentHash, diff --git a/src/v2/extdeps/runtimes/v2_evaluator.dag b/src/v2/extdeps/runtimes/v2_evaluator.dag index 96b5bdeee19..50b77f0731e 100644 --- a/src/v2/extdeps/runtimes/v2_evaluator.dag +++ b/src/v2/extdeps/runtimes/v2_evaluator.dag @@ -6,6 +6,7 @@ import v2.std.collection { List, Map, Present, + empty_map, list_at_optional, map_insert } @@ -89,7 +90,6 @@ import v2.std.runtime { runtime_reject_match_arm, runtime_value_resolved_type } -import v2.std.optional { Optional, optional_absent } type V4EvaluatorRuntime { runtime_identity: Symbol core: ModelCore @@ -159,14 +159,8 @@ fn v2_eval_runtime_diagnostic(node: Node) -> Diagnostic { } } -fn v2_eval_binding_lookup_miss(_key: EnvironmentBindingKey) -> Optional { - optional_absent() -} - -fn v2_eval_empty_bindings() -> PartialFunction { - PartialFunction { - lookup: v2_eval_binding_lookup_miss - } +fn v2_eval_empty_bindings() -> Map { + empty_map() } fn v2_eval_empty_environment() -> EvaluationEnvironment { diff --git a/src/v2/lens/reference_deps.dag b/src/v2/lens/reference_deps.dag index d7b9a7a08af..5b6ba61a997 100644 --- a/src/v2/lens/reference_deps.dag +++ b/src/v2/lens/reference_deps.dag @@ -3,9 +3,11 @@ module v2.lens.reference_deps import std.dissolution { DissolutionCondition, unbound_dissolution } import std.measure { ClockBasis, WallClock, Millisecond, millisecond } -import v2.extdeps.languages.dag { dag_language_model, qualified_name_from_module_node } +import v2.extdeps.languages.dag { dag_language_model, parse_production_emitted_identity_optional, qualified_name_from_module_node } import v2.lens.module_graph { map_lookup_where_rejected_unreachable, no_paths, module_graph_exclude_substrings } -import v2.std.algebra { contains } +import v2.std.algebra { contains, fold_list, list_reverse } +import std.algebra { Cons, Empty, FreeMonoid } +import v2.compiler.name_resolve { Admission, Import, ImportVisible, ResolutionSubject, resolve_diagnostics } type ReferenceResolutionFact { @@ -954,3 +956,68 @@ data construction_justification: ConstructionJustification = ConstructionJustifi } data reference_deps_dissolve_on: DissolutionCondition = unbound_dissolution(description: "the namespace terminal step lands and reference edges come from the containment authority rather than this segment-prefix match over parsed-tree qualified-name use sites (namespace-resolution-design section 8)") + +fn collect_import_decl_nodes(n: Node, acc: FreeMonoid) -> FreeMonoid { + let here = match parse_production_emitted_identity_optional(node: n) { + Present { value: id } => + if id == ^dag_surface_import_decl { + Cons { head: n, tail: acc } + } else { + acc + } + Absent => acc + } + fold(n.children, init: here, f: fn(a, e) { + collect_import_decl_nodes(n: e.target, acc: a) + }) +} + +type ImportRowsState + = ImportRowsFailed { reason: Symbol } + | ImportRowsOk { rows: List } + +fn import_rows_from_parsed_module(root: Node) -> ImportRowsState { + let gathered = fold_list( + xs: list_reverse(xs: collect_import_decl_nodes(n: root, acc: Empty)), + empty: ImportRowsOk { rows: Empty }, + cons: fn(state, import_node) { + match state { + ImportRowsFailed { reason: r } => ImportRowsFailed { reason: r } + ImportRowsOk { rows: prior } => + match reference_qn_from_import_decl_strict(node: import_node, module_root: root) { + Rejected { diagnostics: d } => ImportRowsFailed { reason: d.head.reason } + Accepted { value: target_qn, diagnostics: _ } => + ImportRowsOk { + rows: Cons { + head: Import { target: target_qn, visibility: ImportVisible }, + tail: prior + } + } + } + } + } + ) + match gathered { + ImportRowsFailed { reason: r } => ImportRowsFailed { reason: r } + ImportRowsOk { rows: rev } => ImportRowsOk { rows: list_reverse(xs: rev) } + } +} + +fn admission_from_module_root(root: Node) -> Outcome { + match qualified_name_from_module_node(root: root) { + Rejected { diagnostics: d } => Rejected { diagnostics: d } + Accepted { value: subject_qn, diagnostics: _ } => + match import_rows_from_parsed_module(root: root) { + ImportRowsFailed { reason: r } => + Rejected { diagnostics: resolve_diagnostics(reason: r) } + ImportRowsOk { rows: rows } => + Accepted { + value: Admission { + subject: ResolutionSubject { name: subject_qn }, + imports: rows + }, + diagnostics: None + } + } + } +} diff --git a/src/v2/std/collection.dag b/src/v2/std/collection.dag index 8fb9318dd84..507bac43143 100644 --- a/src/v2/std/collection.dag +++ b/src/v2/std/collection.dag @@ -55,15 +55,11 @@ fn empty_map_primitive_delegate() -> Map { fn empty_map() -> Map { empty_map_primitive_delegate() } +fn map_insert_primitive_delegate(m: Map, key: K, value: V) -> Map { + map_insert_primitive_delegate(m: m, key: key, value: value) +} fn map_insert(m: Map, key: K, value: V) -> Map { - Map { - lookup: fn(candidate) { - match candidate == key { - true => Present { value: value } - false => m.lookup(candidate) - } - } - } + map_insert_primitive_delegate(m: m, key: key, value: value) } // LOOKUP IS TOTAL. A map either holds the key or does not, and both are answers — there is no diff --git a/src/v2/std/compilers/target_model.dag b/src/v2/std/compilers/target_model.dag index 8ebc0442fd4..d3780ce303b 100644 --- a/src/v2/std/compilers/target_model.dag +++ b/src/v2/std/compilers/target_model.dag @@ -9982,7 +9982,7 @@ fn target_representation_parameter_slots_from_node( match acc { Rejected { diagnostics: r } => Rejected { diagnostics: r } Accepted { value: slots, diagnostics: _ } => - match slots.lookup(parameter) { + match map_lookup(m: slots, key: parameter) { Present { value: _ } => outcome_rejected( target_derive_supplemental_generic_bound_contract_choice_malformed_diagnostic( diff --git a/src/v2/std/runtime.dag b/src/v2/std/runtime.dag index bf64b5795cd..10135c68890 100644 --- a/src/v2/std/runtime.dag +++ b/src/v2/std/runtime.dag @@ -54,7 +54,7 @@ fn environment_binding_key_for_symbol(sym: Symbol) -> EnvironmentBindingKey { } type EvaluationEnvironment { - bindings: PartialFunction + bindings: Map } type RuntimePrimitiveValue { diff --git a/src/v2/workflow/compile_door_ledger.dag b/src/v2/workflow/compile_door_ledger.dag index b3cafb492da..83deb97dbae 100644 --- a/src/v2/workflow/compile_door_ledger.dag +++ b/src/v2/workflow/compile_door_ledger.dag @@ -4,10 +4,8 @@ import extdeps.communication.medium { Lossless, Medium } import extdeps.filesystem.filesystem_io import std.algebra { Cons, Empty, FreeMonoid } import v2.compiler.compile { compile_source_root_ingest_with_admission } -import v2.compiler.name_resolve { - Admission, - admission_from_module_root -} +import v2.compiler.name_resolve { Admission } +import v2.lens.reference_deps { admission_from_module_root } import v2.compiler.source_authority { DagSourceReadWitness, SourceRootIngest } import v2.extdeps.languages.rust { rust_target_model } import v2.lens.module_graph { From db404818b44832a1680d3bb60cba24e79e3f74ec Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 05:59:18 +0000 Subject: [PATCH 39/75] =?UTF-8?q?XL-0N:=20generic=20LiteralElaboration/Ope?= =?UTF-8?q?ratorRealization=20authority=20=E2=80=94=20typed=20literal-to-Z?= =?UTF-8?q?ero/Succ=20homomorphism=20at=20every=20boundary,=20operator=20r?= =?UTF-8?q?ealization=20by=20exact=20operand=20structure,=20structural=20P?= =?UTF-8?q?eano=20Nat=20operations=20(no=20i64=20row)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dag/gunbc/structural_realization_bindings.dag | 49 ++++ dag/std/literal_elaboration.dag | 164 ++++++++++++ dag/std/operator_realization.dag | 176 +++++++++++++ ...eral_operator_realization_witness_test.dag | 129 ++++++++++ scratch-probe/test/claim/peano_probe.dag | 12 + src/v1/00_core.dag | 9 + src/v1/04_env.dag | 40 ++- src/v1/04_infer.dag | 179 ++++++++++++- src/v1/04_resolve.dag | 3 +- src/v1/05_emit.dag | 8 +- src/v1/05_emit_rust.dag | 96 ++++--- src/v1/coercion.dag | 13 + src/v1/compile.dag | 2 + src/v1/complexity.dag | 13 +- src/v1/dag_collect_support.dag | 3 +- src/v1/ownership.dag | 4 +- src/v1/stage0/src/v1_interpreter.rs | 16 +- src/v2/std/integer.dag | 118 ++++++--- src/v2/std/nat.dag | 79 +++++- src/v2/std/native_agreement.dag | 10 +- .../peano_nat_structural_realization_test.dag | 236 ++++++++++++++++++ src/v2/workflow/realization_sweep.dag | 8 +- 22 files changed, 1271 insertions(+), 96 deletions(-) create mode 100644 dag/gunbc/structural_realization_bindings.dag create mode 100644 dag/std/literal_elaboration.dag create mode 100644 dag/std/operator_realization.dag create mode 100644 dag/test/claim/self_host_peano_literal_operator_realization_witness_test.dag create mode 100644 scratch-probe/test/claim/peano_probe.dag create mode 100644 src/v2/test/claim/self_host/peano_nat_structural_realization_test.dag diff --git a/dag/gunbc/structural_realization_bindings.dag b/dag/gunbc/structural_realization_bindings.dag new file mode 100644 index 00000000000..33130d759ee --- /dev/null +++ b/dag/gunbc/structural_realization_bindings.dag @@ -0,0 +1,49 @@ +module gunbc.structural_realization_bindings + +import std.types { List, String, Bool, NonEmptyStr } +import std.decl_ref { DeclarationRef, decl_ref } +import std.literal_elaboration { LiteralHomomorphism, LiteralSourceKind, KernelIntLiteral, LiteralUnfolding, PeanoUnfold } +import std.operator_realization { StructuralOrderingBinding } + +// THE CORPUS'S HALF OF LITERAL ELABORATION AND OPERATOR REALIZATION (std.literal_elaboration, +// std.operator_realization): which of THIS corpus's structural declarations supply a kernel literal, +// and through which of their own constructors; and which declare an ordering, and by which +// comparison. Keyed on the exact declaration, never on a spelling: std.nat Nat (a native-realizing +// semiring alias) and v2.std.nat Nat (the Peano coproduct) share a spelling and only the second is +// a row here. The sibling gunbc.rust_source_type_bindings answers the OTHER question -- which +// declarations realize natively on the Rust target -- and a declaration is never in both: a native +// realization takes the kernel literal directly and the host operator directly. +// +// A ROW MAY ONLY STATE A HOMOMORPHISM THAT IS ALREADY TRUE OF THE DESTINATION, never be added to +// make a failing site compile (the same discipline gunbc.rust_source_type_bindings and +// v1.compiler.coercion numeric_realization_roster_extension_note hold for the native roster). The +// Peano row is true by the definition of the naturals: n maps to succ^n(zero), and that map is the +// unique semiring homomorphism from the kernel integers restricted to the nonnegatives. + +fn peano_literal_homomorphism(module_path: String, nat: String, zero: String, succ: String, prev_field: String) -> LiteralHomomorphism { + LiteralHomomorphism { + source_kind: KernelIntLiteral, + destination: decl_ref(module_path: module_path, decl_name: nat), + producer: PeanoUnfold { + zero: decl_ref(module_path: module_path, decl_name: zero), + succ: decl_ref(module_path: module_path, decl_name: succ), + prev_field: prev_field as NonEmptyStr + } + } +} + +data literal_homomorphism_rows: List = [ + peano_literal_homomorphism(module_path: "v2.std.nat", nat: "Nat", zero: "Zero", succ: "Succ", prev_field: "prev") +] + +fn structural_ordering_binding(carrier_module: String, carrier: String, compare_module: String, compare: String, ordering_module: String, ordering: String) -> StructuralOrderingBinding { + StructuralOrderingBinding { + carrier: decl_ref(module_path: carrier_module, decl_name: carrier), + compare: decl_ref(module_path: compare_module, decl_name: compare), + ordering: decl_ref(module_path: ordering_module, decl_name: ordering) + } +} + +data structural_ordering_rows: List = [ + structural_ordering_binding(carrier_module: "v2.std.nat", carrier: "Nat", compare_module: "v2.std.nat", compare: "nat_compare", ordering_module: "std.algebra", ordering: "Ordering") +] diff --git a/dag/std/literal_elaboration.dag b/dag/std/literal_elaboration.dag new file mode 100644 index 00000000000..413562413c9 --- /dev/null +++ b/dag/std/literal_elaboration.dag @@ -0,0 +1,164 @@ +module std.literal_elaboration + +import std.types { List, String, Bool, Int, NonEmptyStr } +import std.decl_ref { DeclarationRef, declaration_ref_eq } +import std.syntax { LiteralValue, LitStr, LitInt, LitFloat, LitBool, LitNull, LitSymbol } + +// THE EXPECTED-TYPE-DIRECTED LITERAL INTRODUCTION JUDGMENT, as a model (DESIGN section 4: one +// decision procedure, emission and ingestion are the same homomorphism check read in two directions). +// +// A kernel literal (`0`, `"x"`, `true`, `^s`) is a value of the KERNEL type the parser mints for it. +// When such a literal reaches a typed boundary -- a call argument, a declared return, a record +// field, a data initializer, an annotated let, the other operand of a binary operator -- the +// boundary names a DESTINATION declaration. Three things can be true of that pair, and they are +// three outcomes, never one row with a flag: +// DirectLiteral the destination realizes the kernel type itself (a host numeric, the kernel +// type, a native-realizing alias): the literal is already its own value. +// ViaHomomorphism the destination is a STRUCTURAL declaration that SUPPLIES the literal: one +// declared homomorphism from the kernel value into the destination's own +// constructors (a Peano numeral into Zero/Succ, a text into a FreeMonoid of +// scalars). The typed tree carries the destination and the homomorphism at the +// occurrence; emission renders the image and never re-decides from spelling. +// Refused the roster is defective at this key (two rows for one destination). +// A destination with NO row and no native realization is not refused HERE: whether a kernel +// numeral inhabits such a declaration is the inhabitance judgment's question and it already owns +// that refusal (v1.compiler.infer declared_type_inhabitance). Answering it twice would be the two- +// authority state DESIGN section 3 forbids; this judgment introduces values, it does not police them. +// +// GENERIC BY CONSTRUCTION. The judgment is keyed on (source kind, exact destination DeclarationRef) +// and the image is produced by a closed roster of UNFOLDINGS, one arm per structural shape a kernel +// value can be unfolded into. A consumer that needs a new destination adds one ROW to the corpus +// roster (gunbc.structural_realization_bindings) and, if its destination's shape is new, one +// unfolding ARM here -- never a second elaboration fold and never a per-destination special case +// in inference or emission. The Peano arm is the first inhabitant; the FreeMonoid-of-scalars arm +// is the structural-text lane's (XL-0T) to add beside it. +// +// WHY A NEGATIVE-VALUE REFUSAL IS ABSENT ON PURPOSE (DESIGN section 4b: ask whether the RED is +// authorable before writing the check). A kernel integer literal is never negative -- `-3` parses +// as a unary negation applied to the literal `3`, and the negation is an ordinary expression that +// reaches inference through its own arm, not through this judgment. A ValueOutsideHomomorphismDomain +// arm for the Peano unfolding would therefore be permanently green and would be cited as coverage. + +type LiteralSourceKind + = KernelIntLiteral + | KernelStringLiteral + | KernelFloatLiteral + | KernelBoolLiteral + | KernelSymbolLiteral + | KernelNullLiteral + +fn literal_source_kind_of(value: LiteralValue) -> LiteralSourceKind { + match value { + LitInt { value: _ } => KernelIntLiteral + LitStr { value: _ } => KernelStringLiteral + LitFloat { value: _ } => KernelFloatLiteral + LitBool { value: _ } => KernelBoolLiteral + LitSymbol { value: _ } => KernelSymbolLiteral + LitNull => KernelNullLiteral + } +} + +fn literal_source_kind_label(kind: LiteralSourceKind) -> String { + match kind { + KernelIntLiteral => "kernel_int_literal" + KernelStringLiteral => "kernel_string_literal" + KernelFloatLiteral => "kernel_float_literal" + KernelBoolLiteral => "kernel_bool_literal" + KernelSymbolLiteral => "kernel_symbol_literal" + KernelNullLiteral => "kernel_null_literal" + } +} + +fn literal_source_kind_eq(a: LiteralSourceKind, b: LiteralSourceKind) -> Bool { + literal_source_kind_label(kind: a) == literal_source_kind_label(kind: b) +} + +// HOW A KERNEL VALUE IS UNFOLDED INTO A DESTINATION'S CONSTRUCTORS. Each arm names the destination's +// own constructors by exact DeclarationRef -- the unfolding is a fact about the destination, so a +// renamed variant is a changed row, never a stale spelling inside the compiler. +// PeanoUnfold a nonnegative integer n unfolds to succ^n(zero): `succ { prev_field: ... }` nested +// n deep around the nullary `zero`. +type LiteralUnfolding + = PeanoUnfold { zero: DeclarationRef, succ: DeclarationRef, prev_field: NonEmptyStr } + +type LiteralHomomorphism { + source_kind: LiteralSourceKind + destination: DeclarationRef + producer: LiteralUnfolding +} + +type LiteralHomomorphismLookup + = LiteralHomomorphismFound { row: LiteralHomomorphism } + | LiteralHomomorphismAbsent + | LiteralHomomorphismAmbiguous { row_count: Int } + +fn literal_homomorphism_for( + rows: List, + source_kind: LiteralSourceKind, + destination: DeclarationRef +) -> LiteralHomomorphismLookup { + let matching = rows |> filter(r => + literal_source_kind_eq(a: r.source_kind, b: source_kind) + && declaration_ref_eq(a: r.destination, b: destination)) + let n = matching |> count + if n == 0 { + LiteralHomomorphismAbsent + } else if n == 1 { + match matching |> first { + Present { value: row } => LiteralHomomorphismFound { row: row } + Absent => LiteralHomomorphismAbsent + } + } else { + LiteralHomomorphismAmbiguous { row_count: n } + } +} + +type LiteralElaborationRefusal + = HomomorphismDuplicated { source_kind: LiteralSourceKind, destination: DeclarationRef, row_count: Int } + +fn literal_elaboration_refusal_message(cause: LiteralElaborationRefusal) -> String { + match cause { + HomomorphismDuplicated { source_kind: k, destination: d, row_count: n } => + concat( + "literal elaboration: ", literal_source_kind_label(kind: k), " into ", + d.module_path as String, ".", d.decl_name as String, + " has more than one declared homomorphism (gunbc.structural_realization_bindings authoring defect)" + ) + } +} + +// THE DECISION. `destination_realizes_natively` is the caller's answer to "does this declaration +// realize the kernel type itself" (v1.compiler.coercion decl_file_realizes_natively / the exact +// Rust binding), passed in rather than re-derived so this module stays target-agnostic. +type LiteralElaborationOutcome + = DirectLiteral + | ViaHomomorphism { homomorphism: LiteralHomomorphism } + | LiteralElaborationRefused { cause: LiteralElaborationRefusal } + +fn elaborate_literal_at( + rows: List, + source_kind: LiteralSourceKind, + destination: DeclarationRef, + destination_realizes_natively: Bool +) -> LiteralElaborationOutcome { + if destination_realizes_natively { + DirectLiteral + } else { + match literal_homomorphism_for(rows: rows, source_kind: source_kind, destination: destination) { + LiteralHomomorphismFound { row: row } => ViaHomomorphism { homomorphism: row } + LiteralHomomorphismAbsent => DirectLiteral + LiteralHomomorphismAmbiguous { row_count: n } => + LiteralElaborationRefused { cause: HomomorphismDuplicated { source_kind: source_kind, destination: destination, row_count: n } } + } + } +} + +// WHAT THE TYPED TREE CARRIES at an elaborated occurrence: the source kind, the exact destination, +// and the homomorphism selected. The occurrence itself is the node this record sits on (its +// occurrence identity), so it is not duplicated here. Only ViaHomomorphism occurrences carry a +// record -- a DirectLiteral is the ordinary literal node and needs nothing said about it. +type LiteralElaboration { + source_kind: LiteralSourceKind + destination: DeclarationRef + homomorphism: LiteralHomomorphism +} diff --git a/dag/std/operator_realization.dag b/dag/std/operator_realization.dag new file mode 100644 index 00000000000..6bc24d8f05a --- /dev/null +++ b/dag/std/operator_realization.dag @@ -0,0 +1,176 @@ +module std.operator_realization + +import std.types { List, String, Bool, Int, NonEmptyStr } +import std.decl_ref { DeclarationRef, declaration_ref_eq } +import std.syntax { BinOp, Add, Sub, Mul, Div, Mod, Eq, Ne, Lt, Gt, Le, Ge, And, Or, NullCoalesce } + +// OPERATOR REALIZATION BY EXACT OPERAND STRUCTURE (DESIGN section 4b, the floor: an operator is +// admitted by algebra inhabitance, but what it RENDERS AS is a fact about the operand's declaration +// and the target, never about the operator's spelling). +// +// The seed emitter rendered every binary operator as the host operator token. That is correct +// exactly when the operand realizes as a host value with that operator -- a machine integer, a +// float, a bool -- and wrong for every structural declaration: a Peano coproduct has no host `<`, +// and rustc's E0369 on `Rc < Rc` was the emitter re-deciding, from the operator's +// spelling alone, a question the operand's declaration already answers. The decision is keyed on +// the operand's exact DeclarationRef and has four outcomes: +// HostOperator the operand realizes natively on the target; the host token is the op. +// StructuralEquality equality on a structural declaration: derived structurally (the target's +// structural equality over the declaration's own constructors). +// StructuralComparison an ordering on a structural declaration: a call to the declaration's +// DECLARED comparison, whose result is tested against std.algebra Ordering. +// Refused a host-only operator (arithmetic) on a structural operand that declares +// no operation for it, or an operand whose identity is unknown at the site. +// Typed and located: the line stops (DESIGN section 5), it does not emit a +// token rustc will refuse later under a code nobody joins back to the site. +// +// Arithmetic on a structural declaration is deliberately NOT realized by this decision. A Peano +// quotient with a typed zero-divisor outcome is a DECLARED OPERATION the source calls by name +// (v2.std.nat nat_div_rem); an infix `/` that silently became that call would hide the outcome the +// operation exists to expose. So the source spells structural arithmetic as calls, and this +// decision refuses the infix form on structural operands. + +type OperandRealization + = HostNumericOperand + | StructuralOperand { declaration: DeclarationRef } + | OperandIdentityUnavailable + +// A structural declaration's declared ordering: the comparison to call and the Ordering declaration +// whose variants its result is tested against. Keyed on the carrier's exact DeclarationRef. +type StructuralOrderingBinding { + carrier: DeclarationRef + compare: DeclarationRef + ordering: DeclarationRef +} + +type StructuralOrderingLookup + = StructuralOrderingFound { row: StructuralOrderingBinding } + | StructuralOrderingAbsent + | StructuralOrderingAmbiguous { row_count: Int } + +fn structural_ordering_for(rows: List, carrier: DeclarationRef) -> StructuralOrderingLookup { + let matching = rows |> filter(r => declaration_ref_eq(a: r.carrier, b: carrier)) + let n = matching |> count + if n == 0 { + StructuralOrderingAbsent + } else if n == 1 { + match matching |> first { + Present { value: row } => StructuralOrderingFound { row: row } + Absent => StructuralOrderingAbsent + } + } else { + StructuralOrderingAmbiguous { row_count: n } + } +} + +// The test an ordering operator performs on a comparison's result, grounded on std.algebra +// Ordering = Less | Equal | Greater: `<` is `== Less`, `>` is `== Greater`, `<=` is `!= Greater`, +// `>=` is `!= Less`. Non-ordering operators have no test. +type OrderingTest + = OrderingIs { variant: NonEmptyStr } + | OrderingIsNot { variant: NonEmptyStr } + +fn ordering_test_for(op: BinOp) -> OrderingTest? { + match op { + Lt => Present { value: OrderingIs { variant: "Less" as NonEmptyStr } } + Gt => Present { value: OrderingIs { variant: "Greater" as NonEmptyStr } } + Le => Present { value: OrderingIsNot { variant: "Greater" as NonEmptyStr } } + Ge => Present { value: OrderingIsNot { variant: "Less" as NonEmptyStr } } + _ => none + } +} + +fn binop_is_equality(op: BinOp) -> Bool { + match op { + Eq => true + Ne => true + _ => false + } +} + +fn binop_is_ordering(op: BinOp) -> Bool { + ordering_test_for(op: op) != none +} + +fn binop_label(op: BinOp) -> String { + match op { + Add => "+" + Sub => "-" + Mul => "*" + Div => "/" + Mod => "%" + Eq => "==" + Ne => "!=" + Lt => "<" + Gt => ">" + Le => "<=" + Ge => ">=" + And => "&&" + Or => "||" + NullCoalesce => "??" + } +} + +type OperatorRealizationRefusal + = NoStructuralOperationDeclared { declaration: DeclarationRef, operator: String } + | StructuralOrderingDuplicated { declaration: DeclarationRef, row_count: Int } + +type OperatorRealization + = HostOperator + | StructuralEquality { declaration: DeclarationRef } + | StructuralComparison { declaration: DeclarationRef, binding: StructuralOrderingBinding, test: OrderingTest } + | OperatorRealizationRefused { cause: OperatorRealizationRefusal } + +fn operator_realization_refusal_message(cause: OperatorRealizationRefusal) -> String { + match cause { + NoStructuralOperationDeclared { declaration: d, operator: o } => + concat( + "operator realization: host operator `", o, "` on structural operand ", + d.module_path as String, ".", d.decl_name as String, + " -- the declaration has no host realization and declares no operation for this operator; spell the operation as a call to the declared structural operation" + ) + StructuralOrderingDuplicated { declaration: d, row_count: n } => + concat( + "operator realization: structural ordering for ", + d.module_path as String, ".", d.decl_name as String, + " has more than one declared comparison (gunbc.structural_realization_bindings authoring defect)" + ) + } +} + +// THE DECISION. Logical connectives and null-coalescing are not operand-structure questions (their +// operands are the kernel Bool and an Optional respectively) and answer HostOperator; an operand +// whose identity is unavailable at the site is the seed's pre-existing host path and also answers +// HostOperator, because refusing there would refuse every kernel-minted operand (a literal's own +// type carries no declaration) -- the structural arm is entered only on a RESOLVED structural +// declaration, which is the only place the host token was ever wrong. +fn operator_realization_for( + op: BinOp, + operand: OperandRealization, + ordering_rows: List +) -> OperatorRealization { + match operand { + HostNumericOperand => HostOperator + OperandIdentityUnavailable => HostOperator + StructuralOperand { declaration: d } => + if binop_is_equality(op: op) { + StructuralEquality { declaration: d } + } else { + match ordering_test_for(op: op) { + Present { value: test } => + match structural_ordering_for(rows: ordering_rows, carrier: d) { + StructuralOrderingFound { row: row } => StructuralComparison { declaration: d, binding: row, test: test } + StructuralOrderingAbsent => OperatorRealizationRefused { cause: NoStructuralOperationDeclared { declaration: d, operator: binop_label(op: op) } } + StructuralOrderingAmbiguous { row_count: n } => OperatorRealizationRefused { cause: StructuralOrderingDuplicated { declaration: d, row_count: n } } + } + Absent => + match op { + And => HostOperator + Or => HostOperator + NullCoalesce => HostOperator + _ => OperatorRealizationRefused { cause: NoStructuralOperationDeclared { declaration: d, operator: binop_label(op: op) } } + } + } + } + } +} diff --git a/dag/test/claim/self_host_peano_literal_operator_realization_witness_test.dag b/dag/test/claim/self_host_peano_literal_operator_realization_witness_test.dag new file mode 100644 index 00000000000..2e7f714032d --- /dev/null +++ b/dag/test/claim/self_host_peano_literal_operator_realization_witness_test.dag @@ -0,0 +1,129 @@ +module test.claim.self_host_peano_literal_operator_realization_witness_test + +import v2.std.live_tree { LiveTreeDisposition, SubstrateInputsOnly } + +data live_tree_disposition: LiveTreeDisposition = SubstrateInputsOnly + +// THE EMITTED-BYTES HALF OF THE STRUCTURAL PEANO NAT FALSIFIERS (XL-0N, adhoc-aec65f93-b00). +// Each row compiles a virtual module through the PRODUCTION v1 emitter (compile_dag_rust_emit_check) +// and asserts on the Rust it writes. The interpreter-executed half -- the declared structural +// operations on nontrivial Succ values and the generic decisions by row and identity -- is +// v2.test.claim.self_host.peano_nat_structural_realization_test. +// +// The forbidden tokens are the emitter's rendering BEFORE this lane, read off the same probes +// compiled with the pre-lane binary (recorded here so a reader can see what each row turns red on): +// arg boundary crate::v2_std_nat::nat_add(n.clone(), 2) -> E0308 Rc vs integer +// return boundary -> Rc {\n 2\n} -> E0308 +// literal equality (a.clone() == 3) -> E0308 +// ordering (a.clone() < b.clone()) -> E0369 on Rc +// arithmetic (a.clone() / b.clone()) -> E0369 on Rc +// The two host-control rows pin that the SAME operators on a native i64 operand keep the host +// token and the bare digit: the decision is keyed on the operand's declaration, not the spelling. + +// A kernel integer literal at a v2.std.nat.Nat ARGUMENT boundary elaborates to its Zero/Succ +// image (std.literal_elaboration PeanoUnfold, the row in gunbc.structural_realization_bindings). +test fn w_literal_at_peano_argument_boundary_emits_its_image() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.peano_arg_probe\nimport std.types { Bool }\nimport v2.std.nat { Nat, nat_add }\nfn probe(n: Nat) -> Nat { nat_add(a: n, b: 2) }\n", + "src/test_claim_peano_arg_probe.rs", + ["Nat::Succ { prev: Rc::new(Nat::Succ { prev: Rc::new(Nat::Zero) }) }"], + [", 2)"] + ) +} + +// The same at a declared RETURN boundary. +test fn w_literal_at_peano_return_boundary_emits_its_image() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.peano_return_probe\nimport v2.std.nat { Nat }\nfn probe() -> Nat { 2 }\n", + "src/test_claim_peano_return_probe.rs", + ["Nat::Succ { prev: Rc::new(Nat::Succ { prev: Rc::new(Nat::Zero) }) }"], + ["{\n 2\n}"] + ) +} + +// The other OPERAND of a binary operator is a boundary: `a == 3` with a: Nat introduces 3 at Nat, +// and equality on the Peano operand is structural (the emitted enum derives PartialEq). +test fn w_literal_operand_of_peano_equality_emits_its_image() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.peano_literal_eq_probe\nimport std.types { Bool }\nimport v2.std.nat { Nat }\nfn probe(a: Nat) -> Bool { a == 3 }\n", + "src/test_claim_peano_literal_eq_probe.rs", + ["== Rc::new(Nat::Succ { prev: Rc::new(Nat::Succ { prev: Rc::new(Nat::Succ { prev: Rc::new(Nat::Zero) }) }) }))"], + ["== 3)"] + ) +} + +// Zero is the image of 0: the nullary constructor, not a digit. +test fn w_zero_literal_emits_the_nullary_constructor() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.peano_zero_probe\nimport v2.std.nat { Nat }\nfn probe() -> Nat { 0 }\n", + "src/test_claim_peano_zero_probe.rs", + ["Rc::new(Nat::Zero)"], + ["{\n 0\n}"] + ) +} + +// An ORDERING on Peano operands is a call to the declared comparison tested against std.algebra +// Ordering (std.operator_realization StructuralComparison), never the host `<`. +test fn w_ordering_on_peano_operands_calls_the_declared_comparison() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.peano_lt_probe\nimport std.types { Bool }\nimport v2.std.nat { Nat }\nfn probe(a: Nat, b: Nat) -> Bool { a < b }\n", + "src/test_claim_peano_lt_probe.rs", + ["(crate::v2_std_nat::nat_compare(a.clone(), b.clone()) == crate::std_algebra::Ordering::Less)"], + [" < "] + ) +} + +// A non-strict ordering negates the opposite variant: `<=` is `!= Greater`. +test fn w_non_strict_ordering_negates_the_opposite_variant() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.peano_le_probe\nimport std.types { Bool }\nimport v2.std.nat { Nat }\nfn probe(a: Nat, b: Nat) -> Bool { a <= b }\n", + "src/test_claim_peano_le_probe.rs", + ["(crate::v2_std_nat::nat_compare(a.clone(), b.clone()) != crate::std_algebra::Ordering::Greater)"], + [" <= "] + ) +} + +// FORCING HOST ARITHMETIC ONTO PEANO OPERANDS REDS IN THE BYTES: infix `/` on Nat is refused by +// a typed compile_error naming the declaration and the operator, not emitted as a token rustc +// refuses later under E0369. +test fn w_host_arithmetic_on_peano_operands_refuses_in_the_bytes() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.peano_div_probe\nimport v2.std.nat { Nat }\nfn probe(a: Nat, b: Nat) -> Nat { a / b }\n", + "src/test_claim_peano_div_probe.rs", + ["compile_error!(\"operator realization: host operator `/` on structural operand v2.std.nat.Nat"], + [" / "] + ) +} + +// HOST CONTROL: the same ordering on a native i64 operand keeps the host token. Without this row +// a realization that routed EVERY `<` through a comparison call would pass the Peano rows. +test fn w_ordering_on_native_operands_keeps_the_host_operator() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.native_lt_probe\nimport std.types { Bool, Int }\nfn probe(a: Int, b: Int) -> Bool { a < b }\n", + "src/test_claim_native_lt_probe.rs", + ["(a.clone() < b.clone())"], + ["nat_compare", "compile_error!"] + ) +} + +// HOST CONTROL: a literal at a native Int boundary stays the bare digit (DirectLiteral). +test fn w_literal_at_native_boundary_stays_direct() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.native_literal_probe\nimport std.types { Int }\nfn probe(a: Int) -> Int { a + 2 }\n", + "src/test_claim_native_literal_probe.rs", + ["(a.clone() + 2)"], + ["Succ", "Zero"] + ) +} + +// SAME SPELLING, DIFFERENT DECLARATION: std.nat Nat is the native-realizing semiring alias, and a +// literal at ITS boundary stays direct while the host `<` stays the host token. This is the row a +// spelling-keyed decision cannot pass together with the Peano rows above. +test fn w_native_nat_declaration_keeps_direct_literal_and_host_operator() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.native_nat_probe\nimport std.types { Bool }\nimport std.nat { Nat }\nfn probe(a: Nat) -> Bool { a < 2 }\n", + "src/test_claim_native_nat_probe.rs", + ["(a.clone() < 2)"], + ["Succ", "nat_compare", "compile_error!"] + ) +} diff --git a/scratch-probe/test/claim/peano_probe.dag b/scratch-probe/test/claim/peano_probe.dag new file mode 100644 index 00000000000..5404778f153 --- /dev/null +++ b/scratch-probe/test/claim/peano_probe.dag @@ -0,0 +1,12 @@ +module test.claim.peano_probe +import std.types { Int, Bool } +import v2.std.nat { Nat, Zero, Succ, nat_add } +fn arg_boundary(n: Nat) -> Nat { nat_add(a: n, b: 2) } +fn return_boundary() -> Nat { 2 } +fn ordering(a: Nat, b: Nat) -> Bool { a < b } +fn ordering_le(a: Nat, b: Nat) -> Bool { a <= b } +fn equality(a: Nat, b: Nat) -> Bool { a == b } +fn literal_equality(a: Nat) -> Bool { a == 3 } +fn arithmetic(a: Nat, b: Nat) -> Nat { a / b } +fn host_ordering(a: Int, b: Int) -> Bool { a < b } +fn host_literal(a: Int) -> Int { a + 2 } diff --git a/src/v1/00_core.dag b/src/v1/00_core.dag index 9aaa6dfe0d7..e4fb438ae52 100644 --- a/src/v1/00_core.dag +++ b/src/v1/00_core.dag @@ -8,6 +8,7 @@ import std.syntax { AlgebraFieldKind, AlgAdd, AlgMul, AlgReciprocal, AlgQuotient, AlgRemainder, AlgCompare, AlgMeet, AlgJoin } import std.algebra { CollectionSizeEffect, CostShape, AlgebraFieldTemplate } +import std.literal_elaboration { LiteralElaboration } import std.induction { SubValueRelation } import std.occurrence_identity { NodeOccurrenceIdentity, @@ -165,6 +166,7 @@ type ExprErrorKind = ParseRecoveryError | SemanticExprError | InternalExprError type ExprData = NoExprData | ExprLiteral { value: LiteralValue } + | ExprElaboratedLiteral { value: LiteralValue, elaboration: LiteralElaboration } | ExprError { kind: ExprErrorKind, message: String } | ExprVar { binding_kind: VarBindingKind? } | ExprFieldAccess { summary: FieldSummary? } @@ -1486,6 +1488,11 @@ fn expr_literal_int_optional(expr: Node) -> Int? { LitInt { value: v } => Present { value: v } _ => none } + ExprElaboratedLiteral { value: lit, elaboration: _ } => + match lit { + LitInt { value: v } => Present { value: v } + _ => none + } ExprUnaryOp { op: Neg } => match expr_literal_int_optional(expr: unaryop_operand(texpr: expr)) { Present { value: v } => Present { value: 0 - v } @@ -1524,6 +1531,7 @@ fn expr_is_any_literal(expr: Node) -> Bool { LitNull => false _ => true } + ExprElaboratedLiteral { value: _, elaboration: _ } => true ExprUnaryOp { op: Neg } => expr_is_any_literal(expr: unaryop_operand(texpr: expr)) _ => false } @@ -1754,6 +1762,7 @@ fn expr_has_non_tail_self_call(texpr: Node, fn_name: String, in_tail: Bool, sour ExprError { kind: _, message: _ } => false ExprVar { binding_kind: _ } => false ExprLiteral { value: _ } => false + ExprElaboratedLiteral { value: _, elaboration: _ } => false ExprFieldAccess { summary: _ } => texpr.children |> any(child => expr_has_non_tail_self_call(texpr: child, fn_name: fn_name, in_tail: false, source_indices: source_indices)) ExprMethodCall { method_semantics: _ } => diff --git a/src/v1/04_env.dag b/src/v1/04_env.dag index b72773148d9..edb4cb01666 100644 --- a/src/v1/04_env.dag +++ b/src/v1/04_env.dag @@ -2,10 +2,11 @@ module v1.compiler.infer_env import std.occurrence_identity { OccurrenceSynthetic } -import v1.std.core { Node, NewlineIndex, InternTable, empty_intern_table, merge_intern_tables, intern, intern_find, intern_str, source_text_at, authored_name_at, find_child_named, Cardinality, Connective, ExprData, InferredNode, kernel_span, module_path_segments, param_node_name_at, param_node_type_expr, CompilerDiagnostic, AmbiguousReference, UnresolvedType } +import v1.std.core { Node, NewlineIndex, InternTable, Resolved, qualified_last_segment, empty_intern_table, merge_intern_tables, intern, intern_find, intern_str, source_text_at, authored_name_at, find_child_named, Cardinality, Connective, ExprData, InferredNode, kernel_span, module_path_segments, param_node_name_at, param_node_type_expr, CompilerDiagnostic, AmbiguousReference, UnresolvedType } import v1.compiler.type_head_exposure { TypeHeadExposure } import std.types { SourceSpan, is_kernel_type } +import std.decl_ref { decl_ref, DeclarationRef } import std.induction { InductiveField, RecursionShape, DirectRecursion, ListRecursion, OptionalRecursion, SetRecursion, MapValueRecursion, SubValueRelation, SubValueUnknown, PreservedValue } import std.algebra { FreeMonoid, Empty, Cons } @@ -1222,3 +1223,40 @@ fn env_with_type_variable_bindings(env: TypeEnv, tp_names: List) -> Type } ) } + +// THE EXACT PATH, AT ANY CONSUMER (relocated from v1.compiler.emit_rust, XL-0N). A type reference +// carries its resolved declaration (`inferred: Resolved { node }`); the declaration's module is the +// containment fact the corpus-wide bare-name census already holds (SymbolIndex.global_bare, one row +// per declared name with its module_path and the declaration node), so the DeclarationRef is read +// from that census by identity -- the candidate whose declaration node IS the resolved node, by +// ident_span -- and never minted from a spelling. Identity the census cannot supply (a kernel mint, +// a variant alias, an unresolved reference) is absent. +fn binding_declares_span(binding: TypeBinding, sp: SourceSpan) -> Bool { + match binding.resolved.ident_span { + Present { value: s } => s.file == sp.file && s.start == sp.start + Absent => false + } +} + +fn type_reference_declaration_ref(n: Node, source_indices: Map, env: TypeEnv) -> DeclarationRef? { + let rt = match n.inferred { + Present { value: Resolved { node: r } } => r + _ => n + } + let decl_name = qualified_last_segment(name: authored_name_at(source_indices: source_indices, node: rt)) + if decl_name == "" { return none } + match rt.ident_span { + Absent => none + Present { value: sp } => + match map_get(env.symbol_index.global_bare, decl_name) { + Present { value: GlobalBareUniqueBinding { module_path: mp, binding: b } } => + if binding_declares_span(binding: b, sp: sp) { Present { value: decl_ref(module_path: mp, decl_name: decl_name) } } else { none } + Present { value: GlobalBareAmbiguousBinding { candidates: cands } } => + match cands |> filter(c => binding_declares_span(binding: c.binding, sp: sp)) |> first { + Present { value: c } => Present { value: decl_ref(module_path: c.module_path, decl_name: decl_name) } + Absent => none + } + Absent => none + } + } +} diff --git a/src/v1/04_infer.dag b/src/v1/04_infer.dag index a7da42b7336..7a750d8d91c 100644 --- a/src/v1/04_infer.dag +++ b/src/v1/04_infer.dag @@ -8,7 +8,14 @@ import std.content_hash { content_hash_validate_lower_hex_length, } import extdeps.container.oci.digest { oci_other_digest_algorithm, oci_other_digest_encoded } -import std.syntax { Add, BinOp, LitStr, LiteralValue } +import std.syntax { Add, BinOp, LitStr, LitInt, LiteralValue } +import std.decl_ref { DeclarationRef } +import std.literal_elaboration { + LiteralElaboration, LiteralHomomorphism, LiteralUnfolding, PeanoUnfold, + LiteralElaborationOutcome, DirectLiteral, ViaHomomorphism, LiteralElaborationRefused, + elaborate_literal_at, literal_source_kind_of, literal_elaboration_refusal_message +} +import gunbc.structural_realization_bindings { literal_homomorphism_rows } import std.coercion { dag_can_cast, is_dag_cast_domain_type } import v1.compiler.type_head_exposure { TypeHeadView, KernelScalarHead, ApplicationHead, ProductHead, CoproductHead, CallableHead, @@ -25,7 +32,7 @@ import v1.std.core { field_node_type_expr, field_node_name_at, Connective, Conj, Disj, NoConnective, Arrow, ExprData, NoExprData, - ExprLiteral, ExprError, ExprVar, ExprFieldAccess, ExprCall, ExprMethodCall, + ExprLiteral, ExprElaboratedLiteral, ExprError, ExprVar, ExprFieldAccess, ExprCall, ExprMethodCall, ExprMatch, ExprIf, ExprLet, ExprRecordLit, ExprListLit, ExprBinOp, ExprUnaryOp, ExprLambda, ExprStringInterp, ExprBlock, ExprCast, ExprForEach, ExprIndex, ExprSlice, ExprReturn, @@ -115,7 +122,7 @@ import v1.compiler.infer_env { qualify_borrowed_type_names, qualify_borrowed_inferred, qualified_all_but_last, env_with_type_variable_bindings, GlobalBareCandidate, node_with_inferred, node_with_children, ServiceCensusEntry, qualify_decl_reference_positions, - lookup_binding_by_name, binding_declares_name, + lookup_binding_by_name, binding_declares_name, type_reference_declaration_ref, listed_import_required_bare_call_blocked, effective_visible_binding, unit_variant_index_shadow_insert, build_unit_variant_index, UnitVariantContribution @@ -4666,11 +4673,170 @@ fn qualified_value_projection(texpr: Node, scope: InferScope, span: SourceSpan) // which is exactly how the deleted `func_sig_if_resolved` came to erase the ambiguity in // the first place. + +// --------------------------------------------------------------------------------------------- +// LITERAL ELABORATION AT A TYPED BOUNDARY (std.literal_elaboration; XL-0N, adhoc-aec65f93-b00). +// +// The literal arm below receives the boundary's expected type at every position that supplies one +// -- call argument, declared return, record field, data initializer, annotated let, list element, +// map value, block tail, and (via infer_binop_operands) the other operand of a binary operator -- +// and asks ONE judgment: does the destination declaration supply this kernel literal through a +// declared homomorphism? When it does, the literal is REPLACED in the typed tree by an +// ExprElaboratedLiteral whose record names the source kind, the exact destination and the selected +// homomorphism, and whose single child is the literal's IMAGE under that homomorphism -- ordinary +// constructor nodes of the destination (Zero / Succ { prev: ... } for the Peano unfolding), typed +// as the destination. Emission renders the image the way it renders any constructor and never +// re-decides from spelling, imports, or the host compiler's expectations. +// +// Identity, not spelling: the destination is read by type_reference_declaration_ref (the same +// exact-identity reader the Rust renderer uses), so std.nat Nat and v2.std.nat Nat -- one spelling, +// two declarations -- take different arms by construction. A destination the census cannot +// identify, an optional-cardinality boundary, and a destination with no row all leave the literal +// exactly as it was (DirectLiteral); the inhabitance judgment owns any refusal there. +// --------------------------------------------------------------------------------------------- + +type LiteralBoundary + = LiteralBoundaryPlain + | LiteralBoundaryElaborated { elaboration: LiteralElaboration, destination_type: Node } + | LiteralBoundaryRefused { message: String } + +fn literal_boundary_elaboration(lit: LiteralValue, expected: Node?, scope: InferScope) -> LiteralBoundary { + match expected { + Absent => LiteralBoundaryPlain + Present { value: exp } => + if exp.return_cardinality == CardOptional { + LiteralBoundaryPlain + } else { + match type_reference_declaration_ref(n: exp, source_indices: scope.type_env.source_indices, env: scope.type_env) { + Absent => LiteralBoundaryPlain + Present { value: destination } => + let kind = literal_source_kind_of(value: lit) + let natively = decl_file_realizes_natively(decl_file: type_reference_decl_file(n: exp)) + match elaborate_literal_at(rows: literal_homomorphism_rows, source_kind: kind, destination: destination, destination_realizes_natively: natively) { + DirectLiteral => LiteralBoundaryPlain + ViaHomomorphism { homomorphism: h } => + LiteralBoundaryElaborated { + elaboration: LiteralElaboration { source_kind: kind, destination: destination, homomorphism: h }, + destination_type: exp + } + LiteralElaborationRefused { cause: c } => + LiteralBoundaryRefused { message: literal_elaboration_refusal_message(cause: c) } + } + } + } + } +} + +// The image's nodes carry a synthetic ident_span whose file is not a source index, so every +// name reader (authored_name_at) answers from the node's own name -- the constructor names come +// from the homomorphism row, never from source text. +fn elaborated_span(name: String) -> SourceSpan { + SourceSpan { file: "", start: 0, end: string_length(s: name) } +} + +fn elaborated_expr_node(name: String, expr_data: ExprData, children: List, destination_type: Node, span: SourceSpan) -> Node { + Node { + occurrence_identity: OccurrenceSynthetic, + name: name, span: span, ident_span: Present { value: elaborated_span(name: name) }, children: children, + connective: NoConnective, + params: [], inferred: Present { value: Resolved { node: destination_type } }, return_cardinality: Required, + uses: [], body: none, transport: none, properties: [], + type_annotation: none, is_self_recursive: false, + has_non_tail_self_call: false, match_pattern: none, expr_data: expr_data + } +} + +fn unfold_peano_image(n: Int, zero: String, succ: String, prev_field: String, parent: String, destination_type: Node, span: SourceSpan) -> Node { + if n <= 0 { + elaborated_expr_node( + name: zero, + expr_data: ExprVar { binding_kind: Present { value: VariantValueBinding { parent_enum: parent } } }, + children: [], destination_type: destination_type, span: span + ) + } else { + let prev = unfold_peano_image(n: n - 1, zero: zero, succ: succ, prev_field: prev_field, parent: parent, destination_type: destination_type, span: span) + let field = make_field_init_node(occurrence_identity: OccurrenceSynthetic, name: prev_field, value: prev, span: span, name_span: elaborated_span(name: prev_field)) + elaborated_expr_node( + name: succ, + expr_data: ExprRecordLit { parent_enum: Present { value: parent } }, + children: [field], destination_type: destination_type, span: span + ) + } +} + +fn unfold_literal_image(lit: LiteralValue, elaboration: LiteralElaboration, destination_type: Node, span: SourceSpan) -> Node { + match elaboration.homomorphism.producer { + PeanoUnfold { zero: zero, succ: succ, prev_field: prev_field } => + match lit { + LitInt { value: n } => + unfold_peano_image( + n: n, + zero: zero.decl_name as String, succ: succ.decl_name as String, prev_field: prev_field as String, + parent: elaboration.destination.decl_name as String, + destination_type: destination_type, span: span + ) + _ => make_expr_error_node(occurrence_identity: OccurrenceSynthetic, kind: InternalExprError, message: "literal elaboration: a Peano unfolding row was selected for a non-integer literal (gunbc.structural_realization_bindings keys the row on KernelIntLiteral, so this row is malformed)", span: span) + } + } +} + +// A binary operator's operands are a typed boundary for each other: a literal operand is +// introduced at the OTHER operand's resolved type (`digit == 0` with digit: v2.std.nat.Nat asks +// the Peano row for 0). Only a literal operand takes the other's type as expected -- every other +// operand shape is inferred exactly as before -- and it takes it through infer_expr_body, not the +// refinement-checking infer_expr wrapper, because comparing against a literal is not a refinement +// boundary (`x == 0` with x refined positive is a legitimate test, not an assignment). +type BinopOperands { + left: InferResult + right: InferResult +} + +fn infer_operand_literal(lit_expr: Node, other: Node, scope: InferScope) -> InferResult { + let other_type = match other.inferred { + Present { value: Resolved { node: rt } } => Present { value: rt } + _ => none + } + infer_expr_body(texpr: lit_expr, scope: scope, expected: other_type) +} + +fn infer_binop_operands(left_expr: Node, right_expr: Node, scope: InferScope) -> BinopOperands { + let left_is_literal = expr_is_any_literal(expr: left_expr) + let right_is_literal = expr_is_any_literal(expr: right_expr) + if right_is_literal && !left_is_literal { + let l = infer_expr(texpr: left_expr, scope: scope, expected: none) + BinopOperands { left: l, right: infer_operand_literal(lit_expr: right_expr, other: l.typed, scope: scope) } + } else if left_is_literal && !right_is_literal { + let r = infer_expr(texpr: right_expr, scope: scope, expected: none) + BinopOperands { left: infer_operand_literal(lit_expr: left_expr, other: r.typed, scope: scope), right: r } + } else { + BinopOperands { + left: infer_expr(texpr: left_expr, scope: scope, expected: none), + right: infer_expr(texpr: right_expr, scope: scope, expected: none) + } + } +} + fn infer_expr_body(texpr: Node, scope: InferScope, expected: Node?) -> InferResult { match texpr.expr_data { ExprLiteral { value: lit } => let span = texpr.span - ok_infer(texpr: make_expr_node(occurrence_identity: texpr.occurrence_identity, expr_data: ExprLiteral { value: lit }, children: [], inferred: Present { value: Resolved { node: infer_literal_node(lit: lit) } }, span: span)) + let plain = make_expr_node(occurrence_identity: texpr.occurrence_identity, expr_data: ExprLiteral { value: lit }, children: [], inferred: Present { value: Resolved { node: infer_literal_node(lit: lit) } }, span: span) + match literal_boundary_elaboration(lit: lit, expected: expected, scope: scope) { + LiteralBoundaryPlain => ok_infer(texpr: plain) + LiteralBoundaryElaborated { elaboration: e, destination_type: dt } => + ok_infer(texpr: make_expr_node( + occurrence_identity: texpr.occurrence_identity, + expr_data: ExprElaboratedLiteral { value: lit, elaboration: e }, + children: [unfold_literal_image(lit: lit, elaboration: e, destination_type: dt, span: span)], + inferred: Present { value: Resolved { node: dt } }, + span: span + )) + LiteralBoundaryRefused { message: m } => + InferResult { typed: plain, diagnostics: [inference_error(message: m, span: span, module_name: scope.module_name)] } + } + + ExprElaboratedLiteral { value: _, elaboration: _ } => + ok_infer(texpr: texpr) ExprError { kind: kind, message: message } => let span = texpr.span @@ -5761,10 +5927,11 @@ fn infer_expr_body(texpr: Node, scope: InferScope, expected: Node?) -> InferResu let span = texpr.span let left_expr = binop_left(texpr: texpr) let right_expr = binop_right(texpr: texpr) - let left_result = infer_expr(texpr: left_expr, scope: scope, expected: none) + let operands = infer_binop_operands(left_expr: left_expr, right_expr: right_expr, scope: scope) + let left_result = operands.left let left_typed = left_result.typed let left_diags = left_result.diagnostics - let right_result = infer_expr(texpr: right_expr, scope: scope, expected: none) + let right_result = operands.right let right_typed = right_result.typed let right_diags = right_result.diagnostics let binop_info = infer_binop_type_node(op: op, left_type: resolved_type(n: left_typed), source_indices: scope.type_env.source_indices) diff --git a/src/v1/04_resolve.dag b/src/v1/04_resolve.dag index 4a7b8b200b2..7bd0faaa823 100644 --- a/src/v1/04_resolve.dag +++ b/src/v1/04_resolve.dag @@ -19,7 +19,7 @@ import v1.std.core { StringPart, Text, Interpolation, MatchPattern, Wildcard, ExprData, NoExprData, - ExprLiteral, ExprError, ExprVar, ExprFieldAccess, ExprCall, ExprMethodCall, + ExprLiteral, ExprElaboratedLiteral, ExprError, ExprVar, ExprFieldAccess, ExprCall, ExprMethodCall, ExprMatch, ExprIf, ExprLet, ExprRecordLit, ExprListLit, ExprBinOp, ExprUnaryOp, ExprLambda, ExprStringInterp, ExprBlock, ExprCast, ExprForEach, ExprIndex, ExprSlice, ExprReturn, @@ -844,6 +844,7 @@ fn resolve_transport_binding(transport: Node, env: TypeEnv, module_name: String) fn resolve_expr_types(texpr: Node, env: TypeEnv, module_name: String) -> ExprResolveResult { match texpr.expr_data { ExprLiteral { value: _ } => ExprResolveResult { expr: texpr, diagnostics: [] } + ExprElaboratedLiteral { value: _, elaboration: _ } => ExprResolveResult { expr: texpr, diagnostics: [] } ExprError { kind: kind, message: message } => ExprResolveResult { expr: make_expr_error_node(occurrence_identity: OccurrenceSynthetic, kind: kind, message: message, span: texpr.span), diff --git a/src/v1/05_emit.dag b/src/v1/05_emit.dag index fb1064a17f7..4593c9cd4f2 100644 --- a/src/v1/05_emit.dag +++ b/src/v1/05_emit.dag @@ -8,7 +8,7 @@ import v1.std.core { module_imports, module_items, param_node_name_at, param_node_type_expr, qualified_last_segment, param_node_default_value, NewlineIndex, authored_name_at, empty_intern_table, expr_var_name_at, expr_call_func_at, let_binding_name_at, field_access_field_at, ExprData, - NoExprData, VarBindingKind, ExprLiteral, ExprVar, ExprFieldAccess, ExprCall, ExprMethodCall, + NoExprData, VarBindingKind, ExprLiteral, ExprElaboratedLiteral, ExprVar, ExprFieldAccess, ExprCall, ExprMethodCall, ExprMatch, ExprIf, ExprLet, ExprRecordLit, ExprListLit, ExprBinOp, ExprUnaryOp, ExprLambda, ExprStringInterp, ExprBlock, ExprCast, ExprForEach, ExprIndex, ExprSlice, ExprError, ExprReturn, StringPart, Text, Interpolation, TextFile, SourceSpan, UnaryOpKind, NullCoalesce, @@ -1264,6 +1264,7 @@ type ExprCategory fn classify_expr(texpr: Node) -> ExprCategory { match texpr.expr_data { ExprLiteral { value: _ } => ExprCatLeaf + ExprElaboratedLiteral { value: _, elaboration: _ } => ExprCatLeaf ExprError { kind: _, message: _ } => ExprCatLeaf ExprVar { binding_kind: _ } => ExprCatLeaf ExprFieldAccess { summary: _ } => ExprCatCompound @@ -2476,6 +2477,11 @@ fn emit_shared_expr( match texpr.expr_data { ExprLiteral { value: v } => wrap_result(emit_literal(value: v, target: target)) + ExprElaboratedLiteral { value: _, elaboration: _ } => + match texpr.children |> first { + Present { value: image } => recurse(image) + Absent => wrap_result(emit_error_expr(message: "elaborated literal carries no image (v1.compiler.infer unfold_literal_image)", target: target)) + } ExprError { kind: _, message: message } => wrap_result(emit_error_expr(message: message, target: target)) ExprVar { binding_kind: _ } => diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index d8524b9b0cd..64276949c59 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -90,7 +90,8 @@ import v1.compiler.closure_stub_v2_std_integer_rust { closure_stub_v2_std_intege import v1.compiler.closure_stub_v2_std_text_rust { closure_stub_v2_std_text_source } import v1.compiler.coercion { coerce_primitive_type, is_copy, lookup_checkpoint, type_reference_decl_file, - rust_seed_host_numeric_alias, target_callable, rust_lookup_exact_binding + rust_seed_host_numeric_alias, target_callable, rust_lookup_exact_binding, + declaration_realizes_natively_on_rust } import v1.compiler.trait_derive_emit { v1_emit_enum_derives, @@ -113,7 +114,14 @@ import v1.compiler.trait_bound_witness { import std.types { is_container_type, is_kernel_type, container_template_algebra } import std.serialization { CoproductWireContract, VariantEncoding, VariantNaming } -import v1.compiler.infer_env { TypeEnv, TypeBinding, authored_name, lookup_type_by_name, lookup_type_for, GlobalBareLookupState, GlobalBareUniqueBinding, GlobalBareAmbiguousBinding, empty_symbol_index } +import v1.compiler.infer_env { TypeEnv, TypeBinding, authored_name, lookup_type_by_name, lookup_type_for, GlobalBareLookupState, GlobalBareUniqueBinding, GlobalBareAmbiguousBinding, empty_symbol_index, binding_declares_span, type_reference_declaration_ref } +import std.operator_realization { + OperatorRealization, HostOperator, StructuralEquality, StructuralComparison, OperatorRealizationRefused, + OperandRealization, HostNumericOperand, StructuralOperand, OperandIdentityUnavailable, + StructuralOrderingBinding, OrderingTest, OrderingIs, OrderingIsNot, + operator_realization_for, operator_realization_refusal_message +} +import gunbc.structural_realization_bindings { structural_ordering_rows } import v1.compiler.infer_types { resolved_type, normalize_access_type_node, for_each_element_type_node, child_type_node, emit_map_has, @@ -642,35 +650,9 @@ fn rust_render_checkpoint_scalar_bare(n: Node, source_indices: Map Bool { - match binding.resolved.ident_span { - Present { value: s } => s.file == sp.file && s.start == sp.start - Absent => false - } -} - -fn type_reference_declaration_ref(n: Node, source_indices: Map, env: TypeEnv) -> DeclarationRef? { - let rt = match n.inferred { - Present { value: Resolved { node: r } } => r - _ => n - } - let decl_name = qualified_last_segment(name: authored_name_at(source_indices: source_indices, node: rt)) - if decl_name == "" { return none } - match rt.ident_span { - Absent => none - Present { value: sp } => - match map_get(env.symbol_index.global_bare, decl_name) { - Present { value: GlobalBareUniqueBinding { module_path: mp, binding: b } } => - if binding_declares_span(binding: b, sp: sp) { Present { value: decl_ref(module_path: mp, decl_name: decl_name) } } else { none } - Present { value: GlobalBareAmbiguousBinding { candidates: cands } } => - match cands |> filter(c => binding_declares_span(binding: c.binding, sp: sp)) |> first { - Present { value: c } => Present { value: decl_ref(module_path: c.module_path, decl_name: decl_name) } - Absent => none - } - Absent => none - } - } -} +// binding_declares_span and type_reference_declaration_ref are RELOCATED to v1.compiler.infer_env +// (XL-0N, adhoc-aec65f93-b00): inference now asks the same exact-identity question at every literal +// boundary, and infer_env is the module both stages already import -- one reader, two consumers. // The four arms of the exact resolver, rendered. Two answer a spelling; two are LOUD in the emitted // bytes -- a declaration bound to a representation with no realization row, and two rows for one @@ -11906,6 +11888,57 @@ fn emit_typed_bin_op(op: BinOp, algebra_field: AlgebraFieldKind?, left: Node, ri if is_null_coalesce(op: op) { emit_null_coalesce(l_str: l_str, r_str: r_str, target: Rust) } else { + match binop_operator_realization(op: op, left: left, scope: scope) { + OperatorRealizationRefused { cause: c } => + emit_rust_compile_error_expr(message: operator_realization_refusal_message(cause: c)) + StructuralComparison { declaration: _, binding: b, test: t } => + emit_rust_structural_comparison(l_str: l_str, r_str: r_str, binding: b, test: t) + StructuralEquality { declaration: _ } => + emit_rust_host_bin_op(op: op, algebra_field: algebra_field, left: left, right: right, l_str: l_str, r_str: r_str, scope: scope) + HostOperator => + emit_rust_host_bin_op(op: op, algebra_field: algebra_field, left: left, right: right, l_str: l_str, r_str: r_str, scope: scope) + } + } +} + +// OPERATOR REALIZATION BY EXACT OPERAND STRUCTURE (std.operator_realization). The operand's +// declaration is read by identity (v1.compiler.infer_env type_reference_declaration_ref) and its +// native realization asked of the same authority the type renderer asks (v1.compiler.coercion): +// a host numeric keeps the host token; a structural declaration renders equality structurally +// (the emitted enum derives PartialEq over its own constructors) and an ordering as a call to its +// declared comparison tested against std.algebra Ordering; arithmetic on a structural operand +// refuses, typed and located, instead of emitting a token rustc refuses under E0369 later. +fn rust_operand_realization(operand: Node, scope: InferScope) -> OperandRealization { + let rt = resolved_type(n: operand) + match type_reference_declaration_ref(n: rt, source_indices: scope.type_env.source_indices, env: scope.type_env) { + Absent => OperandIdentityUnavailable + Present { value: d } => + if declaration_realizes_natively_on_rust(declaration: d, decl_file: type_reference_decl_file(n: rt)) { + HostNumericOperand + } else { + StructuralOperand { declaration: d } + } + } +} + +fn binop_operator_realization(op: BinOp, left: Node, scope: InferScope) -> OperatorRealization { + operator_realization_for(op: op, operand: rust_operand_realization(operand: left, scope: scope), ordering_rows: structural_ordering_rows) +} + +fn rust_declaration_path(module_path: String, decl_name: String) -> String { + concat("crate::", module_to_filename(name: module_path), "::", emit_ident(name: decl_name, target: Rust)) +} + +fn emit_rust_structural_comparison(l_str: String, r_str: String, binding: StructuralOrderingBinding, test: OrderingTest) -> String { + let call = concat(rust_declaration_path(module_path: binding.compare.module_path as String, decl_name: binding.compare.decl_name as String), "(", l_str, ", ", r_str, ")") + let ordering = concat("crate::", module_to_filename(name: binding.ordering.module_path as String), "::", binding.ordering.decl_name as String) + match test { + OrderingIs { variant: v } => concat("(", call, " == ", ordering, "::", v as String, ")") + OrderingIsNot { variant: v } => concat("(", call, " != ", ordering, "::", v as String, ")") + } +} + +fn emit_rust_host_bin_op(op: BinOp, algebra_field: AlgebraFieldKind?, left: Node, right: Node, l_str: String, r_str: String, scope: InferScope) -> String { let op_str = emit_bin_op_symbol(op: op, target: Rust, algebra_field: algebra_field) if is_string_comparison(op: op, left: left, right: right, source_indices: scope.type_env.source_indices) { let l_optional = is_optional_typed_expr(e: left) @@ -11926,7 +11959,6 @@ fn emit_typed_bin_op(op: BinOp, algebra_field: AlgebraFieldKind?, left: Node, ri concat("(", l_str, " ", op_str, " ", r_str, ")") } } - } } fn is_optional_typed_expr(e: Node) -> Bool { diff --git a/src/v1/coercion.dag b/src/v1/coercion.dag index 214d0fd7bc9..30559ff39ba 100644 --- a/src/v1/coercion.dag +++ b/src/v1/coercion.dag @@ -338,6 +338,19 @@ fn rust_exact_realization_decision(source: DeclarationRef?) -> TypeRealizationDe // carries a verdict in gunbc.rust_source_type_bindings, and a name with no verdict is not a table // row at all (false here means the spelling-keyed arm refuses for it). Consulted by // type_realization_decision ahead of the table so a Migrated name cannot be answered by spelling. +// Whether a DECLARATION realizes natively on the Rust target: the exact binding first +// (gunbc.rust_source_type_bindings), then the spelling-keyed checkpoint under the declaration's own +// identity gate (lookup_checkpoint, which refuses a known structural declaration and honours the +// bare-row verdicts). This is the ONE question std.literal_elaboration and std.operator_realization +// ask of the target (XL-0N): a native declaration takes the kernel literal and the host operator +// directly; anything else is a structural operand. +fn declaration_realizes_natively_on_rust(declaration: DeclarationRef, decl_file: String) -> Bool { + match rust_exact_realization_decision(source: Present { value: declaration }) { + Realized { checkpoint: _ } => true + _ => lookup_checkpoint(target: Rust, dag_name: declaration.decl_name as String, decl_file: decl_file) != none + } +} + fn rust_checkpoint_row_keeps_bare_row(dag_name: String) -> Bool { if dag_name == "" { false } else { diff --git a/src/v1/compile.dag b/src/v1/compile.dag index f1b21bf910a..58570153775 100644 --- a/src/v1/compile.dag +++ b/src/v1/compile.dag @@ -637,6 +637,8 @@ fn serialize_expr_data(expr_node: Node, source_indices: Map "{\"kind\": \"NoExprData\"}" ExprLiteral { value: value } => concat("{\"kind\": \"ExprLiteral\", \"value\": ", serialize_literal(value: value), "}") + ExprElaboratedLiteral { value: value, elaboration: _ } => + concat("{\"kind\": \"ExprElaboratedLiteral\", \"value\": ", serialize_literal(value: value), "}") ExprError { kind: kind, message: message } => concat( "{\"kind\": \"ExprError\", \"error_kind\": ", json_quote(s: expr_error_kind_name(value: kind)), diff --git a/src/v1/complexity.dag b/src/v1/complexity.dag index bee6c3bd817..0588e869099 100644 --- a/src/v1/complexity.dag +++ b/src/v1/complexity.dag @@ -38,7 +38,7 @@ import std.computation { } import std.syntax { BinOp, LiteralValue } import v1.std.core { - Node, NewlineIndex, ExprData, ExprLiteral, ExprError, ExprVar, ExprFieldAccess, ExprCall, + Node, NewlineIndex, ExprData, ExprLiteral, ExprElaboratedLiteral, ExprError, ExprVar, ExprFieldAccess, ExprCall, ExprMethodCall, ExprBinOp, ExprUnaryOp, Sub, Div, ExprMatch, ExprIf, ExprLet, ExprRecordLit, ExprBlock, ExprForEach, ExprReturn, ExprLambda, MatchPattern, Bind, VariantPattern, field_init_node_name_at, field_init_node_value, arg_name_at, arg_value, arm_body, arm_guard, @@ -4143,6 +4143,17 @@ fn cost_of_expr(texpr: Node, func_index: Map, scc_index: Map< table: table } + ExprElaboratedLiteral { value: _, elaboration: _ } => + SummaryResult { + summary: ComplexitySummary { + work: CostConst { value: 1 }, + span: CostConst { value: 1 }, + output_size: empty_map(), + certainty: Proven + }, + table: table + } + ExprError { kind: _, message: _ } => SummaryResult { summary: ComplexitySummary { diff --git a/src/v1/dag_collect_support.dag b/src/v1/dag_collect_support.dag index ffcac39d682..a47275cec2a 100644 --- a/src/v1/dag_collect_support.dag +++ b/src/v1/dag_collect_support.dag @@ -3,7 +3,7 @@ module v1.compiler.dag_collect_support import v1.std.core { Node, InferredNode, Resolved, CompilerError, TypeVariable, - ExprData, + ExprData, ExprElaboratedLiteral, Connective, NoConnective, Arrow, MatchPattern, Bind, LitPattern, VariantPattern, Wildcard, SourceSpan, ErrorNode, make_error_node, InternalError @@ -55,6 +55,7 @@ fn expr_data_variant(data: ExprData) -> String { match data { NoExprData => "NoExprData" ExprLiteral { value: _ } => "ExprLiteral" + ExprElaboratedLiteral { value: _, elaboration: _ } => "ExprElaboratedLiteral" ExprError { kind: _, message: _ } => "ExprError" ExprVar { binding_kind: _ } => "ExprVar" ExprFieldAccess { summary: _ } => "ExprFieldAccess" diff --git a/src/v1/ownership.dag b/src/v1/ownership.dag index 22ff1662a46..8dec0b7ad43 100644 --- a/src/v1/ownership.dag +++ b/src/v1/ownership.dag @@ -3,7 +3,7 @@ module v1.compiler.ownership import v1.std.core { Node, ExprData, NoExprData, ExprError, - ExprLiteral, ExprVar, ExprFieldAccess, ExprCall, ExprMethodCall, + ExprLiteral, ExprElaboratedLiteral, ExprVar, ExprFieldAccess, ExprCall, ExprMethodCall, ExprMatch, ExprIf, ExprLet, ExprBlock, ExprReturn, ExprLambda, ExprForEach, ExprRecordLit, VarBindingKind, LocalValueBinding, FunctionValueBinding, @@ -169,6 +169,7 @@ fn walk_expr(accum: UsageAccum, texpr: Node, in_tail: Bool, si: Map accum + ExprElaboratedLiteral { value: _, elaboration: _ } => accum ExprFieldAccess => let base_node = field_access_base(texpr: texpr) @@ -375,6 +376,7 @@ fn collect_callable_refs(texpr: Node, si: Map) -> Set empty_set() } ExprLiteral { value: _ } => empty_set() + ExprElaboratedLiteral { value: _, elaboration: _ } => empty_set() ExprFieldAccess => collect_callable_refs(texpr: field_access_base(texpr: texpr), si: si) ExprCall => diff --git a/src/v1/stage0/src/v1_interpreter.rs b/src/v1/stage0/src/v1_interpreter.rs index 01a7f71bcc3..9c46de5d164 100644 --- a/src/v1/stage0/src/v1_interpreter.rs +++ b/src/v1/stage0/src/v1_interpreter.rs @@ -4657,6 +4657,17 @@ fn eval_expr_inner(node: &Rc, env: &Rc, ctx: &InterpContext) -> Inter match (*node.expr_data).clone() { ExprData::ExprLiteral { value } => eval_literal(&value), + // An elaborated literal evaluates as its image under the selected homomorphism + // (std.literal_elaboration): the child is ordinary constructor nodes of the destination, + // which the interpreter's own numeric grounding folds exactly as authored ones. + ExprData::ExprElaboratedLiteral { .. } => match node.children.get(0) { + Some(image) => eval_expr(image, env, ctx), + None => Err(InterpError::TypeError { + msg: "elaborated literal carries no image (v1.compiler.infer unfold_literal_image)" + .to_string(), + }), + }, + ExprData::ExprVar { binding_kind } => eval_var(node, binding_kind.as_deref(), env, ctx), ExprData::ExprBinOp { op, .. } => { @@ -9639,6 +9650,7 @@ pub(crate) fn expr_data_form_name(expr_data: &ExprData) -> &'static str { match expr_data { ExprData::NoExprData => "NoExprData", ExprData::ExprLiteral { .. } => "ExprLiteral", + ExprData::ExprElaboratedLiteral { .. } => "ExprElaboratedLiteral", ExprData::ExprError { .. } => "ExprError", ExprData::ExprVar { .. } => "ExprVar", ExprData::ExprFieldAccess { .. } => "ExprFieldAccess", @@ -16206,7 +16218,7 @@ pub fn list_cons_tail_split_snapshot() -> (u64, u64) { ) } -pub const EXPR_VARIANT_COUNT: usize = 22; +pub const EXPR_VARIANT_COUNT: usize = 23; fn expr_variant_index(d: &ExprData) -> usize { match d { @@ -16232,6 +16244,7 @@ fn expr_variant_index(d: &ExprData) -> usize { ExprData::ExprIndex => 19, ExprData::ExprSlice => 20, ExprData::ExprReturn => 21, + ExprData::ExprElaboratedLiteral { .. } => 22, } } @@ -16259,6 +16272,7 @@ pub fn expr_variant_name(i: usize) -> &'static str { "ExprIndex", "ExprSlice", "ExprReturn", + "ExprElaboratedLiteral", ]; NAMES.get(i).copied().unwrap_or("?") } diff --git a/src/v2/std/integer.dag b/src/v2/std/integer.dag index 17aec4a2b12..e378900fc3f 100644 --- a/src/v2/std/integer.dag +++ b/src/v2/std/integer.dag @@ -29,7 +29,7 @@ import v2.std.machine { Word64, Word128 } -import v2.std.nat { Nat } +import v2.std.nat { Nat, Zero, Succ, NatQuotient, nat_div_rem_by_succ } import v2.std.text { Char, CharAbsent, CharFound, String, string_head, string_tail } type Int = GroupCompletion type UInt = v2.std.nat.Nat @@ -1306,41 +1306,97 @@ fn integer_signed_i32_le_bytes_to_int(bytes: List) -> Outcome { } } +// ONE GLYPH TABLE for the ten decimal digits, keyed on the DecimalDigit coproduct this module +// already owns; both the Peano and the machine-integer renderings below reach it through their +// own digit selection rather than each carrying a second copy of the ten glyphs. +fn decimal_digit_glyph(d: DecimalDigit) -> String { + match d { + D0 => "0" + D1 => "1" + D2 => "2" + D3 => "3" + D4 => "4" + D5 => "5" + D6 => "6" + D7 => "7" + D8 => "8" + D9 => "9" + } +} + +// The Peano value of each decimal digit. Every arm is a kernel integer literal at a +// v2.std.nat.Nat return boundary: the literal elaborates through the declared homomorphism +// (gunbc.structural_realization_bindings literal_homomorphism_rows) to its Zero/Succ image -- +// this function is the return-position exemplar of std.literal_elaboration. +fn decimal_digit_nat(d: DecimalDigit) -> v2.std.nat.Nat { + match d { + D0 => 0 + D1 => 1 + D2 => 2 + D3 => 3 + D4 => 4 + D5 => 5 + D6 => 6 + D7 => 7 + D8 => 8 + D9 => 9 + } +} + +// A Peano digit (a Nat below ten) to its glyph: select the DecimalDigit whose Peano value equals +// the digit by STRUCTURAL equality (std.operator_realization StructuralEquality on v2.std.nat.Nat), +// then read the one glyph table. A digit outside the roster (ten or more) is not a decimal digit +// and this function is not its authority: the caller obtains digits from nat_div_rem_by_succ by +// ten, whose remainder is below ten by construction, so the fold's D0 seed is never the answer +// for an in-domain input. fn integer_nat_decimal_digit_char(digit: v2.std.nat.Nat) -> String { - if digit == 0 { - "0" - } else if digit == 1 { - "1" - } else if digit == 2 { - "2" - } else if digit == 3 { - "3" - } else if digit == 4 { - "4" - } else if digit == 5 { - "5" - } else if digit == 6 { - "6" - } else if digit == 7 { - "7" - } else if digit == 8 { - "8" + decimal_digit_glyph(d: fold_list( + xs: decimal_digit_roster, + empty: D0, + cons: fn(acc, d) { if decimal_digit_nat(d: d) == digit { d } else { acc } } + )) +} + +// PEANO NAT TO DECIMAL TEXT over the DECLARED structural operations: division by ten is +// nat_div_rem_by_succ with divisor predecessor nine (the divisor Succ { prev: 9 } is nonzero by +// construction, so no zero-divisor arm exists to be handled), and the recursion descends on the +// quotient. The literal 9 elaborates at the argument boundary (std.literal_elaboration). No host +// operator is applied to a Nat here: the previous body spelled `value == 0`, `value < 10`, +// `value / 10` and `value - (rest * 10)` on Rc, which rustc refused (E0308 x10, E0369) and +// which the operator realization authority now refuses at emission by typed diagnostic instead. +fn integer_nat_to_decimal_string(value: v2.std.nat.Nat) -> String { + let q = nat_div_rem_by_succ(a: value, divisor_prev: 9) + match q.quotient { + Zero => integer_nat_decimal_digit_char(digit: q.remainder) + Succ { prev: _ } => + concat( + integer_nat_to_decimal_string(value: q.quotient), + integer_nat_decimal_digit_char(digit: q.remainder) + ) + } +} + +// MACHINE INTEGER TO DECIMAL TEXT. Int realizes as the host integer, so host division and +// remainder are its declared operations (std.operator_realization HostOperator); the digit glyph +// comes from the same one table. This is the formatter the two Int-valued callers that previously +// passed an Int into the Nat renderer's parameter (v2.std.native_agreement octet_display, +// v2.workflow.realization_sweep sweep_histogram_tsv) actually asked for -- the interpreter's +// numeric grounding made that mismatch invisible there, and the emitted closure refused it +// (E0308 Rc vs integer). +fn integer_int_to_decimal_string(value: Int) -> String { + if value < 0 { + concat("-", integer_int_magnitude_to_decimal_string(value: 0 - value)) } else { - "9" + integer_int_magnitude_to_decimal_string(value: value) } } -fn integer_nat_to_decimal_string(value: v2.std.nat.Nat) -> String { - if value == 0 { - "0" - } else if value < 10 { - integer_nat_decimal_digit_char(digit: value) +fn integer_int_magnitude_to_decimal_string(value: Int) -> String { + let rest = value / 10 + let digit = decimal_digit_glyph(d: decimal_digit_of_units(value: value - (rest * 10))) + if rest == 0 { + digit } else { - let rest = value / 10 - let digit = value - (rest * 10) - concat( - integer_nat_to_decimal_string(value: rest), - integer_nat_decimal_digit_char(digit: digit) - ) + concat(integer_int_magnitude_to_decimal_string(value: rest), digit) } } diff --git a/src/v2/std/nat.dag b/src/v2/std/nat.dag index 70218c5b9e4..90086d36995 100644 --- a/src/v2/std/nat.dag +++ b/src/v2/std/nat.dag @@ -26,15 +26,78 @@ fn nat_mul(a: Nat, b: Nat) -> Nat { nat_cata(n: a, zero: Zero, succ: fn(acc) { nat_add(a: b, b: acc) }) } +// THE DECLARED ORDERING OF THE PEANO NATURALS, by exact operand structure: two Zeros are Equal, +// Zero precedes any Succ, and two Succs compare as their predecessors. This is the comparison the +// operator realization authority calls for `<`, `<=`, `>`, `>=` on v2.std.nat.Nat operands +// (gunbc.structural_realization_bindings structural_ordering_rows -> std.operator_realization), +// so it must not itself be written with a host ordering operator on Nat -- the previous body +// (`if a == b .. if a < b`) was exactly the host `<` on Rc that rustc refused (E0369). fn nat_compare(a: Nat, b: Nat) -> Ordering { - if a == b { - Equal - } else { - if a < b { - Less - } else { - Greater - } + match a { + Zero => + match b { + Zero => Equal + Succ { prev: _ } => Less + } + Succ { prev: pa } => + match b { + Zero => Greater + Succ { prev: pb } => nat_compare(a: pa, b: pb) + } + } +} + +// TRUNCATED SUBTRACTION (monus) WITH A TYPED UNDERFLOW OUTCOME. The naturals are not closed under +// subtraction; a - b for b > a has no answer here and says so as its own arm, never a wrapped or +// fabricated Zero. +type NatSubtraction + = NatDifference { value: Nat } + | NatSubtrahendExceedsMinuend + +fn nat_sub(a: Nat, b: Nat) -> NatSubtraction { + match b { + Zero => NatDifference { value: a } + Succ { prev: pb } => + match a { + Zero => NatSubtrahendExceedsMinuend + Succ { prev: pa } => nat_sub(a: pa, b: pb) + } + } +} + +// EUCLIDEAN DIVISION WITH A TYPED ZERO-DIVISOR OUTCOME. nat_div_rem is the general operation: a +// Zero divisor is its own arm. nat_div_rem_by_succ is the TOTAL form for a divisor that is nonzero +// BY CONSTRUCTION -- the caller supplies the divisor's predecessor, so the divisor Succ { prev } +// cannot be Zero and no zero-divisor arm exists to handle (DESIGN section 4b, the top rung: the +// invalid state has no constructor). A caller dividing by a literal that it knows is nonzero +// (decimal conversion by ten) uses the by-succ form rather than matching a zero arm it cannot reach. +type NatQuotient { + quotient: Nat + remainder: Nat +} + +type NatDivision + = NatQuotientRemainder { quotient: Nat, remainder: Nat } + | NatDivisionByZero + +fn nat_div_rem(a: Nat, b: Nat) -> NatDivision { + match b { + Zero => NatDivisionByZero + Succ { prev: divisor_prev } => + let q = nat_div_rem_by_succ(a: a, divisor_prev: divisor_prev) + NatQuotientRemainder { quotient: q.quotient, remainder: q.remainder } + } +} + +fn nat_div_rem_by_succ(a: Nat, divisor_prev: Nat) -> NatQuotient { + nat_div_rem_by_succ_accumulate(a: a, divisor_prev: divisor_prev, quotient: Zero) +} + +fn nat_div_rem_by_succ_accumulate(a: Nat, divisor_prev: Nat, quotient: Nat) -> NatQuotient { + match nat_sub(a: a, b: Succ { prev: divisor_prev }) { + NatSubtrahendExceedsMinuend => NatQuotient { quotient: quotient, remainder: a } + NatDifference { value: rest } => + nat_div_rem_by_succ_accumulate(a: rest, divisor_prev: divisor_prev, quotient: Succ { prev: quotient }) } } diff --git a/src/v2/std/native_agreement.dag b/src/v2/std/native_agreement.dag index 8f750e259e9..1bcefe17c34 100644 --- a/src/v2/std/native_agreement.dag +++ b/src/v2/std/native_agreement.dag @@ -11,7 +11,7 @@ import v2.std.optional { Absent } import v2.std.logic { Bool } -import v2.std.integer { integer_nat_to_decimal_string } +import v2.std.integer { integer_int_to_decimal_string } import v2.std.runtime { RuntimePrimitive, RuntimePrimitiveValue, RuntimeValue } import v2.std.text { String } @@ -24,13 +24,7 @@ type NativeAgreementDivergence { data native_agreement_authority_note: String = "Native-vs-interpreted agreement loudness (ROADMAP 2a Lane B, 2026-07-23): when emit_on_demand family-crate per-PR agreement redds, the floor receipt MUST name the failing member and BOTH runtime answers — the srv2-05 revert (#7091, routed_flip_reverted_note) carried compile_skipped=true x3 then Bool(false) with member and values unknown. This module is the typed divergence carrier + formatter; claim_executor invokes the companion *_failure_receipt fn on Bool(false) witnesses. Verdict-to-divergence extraction lives in v2.compiler.self_host.native_agreement_support (acyclicity: the compiler layer imports std, so std cannot import compiler back)." fn octet_display(octet: Int) -> String { - if octet == 0 { - "0" - } else if octet == 1 { - "1" - } else { - integer_nat_to_decimal_string(value: octet) - } + integer_int_to_decimal_string(value: octet) } fn runtime_value_discriminant_octet(value: RuntimeValue) -> Optional { diff --git a/src/v2/test/claim/self_host/peano_nat_structural_realization_test.dag b/src/v2/test/claim/self_host/peano_nat_structural_realization_test.dag new file mode 100644 index 00000000000..b7c24cacb93 --- /dev/null +++ b/src/v2/test/claim/self_host/peano_nat_structural_realization_test.dag @@ -0,0 +1,236 @@ +module v2.test.claim.self_host.peano_nat_structural_realization_test + +import std.types { Bool, Int, String, List } +import std.algebra { Ordering, Less, Equal, Greater } +import std.decl_ref { decl_ref } +import std.literal_elaboration { + KernelIntLiteral, KernelStringLiteral, + LiteralHomomorphismFound, LiteralHomomorphismAbsent, LiteralHomomorphismAmbiguous, + DirectLiteral, ViaHomomorphism, LiteralElaborationRefused, + PeanoUnfold, + literal_homomorphism_for, elaborate_literal_at +} +import std.operator_realization { + HostNumericOperand, StructuralOperand, OperandIdentityUnavailable, + HostOperator, StructuralEquality, StructuralComparison, OperatorRealizationRefused, + NoStructuralOperationDeclared, OrderingIs, OrderingIsNot, + operator_realization_for +} +import std.syntax { BinOp, Lt, Le, Gt, Ge, Eq, Div, Mod, Sub, And } +import gunbc.structural_realization_bindings { literal_homomorphism_rows, structural_ordering_rows } +import v2.std.nat { + Nat, Zero, Succ, + NatDifference, NatSubtrahendExceedsMinuend, + NatQuotientRemainder, NatDivisionByZero, + nat_compare, nat_sub, nat_div_rem, nat_div_rem_by_succ +} +import v2.std.integer { integer_nat_to_decimal_string, integer_int_to_decimal_string, decimal_digit_nat, D0, D7 } + +// FALSIFIERS FOR THE STRUCTURAL PEANO NAT REALIZATION (XL-0N, adhoc-aec65f93-b00), the +// interpreter-executed half. The emitted-bytes half -- that a kernel literal at a v2.std.nat.Nat +// boundary renders as its Zero/Succ image, that `<` on Nat renders as a call to nat_compare tested +// against std.algebra Ordering, that infix arithmetic on Nat refuses in the emitted bytes -- lives +// in test.claim.self_host_peano_literal_operator_realization_witness_test, because it must run the +// production emitter through compile_dag_rust_emit_check. +// +// Two subjects here. (1) The declared structural operations on v2.std.nat.Nat behave on NONTRIVIAL +// Succ values -- not merely on Zero and one -- which is what a reader of `nat_compare` as a two-arm +// match would otherwise take on faith. (2) The generic authorities decide by the ROW and by exact +// identity: the same literal into the native std.nat.Nat is Direct, into the Peano v2.std.nat.Nat +// is ViaHomomorphism, and with the row REMOVED it is Direct again -- which is exactly the state in +// which the emitted bytes carried a bare digit against Rc (the E0308 identities of XL-0's +// census). That last row is the executable form of "removing the elaboration row brings the +// E0308 identities back": the decision the emitter consumes flips, so the bytes flip. + +fn three() -> Nat { Succ { prev: Succ { prev: Succ { prev: Zero } } } } +fn five() -> Nat { Succ { prev: Succ { prev: three() } } } +fn seven() -> Nat { Succ { prev: Succ { prev: five() } } } + +test fn nat_compare_orders_nontrivial_succ_values() -> Bool { + nat_compare(a: three(), b: five()) == Less + && nat_compare(a: five(), b: three()) == Greater + && nat_compare(a: five(), b: five()) == Equal + && nat_compare(a: Zero, b: three()) == Less + && nat_compare(a: three(), b: Zero) == Greater +} + +test fn nat_sub_answers_underflow_as_its_own_arm() -> Bool { + let difference_holds = match nat_sub(a: seven(), b: five()) { + NatDifference { value: d } => nat_compare(a: d, b: Succ { prev: Succ { prev: Zero } }) == Equal + NatSubtrahendExceedsMinuend => false + } + let underflow_holds = match nat_sub(a: three(), b: five()) { + NatDifference { value: _ } => false + NatSubtrahendExceedsMinuend => true + } + difference_holds && underflow_holds +} + +test fn nat_div_rem_divides_nontrivial_values() -> Bool { + match nat_div_rem(a: seven(), b: Succ { prev: Succ { prev: Zero } }) { + NatQuotientRemainder { quotient: q, remainder: r } => + nat_compare(a: q, b: three()) == Equal && nat_compare(a: r, b: Succ { prev: Zero }) == Equal + NatDivisionByZero => false + } +} + +test fn nat_div_rem_by_zero_is_typed() -> Bool { + match nat_div_rem(a: seven(), b: Zero) { + NatQuotientRemainder { quotient: _, remainder: _ } => false + NatDivisionByZero => true + } +} + +test fn nat_div_rem_by_succ_has_no_zero_arm_and_divides() -> Bool { + let q = nat_div_rem_by_succ(a: seven(), divisor_prev: Succ { prev: Succ { prev: Zero } }) + nat_compare(a: q.quotient, b: Succ { prev: Succ { prev: Zero } }) == Equal + && nat_compare(a: q.remainder, b: Succ { prev: Zero }) == Equal +} + +test fn nat_to_decimal_converts_nontrivial_values() -> Bool { + integer_nat_to_decimal_string(value: Zero) == "0" + && integer_nat_to_decimal_string(value: seven()) == "7" + && integer_nat_to_decimal_string(value: Succ { prev: Succ { prev: Succ { prev: seven() } } }) == "10" + && integer_nat_to_decimal_string(value: 23) == "23" +} + +test fn decimal_digit_nat_supplies_the_peano_value() -> Bool { + nat_compare(a: decimal_digit_nat(d: D0), b: Zero) == Equal + && nat_compare(a: decimal_digit_nat(d: D7), b: seven()) == Equal +} + +test fn int_to_decimal_is_the_machine_integer_formatter() -> Bool { + integer_int_to_decimal_string(value: 0) == "0" + && integer_int_to_decimal_string(value: 42) == "42" + && integer_int_to_decimal_string(value: 0 - 7) == "-7" + && integer_int_to_decimal_string(value: 1000) == "1000" +} + +// --------------------------------------------------------------------------------------------- +// The generic authorities, decided by row and by exact identity. +// --------------------------------------------------------------------------------------------- + +test fn peano_row_is_found_by_exact_destination() -> Bool { + match literal_homomorphism_for(rows: literal_homomorphism_rows, source_kind: KernelIntLiteral, destination: decl_ref(module_path: "v2.std.nat", decl_name: "Nat")) { + LiteralHomomorphismFound { row: r } => + match r.producer { + PeanoUnfold { zero: z, succ: s, prev_field: p } => + (z.decl_name as String) == "Zero" && (s.decl_name as String) == "Succ" && (p as String) == "prev" + } + LiteralHomomorphismAbsent => false + LiteralHomomorphismAmbiguous { row_count: _ } => false + } +} + +// Same spelling, different declaration: the native std.nat Nat has no row and is Direct. +test fn same_spelling_native_declaration_is_direct() -> Bool { + match elaborate_literal_at(rows: literal_homomorphism_rows, source_kind: KernelIntLiteral, destination: decl_ref(module_path: "std.nat", decl_name: "Nat"), destination_realizes_natively: true) { + DirectLiteral => true + ViaHomomorphism { homomorphism: _ } => false + LiteralElaborationRefused { cause: _ } => false + } +} + +test fn peano_destination_elaborates_via_the_homomorphism() -> Bool { + match elaborate_literal_at(rows: literal_homomorphism_rows, source_kind: KernelIntLiteral, destination: decl_ref(module_path: "v2.std.nat", decl_name: "Nat"), destination_realizes_natively: false) { + DirectLiteral => false + ViaHomomorphism { homomorphism: h } => (h.destination.decl_name as String) == "Nat" + LiteralElaborationRefused { cause: _ } => false + } +} + +// THE ROW-REMOVAL FALSIFIER. With no rows the same boundary is Direct -- the literal stays a bare +// kernel digit, which against an Rc parameter is precisely the E0308 shape the census held. +test fn removing_the_row_returns_the_literal_to_direct() -> Bool { + match elaborate_literal_at(rows: [], source_kind: KernelIntLiteral, destination: decl_ref(module_path: "v2.std.nat", decl_name: "Nat"), destination_realizes_natively: false) { + DirectLiteral => true + ViaHomomorphism { homomorphism: _ } => false + LiteralElaborationRefused { cause: _ } => false + } +} + +// A kernel STRING literal into the Peano Nat has no row: the source kind is part of the key. +test fn source_kind_is_part_of_the_key() -> Bool { + match literal_homomorphism_for(rows: literal_homomorphism_rows, source_kind: KernelStringLiteral, destination: decl_ref(module_path: "v2.std.nat", decl_name: "Nat")) { + LiteralHomomorphismFound { row: _ } => false + LiteralHomomorphismAbsent => true + LiteralHomomorphismAmbiguous { row_count: _ } => false + } +} + +// Two rows for one key refuse rather than picking one. +test fn duplicated_row_refuses() -> Bool { + let doubled = concat(literal_homomorphism_rows, literal_homomorphism_rows) + match elaborate_literal_at(rows: doubled, source_kind: KernelIntLiteral, destination: decl_ref(module_path: "v2.std.nat", decl_name: "Nat"), destination_realizes_natively: false) { + DirectLiteral => false + ViaHomomorphism { homomorphism: _ } => false + LiteralElaborationRefused { cause: _ } => true + } +} + +test fn ordering_on_the_peano_operand_calls_the_declared_comparison() -> Bool { + let nat = decl_ref(module_path: "v2.std.nat", decl_name: "Nat") + match operator_realization_for(op: Lt, operand: StructuralOperand { declaration: nat }, ordering_rows: structural_ordering_rows) { + StructuralComparison { declaration: _, binding: b, test: t } => + (b.compare.decl_name as String) == "nat_compare" + && (b.ordering.module_path as String) == "std.algebra" + && match t { OrderingIs { variant: v } => (v as String) == "Less" OrderingIsNot { variant: _ } => false } + _ => false + } +} + +test fn non_strict_ordering_negates_the_opposite_variant() -> Bool { + let nat = decl_ref(module_path: "v2.std.nat", decl_name: "Nat") + match operator_realization_for(op: Le, operand: StructuralOperand { declaration: nat }, ordering_rows: structural_ordering_rows) { + StructuralComparison { declaration: _, binding: _, test: t } => + match t { OrderingIs { variant: _ } => false OrderingIsNot { variant: v } => (v as String) == "Greater" } + _ => false + } +} + +test fn equality_on_the_peano_operand_is_structural() -> Bool { + match operator_realization_for(op: Eq, operand: StructuralOperand { declaration: decl_ref(module_path: "v2.std.nat", decl_name: "Nat") }, ordering_rows: structural_ordering_rows) { + StructuralEquality { declaration: d } => (d.decl_name as String) == "Nat" + _ => false + } +} + +// FORCING HOST ARITHMETIC ONTO A PEANO OPERAND REDS: the decision refuses, typed, naming the +// declaration and the operator. The emitted-bytes form of this row is in the emit-check witness. +fn host_arithmetic_on_peano_refuses(op: BinOp) -> Bool { + match operator_realization_for(op: op, operand: StructuralOperand { declaration: decl_ref(module_path: "v2.std.nat", decl_name: "Nat") }, ordering_rows: structural_ordering_rows) { + OperatorRealizationRefused { cause: NoStructuralOperationDeclared { declaration: d, operator: _ } } => (d.decl_name as String) == "Nat" + _ => false + } +} + +test fn host_arithmetic_on_the_peano_operand_refuses() -> Bool { + host_arithmetic_on_peano_refuses(op: Div) && host_arithmetic_on_peano_refuses(op: Mod) && host_arithmetic_on_peano_refuses(op: Sub) +} + +// A structural declaration with NO ordering row refuses `<` rather than emitting the host token. +test fn ordering_without_a_declared_comparison_refuses() -> Bool { + match operator_realization_for(op: Gt, operand: StructuralOperand { declaration: decl_ref(module_path: "v2.std.text", decl_name: "String") }, ordering_rows: structural_ordering_rows) { + OperatorRealizationRefused { cause: _ } => true + _ => false + } +} + +test fn host_numeric_operand_keeps_the_host_operator() -> Bool { + let native_holds = match operator_realization_for(op: Div, operand: HostNumericOperand, ordering_rows: structural_ordering_rows) { + HostOperator => true + _ => false + } + let unknown_holds = match operator_realization_for(op: Ge, operand: OperandIdentityUnavailable, ordering_rows: structural_ordering_rows) { + HostOperator => true + _ => false + } + native_holds && unknown_holds +} + +test fn logical_connective_on_a_structural_operand_stays_host() -> Bool { + match operator_realization_for(op: And, operand: StructuralOperand { declaration: decl_ref(module_path: "v2.std.logic", decl_name: "Bool") }, ordering_rows: structural_ordering_rows) { + HostOperator => true + _ => false + } +} diff --git a/src/v2/workflow/realization_sweep.dag b/src/v2/workflow/realization_sweep.dag index f5c7afcc4b5..312a0fd569c 100644 --- a/src/v2/workflow/realization_sweep.dag +++ b/src/v2/workflow/realization_sweep.dag @@ -25,7 +25,7 @@ import v2.compiler.source_authority { source_root_ingest_build_from_source_refs } import v2.std.compilers.lexing { symbol_intern_lexeme, symbol_lexeme } -import v2.std.integer { integer_nat_to_decimal_string } +import v2.std.integer { integer_int_to_decimal_string } import v2.std.optional { Optional, Present, Absent } import v2.std.algebra { fold_list, length } import v2.std.collection { list_at_optional } @@ -338,15 +338,15 @@ fn sweep_histogram_tsv(rows: List) -> String { SweepHistogramState { prev: k, count: 1, - out: if st.out == "" { concat(st.prev, "\t", integer_nat_to_decimal_string(value: st.count)) } else { concat(st.out, "\n", st.prev, "\t", integer_nat_to_decimal_string(value: st.count)) } + out: if st.out == "" { concat(st.prev, "\t", integer_int_to_decimal_string(value: st.count)) } else { concat(st.out, "\n", st.prev, "\t", integer_int_to_decimal_string(value: st.count)) } } } }) if folded.count == 0 { folded.out } else if folded.out == "" { - concat(folded.prev, "\t", integer_nat_to_decimal_string(value: folded.count)) + concat(folded.prev, "\t", integer_int_to_decimal_string(value: folded.count)) } else { - concat(folded.out, "\n", folded.prev, "\t", integer_nat_to_decimal_string(value: folded.count)) + concat(folded.out, "\n", folded.prev, "\t", integer_int_to_decimal_string(value: folded.count)) } } From 0812548d0cc4057238abc9c2cbcb5334eb7b904f Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 06:00:38 +0000 Subject: [PATCH 40/75] XL-0N: the Peano-Nat inhabitance witness asserts the ruled admission through its homomorphism; its expected-red row is retired by its trigger --- ...e_inhabitance_direct_call_witness_test.dag | 24 ++++++++++++------- src/v2/workflow/floor_cost_debt.dag | 2 +- src/v2/workflow/floor_expected_red.dag | 10 +++++++- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/dag/test/claim/declared_type_inhabitance_direct_call_witness_test.dag b/dag/test/claim/declared_type_inhabitance_direct_call_witness_test.dag index d9acd2d48df..b1cd3ca0973 100644 --- a/dag/test/claim/declared_type_inhabitance_direct_call_witness_test.dag +++ b/dag/test/claim/declared_type_inhabitance_direct_call_witness_test.dag @@ -38,16 +38,24 @@ fn violation_count(source: String, wanted: String) -> Int { // which is the whole point of enrolling it: DESIGN 4b(4) keeps the evidence after a climb // precisely so the higher rung stays real. -// RED, AND CURRENTLY FAILING -- ENROLLED IN v2.workflow.floor_expected_red rather than fixed. -// A kernel integer at the PEANO Nat. 5 is not Zero and not Succ and no realization row covers -// src/v2/std/nat.dag, so this OUGHT to refuse. It does not, and the control run on 2026-08-23 -// establishes that it never did: gunbc built from origin/main 907f19c2cc7 admits this source -// exactly as the branch does. The refusal was ASSERTED here, not broken by this change. -// The enrolment row carries the full branch-and-main control table and the next-rung trigger. +// A kernel integer at the PEANO Nat -- RULED ADMITTED THROUGH THE DECLARED HOMOMORPHISM, and this +// row's claim changed with the ruling (XL-0N, adhoc-aec65f93-b00, operator ruling 2026-08-30). +// This row used to assert a refusal (5 is not Zero and not Succ) and sat in +// v2.workflow.floor_expected_red with the trigger "the expected-type-directed literal introduction +// judgment -- the MODEL half -- is NOT built". It is built: std.literal_elaboration elaborates the +// kernel literal at the exact v2.std.nat.Nat boundary through the ONE declared Peano homomorphism +// (gunbc.structural_realization_bindings) into Succ^5(Zero), typed as the destination, so the +// value the inhabitance judgment sees IS a Nat. Admission here is therefore the ruled answer, and +// this row is the positive control for it. The DISCRIMINATING evidence -- that the literal is +// elaborated rather than merely waved through -- is the emitted-bytes witness +// test.claim.self_host_peano_literal_operator_realization_witness_test +// w_literal_at_peano_argument_boundary_emits_its_image, whose forbidden token is exactly the bare +// digit this probe used to carry; the two rows are read together. DESIGN 4b(4): the probe flips +// to a permanent regression control, it does not retire. data peano_nat_arg_source: String = "module probe_inhabit_peano\nimport v2.std.nat { Nat }\nfn takes_peano(n: Nat) -> Int { 1 }\nfn probe() -> Int { takes_peano(n: 5) }\n" -test fn w_kernel_numeric_at_the_peano_nat_is_refused() -> Bool { - violation_count(source: peano_nat_arg_source, wanted: "DeclaredTypeNotInhabited") > 0 +test fn w_kernel_numeric_at_the_peano_nat_is_admitted_through_its_homomorphism() -> Bool { + violation_count(source: peano_nat_arg_source, wanted: "DeclaredTypeNotInhabited") == 0 } // GREEN -- the same literal at the NATIVE Nat. Structurally this is a kernel value at an diff --git a/src/v2/workflow/floor_cost_debt.dag b/src/v2/workflow/floor_cost_debt.dag index e5846ec2d35..7c12e98b075 100644 --- a/src/v2/workflow/floor_cost_debt.dag +++ b/src/v2/workflow/floor_cost_debt.dag @@ -135,7 +135,7 @@ import v2.std.text { String } // test.claim.callable_candidate_ambiguity_witness.a_listed_import_does_not_exclude_a_transitively_reached_homonym // test.claim.callable_candidate_ambiguity_witness.neither_green_source_refuses_and_neither_mis_resolves // test.claim.declared_type_inhabitance_direct_call_witness.w_kernel_numeric_at_the_natively_realized_nat_is_admitted -// test.claim.declared_type_inhabitance_direct_call_witness.w_kernel_numeric_at_the_peano_nat_is_refused +// test.claim.declared_type_inhabitance_direct_call_witness.w_kernel_numeric_at_the_peano_nat_is_admitted_through_its_homomorphism // test.claim.declared_type_inhabitance_list_element_witness.w_declared_coproduct_member_is_accepted // test.claim.declared_type_inhabitance_list_element_witness.w_optional_carrier_is_undecidable_not_refused // test.claim.declared_type_inhabitance_list_element_witness.w_reachability_control_discriminates_on_the_name diff --git a/src/v2/workflow/floor_expected_red.dag b/src/v2/workflow/floor_expected_red.dag index 3bf747da96b..d1be9bf977c 100644 --- a/src/v2/workflow/floor_expected_red.dag +++ b/src/v2/workflow/floor_expected_red.dag @@ -557,8 +557,16 @@ fn floor_expected_red_chunk_13() -> List { // worth leaving on the record rather than editing out: it read the two halves of its own trigger as // one event. The mechanical repair and the literal-introduction model are independent, and only the // first is a predicate repair. +// RETIRED BY ITS TRIGGER (XL-0N, adhoc-aec65f93-b00): the expected-type-directed literal +// introduction judgment is std.literal_elaboration, consumed by v1.compiler.infer at every typed +// boundary, and the ruling (2026-08-30) admits the kernel numeral at the Peano Nat THROUGH its +// declared homomorphism rather than refusing it. The row's witness is renamed to the ruled claim +// (w_kernel_numeric_at_the_peano_nat_is_admitted_through_its_homomorphism) and stays enrolled as +// a permanent control beside the emitted-bytes falsifier in +// test.claim.self_host_peano_literal_operator_realization_witness_test. The chunk stays so the +// roster's shape is unchanged; it carries nothing. fn floor_expected_red_chunk_14() -> List { - Cons { head: "test.claim.declared_type_inhabitance_direct_call_witness.w_kernel_numeric_at_the_peano_nat_is_refused", tail: Empty {} } + Empty {} } // THE LIST-ELEMENT ARM OF THE DIRECT-CALL INHABITANCE WITNESS. It asserts that a wrong element From aa373f93dab31bec5e3fbe8bcba34cae7f531a3b Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 06:20:40 +0000 Subject: [PATCH 41/75] C corrected: InferredTree.facts stays the open PartialFunction; PartialFunction realizes as its algebra struct everywhere (HashMap rows deleted); frontier row dissolved; two TargetChanged admissions The CI floor on 4da6059 showed the facts retyping over-reached: about 120 test and fixture sites plus program.dag / 05_emit_orchestration define InferredTree.facts by a predicate closure, which is exactly what the open carrier is for. inferred_tree / 04_infer / program_partition are restored. The fork was the emitter realizing PartialFunction as HashMap in signature position and as the algebra struct in field position; the PartialFunction HashMap rows in extdeps.languages.rust (types.dag row, the partial_function template) are deleted so one representation stands. EvaluationEnvironment.bindings stays Map (built by map_insert); v2_effect_io_pure's empty environment is empty_map(). The v1 unresolved_method_frontier row for target_model lookup / Primitive(T) is deleted: the slots.lookup -> map_lookup rewrite dissolved its one occurrence. The two TargetChanged binding deltas for admission_from_module_root (frontier_probe, compile_door_ledger) are admitted by exact subject in namespace_wave_admission.rs. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01GXfYKNQTD3VfYyQcnJpxNU --- dag/extdeps/languages/rust/emit.dag | 2 +- dag/extdeps/languages/rust/types.dag | 7 ----- src/v1/04_infer.dag | 8 ----- src/v1/stage0/src/namespace_wave_admission.rs | 31 ++++++++++++++++++- src/v2/compiler/04_infer.dag | 22 ++++++------- src/v2/compiler/inferred_tree.dag | 3 +- src/v2/compiler/program_partition.dag | 2 +- src/v2/extdeps/runtimes/v2_effect_io_pure.dag | 6 +--- 8 files changed, 46 insertions(+), 35 deletions(-) diff --git a/dag/extdeps/languages/rust/emit.dag b/dag/extdeps/languages/rust/emit.dag index 906424fb1be..6246cbbf114 100644 --- a/dag/extdeps/languages/rust/emit.dag +++ b/dag/extdeps/languages/rust/emit.dag @@ -63,7 +63,7 @@ data rust_keywords: Map = { data rust_container_templates: Map = { "list": "Vec<\{0\}>", "set": "BTreeSet<\{0\}>", "pointwise_power": "BTreeSet<\{0\}>", "optional": "Option<\{0\}>", "map": "HashMap<\{0\}, \{1\}>", - "free_monoid": "Vec<\{0\}>", "partial_function": "HashMap<\{0\}, \{1\}>", + "free_monoid": "Vec<\{0\}>", "boolean_algebra": "bool" } diff --git a/dag/extdeps/languages/rust/types.dag b/dag/extdeps/languages/rust/types.dag index 10a211704f1..f5de45d9e21 100644 --- a/dag/extdeps/languages/rust/types.dag +++ b/dag/extdeps/languages/rust/types.dag @@ -58,13 +58,6 @@ data rust_algebra_inhabitants: List = [ import_path: none, is_copy: false }, - { algebra: "PartialFunction", - template: "HashMap<\{0\}, \{1\}>", - arity: 2, - identity_expr: "HashMap::new()", - import_path: none, - is_copy: false }, - { algebra: "FinitelySupportedFunction", template: "HashMap<\{0\}, \{1\}>", arity: 2, diff --git a/src/v1/04_infer.dag b/src/v1/04_infer.dag index a7da42b7336..b9b1a0f2027 100644 --- a/src/v1/04_infer.dag +++ b/src/v1/04_infer.dag @@ -4044,14 +4044,6 @@ fn unresolved_method_frontier() -> List { receiver_shape: "Primitive(std.types.NonEmptyStr)", cause: "the brand-alias class in its LEAF form. The receiver is a coproduct variant payload whose declared type is NonEmptyStr, and it arrives not as the refinement Conj the peel walks but as a plain leaf carrying the QUALIFIED name std.types.NonEmptyStr — so there is no refinement chain to descend and no kernel profile under that name. Three head-resolution strategies were tried against this site and measured: resolving the leaf through lookup_type_for, through lookup_type_by_name on the qualified name, and on its last segment. NONE of them recovered the refinement, so the machinery was deleted rather than shipped unproven, and the site is declared here instead. Why the peel reaches the Conj form but not this one is not yet understood, and saying so is more useful than a fourth guess.", dissolution: unbound_dissolution(description: "one representation for a brand alias at method lookup — the same reconciliation the conformance wall's class (2) names — so the leaf and Conj forms stop being two shapes for one concept") - }, - { - module_name: "v2.std.compilers.target_model", - method: "lookup", - occurrences: 1, - receiver_shape: "Primitive(T)", - cause: "receiver is a bare type variable. This one is genuinely undecidable at this seam rather than a resolution defect: nothing establishes what T offers.", - dissolution: unbound_dissolution(description: "primitive-realization-single-authority, giving every receiver a complete declared method surface") } ] } diff --git a/src/v1/stage0/src/namespace_wave_admission.rs b/src/v1/stage0/src/namespace_wave_admission.rs index 228ec0b3c3c..8f010e3ca90 100644 --- a/src/v1/stage0/src/namespace_wave_admission.rs +++ b/src/v1/stage0/src/namespace_wave_admission.rs @@ -427,7 +427,36 @@ pub struct TransitionAdmission { /// authored with, in the first PR cut from the main that carries the move. The roster is /// EMPTY again and empty is not permissive: a run carrying a real namespace delta still /// refuses it as UNADJUDICATED until its author adds a row here. -pub const NAMESPACE_TRANSITION_ADMISSIONS: &[TransitionAdmission] = &[]; +/// THIRD TRANSITION: `admission_from_module_root` moved home. #9710 relocated +/// `admission_from_module_root` (with `import_rows_from_parsed_module`, `collect_import_decl_nodes` +/// and `ImportRowsState`) from `v2.compiler.name_resolve` to `v2.lens.reference_deps`, the layer +/// of its only two consumers, so that the compiler entry's emitted closure no longer carries the +/// reference_deps subtree for a function no compile path reaches. The two consumers repoint their +/// import; the spelling denotes a different declaration home, so each is a `TargetChanged` +/// binding delta, admitted here by exact subject. Both rows dissolve when the relocation is on +/// main: they then match no delta and report stale, refusing the first unrelated PR -- which is +/// the trigger to delete them. +pub const NAMESPACE_TRANSITION_ADMISSIONS: &[TransitionAdmission] = &[ + TransitionAdmission { + label: "admission_from_module_root relocated to v2.lens.reference_deps (frontier_probe)", + subject: AdmissionSubject::Binding { + module: "v2.compiler.self_host.frontier_probe", + in_declaration: "frontier_probe_admission_from_ingest", + spelling: "admission_from_module_root", + }, + disposition: NamespaceDeltaDisposition::TargetChanged, + }, + TransitionAdmission { + label: + "admission_from_module_root relocated to v2.lens.reference_deps (compile_door_ledger)", + subject: AdmissionSubject::Binding { + module: "v2.workflow.compile_door_ledger", + in_declaration: "derive_module_admission", + spelling: "admission_from_module_root", + }, + disposition: NamespaceDeltaDisposition::TargetChanged, + }, +]; /// The denominators a green must name (DESIGN §5). A run that cannot say what it covered is /// an instrument failure wearing coverage's clothes. diff --git a/src/v2/compiler/04_infer.dag b/src/v2/compiler/04_infer.dag index d1b691796f0..918a0d68658 100644 --- a/src/v2/compiler/04_infer.dag +++ b/src/v2/compiler/04_infer.dag @@ -29,10 +29,7 @@ import v2.std.cardinality { TerminationProof, termination_proof_witness_for_node import v2.std.collection { List, Map, - empty_map, - list_at_optional, - map_insert, - map_lookup + list_at_optional } import v2.std.optional { Absent, @@ -178,7 +175,11 @@ data infer_emit_shape_frontier_note: String = "Test-only emit-shape frontier (re fn infer_emit_shape_frontier_inferred_tree(root: Node) -> InferredTree { InferredTree { root: root, - facts: empty_map() + facts: PartialFunction { + lookup: fn(_key) { + Absent + } + } } } @@ -485,7 +486,7 @@ fn lookup_inferred_facts_in_entries( ) } -fn facts_map_from_entries(entries: List) -> Outcome> { +fn facts_map_from_entries(entries: List) -> Outcome> { match fold(entries, init: Accepted { value: empty_inferred_facts_entry_list(), diagnostics: None }, f: fn(acc, entry) { match acc { Rejected { diagnostics: r } => Rejected { diagnostics: r } @@ -504,12 +505,11 @@ fn facts_map_from_entries(entries: List) -> Outcome Rejected { diagnostics: r } Accepted { value: admitted, diagnostics: d } => Accepted { - value: fold(admitted, init: empty_map(), f: fn(acc, entry) { - match map_lookup(m: acc, key: entry.node) { - Present { value: _ } => acc - Absent => map_insert(m: acc, key: entry.node, value: entry.facts) + value: PartialFunction { + lookup: fn(key) { + lookup_inferred_facts_in_entries(entries: admitted, key: key) } - }), + }, diagnostics: d } } diff --git a/src/v2/compiler/inferred_tree.dag b/src/v2/compiler/inferred_tree.dag index 0e20caefc06..1a5f50b2c85 100644 --- a/src/v2/compiler/inferred_tree.dag +++ b/src/v2/compiler/inferred_tree.dag @@ -5,6 +5,7 @@ import v2.std.collection { Map } import v2.std.constraints { CanonicalGrounding } import v2.std.node { Node } import v2.std.witness { Witness } +import std.algebra { PartialFunction } // InferredFacts/InferredTree/InferredFactsEntry are the SHAPE infer's pass // produces and consumers hold -- not the pass itself. They lived inside @@ -31,7 +32,7 @@ type InferredFacts { type InferredTree { root: Node - facts: Map + facts: PartialFunction } type InferredFactsEntry { diff --git a/src/v2/compiler/program_partition.dag b/src/v2/compiler/program_partition.dag index a8390c380eb..b7db016e152 100644 --- a/src/v2/compiler/program_partition.dag +++ b/src/v2/compiler/program_partition.dag @@ -468,7 +468,7 @@ fn facts_closure_entries_fold( ) } -fn facts_closure_fold(partition: ProgramPartition) -> Outcome> { +fn facts_closure_fold(partition: ProgramPartition) -> Outcome> { match partition.boundary { AmbientContextAvailable => outcome_accepted(value: partition.ambient.facts) diff --git a/src/v2/extdeps/runtimes/v2_effect_io_pure.dag b/src/v2/extdeps/runtimes/v2_effect_io_pure.dag index aae02a87048..a958be660be 100644 --- a/src/v2/extdeps/runtimes/v2_effect_io_pure.dag +++ b/src/v2/extdeps/runtimes/v2_effect_io_pure.dag @@ -108,11 +108,7 @@ fn effect_io_pure_operation_ref() -> PrimitiveOperationRef { fn effect_io_pure_empty_environment() -> EvaluationEnvironment { EvaluationEnvironment { - bindings: PartialFunction { - lookup: fn(_) { - Absent - } - } + bindings: empty_map() } } From 657010b8a7ecc3e02ca76da28ba927fda6a9525d Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 06:35:09 +0000 Subject: [PATCH 42/75] XL-0N: operand realization hops alias/refinement declarations to their target (NonEmptyStr, Char, VersionIdentity compare/add as their host targets) --- src/v1/05_emit_rust.dag | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index f79010d9a1e..8d622fde6a4 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -11971,14 +11971,37 @@ fn emit_typed_bin_op(op: BinOp, algebra_field: AlgebraFieldKind?, left: Node, ri // declared comparison tested against std.algebra Ordering; arithmetic on a structural operand // refuses, typed and located, instead of emitting a token rustc refuses under E0369 later. fn rust_operand_realization(operand: Node, scope: InferScope) -> OperandRealization { - let rt = resolved_type(n: operand) + rust_operand_realization_of_type(rt: resolved_type(n: operand), scope: scope, fuel: 8) +} + +// AN ALIAS OR REFINEMENT DECLARATION REALIZES AS ITS TARGET. `type NonEmptyStr = String where +// non_empty`, `type Char = Int where unicode_scalar, brand("Char")` and their like are bare-leaf +// declarations (NoConnective, no children, an inferred right-hand side) whose Rust realization IS +// the right-hand side's -- the type renderer already renders them that way -- so the operand +// decision hops to the right-hand side before judging, exactly as the derive lane's alias hop does +// (v1.compiler.trait_derive_emit v1_item_alias_hop_type_exprs). The seed's own semver and unicode +// modules compare NonEmptyStr and add to Char; without the hop those were refused as structural. +// Fuel bounds an alias chain; a chain longer than it is judged at its last declaration. +fn rust_operand_realization_of_type(rt: Node, scope: InferScope, fuel: Int) -> OperandRealization { match type_reference_declaration_ref(n: rt, source_indices: scope.type_env.source_indices, env: scope.type_env) { Absent => OperandIdentityUnavailable Present { value: d } => if declaration_realizes_natively_on_rust(declaration: d, decl_file: type_reference_decl_file(n: rt)) { HostNumericOperand } else { - StructuralOperand { declaration: d } + let decl = match rt.inferred { + Present { value: Resolved { node: r } } => r + _ => rt + } + let is_bare_leaf_alias = decl.connective == NoConnective && decl.children |> count == 0 && decl.inferred != none + if is_bare_leaf_alias && fuel > 0 { + match decl.inferred { + Present { value: Resolved { node: target } } => rust_operand_realization_of_type(rt: target, scope: scope, fuel: fuel - 1) + _ => StructuralOperand { declaration: d } + } + } else { + StructuralOperand { declaration: d } + } } } } From c6d9b22469c2863dd0c1d0438aade5ebc8ae2c0c Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 07:25:30 +0000 Subject: [PATCH 43/75] Regenerate the stage0 mirror for A1 + C (aa373f9): byte fixed point at round 3 Round 1 changed the five authority mirrors (extdeps_languages_rust_emit, extdeps_languages_rust_types, std_primitive_projection, v1_compiler_emit_rust, v1_compiler_infer), round 2 only compiler_tests.rs, round 3 byte-identical; installed tree f53efd0d0173a43e, gunbc 1a2d53dd15920cf1. Unit 552/0. Emitted closure cargo check 392 -> 278; line-insensitive identity diff vs commit 2: 112 removed, 0 added. Batteries on the converged binary: 29/29 (the two C rows red on the pre-fix compiler by fixture emit), 14/14, 20/20. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01GXfYKNQTD3VfYyQcnJpxNU --- src/v1/stage0/src/compiler_tests.rs | 4 - .../stage0/src/extdeps_languages_rust_emit.rs | 1 - .../src/extdeps_languages_rust_types.rs | 2 +- src/v1/stage0/src/std_primitive_projection.rs | 6 + src/v1/stage0/src/v1_compiler_emit_rust.rs | 188 +++++++++++++++--- src/v1/stage0/src/v1_compiler_infer.rs | 7 - 6 files changed, 170 insertions(+), 38 deletions(-) diff --git a/src/v1/stage0/src/compiler_tests.rs b/src/v1/stage0/src/compiler_tests.rs index 68c4614c105..9e4f5de6bf1 100644 --- a/src/v1/stage0/src/compiler_tests.rs +++ b/src/v1/stage0/src/compiler_tests.rs @@ -1991,10 +1991,6 @@ mod compiler_tests { coerce_container_template(RenderTarget::Rust, "Map".into()), Some("HashMap<{0}, {1}>".to_string()) ); - assert_eq!( - coerce_container_template(RenderTarget::Rust, "PartialFunction".into()), - Some("HashMap<{0}, {1}>".to_string()) - ); assert_eq!( coerce_container_template(RenderTarget::Rust, "PointwisePower".into()), Some("BTreeSet<{0}>".to_string()) diff --git a/src/v1/stage0/src/extdeps_languages_rust_emit.rs b/src/v1/stage0/src/extdeps_languages_rust_emit.rs index fd50682ac44..aec272b370f 100644 --- a/src/v1/stage0/src/extdeps_languages_rust_emit.rs +++ b/src/v1/stage0/src/extdeps_languages_rust_emit.rs @@ -78,7 +78,6 @@ pub fn rust_container_templates() -> Rc> { __m.insert("optional".to_string(), "Option<{0}>".to_string()); __m.insert("map".to_string(), "HashMap<{0}, {1}>".to_string()); __m.insert("free_monoid".to_string(), "Vec<{0}>".to_string()); - __m.insert("partial_function".to_string(), "HashMap<{0}, {1}>".to_string()); __m.insert("boolean_algebra".to_string(), "bool".to_string()); Rc::new(__m) }; diff --git a/src/v1/stage0/src/extdeps_languages_rust_types.rs b/src/v1/stage0/src/extdeps_languages_rust_types.rs index b6f0935923d..e19f3fb50c5 100644 --- a/src/v1/stage0/src/extdeps_languages_rust_types.rs +++ b/src/v1/stage0/src/extdeps_languages_rust_types.rs @@ -68,7 +68,7 @@ pub fn rust_checkpoint_scalar_arity_note() -> String { pub fn rust_algebra_inhabitants() -> Rc>> { thread_local! { static CACHED: Rc>> = { - serde_json::from_value(serde_json::json!([{"algebra": "FreeMonoid", "template": "Vec<{0}>", "arity": 1, "identity_expr": "Vec::new()", "import_path": null, "is_copy": false}, {"algebra": "FinitePowerSet", "template": "BTreeSet<{0}>", "arity": 1, "identity_expr": "BTreeSet::new()", "import_path": null, "is_copy": false}, {"algebra": "PointwisePower", "template": "BTreeSet<{0}>", "arity": 1, "identity_expr": "BTreeSet::new()", "import_path": null, "is_copy": false}, {"algebra": "PartialFunction", "template": "HashMap<{0}, {1}>", "arity": 2, "identity_expr": "HashMap::new()", "import_path": null, "is_copy": false}, {"algebra": "FinitelySupportedFunction", "template": "HashMap<{0}, {1}>", "arity": 2, "identity_expr": "HashMap::new()", "import_path": null, "is_copy": false}, {"algebra": "OrderedRing", "template": "i64", "arity": 0, "identity_expr": "0i64", "import_path": null, "is_copy": true}, {"algebra": "ApproximateField", "template": "f64", "arity": 0, "identity_expr": "0.0f64", "import_path": null, "is_copy": true}])) + serde_json::from_value(serde_json::json!([{"algebra": "FreeMonoid", "template": "Vec<{0}>", "arity": 1, "identity_expr": "Vec::new()", "import_path": null, "is_copy": false}, {"algebra": "FinitePowerSet", "template": "BTreeSet<{0}>", "arity": 1, "identity_expr": "BTreeSet::new()", "import_path": null, "is_copy": false}, {"algebra": "PointwisePower", "template": "BTreeSet<{0}>", "arity": 1, "identity_expr": "BTreeSet::new()", "import_path": null, "is_copy": false}, {"algebra": "FinitelySupportedFunction", "template": "HashMap<{0}, {1}>", "arity": 2, "identity_expr": "HashMap::new()", "import_path": null, "is_copy": false}, {"algebra": "OrderedRing", "template": "i64", "arity": 0, "identity_expr": "0i64", "import_path": null, "is_copy": true}, {"algebra": "ApproximateField", "template": "f64", "arity": 0, "identity_expr": "0.0f64", "import_path": null, "is_copy": true}])) .expect("valid data definition") }; } diff --git a/src/v1/stage0/src/std_primitive_projection.rs b/src/v1/stage0/src/std_primitive_projection.rs index ecf7cc5961e..c1493ae0e3e 100644 --- a/src/v1/stage0/src/std_primitive_projection.rs +++ b/src/v1/stage0/src/std_primitive_projection.rs @@ -278,6 +278,12 @@ pub fn primitive_projection_roster() -> Rc>> { "empty_map_primitive_delegate".to_string(), Rc::new(ProjectionFidelity::HostRealizedSeam), ), + primitive_projection_row( + primitive_map_insert(), + "v2.std.collection".to_string(), + "map_insert_primitive_delegate".to_string(), + Rc::new(ProjectionFidelity::HostRealizedSeam), + ), primitive_projection_row( primitive_symbol_lexeme(), "v2.std.compilers.lexing".to_string(), diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index fd55daa155c..c6ef91580a3 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -174,8 +174,8 @@ pub use crate::v1_compiler_trait_derive_emit::{ v1_emit_struct_from_capability_table, v1_emit_type_params_with_bounds, v1_emit_type_params_with_clone_bounds, v1_generic_params_needing_clone_bound, v1_item_clone_bounded_param_names, v1_item_clone_undecided_head, v1_item_field_type_exprs, - v1_item_wf_propagated_clone_bounded_param_names, v1_map_key_required_type_names, - v1_trait_derive_refuse, v1_with_map_key_requirement, + v1_item_wf_propagated_clone_bounded_param_names, v1_map_key_head_names_in_type_expr, + v1_map_key_required_type_names, v1_trait_derive_refuse, v1_with_map_key_requirement, }; use crate::v1_rt; use crate::v1_rt::{VecCompat, VecJoin}; @@ -2872,6 +2872,65 @@ pub fn alias_rhs_qualified_name_routing_note() -> String { CACHED.with(|c: &String| c.clone()) } +pub fn rust_alias_rhs_applied_container_or_base( + n: Rc, + leaf: String, + base: String, + arg_list: Rc>, + source_indices: Rc>>, +) -> String { + if crate::v1_compiler_infer_types::node_is_keyed_collection(n.clone(), source_indices.clone()) { + match arg_list.clone().first().cloned() { + Some(k) => match arg_list.clone().iter().cloned().skip(1 as usize).next() { + Some(v) => { + crate::v1_compiler_emit::emit_map_type(k.clone(), v.clone(), RenderTarget::Rust) + } + None => v1_rt::concat( + v1_rt::concat( + v1_rt::concat(base.clone(), "<".to_string()), + arg_list.clone().join(&", ".to_string()), + ), + ">".to_string(), + ), + }, + None => v1_rt::concat( + v1_rt::concat( + v1_rt::concat(base.clone(), "<".to_string()), + arg_list.clone().join(&", ".to_string()), + ), + ">".to_string(), + ), + } + } else { + if (crate::v1_compiler_infer_types::node_is_collection(n.clone(), source_indices.clone()) + && ((arg_list.clone().len() as i64) == 1)) + { + match arg_list.clone().first().cloned() { + Some(inner) => crate::v1_compiler_emit::emit_container( + leaf.clone(), + inner.clone(), + RenderTarget::Rust, + ), + None => v1_rt::concat( + v1_rt::concat( + v1_rt::concat(base.clone(), "<".to_string()), + arg_list.clone().join(&", ".to_string()), + ), + ">".to_string(), + ), + } + } else { + v1_rt::concat( + v1_rt::concat( + v1_rt::concat(base.clone(), "<".to_string()), + arg_list.clone().join(&", ".to_string()), + ), + ">".to_string(), + ) + } + } +} + pub fn render_rust_alias_rhs_type( n: Rc, generic_param_names: Rc>, @@ -3060,7 +3119,7 @@ pub fn render_rust_alias_rhs_type( source_indices.clone(), module_index.clone(), ); - let args = Rc::new({ + let arg_list = Rc::new({ let mut __result = Vec::new(); for arg in n.children.clone().iter().cloned() { __result.push(if peel.clone() { @@ -3099,14 +3158,14 @@ pub fn render_rust_alias_rhs_type( }); } __result - }) - .join(&", ".to_string()); - let applied_ty = v1_rt::concat( - v1_rt::concat( - v1_rt::concat(base.clone(), "<".to_string()), - args.clone(), - ), - ">".to_string(), + }); + let args = arg_list.clone().join(&", ".to_string()); + let applied_ty = rust_alias_rhs_applied_container_or_base( + n.clone(), + leaf.clone(), + base.clone(), + arg_list.clone(), + source_indices.clone(), ); if (v1_rt::set_contains(&shared_types, leaf.clone()) && !rust_type_is_rc_wrapped(applied_ty.clone())) @@ -3132,7 +3191,7 @@ pub fn render_rust_alias_rhs_type( source_indices.clone(), module_index.clone(), ); - let args = Rc::new({ + let arg_list = Rc::new({ let mut __result = Vec::new(); for arg in n.children.clone().iter().cloned() { __result.push(if peel.clone() { @@ -3171,14 +3230,14 @@ pub fn render_rust_alias_rhs_type( }); } __result - }) - .join(&", ".to_string()); - let applied_ty = v1_rt::concat( - v1_rt::concat( - v1_rt::concat(base.clone(), "<".to_string()), - args.clone(), - ), - ">".to_string(), + }); + let args = arg_list.clone().join(&", ".to_string()); + let applied_ty = rust_alias_rhs_applied_container_or_base( + n.clone(), + leaf.clone(), + base.clone(), + arg_list.clone(), + source_indices.clone(), ); if (v1_rt::set_contains(&shared_types, leaf.clone()) && !rust_type_is_rc_wrapped(applied_ty.clone())) @@ -16402,6 +16461,7 @@ pub fn v1_fn_body_derived_clone_param_names( pub fn v1_fn_bounds_by_param( clone_param_names: Rc>, eq_param_names: Rc>, + map_key_param_names: Rc>, ) -> Rc>>> { { let with_clone = clone_param_names.iter().cloned().fold( @@ -16410,7 +16470,7 @@ pub fn v1_fn_bounds_by_param( v1_rt::rc_map_insert(m, n.clone(), Rc::new(vec!["Clone".to_string()])) }, ); - eq_param_names.iter().cloned().fold( + let with_eq = eq_param_names.iter().cloned().fold( with_clone.clone(), |m: Rc>>>, n: String| match v1_rt::map_get(&m, n.clone()) { @@ -16425,10 +16485,78 @@ pub fn v1_fn_bounds_by_param( Rc::new(vec!["PartialEq".to_string()]), ), }, + ); + map_key_param_names.iter().cloned().fold( + with_eq.clone(), + |m: Rc>>>, n: String| match v1_rt::map_get(&m, n.clone()) + { + Some(traits) => v1_rt::rc_map_insert( + m.clone(), + n.clone(), + v1_rt::concat(traits.clone(), rust_map_key_bound_traits()), + ), + None => v1_rt::rc_map_insert(m.clone(), n.clone(), rust_map_key_bound_traits()), + }, ) } } +pub fn rust_map_key_bound_traits() -> Rc> { + Rc::new(vec![ + "std::cmp::Eq".to_string(), + "std::hash::Hash".to_string(), + ]) +} + +pub fn v1_fn_signature_map_key_param_names( + value_params: Rc>>, + ret: Rc, + generic_param_names: Rc>, + source_indices: Rc>>, +) -> Rc> { + { + let from_params = Rc::new({ + let mut __result = Vec::new(); + for p in value_params.iter().cloned() { + __result.extend( + (*crate::v1_compiler_trait_derive_emit::v1_map_key_head_names_in_type_expr( + crate::v1_std_core::param_node_type_expr(p.clone()), + source_indices.clone(), + )) + .iter() + .cloned(), + ); + } + __result + }); + let from_ret = crate::v1_compiler_trait_derive_emit::v1_map_key_head_names_in_type_expr( + ret.clone(), + source_indices.clone(), + ); + crate::v1_compiler_emit_core_support::unique_strings(Rc::new({ + let mut __result = Vec::new(); + for n in v1_rt::concat(from_params.clone(), from_ret.clone()) + .iter() + .cloned() + { + if { + let mut __found = false; + for g in generic_param_names.iter().cloned() { + if (g.clone() == n.clone()) { + __found = true; + break; + } + } + __found + } { + __result.push(n); + } + } + __result + })) + } +} + pub fn v1_fn_body_equality_bound_param_names( body: Rc, generic_param_names: Rc>, @@ -16843,10 +16971,20 @@ pub fn emit_fn_def( self_eq_param_names.clone(), call_forwarding_eq_param_names.clone(), ); - let bounds_by_param = - v1_fn_bounds_by_param(clone_param_names.clone(), eq_param_names.clone()); - let needs_bound = (((clone_param_names.clone().len() as i64) > 0) - || ((eq_param_names.clone().len() as i64) > 0)); + let map_key_param_names = v1_fn_signature_map_key_param_names( + value_params.clone(), + inferred.clone(), + generic_param_names.clone(), + si.clone(), + ); + let bounds_by_param = v1_fn_bounds_by_param( + clone_param_names.clone(), + eq_param_names.clone(), + map_key_param_names.clone(), + ); + let needs_bound = ((((clone_param_names.clone().len() as i64) > 0) + || ((eq_param_names.clone().len() as i64) > 0)) + || ((map_key_param_names.clone().len() as i64) > 0)); let type_params_str = if needs_bound.clone() { crate::v1_compiler_trait_derive_emit::v1_emit_type_params_with_bounds( type_params.clone(), diff --git a/src/v1/stage0/src/v1_compiler_infer.rs b/src/v1/stage0/src/v1_compiler_infer.rs index 99b310179bc..b608364f232 100644 --- a/src/v1/stage0/src/v1_compiler_infer.rs +++ b/src/v1/stage0/src/v1_compiler_infer.rs @@ -6249,13 +6249,6 @@ pub fn unresolved_method_frontier() -> Rc>> receiver_shape: "Primitive(std.types.NonEmptyStr)".to_string(), cause: "the brand-alias class in its LEAF form. The receiver is a coproduct variant payload whose declared type is NonEmptyStr, and it arrives not as the refinement Conj the peel walks but as a plain leaf carrying the QUALIFIED name std.types.NonEmptyStr — so there is no refinement chain to descend and no kernel profile under that name. Three head-resolution strategies were tried against this site and measured: resolving the leaf through lookup_type_for, through lookup_type_by_name on the qualified name, and on its last segment. NONE of them recovered the refinement, so the machinery was deleted rather than shipped unproven, and the site is declared here instead. Why the peel reaches the Conj form but not this one is not yet understood, and saying so is more useful than a fourth guess.".to_string(), dissolution: crate::std_dissolution::unbound_dissolution("one representation for a brand alias at method lookup — the same reconciliation the conformance wall's class (2) names — so the leaf and Conj forms stop being two shapes for one concept".to_string()), -}), Rc::new(UnresolvedMethodFrontierRow { - module_name: "v2.std.compilers.target_model".to_string(), - method: "lookup".to_string(), - occurrences: 1, - receiver_shape: "Primitive(T)".to_string(), - cause: "receiver is a bare type variable. This one is genuinely undecidable at this seam rather than a resolution defect: nothing establishes what T offers.".to_string(), - dissolution: crate::std_dissolution::unbound_dissolution("primitive-realization-single-authority, giving every receiver a complete declared method surface".to_string()), })]) } From 2656610f2c828e4d30a92806129d59a45130f960 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 07:32:29 +0000 Subject: [PATCH 44/75] XL-0N: Bool row -- KernelBoolLiteral into v2.std.logic.Bool via BooleanUnfold (True/False); interpreter evaluates an elaborated literal as its kernel value; falsifier pair (row found/removed in the interpreter, constructor image vs host keyword on the emitted path) Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_013koFunEtpLQCnvUiz85k7Y --- dag/gunbc/structural_realization_bindings.dag | 19 ++++++++- dag/std/literal_elaboration.dag | 7 +++- ...eral_operator_realization_witness_test.dag | 23 +++++++++++ src/v1/04_infer.dag | 14 ++++++- src/v1/stage0/src/v1_interpreter.rs | 18 ++++----- .../peano_nat_structural_realization_test.dag | 39 ++++++++++++++++++- 6 files changed, 102 insertions(+), 18 deletions(-) diff --git a/dag/gunbc/structural_realization_bindings.dag b/dag/gunbc/structural_realization_bindings.dag index 33130d759ee..bb28e10cf8c 100644 --- a/dag/gunbc/structural_realization_bindings.dag +++ b/dag/gunbc/structural_realization_bindings.dag @@ -2,7 +2,7 @@ module gunbc.structural_realization_bindings import std.types { List, String, Bool, NonEmptyStr } import std.decl_ref { DeclarationRef, decl_ref } -import std.literal_elaboration { LiteralHomomorphism, LiteralSourceKind, KernelIntLiteral, LiteralUnfolding, PeanoUnfold } +import std.literal_elaboration { LiteralHomomorphism, LiteralSourceKind, KernelIntLiteral, KernelBoolLiteral, LiteralUnfolding, PeanoUnfold, BooleanUnfold } import std.operator_realization { StructuralOrderingBinding } // THE CORPUS'S HALF OF LITERAL ELABORATION AND OPERATOR REALIZATION (std.literal_elaboration, @@ -32,8 +32,23 @@ fn peano_literal_homomorphism(module_path: String, nat: String, zero: String, su } } +fn boolean_literal_homomorphism(module_path: String, bool_decl: String, true_variant: String, false_variant: String) -> LiteralHomomorphism { + LiteralHomomorphism { + source_kind: KernelBoolLiteral, + destination: decl_ref(module_path: module_path, decl_name: bool_decl), + producer: BooleanUnfold { + true_variant: decl_ref(module_path: module_path, decl_name: true_variant), + false_variant: decl_ref(module_path: module_path, decl_name: false_variant) + } + } +} + +// v2.std.logic Bool = True | False is gated structural on purpose (v1.compiler.coercion +// structural_declaration_modules_for); the corpus-wide prelude std.types Bool realizes natively and +// is NOT a row -- a kernel true/false at that boundary stays the host bool. data literal_homomorphism_rows: List = [ - peano_literal_homomorphism(module_path: "v2.std.nat", nat: "Nat", zero: "Zero", succ: "Succ", prev_field: "prev") + peano_literal_homomorphism(module_path: "v2.std.nat", nat: "Nat", zero: "Zero", succ: "Succ", prev_field: "prev"), + boolean_literal_homomorphism(module_path: "v2.std.logic", bool_decl: "Bool", true_variant: "True", false_variant: "False") ] fn structural_ordering_binding(carrier_module: String, carrier: String, compare_module: String, compare: String, ordering_module: String, ordering: String) -> StructuralOrderingBinding { diff --git a/dag/std/literal_elaboration.dag b/dag/std/literal_elaboration.dag index 413562413c9..a273c88fdfc 100644 --- a/dag/std/literal_elaboration.dag +++ b/dag/std/literal_elaboration.dag @@ -76,10 +76,13 @@ fn literal_source_kind_eq(a: LiteralSourceKind, b: LiteralSourceKind) -> Bool { // HOW A KERNEL VALUE IS UNFOLDED INTO A DESTINATION'S CONSTRUCTORS. Each arm names the destination's // own constructors by exact DeclarationRef -- the unfolding is a fact about the destination, so a // renamed variant is a changed row, never a stale spelling inside the compiler. -// PeanoUnfold a nonnegative integer n unfolds to succ^n(zero): `succ { prev_field: ... }` nested -// n deep around the nullary `zero`. +// PeanoUnfold a nonnegative integer n unfolds to succ^n(zero): `succ { prev_field: ... }` nested +// n deep around the nullary `zero`. +// BooleanUnfold a kernel bool unfolds to the destination's nullary true or false constructor +// (v2.std.logic Bool = True | False, declared structural on purpose). type LiteralUnfolding = PeanoUnfold { zero: DeclarationRef, succ: DeclarationRef, prev_field: NonEmptyStr } + | BooleanUnfold { true_variant: DeclarationRef, false_variant: DeclarationRef } type LiteralHomomorphism { source_kind: LiteralSourceKind diff --git a/dag/test/claim/self_host_peano_literal_operator_realization_witness_test.dag b/dag/test/claim/self_host_peano_literal_operator_realization_witness_test.dag index 2e7f714032d..2237bae82e4 100644 --- a/dag/test/claim/self_host_peano_literal_operator_realization_witness_test.dag +++ b/dag/test/claim/self_host_peano_literal_operator_realization_witness_test.dag @@ -95,6 +95,29 @@ test fn w_host_arithmetic_on_peano_operands_refuses_in_the_bytes() -> Bool { ) } +// THE BOOL ROW ON THE EMITTED PATH: a kernel true at a v2.std.logic.Bool boundary emits the +// structural constructor. (The interpreter realizes Bool natively and never executes this image; +// the emitted bytes are the only place the image exists, so this row is its whole evidence.) +test fn w_kernel_bool_at_structural_bool_boundary_emits_its_constructor() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.structural_bool_probe\nimport v2.std.logic { Bool }\nfn probe() -> Bool { true }\nfn probe_false(b: Bool) -> Bool { false }\n", + "src/test_claim_structural_bool_probe.rs", + ["Bool::True", "Bool::False"], + ["{\n true\n}", "{\n false\n}"] + ) +} + +// HOST CONTROL for the Bool row: the prelude std.types Bool realizes natively and keeps the host +// keyword -- a rule keyed on the spelling `Bool` cannot pass this row and the one above together. +test fn w_kernel_bool_at_native_bool_boundary_stays_the_keyword() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.native_bool_probe\nimport std.types { Bool }\nfn probe() -> Bool { true }\n", + "src/test_claim_native_bool_probe.rs", + ["{\n true\n}"], + ["Bool::True"] + ) +} + // HOST CONTROL: the same ordering on a native i64 operand keeps the host token. Without this row // a realization that routed EVERY `<` through a comparison call would pass the Peano rows. test fn w_ordering_on_native_operands_keeps_the_host_operator() -> Bool { diff --git a/src/v1/04_infer.dag b/src/v1/04_infer.dag index 7a750d8d91c..b1ea2e8ebd5 100644 --- a/src/v1/04_infer.dag +++ b/src/v1/04_infer.dag @@ -8,10 +8,10 @@ import std.content_hash { content_hash_validate_lower_hex_length, } import extdeps.container.oci.digest { oci_other_digest_algorithm, oci_other_digest_encoded } -import std.syntax { Add, BinOp, LitStr, LitInt, LiteralValue } +import std.syntax { Add, BinOp, LitStr, LitInt, LitBool, LiteralValue } import std.decl_ref { DeclarationRef } import std.literal_elaboration { - LiteralElaboration, LiteralHomomorphism, LiteralUnfolding, PeanoUnfold, + LiteralElaboration, LiteralHomomorphism, LiteralUnfolding, PeanoUnfold, BooleanUnfold, LiteralElaborationOutcome, DirectLiteral, ViaHomomorphism, LiteralElaborationRefused, elaborate_literal_at, literal_source_kind_of, literal_elaboration_refusal_message } @@ -4777,6 +4777,16 @@ fn unfold_literal_image(lit: LiteralValue, elaboration: LiteralElaboration, dest ) _ => make_expr_error_node(occurrence_identity: OccurrenceSynthetic, kind: InternalExprError, message: "literal elaboration: a Peano unfolding row was selected for a non-integer literal (gunbc.structural_realization_bindings keys the row on KernelIntLiteral, so this row is malformed)", span: span) } + BooleanUnfold { true_variant: t, false_variant: f } => + match lit { + LitBool { value: b } => + elaborated_expr_node( + name: if b { t.decl_name as String } else { f.decl_name as String }, + expr_data: ExprVar { binding_kind: Present { value: VariantValueBinding { parent_enum: elaboration.destination.decl_name as String } } }, + children: [], destination_type: destination_type, span: span + ) + _ => make_expr_error_node(occurrence_identity: OccurrenceSynthetic, kind: InternalExprError, message: "literal elaboration: a Boolean unfolding row was selected for a non-boolean literal (gunbc.structural_realization_bindings keys the row on KernelBoolLiteral, so this row is malformed)", span: span) + } } } diff --git a/src/v1/stage0/src/v1_interpreter.rs b/src/v1/stage0/src/v1_interpreter.rs index 9c46de5d164..d2211507f7b 100644 --- a/src/v1/stage0/src/v1_interpreter.rs +++ b/src/v1/stage0/src/v1_interpreter.rs @@ -4657,16 +4657,14 @@ fn eval_expr_inner(node: &Rc, env: &Rc, ctx: &InterpContext) -> Inter match (*node.expr_data).clone() { ExprData::ExprLiteral { value } => eval_literal(&value), - // An elaborated literal evaluates as its image under the selected homomorphism - // (std.literal_elaboration): the child is ordinary constructor nodes of the destination, - // which the interpreter's own numeric grounding folds exactly as authored ones. - ExprData::ExprElaboratedLiteral { .. } => match node.children.get(0) { - Some(image) => eval_expr(image, env, ctx), - None => Err(InterpError::TypeError { - msg: "elaborated literal carries no image (v1.compiler.infer unfold_literal_image)" - .to_string(), - }), - }, + // An elaborated literal (std.literal_elaboration) evaluates as the kernel value: this + // interpreter realizes the structural destinations natively by its own grounding + // (Zero/Succ as Int per #5428, v2.std.logic Bool as bool), so the image of the literal + // under that grounding IS the literal, and evaluating the constructor tree instead would + // route a natively-realized Bool through variant patterns that have no runtime form here. + // The structural image is consumed by emission, which is where the destination is + // structural; the emitted-bytes witnesses exercise that path. + ExprData::ExprElaboratedLiteral { value, .. } => eval_literal(&value), ExprData::ExprVar { binding_kind } => eval_var(node, binding_kind.as_deref(), env, ctx), diff --git a/src/v2/test/claim/self_host/peano_nat_structural_realization_test.dag b/src/v2/test/claim/self_host/peano_nat_structural_realization_test.dag index b7c24cacb93..4ea098f9c85 100644 --- a/src/v2/test/claim/self_host/peano_nat_structural_realization_test.dag +++ b/src/v2/test/claim/self_host/peano_nat_structural_realization_test.dag @@ -4,10 +4,10 @@ import std.types { Bool, Int, String, List } import std.algebra { Ordering, Less, Equal, Greater } import std.decl_ref { decl_ref } import std.literal_elaboration { - KernelIntLiteral, KernelStringLiteral, + KernelIntLiteral, KernelStringLiteral, KernelBoolLiteral, LiteralHomomorphismFound, LiteralHomomorphismAbsent, LiteralHomomorphismAmbiguous, DirectLiteral, ViaHomomorphism, LiteralElaborationRefused, - PeanoUnfold, + PeanoUnfold, BooleanUnfold, literal_homomorphism_for, elaborate_literal_at } import std.operator_realization { @@ -116,6 +116,7 @@ test fn peano_row_is_found_by_exact_destination() -> Bool { match r.producer { PeanoUnfold { zero: z, succ: s, prev_field: p } => (z.decl_name as String) == "Zero" && (s.decl_name as String) == "Succ" && (p as String) == "prev" + BooleanUnfold { true_variant: _, false_variant: _ } => false } LiteralHomomorphismAbsent => false LiteralHomomorphismAmbiguous { row_count: _ } => false @@ -149,6 +150,40 @@ test fn removing_the_row_returns_the_literal_to_direct() -> Bool { } } +// THE BOOL ROW (kernel true/false -> v2.std.logic.Bool, the structural coproduct): found by exact +// destination, Direct with the row removed, and Direct at the prelude std.types.Bool, which realizes +// natively and has no row. No Bool VARIANT is matched by name in this interpreter-run module -- the +// interpreter realizes Bool natively and has no runtime form for `True` patterns -- so the image +// (Bool::True / Bool::False in the emitted bytes) is asserted only on the emitted path, in +// test.claim.self_host_peano_literal_operator_realization_witness_test. +test fn bool_row_is_found_by_exact_destination() -> Bool { + match literal_homomorphism_for(rows: literal_homomorphism_rows, source_kind: KernelBoolLiteral, destination: decl_ref(module_path: "v2.std.logic", decl_name: "Bool")) { + LiteralHomomorphismFound { row: r } => + match r.producer { + BooleanUnfold { true_variant: t, false_variant: f } => (t.decl_name as String) == "True" && (f.decl_name as String) == "False" + PeanoUnfold { zero: _, succ: _, prev_field: _ } => false + } + LiteralHomomorphismAbsent => false + LiteralHomomorphismAmbiguous { row_count: _ } => false + } +} + +test fn removing_the_bool_row_returns_the_literal_to_direct() -> Bool { + match elaborate_literal_at(rows: [], source_kind: KernelBoolLiteral, destination: decl_ref(module_path: "v2.std.logic", decl_name: "Bool"), destination_realizes_natively: false) { + DirectLiteral => true + ViaHomomorphism { homomorphism: _ } => false + LiteralElaborationRefused { cause: _ } => false + } +} + +test fn prelude_bool_destination_is_direct() -> Bool { + match elaborate_literal_at(rows: literal_homomorphism_rows, source_kind: KernelBoolLiteral, destination: decl_ref(module_path: "std.types", decl_name: "Bool"), destination_realizes_natively: true) { + DirectLiteral => true + ViaHomomorphism { homomorphism: _ } => false + LiteralElaborationRefused { cause: _ } => false + } +} + // A kernel STRING literal into the Peano Nat has no row: the source kind is part of the key. test fn source_kind_is_part_of_the_key() -> Bool { match literal_homomorphism_for(rows: literal_homomorphism_rows, source_kind: KernelStringLiteral, destination: decl_ref(module_path: "v2.std.nat", decl_name: "Nat")) { From 5e73c01742e10fd2666cae9a80d2aeadff0cf9af Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 07:42:14 +0000 Subject: [PATCH 45/75] XL-0N: operand realization hops alias items by is_type_alias_item/resolved_type (the derive lane's own test) -- the structural condition on the declaration node never held, so NonEmptyStr/Char/VersionIdentity host ops were refused in the regenerated compiler Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_013koFunEtpLQCnvUiz85k7Y --- src/v1/05_emit_rust.dag | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index 8d622fde6a4..63438d4a936 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -11975,13 +11975,14 @@ fn rust_operand_realization(operand: Node, scope: InferScope) -> OperandRealizat } // AN ALIAS OR REFINEMENT DECLARATION REALIZES AS ITS TARGET. `type NonEmptyStr = String where -// non_empty`, `type Char = Int where unicode_scalar, brand("Char")` and their like are bare-leaf -// declarations (NoConnective, no children, an inferred right-hand side) whose Rust realization IS -// the right-hand side's -- the type renderer already renders them that way -- so the operand -// decision hops to the right-hand side before judging, exactly as the derive lane's alias hop does -// (v1.compiler.trait_derive_emit v1_item_alias_hop_type_exprs). The seed's own semver and unicode -// modules compare NonEmptyStr and add to Char; without the hop those were refused as structural. -// Fuel bounds an alias chain; a chain longer than it is judged at its last declaration. +// non_empty`, `type Char = Int where unicode_scalar, brand("Char")` and their like are alias items +// (is_type_alias_item: a bare-leaf item whose resolved type is a type-alias return node) whose Rust +// realization IS the right-hand side's -- the type renderer already renders them that way -- so the +// operand decision hops to the right-hand side (resolved_type of the declaration) before judging, +// exactly as the derive lane's alias hop does (v1.compiler.trait_derive_emit +// v1_item_alias_hop_type_exprs). The seed's own semver and unicode modules compare NonEmptyStr and +// add to Char; without the hop those were refused as structural. Fuel bounds an alias chain; a +// chain longer than it is judged at its last declaration. fn rust_operand_realization_of_type(rt: Node, scope: InferScope, fuel: Int) -> OperandRealization { match type_reference_declaration_ref(n: rt, source_indices: scope.type_env.source_indices, env: scope.type_env) { Absent => OperandIdentityUnavailable @@ -11993,12 +11994,8 @@ fn rust_operand_realization_of_type(rt: Node, scope: InferScope, fuel: Int) -> O Present { value: Resolved { node: r } } => r _ => rt } - let is_bare_leaf_alias = decl.connective == NoConnective && decl.children |> count == 0 && decl.inferred != none - if is_bare_leaf_alias && fuel > 0 { - match decl.inferred { - Present { value: Resolved { node: target } } => rust_operand_realization_of_type(rt: target, scope: scope, fuel: fuel - 1) - _ => StructuralOperand { declaration: d } - } + if fuel > 0 && is_type_alias_item(item: decl, source_indices: scope.type_env.source_indices) { + rust_operand_realization_of_type(rt: resolved_type(n: decl), scope: scope, fuel: fuel - 1) } else { StructuralOperand { declaration: d } } From 3bf25c27396fb47092cd6f4809fbc03bf3566cd7 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 08:03:53 +0000 Subject: [PATCH 46/75] Commit 3 of the #9664 closure: six emitter mechanisms, the null keyword by path, and map_insert back to its .dag body under the gate's ruling Emitter (src/v1/05_emit_rust.dag, trait_derive_emit.dag), each with a discriminating row in self_host_emitted_call_target_realization_witness_test (pre-fix bytes observed on the seed): - an argument into a parameter spelled Optional is not unwrapped (the cardinality flag marks only the T? sugar; the applied spelling is asked too) - the shared-field accessor impl of a generic coproduct carries T: Clone - a Violates literal in a record field takes the field's Witness carrier before the fn return - a record pattern over a shared carrier derefs like a shared enum's variant pattern - a fn returning an arrow-field record carries 'static on its generics (same gate as impl Fn) - the fn-field record header prints well-formedness bounds asked per parameter instead of the bounded set minus the seed set (FalsificationReceipt lost A behind ValueDiff) - extdeps.languages.rust emit: the null keyword is std::option::Option::None, because a module declaring a nullary variant named None emits pub struct None; at module scope (std.cache_interface) v2.std.collection: map_insert is its .dag body again and map_insert_primitive_delegate with its primitive_projection row is deleted. The delegate tripped map_carrier_shape_gate on CI at c6d9b22 (record_shaped_map_reaches_map_insert BUDGET-REFUSED): the interpreter's free_call.map_insert arm answers Ok(None) for a non-native shape and the grounding falls through to the delegate's own body, a self-call -- the deferred-refusal class #8887 filed. The closing move is a host fact (a typed refusal in try_v2_std_collection_map_primitive_grounding) and is ledgered in the PR body, not landed here, by the manager's ruling. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01GXfYKNQTD3VfYyQcnJpxNU --- dag/extdeps/languages/rust/emit.dag | 2 +- dag/std/primitive_projection.dag | 1 - ...d_call_target_realization_witness_test.dag | 82 +++++++++++++++++++ src/v1/05_emit_rust.dag | 79 +++++++++++++++--- src/v1/trait_derive_emit.dag | 16 +++- src/v2/std/collection.dag | 12 ++- 6 files changed, 171 insertions(+), 21 deletions(-) diff --git a/dag/extdeps/languages/rust/emit.dag b/dag/extdeps/languages/rust/emit.dag index 6246cbbf114..b16fbbe65cd 100644 --- a/dag/extdeps/languages/rust/emit.dag +++ b/dag/extdeps/languages/rust/emit.dag @@ -55,7 +55,7 @@ data extdeps_external_authority_anchor: ExternalAuthority = ExternalAuthority { } data rust_keywords: Map = { - "true": "true", "false": "false", "null": "None", + "true": "true", "false": "false", "null": "std::option::Option::None", "and": "&&", "or": "||", "not": "!", "div": "/" } diff --git a/dag/std/primitive_projection.dag b/dag/std/primitive_projection.dag index da0a2e30cfe..47a2caa21b9 100644 --- a/dag/std/primitive_projection.dag +++ b/dag/std/primitive_projection.dag @@ -76,7 +76,6 @@ fn primitive_projection_roster() -> List { primitive_projection_row(primitive: primitive_concept_decl_facts, module_path: "v2.std.concept_index", decl_name: "concept_decl_facts", fidelity: HostRealizedSeam), primitive_projection_row(primitive: primitive_concept_decl_facts_live, module_path: "v2.std.concept_index", decl_name: "concept_decl_facts_live", fidelity: HostRealizedSeam), primitive_projection_row(primitive: primitive_empty_map, module_path: "v2.std.collection", decl_name: "empty_map_primitive_delegate", fidelity: HostRealizedSeam), - primitive_projection_row(primitive: primitive_map_insert, module_path: "v2.std.collection", decl_name: "map_insert_primitive_delegate", fidelity: HostRealizedSeam), primitive_projection_row(primitive: primitive_symbol_lexeme, module_path: "v2.std.compilers.lexing", decl_name: "symbol_lexeme", fidelity: HostRealizedSeam), primitive_projection_row(primitive: primitive_symbol_intern_lexeme, module_path: "v2.std.compilers.lexing", decl_name: "symbol_intern_lexeme", fidelity: HostRealizedSeam), primitive_projection_row(primitive: primitive_length, module_path: "v2.std.algebra", decl_name: "length", fidelity: ModeledProjection), diff --git a/dag/test/claim/self_host_emitted_call_target_realization_witness_test.dag b/dag/test/claim/self_host_emitted_call_target_realization_witness_test.dag index 652c591a20d..896a3abc383 100644 --- a/dag/test/claim/self_host_emitted_call_target_realization_witness_test.dag +++ b/dag/test/claim/self_host_emitted_call_target_realization_witness_test.dag @@ -463,3 +463,85 @@ test fn w_service_op_in_a_service_free_fn_refuses_instead_of_awaiting_an_unbound [".await?"] ) } + +// COMMIT-3 MECHANISMS OF THE #9664 CLOSURE, ONE ROW EACH. Every must_not_contain below is the byte +// sequence the pre-fix binary emitted for the same source (observed on the seed at 8781269 before +// the mechanism landed), so each row is a discriminating red that went green by the mechanism it +// names, not a decoration. + +// A parameter declared `Optional` is optional: the applied spelling carries no cardinality flag, +// so the fail-closed unwrap fired on an argument the callee exists to inspect. +test fn w_optional_carrier_parameter_takes_the_optional_argument_without_an_unwrap() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.optional_param_probe\nimport std.types { Int }\nimport v2.std.optional { Optional }\nfn inspect(opt: Optional) -> Optional { opt }\nfn caller(x: Int?) -> Optional { inspect(opt: x) }\n", + "src/test_claim_optional_param_probe.rs", + ["inspect(x.clone())"], + [".expect(\"fail-closed: an optional value flowed into non-optional parameter"] + ) +} + +// The shared-field accessor returns T by value from &self; without T: Clone on its impl rustc +// clones the reference. +test fn w_generic_coproduct_shared_accessor_impl_carries_the_clone_bound() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.shared_accessor_probe\nimport std.types { Int }\ntype Pair = Left { v: T, n: Int } | Right { v: T, m: Int }\nfn v_of(p: Pair) -> T { p.v }\n", + "src/test_claim_shared_accessor_probe.rs", + ["impl Pair {"], + ["impl Pair {"] + ) +} + +// A Violates literal in a record field is typed by its position, not by the enclosing fn's return. +test fn w_violates_literal_in_a_record_field_takes_the_field_witness_carrier() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.witness_field_probe\nimport std.types { Int }\nimport v2.std.node { Node }\nimport v2.std.diagnostic { Diagnostic }\nimport v2.std.witness { Holds, Violates, Witness }\ntype Judged { resolved: Witness, ok: Witness }\nfn judge(d: Diagnostic, n: Int) -> Judged { Judged { resolved: Violates { diagnostic: d }, ok: Holds { value: n } } }\n", + "src/test_claim_witness_field_probe.rs", + ["Witness::>::Violates"], + ["Witness::>::Violates"] + ) +} + +// A record pattern over a generic call's result: the scrutinee carrier is decided by the shared set, +// exactly as a shared enum's variant pattern is, so the pattern must meet the value, not the Rc. +test fn w_record_pattern_over_a_generic_call_result_derefs_the_shared_carrier() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.record_pattern_probe\nimport std.types { Int }\ntype Rec { a: Int, b: Int }\nfn ident(c: C) -> C { c }\nfn probe(r: Rec) -> Int { match ident(c: r) { Rec { a: x, b: _ } => x } }\n", + "src/test_claim_record_pattern_probe.rs", + ["Rec { a: x, .. } => x.clone()"], + ["match ident(r.clone()) {"] + ) +} + +// A generic stored into a `dyn Fn` must outlive it: a fn returning a record whose fields are arrows +// carries 'static on every generic, the same gate the param-side `impl Fn` already fires. +test fn w_fn_returning_an_arrow_field_record_carries_static_on_its_generics() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.static_generic_probe\nimport std.types { Int }\ntype Ops { op: fn(T, T) -> T }\nfn ops(z: T) -> Ops { Ops { op: fn(a, b) { z } } }\n", + "src/test_claim_static_generic_probe.rs", + ["pub fn ops(z: T)"], + ["pub fn ops(z: T)"] + ) +} + +// A module declaring a nullary variant named None also emits `pub struct None;` at module scope, +// which captures the prelude's Option::None: the null keyword row names the item by its path. +test fn w_null_keyword_survives_a_module_declaring_a_none_variant() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.none_capture_probe\nimport std.types { Int }\ntype ScopeX = None | Keyed\ntype PlanX { layer: Int?, scope: ScopeX }\nfn plan_x() -> PlanX { PlanX { layer: none, scope: Keyed } }\n", + "src/test_claim_none_capture_probe.rs", + ["layer: std::option::Option::None,"], + ["layer: None,"] + ) +} + +// The fn-field header prints well-formedness bounds asked per parameter: `divergence: ValueDiff` +// names a type declared ``, so A must carry the bound even though the bare `expected: A` +// earns none; the earlier set-difference dropped both. +test fn w_fn_field_record_header_keeps_the_bound_a_field_type_demands() -> Bool { + compile_dag_rust_emit_check( + "module test.claim.wf_header_probe\nimport std.types { Int }\nimport v2.std.host_run { EmitHostRunReceipt, ValueDiff }\ntype ReceiptX { subject: Subj, expected: A, divergence: ValueDiff, receipt: EmitHostRunReceipt }\n", + "src/test_claim_wf_header_probe.rs", + ["pub struct ReceiptX {"], + ["pub struct ReceiptX {"] + ) +} diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index d97754efe9f..199479ed2b9 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -855,6 +855,15 @@ fn rust_witness_carrier_from_type_node(type_node: Node, shared_types: Set, emit_info: EmitGraphInfo, source_indices: Map) -> String? { + let peeled = rust_peel_all_rc_type_node(type_node: resolved_type, source_indices: source_indices) + if qualified_last_segment(name: peeled.name) == "Witness" { + rust_witness_carrier_from_type_node(type_node: resolved_type, shared_types: shared_types, emit_info: emit_info, source_indices: source_indices) + } else { + none + } +} + fn rust_witness_type_arg_render(type_node: Node, shared_types: Set, emit_info: EmitGraphInfo, source_indices: Map) -> String? { rust_witness_carrier_from_type_node(type_node: type_node, shared_types: shared_types, emit_info: emit_info, source_indices: source_indices) } @@ -885,9 +894,18 @@ fn rust_witness_type_arg_for_variant(variant_name: String, resolved_type: Node, Absent => rust_witness_type_arg_from_fn_return(emit_info: emit_info, shared_types: shared_types, source_indices: source_indices) } } else if variant_name == "Violates" { - match rust_witness_type_arg_from_fn_return(emit_info: emit_info, shared_types: shared_types, source_indices: source_indices) { + // THE LITERAL'S OWN RESOLVED Witness CARRIER FIRST. A Violates literal inside a record field + // or a let is typed by its position (`Witness`), not by the enclosing fn's return; asking + // the return first spelled `Witness::>` for a field of that + // record (E0308 x4 in v2.compiler.eval). The return type answers only when the literal's type + // is not itself a resolved Witness. + match rust_witness_type_arg_if_resolved_witness(resolved_type: resolved_type, shared_types: shared_types, emit_info: emit_info, source_indices: source_indices) { Present { value: arg } => Present { value: arg } - Absent => rust_witness_carrier_from_type_node(type_node: resolved_type, shared_types: shared_types, emit_info: emit_info, source_indices: source_indices) + Absent => + match rust_witness_type_arg_from_fn_return(emit_info: emit_info, shared_types: shared_types, source_indices: source_indices) { + Present { value: arg } => Present { value: arg } + Absent => rust_witness_carrier_from_type_node(type_node: resolved_type, shared_types: shared_types, emit_info: emit_info, source_indices: source_indices) + } } } else { rust_witness_carrier_from_type_node(type_node: resolved_type, shared_types: shared_types, emit_info: emit_info, source_indices: source_indices) @@ -6359,6 +6377,7 @@ fn emit_item_header_clone_param_names( item: item, generic_param_names: generic_param_names, bounds: emit_info.clone_bounded_type_params, + type_decl_items: emit_info.type_decl_items, source_indices: source_indices ) } else { @@ -6937,7 +6956,13 @@ fn emit_enum_shared_accessors(name: String, type_params: String, generic_param_n ) let fns_str = accessor_fns |> join(separator: "\n") let type_application_params = emit_bare_type_params(generic_param_names: generic_param_names) - concat("impl", type_params, " ", name, type_application_params, " {\n", fns_str, "\n}") + // THE ACCESSOR RETURNS T BY VALUE FROM &self, so `__val.clone()` must be T::clone, not the + // reference's; without `T: Clone` on the impl rustc clones the `&T` (E0308 expected `T`, found + // `&T`, six generic carriers). The bound is on the impl the accessor lives in, not on the enum. + let impl_params = if (generic_param_names |> count) == 0 { type_params } else { + concat("<", generic_param_names |> map(g => concat(to_pascal(name: g), ": Clone")) |> join(separator: ", "), ">") + } + concat("impl", impl_params, " ", name, type_application_params, " {\n", fns_str, "\n}") } fn string_without_prefix(value: String, prefix: String) -> String? { @@ -7230,7 +7255,8 @@ fn v1_fn_body_derived_clone_param_names(params: List, inferred: Node, body fn v1_fn_bounds_by_param( clone_param_names: List, eq_param_names: List, - map_key_param_names: List + map_key_param_names: List, + static_param_names: List ) -> Map> { let with_clone = clone_param_names |> fold(init: empty_map(), f: (m, n) => map_insert(m, n, ["Clone"])) let with_eq = eq_param_names |> fold(init: with_clone, f: (m, n) => @@ -7239,12 +7265,23 @@ fn v1_fn_bounds_by_param( Absent => map_insert(m, n, ["PartialEq"]) } ) - map_key_param_names |> fold(init: with_eq, f: (m, n) => + let with_key = map_key_param_names |> fold(init: with_eq, f: (m, n) => match map_get(m, n) { Present { value: traits } => map_insert(m, n, concat(traits, rust_map_key_bound_traits())) Absent => map_insert(m, n, rust_map_key_bound_traits()) } ) + // A GENERIC STORED INTO A `dyn Fn` MUST OUTLIVE IT. The arrow carrier is `Rc`, which + // defaults to `'static`; a fn returning an arrow, or a record whose fields are arrows + // (`Monoid { op: verdict_combine, .. }`), moves its generics into that object, so every generic + // carries `'static` exactly when the param-side gate (`+ 'static` on `impl Fn`) fires + // (E0310 on `Subj`, `T` at verdict_monoid). Same gate, both surfaces. + static_param_names |> fold(init: with_key, f: (m, n) => + match map_get(m, n) { + Present { value: traits } => map_insert(m, n, concat(traits, ["'static"])) + Absent => map_insert(m, n, ["'static"]) + } + ) } // A GENERIC IN KEY POSITION OF A KEYED COLLECTION CARRIES THE HOST KEY BOUNDS. The Rust row for @@ -7675,18 +7712,22 @@ fn emit_fn_def(name: String, params: List, inferred: Node, body: Node, reg generic_param_names: generic_param_names, source_indices: si ) + let returns_arrow_or_fn_field_record = (inferred.params |> count) > 0 + || type_has_fn_fields(name: rust_fn_sig_leaf_name(source_indices: si, n: inferred), emit_info: emit_info) + let static_param_names = if returns_arrow_or_fn_field_record { generic_param_names } else { [] } let bounds_by_param = v1_fn_bounds_by_param( clone_param_names: clone_param_names, eq_param_names: eq_param_names, - map_key_param_names: map_key_param_names + map_key_param_names: map_key_param_names, + static_param_names: static_param_names ) - let needs_bound = (clone_param_names |> count) > 0 || (eq_param_names |> count) > 0 || (map_key_param_names |> count) > 0 + let needs_bound = (clone_param_names |> count) > 0 || (eq_param_names |> count) > 0 || (map_key_param_names |> count) > 0 || (static_param_names |> count) > 0 let type_params_str = if needs_bound { v1_emit_type_params_with_bounds(params: type_params, bounds_by_param: bounds_by_param, source_indices: si) } else { emit_type_params(params: type_params, source_indices: si) } - let params_str = emit_params(params: value_params, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: si, read_only_params: emit_info.read_only_params, variant_to_enum: emit_info.variant_to_enum, env: scope.type_env, enclosing_returns_arrow: (inferred.params |> count) > 0) + let params_str = emit_params(params: value_params, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: si, read_only_params: emit_info.read_only_params, variant_to_enum: emit_info.variant_to_enum, env: scope.type_env, enclosing_returns_arrow: returns_arrow_or_fn_field_record) let ret_str = emit_inferred(inferred: inferred, generic_param_names: generic_param_names, shared_types: shared_types, source_indices: si, variant_to_enum: emit_info.variant_to_enum, env: scope.type_env) let body_scope = build_params_scope(scope: scope, params: value_params) let depth = 0 @@ -8425,9 +8466,17 @@ fn analyze_rc_pattern(pattern: MatchPattern, scrut_type: String, shared_types: S } else { empty_rc_pattern_analysis() } } else { let resolved_parent = pattern_parent_enum(name: bare_n, parent_enum: parent_enum, scrut_type: scrut_type, type_summaries: emit_info.type_summaries) + // A RECORD PATTERN HAS NO PARENT ENUM, BUT ITS CARRIER IS STILL SHARED. `Record { f, .. }` + // over a scrutinee that renders `Rc` needs the same deref a shared enum's variant + // gets; without it the pattern met the Rc (E0308 expected `Rc`, found + // `AdmitExportsFold`, four record sites). The record is decided by the same shared set. let matches_rc_variant = match resolved_parent { Present { value: enum_name } => set_contains(shared_types, enum_name) - Absent => false + Absent => + match map_get(emit_info.type_summaries, bare_n) { + Present { value: _ } => set_contains(shared_types, bare_n) + Absent => false + } } let ref_bound_fields = fbs |> flat_map(fb => let fb_name = field_binding_name_at(n: fb, source_indices: source_indices) @@ -9755,12 +9804,18 @@ fn emit_typed_call_expr(func: String, args: List, inferred: InferredNode?, } else { call_str } } -fn rust_call_arg_fail_closed_unwrap(arg_str: String, arg: Node, callee: ItemInfo?, idx: Int, func: String) -> String { +// A PARAMETER DECLARED `Optional` IS OPTIONAL. The cardinality flag marks the `T?` sugar; the +// applied carrier spelling carries no flag, so a caller passing an optional into +// `witness_from_optional(opt: Optional, ..)` earned a fail-closed `.expect(..)` that unwrapped +// the very value the callee exists to inspect (E0308 expected Option<..>, found .. at six sites). +// Both spellings name one carrier; the predicate asks both. +fn rust_call_arg_fail_closed_unwrap(arg_str: String, arg: Node, callee: ItemInfo?, idx: Int, func: String, source_indices: Map) -> String { match callee { Present { value: info } => match function_value_params(params: info.params) |> skip(idx) |> first { Present { value: param } => - let param_required = param_node_type_expr(n: param).return_cardinality != CardOptional + let param_type = param_node_type_expr(n: param) + let param_required = param_type.return_cardinality != CardOptional && !is_host_optional_carrier_type(n: param_type, source_indices: source_indices) let arg_optional = resolved_type(n: arg).return_cardinality == CardOptional if param_required && arg_optional { concat(arg_str, ".expect(\"fail-closed: an optional value flowed into non-optional parameter ", to_string(value: idx), " of ", func, " (empty Optional at runtime)\")") @@ -9990,7 +10045,7 @@ fn emit_typed_call(func: String, args: List, callee_is_function_value: Boo concat("&", base) } else { let base = emit_cloned_arg(texpr: arg_value(n: a), registry: registry, scope: arg_scope, depth: depth, shared_types: shared_types, emit_info: emit_info) - let unwrapped = rust_call_arg_fail_closed_unwrap(arg_str: base, arg: arg_value(n: a), callee: callee, idx: idx, func: func) + let unwrapped = rust_call_arg_fail_closed_unwrap(arg_str: base, arg: arg_value(n: a), callee: callee, idx: idx, func: func, source_indices: scope.type_env.source_indices) rust_call_arg_function_value_adapt(arg_str: unwrapped, arg: arg_value(n: a), callee: callee, idx: idx) } ) diff --git a/src/v1/trait_derive_emit.dag b/src/v1/trait_derive_emit.dag index 2fba80ae8b7..489c4c429f7 100644 --- a/src/v1/trait_derive_emit.dag +++ b/src/v1/trait_derive_emit.dag @@ -2208,22 +2208,32 @@ fn v1_emit_type_params_with_bounds( // remainder. It is a subtraction rather than a second fixpoint because propagation must still see // every OTHER item's seed -- OrderedClosedInterval earns its bound from its own bare `low: T` // field, and a WF-only fixpoint with no seeds anywhere would have nothing to propagate FROM. +// THE FN-FIELD HEADER PRINTS THE WELL-FORMEDNESS BOUNDS, ASKED DIRECTLY. An fn-field item carries +// a supplemental Clone impl, so the header owes no bound for CLONING a bare `expected: A` -- but it +// still owes every bound a FIELD'S DECLARED TYPE demands to be nameable at all. The earlier form +// subtracted the seed-needed parameters from the bounded set, which removed `A` from +// `FalsificationReceipt` even though its field `divergence: ValueDiff` names a type +// declared `` (E0277 at v2.std.test_claim_falsification). Set difference conflated the +// two obligations; the well-formedness predicate is the single authority for the header and is +// asked per parameter. fn v1_item_wf_propagated_clone_bounded_param_names( item_name: String, item: Node, generic_param_names: List, bounds: Map>, + type_decl_items: Map, source_indices: Map ) -> List { - let field_type_exprs = v1_item_field_type_exprs(item: item, source_indices: source_indices) v1_item_clone_bounded_param_names( item_name: item_name, generic_param_names: generic_param_names, bounds: bounds ) |> filter(g => - !v1_item_type_param_needs_clone_bound_struct( + v1_item_param_wf_needs_clone( param_name: g, - field_type_exprs: field_type_exprs, + item: item, + bounds: bounds, + type_decl_items: type_decl_items, source_indices: source_indices ) ) diff --git a/src/v2/std/collection.dag b/src/v2/std/collection.dag index 507bac43143..8fb9318dd84 100644 --- a/src/v2/std/collection.dag +++ b/src/v2/std/collection.dag @@ -55,11 +55,15 @@ fn empty_map_primitive_delegate() -> Map { fn empty_map() -> Map { empty_map_primitive_delegate() } -fn map_insert_primitive_delegate(m: Map, key: K, value: V) -> Map { - map_insert_primitive_delegate(m: m, key: key, value: value) -} fn map_insert(m: Map, key: K, value: V) -> Map { - map_insert_primitive_delegate(m: m, key: key, value: value) + Map { + lookup: fn(candidate) { + match candidate == key { + true => Present { value: value } + false => m.lookup(candidate) + } + } + } } // LOOKUP IS TOTAL. A map either holds the key or does not, and both are answers — there is no From 3989a1d57f87384739b306cfe1bfdf5d1b1c3a80 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 08:16:37 +0000 Subject: [PATCH 47/75] =?UTF-8?q?Hoist=20commit-3=20rationale=20annotation?= =?UTF-8?q?s=20to=20module-item=20grain=20(=C2=A74c=20refuses=20in-body=20?= =?UTF-8?q?//=20blocks;=2017=20regen=20refusals=20on=20780b394)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01GXfYKNQTD3VfYyQcnJpxNU --- src/v1/05_emit_rust.dag | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index 199479ed2b9..f02fc30b5d7 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -887,6 +887,11 @@ fn rust_witness_type_arg_from_fn_return(emit_info: EmitGraphInfo, shared_types: } } +// THE LITERAL'S OWN RESOLVED Witness CARRIER FIRST. A Violates literal inside a record field +// or a let is typed by its position (`Witness`), not by the enclosing fn's return; asking +// the return first spelled `Witness::>` for a field of that +// record (E0308 x4 in v2.compiler.eval). The return type answers only when the literal's type +// is not itself a resolved Witness. fn rust_witness_type_arg_for_variant(variant_name: String, resolved_type: Node, fields: List, shared_types: Set, emit_info: EmitGraphInfo, source_indices: Map) -> String? { if variant_name == "Holds" { match rust_witness_type_arg_from_holds_value_field(fields: fields, shared_types: shared_types, emit_info: emit_info, source_indices: source_indices) { @@ -894,11 +899,6 @@ fn rust_witness_type_arg_for_variant(variant_name: String, resolved_type: Node, Absent => rust_witness_type_arg_from_fn_return(emit_info: emit_info, shared_types: shared_types, source_indices: source_indices) } } else if variant_name == "Violates" { - // THE LITERAL'S OWN RESOLVED Witness CARRIER FIRST. A Violates literal inside a record field - // or a let is typed by its position (`Witness`), not by the enclosing fn's return; asking - // the return first spelled `Witness::>` for a field of that - // record (E0308 x4 in v2.compiler.eval). The return type answers only when the literal's type - // is not itself a resolved Witness. match rust_witness_type_arg_if_resolved_witness(resolved_type: resolved_type, shared_types: shared_types, emit_info: emit_info, source_indices: source_indices) { Present { value: arg } => Present { value: arg } Absent => @@ -6911,6 +6911,9 @@ fn find_shared_enum_fields(children: List, env: TypeEnv) -> List { ) } +// THE ACCESSOR RETURNS T BY VALUE FROM &self, so `__val.clone()` must be T::clone, not the +// reference's; without `T: Clone` on the impl rustc clones the `&T` (E0308 expected `T`, found +// `&T`, six generic carriers). The bound is on the impl the accessor lives in, not on the enum. fn emit_enum_shared_accessors(name: String, type_params: String, generic_param_names: List, children: List, recursive_types: Set, shared_types: Set, env: TypeEnv, emit_info: EmitGraphInfo) -> String { let all_shared = find_shared_enum_fields(children: children, env: env) if all_shared |> count == 0 { return "" } @@ -6956,9 +6959,6 @@ fn emit_enum_shared_accessors(name: String, type_params: String, generic_param_n ) let fns_str = accessor_fns |> join(separator: "\n") let type_application_params = emit_bare_type_params(generic_param_names: generic_param_names) - // THE ACCESSOR RETURNS T BY VALUE FROM &self, so `__val.clone()` must be T::clone, not the - // reference's; without `T: Clone` on the impl rustc clones the `&T` (E0308 expected `T`, found - // `&T`, six generic carriers). The bound is on the impl the accessor lives in, not on the enum. let impl_params = if (generic_param_names |> count) == 0 { type_params } else { concat("<", generic_param_names |> map(g => concat(to_pascal(name: g), ": Clone")) |> join(separator: ", "), ">") } @@ -7248,6 +7248,11 @@ fn v1_fn_body_derived_clone_param_names(params: List, inferred: Node, body ) } +// A GENERIC STORED INTO A `dyn Fn` MUST OUTLIVE IT. The arrow carrier is `Rc`, which +// defaults to `'static`; a fn returning an arrow, or a record whose fields are arrows +// (`Monoid { op: verdict_combine, .. }`), moves its generics into that object, so every generic +// carries `'static` exactly when the param-side gate (`+ 'static` on `impl Fn`) fires +// (E0310 on `Subj`, `T` at verdict_monoid). Same gate, both surfaces. // Joins the two derivations onto one per-param trait list so a param earning both renders // `K: Clone + PartialEq`. Clone is listed first so the Clone-only case is byte-identical to what // the previous single-trait renderer emitted, which is what lets the regen fixed point act as the @@ -7271,11 +7276,6 @@ fn v1_fn_bounds_by_param( Absent => map_insert(m, n, rust_map_key_bound_traits()) } ) - // A GENERIC STORED INTO A `dyn Fn` MUST OUTLIVE IT. The arrow carrier is `Rc`, which - // defaults to `'static`; a fn returning an arrow, or a record whose fields are arrows - // (`Monoid { op: verdict_combine, .. }`), moves its generics into that object, so every generic - // carries `'static` exactly when the param-side gate (`+ 'static` on `impl Fn`) fires - // (E0310 on `Subj`, `T` at verdict_monoid). Same gate, both surfaces. static_param_names |> fold(init: with_key, f: (m, n) => match map_get(m, n) { Present { value: traits } => map_insert(m, n, concat(traits, ["'static"])) @@ -8446,6 +8446,10 @@ fn field_needs_rc_ref(field_name: String, rc_analysis: RcPatternAnalysis) -> Boo rc_analysis.ref_bound_fields |> any(name => name == field_name) } +// A RECORD PATTERN HAS NO PARENT ENUM, BUT ITS CARRIER IS STILL SHARED. `Record { f, .. }` +// over a scrutinee that renders `Rc` needs the same deref a shared enum's variant +// gets; without it the pattern met the Rc (E0308 expected `Rc`, found +// `AdmitExportsFold`, four record sites). The record is decided by the same shared set. fn analyze_rc_pattern(pattern: MatchPattern, scrut_type: String, shared_types: Set, emit_info: EmitGraphInfo, source_indices: Map) -> RcPatternAnalysis { match pattern { VariantPattern { name: n, parent_enum: parent_enum, field_bindings: fbs } => @@ -8466,10 +8470,6 @@ fn analyze_rc_pattern(pattern: MatchPattern, scrut_type: String, shared_types: S } else { empty_rc_pattern_analysis() } } else { let resolved_parent = pattern_parent_enum(name: bare_n, parent_enum: parent_enum, scrut_type: scrut_type, type_summaries: emit_info.type_summaries) - // A RECORD PATTERN HAS NO PARENT ENUM, BUT ITS CARRIER IS STILL SHARED. `Record { f, .. }` - // over a scrutinee that renders `Rc` needs the same deref a shared enum's variant - // gets; without it the pattern met the Rc (E0308 expected `Rc`, found - // `AdmitExportsFold`, four record sites). The record is decided by the same shared set. let matches_rc_variant = match resolved_parent { Present { value: enum_name } => set_contains(shared_types, enum_name) Absent => From a9acc59d81caf8b050a279daf47b28ecf1c420e4 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 08:21:50 +0000 Subject: [PATCH 48/75] XL-0N: operand realization reads the RESOLVED structure -- a NoConnective childless leaf whose structural name is a kernel type is a host operand (the resolver collapses NonEmptyStr/Char/VersionIdentity to their primitive RHS under the alias identity, so no resolved node is ever an alias item); refusal temporarily carries the operand's shape facts for the regen diagnosis Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_013koFunEtpLQCnvUiz85k7Y --- src/v1/05_emit_rust.dag | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index 63438d4a936..ed9c0b671fe 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -11952,7 +11952,7 @@ fn emit_typed_bin_op(op: BinOp, algebra_field: AlgebraFieldKind?, left: Node, ri } else { match binop_operator_realization(op: op, left: left, scope: scope) { OperatorRealizationRefused { cause: c } => - emit_rust_compile_error_expr(message: operator_realization_refusal_message(cause: c)) + emit_rust_compile_error_expr(message: concat(operator_realization_refusal_message(cause: c), " [", rust_operand_shape_facts(operand: left, scope: scope), "]")) StructuralComparison { declaration: _, binding: b, test: t } => emit_rust_structural_comparison(l_str: l_str, r_str: r_str, binding: b, test: t) StructuralEquality { declaration: _ } => @@ -11983,6 +11983,11 @@ fn rust_operand_realization(operand: Node, scope: InferScope) -> OperandRealizat // v1_item_alias_hop_type_exprs). The seed's own semver and unicode modules compare NonEmptyStr and // add to Char; without the hop those were refused as structural. Fuel bounds an alias chain; a // chain longer than it is judged at its last declaration. +// The resolver collapses a transparent primitive alias to its right-hand side's STRUCTURE under the +// alias's identity (v1.compiler.resolve preserve_nominal_brand_on_resolve: `NonEmptyStr` resolves to a +// childless `String` leaf that still names NonEmptyStr), so the resolved node is never an alias ITEM; +// the structural fact is on the node itself: a NoConnective, childless leaf whose structural name is +// a kernel type realizes as that kernel type on the host (structural_kernel_leaf below). fn rust_operand_realization_of_type(rt: Node, scope: InferScope, fuel: Int) -> OperandRealization { match type_reference_declaration_ref(n: rt, source_indices: scope.type_env.source_indices, env: scope.type_env) { Absent => OperandIdentityUnavailable @@ -11994,7 +11999,10 @@ fn rust_operand_realization_of_type(rt: Node, scope: InferScope, fuel: Int) -> O Present { value: Resolved { node: r } } => r _ => rt } - if fuel > 0 && is_type_alias_item(item: decl, source_indices: scope.type_env.source_indices) { + let structural_kernel_leaf = rt.connective == NoConnective && rt.children |> count == 0 && is_kernel_type(name: qualified_last_segment(name: rt.name)) + if structural_kernel_leaf { + HostNumericOperand + } else if fuel > 0 && is_type_alias_item(item: decl, source_indices: scope.type_env.source_indices) { rust_operand_realization_of_type(rt: resolved_type(n: decl), scope: scope, fuel: fuel - 1) } else { StructuralOperand { declaration: d } @@ -12003,6 +12011,22 @@ fn rust_operand_realization_of_type(rt: Node, scope: InferScope, fuel: Int) -> O } } + +// TEMPORARY (XL-0N regen diagnosis): the operand's resolved-node shape, appended to the refusal. +fn rust_operand_shape_facts(operand: Node, scope: InferScope) -> String { + let rt = resolved_type(n: operand) + let decl = match rt.inferred { Present { value: Resolved { node: r } } => r _ => rt } + concat( + "rt.name=", rt.name, " rt.authored=", authored_name_at(source_indices: scope.type_env.source_indices, node: rt), + " rt.conn=", if rt.connective == NoConnective { "none" } else { "some" }, + " rt.children=", (rt.children |> count) as String, " rt.inferred=", if rt.inferred == none { "absent" } else { "present" }, + " decl.name=", decl.name, " decl.authored=", authored_name_at(source_indices: scope.type_env.source_indices, node: decl), + " decl.conn=", if decl.connective == NoConnective { "none" } else { "some" }, + " decl.children=", (decl.children |> count) as String, " decl.inferred=", if decl.inferred == none { "absent" } else { "present" }, + " decl.params=", (decl.params |> count) as String, " alias_item=", if is_type_alias_item(item: decl, source_indices: scope.type_env.source_indices) { "yes" } else { "no" } + ) +} + fn binop_operator_realization(op: BinOp, left: Node, scope: InferScope) -> OperatorRealization { operator_realization_for(op: op, operand: rust_operand_realization(operand: left, scope: scope), ordering_rows: structural_ordering_rows) } From bcb283cfdac6ea13ac0e4ac513e151654265523a Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 08:49:21 +0000 Subject: [PATCH 49/75] XL-0N: shape-facts suffix spells Int counts with to_string (the seed runtime has no Int-as-String cast; the cast panicked the emitter under regen) Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_013koFunEtpLQCnvUiz85k7Y --- src/v1/05_emit_rust.dag | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index ed9c0b671fe..bde53543402 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -12019,11 +12019,11 @@ fn rust_operand_shape_facts(operand: Node, scope: InferScope) -> String { concat( "rt.name=", rt.name, " rt.authored=", authored_name_at(source_indices: scope.type_env.source_indices, node: rt), " rt.conn=", if rt.connective == NoConnective { "none" } else { "some" }, - " rt.children=", (rt.children |> count) as String, " rt.inferred=", if rt.inferred == none { "absent" } else { "present" }, + " rt.children=", to_string(value: rt.children |> count), " rt.inferred=", if rt.inferred == none { "absent" } else { "present" }, " decl.name=", decl.name, " decl.authored=", authored_name_at(source_indices: scope.type_env.source_indices, node: decl), " decl.conn=", if decl.connective == NoConnective { "none" } else { "some" }, - " decl.children=", (decl.children |> count) as String, " decl.inferred=", if decl.inferred == none { "absent" } else { "present" }, - " decl.params=", (decl.params |> count) as String, " alias_item=", if is_type_alias_item(item: decl, source_indices: scope.type_env.source_indices) { "yes" } else { "no" } + " decl.children=", to_string(value: decl.children |> count), " decl.inferred=", if decl.inferred == none { "absent" } else { "present" }, + " decl.params=", to_string(value: decl.params |> count), " alias_item=", if is_type_alias_item(item: decl, source_indices: scope.type_env.source_indices) { "yes" } else { "no" } ) } From 6ba83b31b474a92554f77691d6b98c628ce37110 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 09:18:00 +0000 Subject: [PATCH 50/75] XL-0N: operand realization hops a where-refinement wrapper to its base (is_where_refinement_type, the type renderer's own route) -- measured under regen: NonEmptyStr/Char/VersionIdentity operands resolve to the one-child Conj refinement node, not a leaf or an alias item Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_013koFunEtpLQCnvUiz85k7Y --- src/v1/05_emit_rust.dag | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index bde53543402..5f96823b449 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -11983,11 +11983,12 @@ fn rust_operand_realization(operand: Node, scope: InferScope) -> OperandRealizat // v1_item_alias_hop_type_exprs). The seed's own semver and unicode modules compare NonEmptyStr and // add to Char; without the hop those were refused as structural. Fuel bounds an alias chain; a // chain longer than it is judged at its last declaration. -// The resolver collapses a transparent primitive alias to its right-hand side's STRUCTURE under the -// alias's identity (v1.compiler.resolve preserve_nominal_brand_on_resolve: `NonEmptyStr` resolves to a -// childless `String` leaf that still names NonEmptyStr), so the resolved node is never an alias ITEM; -// the structural fact is on the node itself: a NoConnective, childless leaf whose structural name is -// a kernel type realizes as that kernel type on the host (structural_kernel_leaf below). +// A `where`-refined declaration resolves to the parser's refinement wrapper -- a one-child Conj +// carrying the predicate as its type_annotation (v1.compiler.parse try_where_clause), which is what +// the operand's resolved node IS at these sites (measured under regen: Conj, one child, no inferred), +// never an alias item. The type renderer already realizes such a node as its base +// (render_rust_alias_rhs_type hops is_where_refinement_type to the first child), so the operand +// decision hops the same way, resolving the base through the env as where_refinement_chain does. fn rust_operand_realization_of_type(rt: Node, scope: InferScope, fuel: Int) -> OperandRealization { match type_reference_declaration_ref(n: rt, source_indices: scope.type_env.source_indices, env: scope.type_env) { Absent => OperandIdentityUnavailable @@ -11999,9 +12000,16 @@ fn rust_operand_realization_of_type(rt: Node, scope: InferScope, fuel: Int) -> O Present { value: Resolved { node: r } } => r _ => rt } - let structural_kernel_leaf = rt.connective == NoConnective && rt.children |> count == 0 && is_kernel_type(name: qualified_last_segment(name: rt.name)) - if structural_kernel_leaf { - HostNumericOperand + if fuel > 0 && is_where_refinement_type(ty: rt) { + match rt.children |> first { + Present { value: base } => + let base_resolved = match lookup_type_for(env: scope.type_env, node: base) { + Present { value: r } => r + Absent => base + } + rust_operand_realization_of_type(rt: base_resolved, scope: scope, fuel: fuel - 1) + Absent => StructuralOperand { declaration: d } + } } else if fuel > 0 && is_type_alias_item(item: decl, source_indices: scope.type_env.source_indices) { rust_operand_realization_of_type(rt: resolved_type(n: decl), scope: scope, fuel: fuel - 1) } else { @@ -12023,7 +12031,7 @@ fn rust_operand_shape_facts(operand: Node, scope: InferScope) -> String { " decl.name=", decl.name, " decl.authored=", authored_name_at(source_indices: scope.type_env.source_indices, node: decl), " decl.conn=", if decl.connective == NoConnective { "none" } else { "some" }, " decl.children=", to_string(value: decl.children |> count), " decl.inferred=", if decl.inferred == none { "absent" } else { "present" }, - " decl.params=", to_string(value: decl.params |> count), " alias_item=", if is_type_alias_item(item: decl, source_indices: scope.type_env.source_indices) { "yes" } else { "no" } + " decl.params=", to_string(value: decl.params |> count), " rt.type_annotation=", if rt.type_annotation == none { "absent" } else { "present" }, " where_refinement=", if is_where_refinement_type(ty: rt) { "yes" } else { "no" }, " alias_item=", if is_type_alias_item(item: decl, source_indices: scope.type_env.source_indices) { "yes" } else { "no" } ) } From f38fdc97096ad3e84b668f67906a598ab665d8d6 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 09:24:40 +0000 Subject: [PATCH 51/75] XL-0N: operator realization matches over BinOp are total (14 closed variants enumerated) -- no non-fold residue rows for the new module Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_013koFunEtpLQCnvUiz85k7Y --- dag/std/operator_realization.dag | 76 +++++++++++++++++++++++--------- 1 file changed, 56 insertions(+), 20 deletions(-) diff --git a/dag/std/operator_realization.dag b/dag/std/operator_realization.dag index 6bc24d8f05a..d1004549f57 100644 --- a/dag/std/operator_realization.dag +++ b/dag/std/operator_realization.dag @@ -76,7 +76,16 @@ fn ordering_test_for(op: BinOp) -> OrderingTest? { Gt => Present { value: OrderingIs { variant: "Greater" as NonEmptyStr } } Le => Present { value: OrderingIsNot { variant: "Greater" as NonEmptyStr } } Ge => Present { value: OrderingIsNot { variant: "Less" as NonEmptyStr } } - _ => none + Add => none + Sub => none + Mul => none + Div => none + Mod => none + Eq => none + Ne => none + And => none + Or => none + NullCoalesce => none } } @@ -84,7 +93,18 @@ fn binop_is_equality(op: BinOp) -> Bool { match op { Eq => true Ne => true - _ => false + Add => false + Sub => false + Mul => false + Div => false + Mod => false + Lt => false + Gt => false + Le => false + Ge => false + And => false + Or => false + NullCoalesce => false } } @@ -153,24 +173,40 @@ fn operator_realization_for( HostNumericOperand => HostOperator OperandIdentityUnavailable => HostOperator StructuralOperand { declaration: d } => - if binop_is_equality(op: op) { - StructuralEquality { declaration: d } - } else { - match ordering_test_for(op: op) { - Present { value: test } => - match structural_ordering_for(rows: ordering_rows, carrier: d) { - StructuralOrderingFound { row: row } => StructuralComparison { declaration: d, binding: row, test: test } - StructuralOrderingAbsent => OperatorRealizationRefused { cause: NoStructuralOperationDeclared { declaration: d, operator: binop_label(op: op) } } - StructuralOrderingAmbiguous { row_count: n } => OperatorRealizationRefused { cause: StructuralOrderingDuplicated { declaration: d, row_count: n } } - } - Absent => - match op { - And => HostOperator - Or => HostOperator - NullCoalesce => HostOperator - _ => OperatorRealizationRefused { cause: NoStructuralOperationDeclared { declaration: d, operator: binop_label(op: op) } } - } - } + match op { + Eq => StructuralEquality { declaration: d } + Ne => StructuralEquality { declaration: d } + Lt => structural_ordering_realization(op: op, declaration: d, ordering_rows: ordering_rows) + Gt => structural_ordering_realization(op: op, declaration: d, ordering_rows: ordering_rows) + Le => structural_ordering_realization(op: op, declaration: d, ordering_rows: ordering_rows) + Ge => structural_ordering_realization(op: op, declaration: d, ordering_rows: ordering_rows) + And => HostOperator + Or => HostOperator + NullCoalesce => HostOperator + Add => structural_arithmetic_refusal(op: op, declaration: d) + Sub => structural_arithmetic_refusal(op: op, declaration: d) + Mul => structural_arithmetic_refusal(op: op, declaration: d) + Div => structural_arithmetic_refusal(op: op, declaration: d) + Mod => structural_arithmetic_refusal(op: op, declaration: d) + } + } +} + +fn structural_arithmetic_refusal(op: BinOp, declaration: DeclarationRef) -> OperatorRealization { + OperatorRealizationRefused { cause: NoStructuralOperationDeclared { declaration: declaration, operator: binop_label(op: op) } } +} + +// An ordering operator on a structural operand: the declared comparison, or the refusal. Reached +// only from the four ordering arms above, so an op with no ordering test is a refusal here too -- +// that arm is unreachable by construction, not a wildcard. +fn structural_ordering_realization(op: BinOp, declaration: DeclarationRef, ordering_rows: List) -> OperatorRealization { + match ordering_test_for(op: op) { + Absent => structural_arithmetic_refusal(op: op, declaration: declaration) + Present { value: test } => + match structural_ordering_for(rows: ordering_rows, carrier: declaration) { + StructuralOrderingFound { row: row } => StructuralComparison { declaration: declaration, binding: row, test: test } + StructuralOrderingAbsent => structural_arithmetic_refusal(op: op, declaration: declaration) + StructuralOrderingAmbiguous { row_count: n } => OperatorRealizationRefused { cause: StructuralOrderingDuplicated { declaration: declaration, row_count: n } } } } } From 9187f3b8cfd167997074a32c2f827957d2f3e223 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 09:33:46 +0000 Subject: [PATCH 52/75] Commit 3 correction after the first regen: withdraw the Violates field-carrier arm (the literal resolves to the Witness declaration, spelling Witness:: at 87 sites), 'static on generics only for fn-field record returns (compose stays bare), re-pin the optional and shared-record rows Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01GXfYKNQTD3VfYyQcnJpxNU --- ...d_call_target_realization_witness_test.dag | 16 ++------ src/v1/05_emit_rust.dag | 37 ++++++------------- 2 files changed, 14 insertions(+), 39 deletions(-) diff --git a/dag/test/claim/self_host_emitted_call_target_realization_witness_test.dag b/dag/test/claim/self_host_emitted_call_target_realization_witness_test.dag index 896a3abc383..b459cc2ea77 100644 --- a/dag/test/claim/self_host_emitted_call_target_realization_witness_test.dag +++ b/dag/test/claim/self_host_emitted_call_target_realization_witness_test.dag @@ -473,7 +473,7 @@ test fn w_service_op_in_a_service_free_fn_refuses_instead_of_awaiting_an_unbound // so the fail-closed unwrap fired on an argument the callee exists to inspect. test fn w_optional_carrier_parameter_takes_the_optional_argument_without_an_unwrap() -> Bool { compile_dag_rust_emit_check( - "module test.claim.optional_param_probe\nimport std.types { Int }\nimport v2.std.optional { Optional }\nfn inspect(opt: Optional) -> Optional { opt }\nfn caller(x: Int?) -> Optional { inspect(opt: x) }\n", + "module test.claim.optional_param_probe\nimport std.types { Int }\nimport v2.std.optional { Optional }\nfn inspect(opt: Optional) -> Optional { opt }\nfn caller(x: Optional) -> Optional { inspect(opt: x) }\n", "src/test_claim_optional_param_probe.rs", ["inspect(x.clone())"], [".expect(\"fail-closed: an optional value flowed into non-optional parameter"] @@ -491,23 +491,13 @@ test fn w_generic_coproduct_shared_accessor_impl_carries_the_clone_bound() -> Bo ) } -// A Violates literal in a record field is typed by its position, not by the enclosing fn's return. -test fn w_violates_literal_in_a_record_field_takes_the_field_witness_carrier() -> Bool { - compile_dag_rust_emit_check( - "module test.claim.witness_field_probe\nimport std.types { Int }\nimport v2.std.node { Node }\nimport v2.std.diagnostic { Diagnostic }\nimport v2.std.witness { Holds, Violates, Witness }\ntype Judged { resolved: Witness, ok: Witness }\nfn judge(d: Diagnostic, n: Int) -> Judged { Judged { resolved: Violates { diagnostic: d }, ok: Holds { value: n } } }\n", - "src/test_claim_witness_field_probe.rs", - ["Witness::>::Violates"], - ["Witness::>::Violates"] - ) -} - // A record pattern over a generic call's result: the scrutinee carrier is decided by the shared set, // exactly as a shared enum's variant pattern is, so the pattern must meet the value, not the Rc. test fn w_record_pattern_over_a_generic_call_result_derefs_the_shared_carrier() -> Bool { compile_dag_rust_emit_check( - "module test.claim.record_pattern_probe\nimport std.types { Int }\ntype Rec { a: Int, b: Int }\nfn ident(c: C) -> C { c }\nfn probe(r: Rec) -> Int { match ident(c: r) { Rec { a: x, b: _ } => x } }\n", + "module test.claim.record_pattern_probe\nimport std.types { Int }\nimport v2.std.collection { List }\ntype Rec { tag: Int, items: List }\nfn ident(c: C) -> C { c }\nfn probe(r: Rec) -> Int { match ident(c: r) { Rec { tag: x, items: _ } => x } }\n", "src/test_claim_record_pattern_probe.rs", - ["Rec { a: x, .. } => x.clone()"], + ["Rec { tag: x, .. } => x.clone()"], ["match ident(r.clone()) {"] ) } diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index f02fc30b5d7..ee0b9c3f513 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -855,15 +855,6 @@ fn rust_witness_carrier_from_type_node(type_node: Node, shared_types: Set, emit_info: EmitGraphInfo, source_indices: Map) -> String? { - let peeled = rust_peel_all_rc_type_node(type_node: resolved_type, source_indices: source_indices) - if qualified_last_segment(name: peeled.name) == "Witness" { - rust_witness_carrier_from_type_node(type_node: resolved_type, shared_types: shared_types, emit_info: emit_info, source_indices: source_indices) - } else { - none - } -} - fn rust_witness_type_arg_render(type_node: Node, shared_types: Set, emit_info: EmitGraphInfo, source_indices: Map) -> String? { rust_witness_carrier_from_type_node(type_node: type_node, shared_types: shared_types, emit_info: emit_info, source_indices: source_indices) } @@ -887,11 +878,6 @@ fn rust_witness_type_arg_from_fn_return(emit_info: EmitGraphInfo, shared_types: } } -// THE LITERAL'S OWN RESOLVED Witness CARRIER FIRST. A Violates literal inside a record field -// or a let is typed by its position (`Witness`), not by the enclosing fn's return; asking -// the return first spelled `Witness::>` for a field of that -// record (E0308 x4 in v2.compiler.eval). The return type answers only when the literal's type -// is not itself a resolved Witness. fn rust_witness_type_arg_for_variant(variant_name: String, resolved_type: Node, fields: List, shared_types: Set, emit_info: EmitGraphInfo, source_indices: Map) -> String? { if variant_name == "Holds" { match rust_witness_type_arg_from_holds_value_field(fields: fields, shared_types: shared_types, emit_info: emit_info, source_indices: source_indices) { @@ -899,13 +885,9 @@ fn rust_witness_type_arg_for_variant(variant_name: String, resolved_type: Node, Absent => rust_witness_type_arg_from_fn_return(emit_info: emit_info, shared_types: shared_types, source_indices: source_indices) } } else if variant_name == "Violates" { - match rust_witness_type_arg_if_resolved_witness(resolved_type: resolved_type, shared_types: shared_types, emit_info: emit_info, source_indices: source_indices) { + match rust_witness_type_arg_from_fn_return(emit_info: emit_info, shared_types: shared_types, source_indices: source_indices) { Present { value: arg } => Present { value: arg } - Absent => - match rust_witness_type_arg_from_fn_return(emit_info: emit_info, shared_types: shared_types, source_indices: source_indices) { - Present { value: arg } => Present { value: arg } - Absent => rust_witness_carrier_from_type_node(type_node: resolved_type, shared_types: shared_types, emit_info: emit_info, source_indices: source_indices) - } + Absent => rust_witness_carrier_from_type_node(type_node: resolved_type, shared_types: shared_types, emit_info: emit_info, source_indices: source_indices) } } else { rust_witness_carrier_from_type_node(type_node: resolved_type, shared_types: shared_types, emit_info: emit_info, source_indices: source_indices) @@ -7250,9 +7232,12 @@ fn v1_fn_body_derived_clone_param_names(params: List, inferred: Node, body // A GENERIC STORED INTO A `dyn Fn` MUST OUTLIVE IT. The arrow carrier is `Rc`, which // defaults to `'static`; a fn returning an arrow, or a record whose fields are arrows -// (`Monoid { op: verdict_combine, .. }`), moves its generics into that object, so every generic -// carries `'static` exactly when the param-side gate (`+ 'static` on `impl Fn`) fires -// (E0310 on `Subj`, `T` at verdict_monoid). Same gate, both surfaces. +// (`Monoid { op: verdict_combine, .. }`), moves its generics into that object. The bound lands on +// the generics only for the RECORD return: a fn item stored into a field is `'static` only when +// its generics are (E0310 on `Subj`, `T` at verdict_monoid), while a returned closure captures +// only its `impl Fn + 'static` parameters, so `compose` stays bare -- pinned by +// w_generic_forwarded_by_a_returned_closure_carries_clone, which went red when this gate was +// first written over both surfaces. // Joins the two derivations onto one per-param trait list so a param earning both renders // `K: Clone + PartialEq`. Clone is listed first so the Clone-only case is byte-identical to what // the previous single-trait renderer emitted, which is what lets the regen fixed point act as the @@ -7712,9 +7697,9 @@ fn emit_fn_def(name: String, params: List, inferred: Node, body: Node, reg generic_param_names: generic_param_names, source_indices: si ) - let returns_arrow_or_fn_field_record = (inferred.params |> count) > 0 - || type_has_fn_fields(name: rust_fn_sig_leaf_name(source_indices: si, n: inferred), emit_info: emit_info) - let static_param_names = if returns_arrow_or_fn_field_record { generic_param_names } else { [] } + let returns_fn_field_record = type_has_fn_fields(name: rust_fn_sig_leaf_name(source_indices: si, n: inferred), emit_info: emit_info) + let returns_arrow_or_fn_field_record = (inferred.params |> count) > 0 || returns_fn_field_record + let static_param_names = if returns_fn_field_record { generic_param_names } else { [] } let bounds_by_param = v1_fn_bounds_by_param( clone_param_names: clone_param_names, eq_param_names: eq_param_names, From c453dd2df247fe2229c4a8efa5f87c21b983276b Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 09:48:22 +0000 Subject: [PATCH 53/75] XL-0N: retire the regen-diagnosis shape-facts suffix -- the where-refinement hop is confirmed at byte fixed point (6ba83b3 regen, round 2 equal) Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_013koFunEtpLQCnvUiz85k7Y --- src/v1/05_emit_rust.dag | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index 8301836f544..7f2e15f7f1a 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -11966,7 +11966,7 @@ fn emit_typed_bin_op(op: BinOp, algebra_field: AlgebraFieldKind?, left: Node, ri } else { match binop_operator_realization(op: op, left: left, scope: scope) { OperatorRealizationRefused { cause: c } => - emit_rust_compile_error_expr(message: concat(operator_realization_refusal_message(cause: c), " [", rust_operand_shape_facts(operand: left, scope: scope), "]")) + emit_rust_compile_error_expr(message: operator_realization_refusal_message(cause: c)) StructuralComparison { declaration: _, binding: b, test: t } => emit_rust_structural_comparison(l_str: l_str, r_str: r_str, binding: b, test: t) StructuralEquality { declaration: _ } => @@ -12034,21 +12034,6 @@ fn rust_operand_realization_of_type(rt: Node, scope: InferScope, fuel: Int) -> O } -// TEMPORARY (XL-0N regen diagnosis): the operand's resolved-node shape, appended to the refusal. -fn rust_operand_shape_facts(operand: Node, scope: InferScope) -> String { - let rt = resolved_type(n: operand) - let decl = match rt.inferred { Present { value: Resolved { node: r } } => r _ => rt } - concat( - "rt.name=", rt.name, " rt.authored=", authored_name_at(source_indices: scope.type_env.source_indices, node: rt), - " rt.conn=", if rt.connective == NoConnective { "none" } else { "some" }, - " rt.children=", to_string(value: rt.children |> count), " rt.inferred=", if rt.inferred == none { "absent" } else { "present" }, - " decl.name=", decl.name, " decl.authored=", authored_name_at(source_indices: scope.type_env.source_indices, node: decl), - " decl.conn=", if decl.connective == NoConnective { "none" } else { "some" }, - " decl.children=", to_string(value: decl.children |> count), " decl.inferred=", if decl.inferred == none { "absent" } else { "present" }, - " decl.params=", to_string(value: decl.params |> count), " rt.type_annotation=", if rt.type_annotation == none { "absent" } else { "present" }, " where_refinement=", if is_where_refinement_type(ty: rt) { "yes" } else { "no" }, " alias_item=", if is_type_alias_item(item: decl, source_indices: scope.type_env.source_indices) { "yes" } else { "no" } - ) -} - fn binop_operator_realization(op: BinOp, left: Node, scope: InferScope) -> OperatorRealization { operator_realization_for(op: op, operand: rust_operand_realization(operand: left, scope: scope), ordering_rows: structural_ordering_rows) } From b621add3ed7db27d1b354bbebe15a63a88cdbbb6 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 10:25:06 +0000 Subject: [PATCH 54/75] XL-0N: regenerated stage0 mirrors at byte fixed point (070a203 source, BuildBuddy regen round 3 first_generation_equal=true; partition crates rendered=14 written=0) Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_013koFunEtpLQCnvUiz85k7Y --- src/v1/stage0/src/emitted_population.rs | 3 + .../gunbc_structural_realization_bindings.rs | 89 + src/v1/stage0/src/lib.rs | 3 + src/v1/stage0/src/std_literal_elaboration.rs | 232 +++ src/v1/stage0/src/std_operator_realization.rs | 311 ++++ src/v1/stage0/src/std_primitive_projection.rs | 6 + src/v1/stage0/src/v1_compiler_coercion.rs | 16 + src/v1/stage0/src/v1_compiler_compile.rs | 7 + src/v1/stage0/src/v1_compiler_complexity.rs | 16 +- .../src/v1_compiler_dag_collect_support.rs | 3 +- src/v1/stage0/src/v1_compiler_emit.rs | 16 +- src/v1/stage0/src/v1_compiler_emit_rust.rs | 1549 +++++++++++------ src/v1/stage0/src/v1_compiler_infer.rs | 312 +++- src/v1/stage0/src/v1_compiler_infer_env.rs | 76 +- .../stage0/src/v1_compiler_infer_resolve.rs | 11 +- src/v1/stage0/src/v1_compiler_ownership.rs | 7 +- src/v1/stage0/src/v1_std_core.rs | 13 + 17 files changed, 2137 insertions(+), 533 deletions(-) create mode 100644 src/v1/stage0/src/gunbc_structural_realization_bindings.rs create mode 100644 src/v1/stage0/src/std_literal_elaboration.rs create mode 100644 src/v1/stage0/src/std_operator_realization.rs diff --git a/src/v1/stage0/src/emitted_population.rs b/src/v1/stage0/src/emitted_population.rs index 20bc0c7ef38..5bcfaae7cde 100644 --- a/src/v1/stage0/src/emitted_population.rs +++ b/src/v1/stage0/src/emitted_population.rs @@ -36,6 +36,7 @@ // src/gunbc_stage0_crate_layout_generated.rs // src/gunbc_stage0_crate_partition_generated.rs // src/gunbc_stage0_emitted_population_manifest.rs +// src/gunbc_structural_realization_bindings.rs // src/lib.rs // src/main.rs // src/std_algebra.rs @@ -57,6 +58,7 @@ // src/std_interface_summary.rs // src/std_keyed_roster.rs // src/std_keyed_row.rs +// src/std_literal_elaboration.rs // src/std_logic.rs // src/std_machine_constraints.rs // src/std_magnitude.rs @@ -67,6 +69,7 @@ // src/std_occurrence_binding_candidates.rs // src/std_occurrence_binding_resolve.rs // src/std_occurrence_identity.rs +// src/std_operator_realization.rs // src/std_pareto.rs // src/std_primitive_projection.rs // src/std_process_termination.rs diff --git a/src/v1/stage0/src/gunbc_structural_realization_bindings.rs b/src/v1/stage0/src/gunbc_structural_realization_bindings.rs new file mode 100644 index 00000000000..fd3bbc59e82 --- /dev/null +++ b/src/v1/stage0/src/gunbc_structural_realization_bindings.rs @@ -0,0 +1,89 @@ +// Generated by v1 compiler -- do not edit. +// Source module: gunbc.structural_realization_bindings + +pub use crate::std_decl_ref::decl_ref; +pub use crate::std_decl_ref::DeclarationRef; +use crate::std_literal_elaboration::LiteralSourceKind::{KernelBoolLiteral, KernelIntLiteral}; +use crate::std_literal_elaboration::LiteralUnfolding::{BooleanUnfold, PeanoUnfold}; +pub use crate::std_literal_elaboration::{ + LiteralHomomorphism, LiteralSourceKind, LiteralUnfolding, +}; +pub use crate::std_operator_realization::StructuralOrderingBinding; +use crate::std_types::Bool::*; +pub use crate::std_types::{Bool, List, NonEmptyStr}; +use crate::v1_rt; +use crate::v1_rt::{VecCompat, VecJoin}; +use crate::NonEmptyBTreeSet; +use crate::NonEmptyVec; +use im::{vector as vec, HashMap, OrdSet as BTreeSet, Vector as Vec}; +use std::rc::Rc; + +pub fn peano_literal_homomorphism( + module_path: String, + nat: String, + zero: String, + succ: String, + prev_field: String, +) -> Rc { + Rc::new(LiteralHomomorphism { + source_kind: LiteralSourceKind::KernelIntLiteral, + destination: crate::std_decl_ref::decl_ref(module_path.clone(), nat.clone()), + producer: Rc::new(LiteralUnfolding::PeanoUnfold { + zero: crate::std_decl_ref::decl_ref(module_path.clone(), zero.clone()), + succ: crate::std_decl_ref::decl_ref(module_path.clone(), succ.clone()), + prev_field: prev_field.clone(), + }), + }) +} + +pub fn boolean_literal_homomorphism( + module_path: String, + bool_decl: String, + true_variant: String, + false_variant: String, +) -> Rc { + Rc::new(LiteralHomomorphism { + source_kind: LiteralSourceKind::KernelBoolLiteral, + destination: crate::std_decl_ref::decl_ref(module_path.clone(), bool_decl.clone()), + producer: Rc::new(LiteralUnfolding::BooleanUnfold { + true_variant: crate::std_decl_ref::decl_ref(module_path.clone(), true_variant.clone()), + false_variant: crate::std_decl_ref::decl_ref( + module_path.clone(), + false_variant.clone(), + ), + }), + }) +} + +pub fn literal_homomorphism_rows() -> Rc>> { + thread_local! { + static CACHED: Rc>> = { + Rc::new(vec![peano_literal_homomorphism("v2.std.nat".to_string(), "Nat".to_string(), "Zero".to_string(), "Succ".to_string(), "prev".to_string()), boolean_literal_homomorphism("v2.std.logic".to_string(), "Bool".to_string(), "True".to_string(), "False".to_string())]) + }; + } + CACHED.with(|c: &Rc>>| c.clone()) +} + +pub fn structural_ordering_binding( + carrier_module: String, + carrier: String, + compare_module: String, + compare: String, + ordering_module: String, + ordering: String, +) -> Rc { + Rc::new(StructuralOrderingBinding { + carrier: crate::std_decl_ref::decl_ref(carrier_module.clone(), carrier.clone()), + compare: crate::std_decl_ref::decl_ref(compare_module.clone(), compare.clone()), + ordering: crate::std_decl_ref::decl_ref(ordering_module.clone(), ordering.clone()), + }) +} + +pub fn structural_ordering_rows() -> Rc>> { + thread_local! { + static CACHED: Rc>> = { + Rc::new(vec![structural_ordering_binding("v2.std.nat".to_string(), "Nat".to_string(), "v2.std.nat".to_string(), "nat_compare".to_string(), "std.algebra".to_string(), "Ordering".to_string())]) + }; + } + CACHED.with(|c: &Rc>>| c.clone()) +} diff --git a/src/v1/stage0/src/lib.rs b/src/v1/stage0/src/lib.rs index d5e60864f72..9c693b75422 100644 --- a/src/v1/stage0/src/lib.rs +++ b/src/v1/stage0/src/lib.rs @@ -50,6 +50,7 @@ pub mod gunbc_rust_source_type_bindings; pub mod gunbc_stage0_crate_layout_generated; pub mod gunbc_stage0_crate_partition_generated; pub mod gunbc_stage0_emitted_population_manifest; +pub mod gunbc_structural_realization_bindings; pub mod std_algebra; pub mod std_checked_arithmetic; pub mod std_coercion; @@ -69,6 +70,7 @@ pub mod std_integer; pub mod std_interface_summary; pub mod std_keyed_roster; pub mod std_keyed_row; +pub mod std_literal_elaboration; pub mod std_logic; pub mod std_machine_constraints; pub mod std_magnitude; @@ -79,6 +81,7 @@ pub mod std_occurrence_binding; pub mod std_occurrence_binding_candidates; pub mod std_occurrence_binding_resolve; pub mod std_occurrence_identity; +pub mod std_operator_realization; pub mod std_pareto; pub mod std_primitive_projection; pub mod std_process_termination; diff --git a/src/v1/stage0/src/std_literal_elaboration.rs b/src/v1/stage0/src/std_literal_elaboration.rs new file mode 100644 index 00000000000..a70d6ddc638 --- /dev/null +++ b/src/v1/stage0/src/std_literal_elaboration.rs @@ -0,0 +1,232 @@ +// Generated by v1 compiler -- do not edit. +// Source module: std.literal_elaboration + +use self::LiteralElaborationOutcome::*; +use self::LiteralElaborationRefusal::*; +use self::LiteralHomomorphismLookup::*; +use self::LiteralSourceKind::*; +use self::LiteralUnfolding::*; +pub use crate::std_decl_ref::declaration_ref_eq; +pub use crate::std_decl_ref::DeclarationRef; +pub use crate::std_syntax::LiteralValue; +use crate::std_syntax::LiteralValue::{LitBool, LitFloat, LitInt, LitNull, LitStr, LitSymbol}; +use crate::std_types::Bool::*; +pub use crate::std_types::{Bool, List, NonEmptyStr}; +use crate::v1_rt; +use crate::v1_rt::{VecCompat, VecJoin}; +use crate::NonEmptyBTreeSet; +use crate::NonEmptyVec; +use im::{vector as vec, HashMap, OrdSet as BTreeSet, Vector as Vec}; +use std::rc::Rc; + +#[derive( + Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize, +)] +#[serde(tag = "_variant")] +pub enum LiteralSourceKind { + KernelIntLiteral, + KernelStringLiteral, + KernelFloatLiteral, + KernelBoolLiteral, + KernelSymbolLiteral, + KernelNullLiteral, +} + +pub fn literal_source_kind_of(value: Rc) -> LiteralSourceKind { + match (*value.clone()).clone() { + LiteralValue::LitInt { value: _, .. } => LiteralSourceKind::KernelIntLiteral, + LiteralValue::LitStr { value: _, .. } => LiteralSourceKind::KernelStringLiteral, + LiteralValue::LitFloat { value: _, .. } => LiteralSourceKind::KernelFloatLiteral, + LiteralValue::LitBool { value: _, .. } => LiteralSourceKind::KernelBoolLiteral, + LiteralValue::LitSymbol { value: _, .. } => LiteralSourceKind::KernelSymbolLiteral, + LiteralValue::LitNull => LiteralSourceKind::KernelNullLiteral, + } +} + +pub fn literal_source_kind_label(kind: LiteralSourceKind) -> String { + match kind.clone() { + LiteralSourceKind::KernelIntLiteral => "kernel_int_literal".to_string(), + LiteralSourceKind::KernelStringLiteral => "kernel_string_literal".to_string(), + LiteralSourceKind::KernelFloatLiteral => "kernel_float_literal".to_string(), + LiteralSourceKind::KernelBoolLiteral => "kernel_bool_literal".to_string(), + LiteralSourceKind::KernelSymbolLiteral => "kernel_symbol_literal".to_string(), + LiteralSourceKind::KernelNullLiteral => "kernel_null_literal".to_string(), + } +} + +pub fn literal_source_kind_eq(a: LiteralSourceKind, b: LiteralSourceKind) -> bool { + (literal_source_kind_label(a.clone()) == literal_source_kind_label(b.clone())) +} + +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[serde(tag = "_variant")] +pub enum LiteralUnfolding { + PeanoUnfold { + zero: Rc, + succ: Rc, + prev_field: NonEmptyStr, + }, + BooleanUnfold { + true_variant: Rc, + false_variant: Rc, + }, +} + +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct LiteralHomomorphism { + pub source_kind: LiteralSourceKind, + pub destination: Rc, + pub producer: Rc, +} + +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[serde(tag = "_variant")] +pub enum LiteralHomomorphismLookup { + LiteralHomomorphismFound { row: Rc }, + LiteralHomomorphismAbsent, + LiteralHomomorphismAmbiguous { row_count: i64 }, +} + +pub fn literal_homomorphism_for( + rows: Rc>>, + source_kind: LiteralSourceKind, + destination: Rc, +) -> Rc { + { + let matching = Rc::new({ + let mut __result = Vec::new(); + for r in rows.iter().cloned() { + if (literal_source_kind_eq(r.source_kind.clone(), source_kind.clone()) + && crate::std_decl_ref::declaration_ref_eq( + r.destination.clone(), + destination.clone(), + )) + { + __result.push(r); + } + } + __result + }); + let n = (matching.clone().len() as i64); + if (n.clone() == 0) { + Rc::new(LiteralHomomorphismLookup::LiteralHomomorphismAbsent) + } else { + if (n.clone() == 1) { + match matching.clone().first().cloned() { + Some(row) => Rc::new(LiteralHomomorphismLookup::LiteralHomomorphismFound { + row: row.clone(), + }), + None => Rc::new(LiteralHomomorphismLookup::LiteralHomomorphismAbsent), + } + } else { + Rc::new(LiteralHomomorphismLookup::LiteralHomomorphismAmbiguous { + row_count: n.clone(), + }) + } + } + } +} + +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[serde(tag = "_variant")] +pub enum LiteralElaborationRefusal { + HomomorphismDuplicated { + source_kind: LiteralSourceKind, + destination: Rc, + row_count: i64, + }, +} +impl LiteralElaborationRefusal { + pub fn source_kind(&self) -> LiteralSourceKind { + match self { + LiteralElaborationRefusal::HomomorphismDuplicated { + source_kind: __val, .. + } => __val.clone(), + } + } + pub fn destination(&self) -> Rc { + match self { + LiteralElaborationRefusal::HomomorphismDuplicated { + destination: __val, .. + } => __val.clone(), + } + } + pub fn row_count(&self) -> i64 { + match self { + LiteralElaborationRefusal::HomomorphismDuplicated { + row_count: __val, .. + } => __val.clone(), + } + } +} + +pub fn literal_elaboration_refusal_message(cause: Rc) -> String { + match (*cause.clone()).clone() { + LiteralElaborationRefusal::HomomorphismDuplicated { source_kind: k, destination: d, row_count: n, .. } => v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("literal elaboration: ".to_string(), literal_source_kind_label(k.clone())), " into ".to_string()), d.module_path.clone()), ".".to_string()), d.decl_name.clone()), " has more than one declared homomorphism (gunbc.structural_realization_bindings authoring defect)".to_string()), +} +} + +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[serde(tag = "_variant")] +pub enum LiteralElaborationOutcome { + DirectLiteral, + ViaHomomorphism { + homomorphism: Rc, + }, + LiteralElaborationRefused { + cause: Rc, + }, +} + +pub fn elaborate_literal_at( + rows: Rc>>, + source_kind: LiteralSourceKind, + destination: Rc, + destination_realizes_natively: bool, +) -> Rc { + if destination_realizes_natively.clone() { + Rc::new(LiteralElaborationOutcome::DirectLiteral) + } else { + match (*literal_homomorphism_for(rows.clone(), source_kind.clone(), destination.clone())) + .clone() + { + LiteralHomomorphismLookup::LiteralHomomorphismFound { row: row, .. } => { + Rc::new(LiteralElaborationOutcome::ViaHomomorphism { + homomorphism: row.clone(), + }) + } + LiteralHomomorphismLookup::LiteralHomomorphismAbsent => { + Rc::new(LiteralElaborationOutcome::DirectLiteral) + } + LiteralHomomorphismLookup::LiteralHomomorphismAmbiguous { row_count: n, .. } => { + Rc::new(LiteralElaborationOutcome::LiteralElaborationRefused { + cause: Rc::new(LiteralElaborationRefusal::HomomorphismDuplicated { + source_kind: source_kind.clone(), + destination: destination.clone(), + row_count: n.clone(), + }), + }) + } + } + } +} + +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct LiteralElaboration { + pub source_kind: LiteralSourceKind, + pub destination: Rc, + pub homomorphism: Rc, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +pub struct KernelIntLiteral; +#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +pub struct KernelStringLiteral; +#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +pub struct KernelFloatLiteral; +#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +pub struct KernelBoolLiteral; +#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +pub struct KernelSymbolLiteral; +#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +pub struct KernelNullLiteral; diff --git a/src/v1/stage0/src/std_operator_realization.rs b/src/v1/stage0/src/std_operator_realization.rs new file mode 100644 index 00000000000..6ebc5313f2e --- /dev/null +++ b/src/v1/stage0/src/std_operator_realization.rs @@ -0,0 +1,311 @@ +// Generated by v1 compiler -- do not edit. +// Source module: std.operator_realization + +use self::OperandRealization::*; +use self::OperatorRealization::*; +use self::OperatorRealizationRefusal::*; +use self::OrderingTest::*; +use self::StructuralOrderingLookup::*; +pub use crate::std_decl_ref::declaration_ref_eq; +pub use crate::std_decl_ref::DeclarationRef; +pub use crate::std_syntax::BinOp; +use crate::std_syntax::BinOp::{ + Add, And, Div, Eq, Ge, Gt, Le, Lt, Mod, Mul, Ne, NullCoalesce, Or, Sub, +}; +use crate::std_types::Bool::*; +pub use crate::std_types::{Bool, List, NonEmptyStr}; +use crate::v1_rt; +use crate::v1_rt::{VecCompat, VecJoin}; +use crate::NonEmptyBTreeSet; +use crate::NonEmptyVec; +use im::{vector as vec, HashMap, OrdSet as BTreeSet, Vector as Vec}; +use std::rc::Rc; + +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[serde(tag = "_variant")] +pub enum OperandRealization { + HostNumericOperand, + StructuralOperand { declaration: Rc }, + OperandIdentityUnavailable, +} +impl OperandRealization { + pub fn declaration(&self) -> Rc { + match self { + OperandRealization::HostNumericOperand => panic!("no declaration on unit variant"), + OperandRealization::StructuralOperand { + declaration: __val, .. + } => __val.clone(), + OperandRealization::OperandIdentityUnavailable => { + panic!("no declaration on unit variant") + } + } + } +} + +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct StructuralOrderingBinding { + pub carrier: Rc, + pub compare: Rc, + pub ordering: Rc, +} + +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[serde(tag = "_variant")] +pub enum StructuralOrderingLookup { + StructuralOrderingFound { row: Rc }, + StructuralOrderingAbsent, + StructuralOrderingAmbiguous { row_count: i64 }, +} + +pub fn structural_ordering_for( + rows: Rc>>, + carrier: Rc, +) -> Rc { + { + let matching = Rc::new({ + let mut __result = Vec::new(); + for r in rows.iter().cloned() { + if crate::std_decl_ref::declaration_ref_eq(r.carrier.clone(), carrier.clone()) { + __result.push(r); + } + } + __result + }); + let n = (matching.clone().len() as i64); + if (n.clone() == 0) { + Rc::new(StructuralOrderingLookup::StructuralOrderingAbsent) + } else { + if (n.clone() == 1) { + match matching.clone().first().cloned() { + Some(row) => Rc::new(StructuralOrderingLookup::StructuralOrderingFound { + row: row.clone(), + }), + None => Rc::new(StructuralOrderingLookup::StructuralOrderingAbsent), + } + } else { + Rc::new(StructuralOrderingLookup::StructuralOrderingAmbiguous { + row_count: n.clone(), + }) + } + } + } +} + +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[serde(tag = "_variant")] +pub enum OrderingTest { + OrderingIs { variant: NonEmptyStr }, + OrderingIsNot { variant: NonEmptyStr }, +} +impl OrderingTest { + pub fn variant(&self) -> NonEmptyStr { + match self { + OrderingTest::OrderingIs { variant: __val, .. } => __val.clone(), + OrderingTest::OrderingIsNot { variant: __val, .. } => __val.clone(), + } + } +} + +pub fn ordering_test_for(op: BinOp) -> Option> { + match op.clone() { + BinOp::Lt => Some(Rc::new(OrderingTest::OrderingIs { + variant: "Less".to_string(), + })), + BinOp::Gt => Some(Rc::new(OrderingTest::OrderingIs { + variant: "Greater".to_string(), + })), + BinOp::Le => Some(Rc::new(OrderingTest::OrderingIsNot { + variant: "Greater".to_string(), + })), + BinOp::Ge => Some(Rc::new(OrderingTest::OrderingIsNot { + variant: "Less".to_string(), + })), + BinOp::Add => None, + BinOp::Sub => None, + BinOp::Mul => None, + BinOp::Div => None, + BinOp::Mod => None, + BinOp::Eq => None, + BinOp::Ne => None, + BinOp::And => None, + BinOp::Or => None, + BinOp::NullCoalesce => None, + } +} + +pub fn binop_is_equality(op: BinOp) -> bool { + match op.clone() { + BinOp::Eq => true, + BinOp::Ne => true, + BinOp::Add => false, + BinOp::Sub => false, + BinOp::Mul => false, + BinOp::Div => false, + BinOp::Mod => false, + BinOp::Lt => false, + BinOp::Gt => false, + BinOp::Le => false, + BinOp::Ge => false, + BinOp::And => false, + BinOp::Or => false, + BinOp::NullCoalesce => false, + } +} + +pub fn binop_is_ordering(op: BinOp) -> bool { + (ordering_test_for(op.clone()) != None) +} + +pub fn binop_label(op: BinOp) -> String { + match op.clone() { + BinOp::Add => "+".to_string(), + BinOp::Sub => "-".to_string(), + BinOp::Mul => "*".to_string(), + BinOp::Div => "/".to_string(), + BinOp::Mod => "%".to_string(), + BinOp::Eq => "==".to_string(), + BinOp::Ne => "!=".to_string(), + BinOp::Lt => "<".to_string(), + BinOp::Gt => ">".to_string(), + BinOp::Le => "<=".to_string(), + BinOp::Ge => ">=".to_string(), + BinOp::And => "&&".to_string(), + BinOp::Or => "||".to_string(), + BinOp::NullCoalesce => "??".to_string(), + } +} + +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[serde(tag = "_variant")] +pub enum OperatorRealizationRefusal { + NoStructuralOperationDeclared { + declaration: Rc, + operator: String, + }, + StructuralOrderingDuplicated { + declaration: Rc, + row_count: i64, + }, +} +impl OperatorRealizationRefusal { + pub fn declaration(&self) -> Rc { + match self { + OperatorRealizationRefusal::NoStructuralOperationDeclared { + declaration: __val, + .. + } => __val.clone(), + OperatorRealizationRefusal::StructuralOrderingDuplicated { + declaration: __val, .. + } => __val.clone(), + } + } +} + +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[serde(tag = "_variant")] +pub enum OperatorRealization { + HostOperator, + StructuralEquality { + declaration: Rc, + }, + StructuralComparison { + declaration: Rc, + binding: Rc, + test: Rc, + }, + OperatorRealizationRefused { + cause: Rc, + }, +} + +pub fn operator_realization_refusal_message(cause: Rc) -> String { + match (*cause.clone()).clone() { + OperatorRealizationRefusal::NoStructuralOperationDeclared { declaration: d, operator: o, .. } => v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("operator realization: host operator `".to_string(), o.clone()), "` on structural operand ".to_string()), d.module_path.clone()), ".".to_string()), d.decl_name.clone()), " -- the declaration has no host realization and declares no operation for this operator; spell the operation as a call to the declared structural operation".to_string()), + OperatorRealizationRefusal::StructuralOrderingDuplicated { declaration: d, row_count: n, .. } => v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("operator realization: structural ordering for ".to_string(), d.module_path.clone()), ".".to_string()), d.decl_name.clone()), " has more than one declared comparison (gunbc.structural_realization_bindings authoring defect)".to_string()), +} +} + +pub fn operator_realization_for( + op: BinOp, + operand: Rc, + ordering_rows: Rc>>, +) -> Rc { + match (*operand.clone()).clone() { + OperandRealization::HostNumericOperand => Rc::new(OperatorRealization::HostOperator), + OperandRealization::OperandIdentityUnavailable => { + Rc::new(OperatorRealization::HostOperator) + } + OperandRealization::StructuralOperand { declaration: d, .. } => match op.clone() { + BinOp::Eq => Rc::new(OperatorRealization::StructuralEquality { + declaration: d.clone(), + }), + BinOp::Ne => Rc::new(OperatorRealization::StructuralEquality { + declaration: d.clone(), + }), + BinOp::Lt => { + structural_ordering_realization(op.clone(), d.clone(), ordering_rows.clone()) + } + BinOp::Gt => { + structural_ordering_realization(op.clone(), d.clone(), ordering_rows.clone()) + } + BinOp::Le => { + structural_ordering_realization(op.clone(), d.clone(), ordering_rows.clone()) + } + BinOp::Ge => { + structural_ordering_realization(op.clone(), d.clone(), ordering_rows.clone()) + } + BinOp::And => Rc::new(OperatorRealization::HostOperator), + BinOp::Or => Rc::new(OperatorRealization::HostOperator), + BinOp::NullCoalesce => Rc::new(OperatorRealization::HostOperator), + BinOp::Add => structural_arithmetic_refusal(op.clone(), d.clone()), + BinOp::Sub => structural_arithmetic_refusal(op.clone(), d.clone()), + BinOp::Mul => structural_arithmetic_refusal(op.clone(), d.clone()), + BinOp::Div => structural_arithmetic_refusal(op.clone(), d.clone()), + BinOp::Mod => structural_arithmetic_refusal(op.clone(), d.clone()), + }, + } +} + +pub fn structural_arithmetic_refusal( + op: BinOp, + declaration: Rc, +) -> Rc { + Rc::new(OperatorRealization::OperatorRealizationRefused { + cause: Rc::new(OperatorRealizationRefusal::NoStructuralOperationDeclared { + declaration: declaration.clone(), + operator: binop_label(op.clone()), + }), + }) +} + +pub fn structural_ordering_realization( + op: BinOp, + declaration: Rc, + ordering_rows: Rc>>, +) -> Rc { + match ordering_test_for(op.clone()) { + None => structural_arithmetic_refusal(op.clone(), declaration.clone()), + Some(test) => { + match (*structural_ordering_for(ordering_rows.clone(), declaration.clone())).clone() { + StructuralOrderingLookup::StructuralOrderingFound { row: row, .. } => { + Rc::new(OperatorRealization::StructuralComparison { + declaration: declaration.clone(), + binding: row.clone(), + test: test.clone(), + }) + } + StructuralOrderingLookup::StructuralOrderingAbsent => { + structural_arithmetic_refusal(op.clone(), declaration.clone()) + } + StructuralOrderingLookup::StructuralOrderingAmbiguous { row_count: n, .. } => { + Rc::new(OperatorRealization::OperatorRealizationRefused { + cause: Rc::new(OperatorRealizationRefusal::StructuralOrderingDuplicated { + declaration: declaration.clone(), + row_count: n.clone(), + }), + }) + } + } + } + } +} diff --git a/src/v1/stage0/src/std_primitive_projection.rs b/src/v1/stage0/src/std_primitive_projection.rs index ecf7cc5961e..c1493ae0e3e 100644 --- a/src/v1/stage0/src/std_primitive_projection.rs +++ b/src/v1/stage0/src/std_primitive_projection.rs @@ -278,6 +278,12 @@ pub fn primitive_projection_roster() -> Rc>> { "empty_map_primitive_delegate".to_string(), Rc::new(ProjectionFidelity::HostRealizedSeam), ), + primitive_projection_row( + primitive_map_insert(), + "v2.std.collection".to_string(), + "map_insert_primitive_delegate".to_string(), + Rc::new(ProjectionFidelity::HostRealizedSeam), + ), primitive_projection_row( primitive_symbol_lexeme(), "v2.std.compilers.lexing".to_string(), diff --git a/src/v1/stage0/src/v1_compiler_coercion.rs b/src/v1/stage0/src/v1_compiler_coercion.rs index eb7d9768374..647f4e4821f 100644 --- a/src/v1/stage0/src/v1_compiler_coercion.rs +++ b/src/v1/stage0/src/v1_compiler_coercion.rs @@ -372,6 +372,22 @@ pub fn rust_exact_realization_decision( } } +pub fn declaration_realizes_natively_on_rust( + declaration: Rc, + decl_file: String, +) -> bool { + match (*rust_exact_realization_decision(Some(declaration.clone()))).clone() { + TypeRealizationDecision::Realized { checkpoint: _, .. } => true, + _ => { + (lookup_checkpoint( + RenderTarget::Rust, + declaration.decl_name.clone(), + decl_file.clone(), + ) != None) + } + } +} + pub fn rust_checkpoint_row_keeps_bare_row(dag_name: String) -> bool { if (dag_name.clone() == "".to_string()) { false diff --git a/src/v1/stage0/src/v1_compiler_compile.rs b/src/v1/stage0/src/v1_compiler_compile.rs index ed809719284..6f74b2c6da7 100644 --- a/src/v1/stage0/src/v1_compiler_compile.rs +++ b/src/v1/stage0/src/v1_compiler_compile.rs @@ -1397,6 +1397,13 @@ pub fn serialize_expr_data( ), "}".to_string(), ), + ExprData::ExprElaboratedLiteral { value, .. } => v1_rt::concat( + v1_rt::concat( + "{\"kind\": \"ExprElaboratedLiteral\", \"value\": ".to_string(), + serialize_literal(value.clone()), + ), + "}".to_string(), + ), ExprData::ExprError { kind, message, .. } => v1_rt::concat( v1_rt::concat( v1_rt::concat( diff --git a/src/v1/stage0/src/v1_compiler_complexity.rs b/src/v1/stage0/src/v1_compiler_complexity.rs index d8ac7fcdcae..debb3ca2029 100644 --- a/src/v1/stage0/src/v1_compiler_complexity.rs +++ b/src/v1/stage0/src/v1_compiler_complexity.rs @@ -74,9 +74,9 @@ pub use crate::v1_compiler_parse::{ParserCallIdentity, ParserResultWitness}; use crate::v1_rt; use crate::v1_rt::{VecCompat, VecJoin}; use crate::v1_std_core::ExprData::{ - ExprBinOp, ExprBlock, ExprCall, ExprError, ExprFieldAccess, ExprForEach, ExprIf, ExprLambda, - ExprLet, ExprLiteral, ExprMatch, ExprMethodCall, ExprRecordLit, ExprReturn, ExprUnaryOp, - ExprVar, + ExprBinOp, ExprBlock, ExprCall, ExprElaboratedLiteral, ExprError, ExprFieldAccess, ExprForEach, + ExprIf, ExprLambda, ExprLet, ExprLiteral, ExprMatch, ExprMethodCall, ExprRecordLit, ExprReturn, + ExprUnaryOp, ExprVar, }; use crate::v1_std_core::MatchPattern::{Bind, VariantPattern}; use crate::v1_std_core::MethodSemantics::{ @@ -9134,6 +9134,16 @@ pub fn cost_of_expr( }), table: table.clone(), }), + ExprData::ExprElaboratedLiteral { .. } => Rc::new(SummaryResult { + summary: Rc::new(ComplexitySummary { + work: Rc::new(CostExpr::CostConst { value: 1 }), + span: Rc::new(CostExpr::CostConst { value: 1 }), + output_size: v1_rt::rc_empty_map::>(), + certainty: Certainty::Proven, + peak_space: None, + }), + table: table.clone(), + }), ExprData::ExprError { .. } => Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: Rc::new(CostExpr::CostConst { value: 0 }), diff --git a/src/v1/stage0/src/v1_compiler_dag_collect_support.rs b/src/v1/stage0/src/v1_compiler_dag_collect_support.rs index db0508ba939..117d2079769 100644 --- a/src/v1/stage0/src/v1_compiler_dag_collect_support.rs +++ b/src/v1/stage0/src/v1_compiler_dag_collect_support.rs @@ -10,7 +10,7 @@ use crate::v1_rt::{VecCompat, VecJoin}; pub use crate::v1_std_core::make_error_node; use crate::v1_std_core::CompilerDiagnostic::InternalError; use crate::v1_std_core::Connective::{Arrow, NoConnective}; -use crate::v1_std_core::ExprData::*; +use crate::v1_std_core::ExprData::ExprElaboratedLiteral; use crate::v1_std_core::InferredNode::{CompilerError, Resolved, TypeVariable}; use crate::v1_std_core::MatchPattern::{Bind, LitPattern, VariantPattern, Wildcard}; pub use crate::v1_std_core::{ @@ -102,6 +102,7 @@ pub fn expr_data_variant(data: Rc) -> String { match (*data.clone()).clone() { ExprData::NoExprData => "NoExprData".to_string(), ExprData::ExprLiteral { value: _, .. } => "ExprLiteral".to_string(), + ExprData::ExprElaboratedLiteral { .. } => "ExprElaboratedLiteral".to_string(), ExprData::ExprError { .. } => "ExprError".to_string(), ExprData::ExprVar { binding_kind: _, .. diff --git a/src/v1/stage0/src/v1_compiler_emit.rs b/src/v1/stage0/src/v1_compiler_emit.rs index 643851bb2fd..8555a301869 100644 --- a/src/v1/stage0/src/v1_compiler_emit.rs +++ b/src/v1/stage0/src/v1_compiler_emit.rs @@ -94,9 +94,10 @@ use crate::v1_std_core::Cardinality::CardOptional; use crate::v1_std_core::CompilerDiagnostic::TransportEmissionNotModeled; use crate::v1_std_core::Connective::{Arrow, Conj, Disj, NoConnective}; use crate::v1_std_core::ExprData::{ - ExprBinOp, ExprBlock, ExprCall, ExprCast, ExprError, ExprFieldAccess, ExprForEach, ExprIf, - ExprIndex, ExprLambda, ExprLet, ExprListLit, ExprLiteral, ExprMatch, ExprMethodCall, - ExprRecordLit, ExprReturn, ExprSlice, ExprStringInterp, ExprUnaryOp, ExprVar, NoExprData, + ExprBinOp, ExprBlock, ExprCall, ExprCast, ExprElaboratedLiteral, ExprError, ExprFieldAccess, + ExprForEach, ExprIf, ExprIndex, ExprLambda, ExprLet, ExprListLit, ExprLiteral, ExprMatch, + ExprMethodCall, ExprRecordLit, ExprReturn, ExprSlice, ExprStringInterp, ExprUnaryOp, ExprVar, + NoExprData, }; use crate::v1_std_core::FieldAccessStyle::{TupleFirst, TupleSecond}; use crate::v1_std_core::InferredNode::{CompilerError, Resolved, TypeVariable}; @@ -2817,6 +2818,7 @@ pub enum ExprCategory { pub fn classify_expr(texpr: Rc) -> ExprCategory { match (*texpr.expr_data.clone()).clone() { ExprData::ExprLiteral { value: _, .. } => ExprCategory::ExprCatLeaf, + ExprData::ExprElaboratedLiteral { .. } => ExprCategory::ExprCatLeaf, ExprData::ExprError { .. } => ExprCategory::ExprCatLeaf, ExprData::ExprVar { binding_kind: _, .. @@ -5401,6 +5403,14 @@ pub fn emit_shared_expr( ExprData::ExprLiteral { value: v, .. } => { wrap_result(emit_literal(v.clone(), target.clone())) } + ExprData::ExprElaboratedLiteral { .. } => match texpr.children.clone().first().cloned() { + Some(image) => recurse(image.clone()), + None => wrap_result(emit_error_expr( + "elaborated literal carries no image (v1.compiler.infer unfold_literal_image)" + .to_string(), + target.clone(), + )), + }, ExprData::ExprError { message, .. } => { wrap_result(emit_error_expr(message.clone(), target.clone())) } diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index 37daf453217..b2a010376c2 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -18,6 +18,7 @@ pub use crate::extdeps_languages_rust_emit::{ rust_method_wraps_result, rust_serde_rename_all_screaming_snake_case, rust_serde_rename_all_snake_case, rust_trait_derive_attr_from_traits, }; +pub use crate::extdeps_languages_rust_representation::rust_exact_type_checkpoint; use crate::gunbc_cli_dispatch_surface::CliOptionArity::{CliAtMostOne, CliRepeated, CliRequired}; use crate::gunbc_cli_dispatch_surface::CliOptionValue::{ CliMillisecondValue, CliPortValue, CliTextValue, CliToggleValue, @@ -34,6 +35,7 @@ pub use crate::gunbc_stage0_emitted_population_manifest::{ emitted_population_manifest_basename, emitted_population_manifest_line_prefix, emitted_population_manifest_line_separator, }; +pub use crate::gunbc_structural_realization_bindings::structural_ordering_rows; pub use crate::std_algebra::trim; pub use crate::std_coercion::TypeCheckpoint; pub use crate::std_content_hash::Fnv1a64Structural; @@ -45,6 +47,19 @@ pub use crate::std_measure::millisecond_count; pub use crate::std_nat::Nat; pub use crate::std_occurrence_identity::NodeOccurrenceIdentity; use crate::std_occurrence_identity::NodeOccurrenceIdentity::OccurrenceSynthetic; +use crate::std_operator_realization::OperandRealization::{ + HostNumericOperand, OperandIdentityUnavailable, StructuralOperand, +}; +use crate::std_operator_realization::OperatorRealization::{ + HostOperator, OperatorRealizationRefused, StructuralComparison, StructuralEquality, +}; +use crate::std_operator_realization::OrderingTest::{OrderingIs, OrderingIsNot}; +pub use crate::std_operator_realization::{ + operator_realization_for, operator_realization_refusal_message, +}; +pub use crate::std_operator_realization::{ + OperandRealization, OperatorRealization, OrderingTest, StructuralOrderingBinding, +}; pub use crate::std_primitive_projection::{ primitive_identity_runtime_name, primitive_projection_row_for_declaration, }; @@ -59,6 +74,10 @@ use crate::std_syntax::AlgebraFieldKind::*; use crate::std_syntax::BinOp::*; use crate::std_syntax::LiteralValue::*; pub use crate::std_syntax::{AlgebraFieldKind, BinOp, LiteralValue}; +pub use crate::std_target_representation::ExactBindingResolution; +use crate::std_target_representation::ExactBindingResolution::{ + ExactBindingAbsent, ExactBindingAmbiguous, ExactSourceIdentityUnavailable, ResolvedExactBinding, +}; pub use crate::std_types::SourceSpan; pub use crate::std_types::{container_template_algebra, is_container_type, is_kernel_type}; pub use crate::v1_compiler_artifact::RenderTarget; @@ -67,8 +86,9 @@ pub use crate::v1_compiler_closure_stub_v2_std_integer_rust::closure_stub_v2_std pub use crate::v1_compiler_closure_stub_v2_std_text_rust::closure_stub_v2_std_text_source; pub use crate::v1_compiler_coercion::decl_identity_file; pub use crate::v1_compiler_coercion::{ - coerce_primitive_type, is_copy, lookup_checkpoint, rust_seed_host_numeric_alias, - target_callable, type_reference_decl_file, + coerce_primitive_type, declaration_realizes_natively_on_rust, is_copy, lookup_checkpoint, + rust_lookup_exact_binding, rust_seed_host_numeric_alias, target_callable, + type_reference_decl_file, }; pub use crate::v1_compiler_compiler_tests_rust::compiler_tests_source; use crate::v1_compiler_emit::BoundOperation::{ @@ -124,9 +144,12 @@ pub use crate::v1_compiler_infer_emit_info::{ variant_belongs_to_enum, variant_summary_key, }; pub use crate::v1_compiler_infer_emit_info::{EmitGraphInfo, TypeRepr, TypeSummary}; -use crate::v1_compiler_infer_env::GlobalBareLookupState::*; +use crate::v1_compiler_infer_env::GlobalBareLookupState::{ + GlobalBareAmbiguousBinding, GlobalBareUniqueBinding, +}; pub use crate::v1_compiler_infer_env::{ - authored_name, empty_symbol_index, lookup_type_by_name, lookup_type_for, + authored_name, binding_declares_span, empty_symbol_index, lookup_type_by_name, lookup_type_for, + type_reference_declaration_ref, }; pub use crate::v1_compiler_infer_env::{GlobalBareLookupState, TypeBinding, TypeEnv}; pub use crate::v1_compiler_infer_items::item_kind; @@ -171,8 +194,8 @@ pub use crate::v1_compiler_trait_derive_emit::{ v1_emit_struct_from_capability_table, v1_emit_type_params_with_bounds, v1_emit_type_params_with_clone_bounds, v1_generic_params_needing_clone_bound, v1_item_clone_bounded_param_names, v1_item_clone_undecided_head, v1_item_field_type_exprs, - v1_item_wf_propagated_clone_bounded_param_names, v1_map_key_required_type_names, - v1_trait_derive_refuse, v1_with_map_key_requirement, + v1_item_wf_propagated_clone_bounded_param_names, v1_map_key_head_names_in_type_expr, + v1_map_key_required_type_names, v1_trait_derive_refuse, v1_with_map_key_requirement, }; use crate::v1_rt; use crate::v1_rt::{VecCompat, VecJoin}; @@ -438,124 +461,142 @@ pub fn render_rust_type_without_applied_binding( emit_info.clone(), ) } else { - if ((((n.connective.clone() == Connective::NoConnective) + if (((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) > 0)) && !crate::std_types::is_container_type(crate::v1_std_core::authored_name_at( source_indices.clone(), n.clone(), ))) - && closed_alias_peels_zero_param(emit_info.fn_type_env.clone(), n.clone())) { - { - let leaf = crate::v1_std_core::qualified_last_segment( - crate::v1_std_core::authored_name_at(source_indices.clone(), n.clone()), - ); - render_rust_shared_type_with_optional( - n.clone(), - leaf.clone(), - leaf.clone(), - shared_types.clone(), - ) - } + render_rust_applied_via_emit_info( + n.clone(), + shared_types.clone(), + source_indices.clone(), + emit_info.clone(), + ) } else { - if (((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) > 0)) - && !crate::std_types::is_container_type(crate::v1_std_core::authored_name_at( - source_indices.clone(), - n.clone(), - ))) - { - render_rust_applied_via_emit_info( - n.clone(), - shared_types.clone(), - source_indices.clone(), - emit_info.clone(), - ) + if crate::v1_compiler_infer_types::node_is_set_collection( + n.clone(), + source_indices.clone(), + ) { + match n.children.clone().first().cloned() { + Some(elem_child) => { + let elem_node = + crate::v1_compiler_infer_types::child_type_node(elem_child.clone()); + let elem_is_type_var = if (elem_node.inferred.clone() != None) { + is_type_variable(elem_node.inferred.clone().clone().unwrap()) + } else { + false + }; + if elem_is_type_var.clone() { + emit_rust_compile_error_expr( + "Set element type unresolved".to_string(), + ) + } else { + if !rust_btree_set_element_ord_eligible( + elem_node.clone(), + source_indices.clone(), + emit_info.clone(), + ) { + { + let elem_name = crate::v1_std_core::authored_name_at( + source_indices.clone(), + elem_node.clone(), + ); + emit_rust_compile_error_expr(v1_rt::concat( + v1_rt::concat( + "Set element type ".to_string(), + elem_name.clone(), + ), + " is not Ord-eligible for BTreeSet".to_string(), + )) + } + } else { + crate::v1_compiler_emit::render_node_type( + n.clone(), + RenderTarget::Rust, + shared_types.clone(), + source_indices.clone(), + ) + } + } + } + None => { + emit_rust_compile_error_expr("Set missing element type".to_string()) + } + } } else { - if crate::v1_compiler_infer_types::node_is_set_collection( + if crate::v1_compiler_infer_types::node_is_keyed_collection( n.clone(), source_indices.clone(), ) { match n.children.clone().first().cloned() { - Some(elem_child) => { - let elem_node = crate::v1_compiler_infer_types::child_type_node( - elem_child.clone(), + Some(key_child) => { + let key_node = crate::v1_compiler_infer_types::child_type_node( + key_child.clone(), ); - let elem_is_type_var = if (elem_node.inferred.clone() != None) { - is_type_variable(elem_node.inferred.clone().clone().unwrap()) - } else { - false - }; - if elem_is_type_var.clone() { - emit_rust_compile_error_expr( - "Set element type unresolved".to_string(), - ) - } else { - if !rust_btree_set_element_ord_eligible( - elem_node.clone(), - source_indices.clone(), - emit_info.clone(), - ) { - { - let elem_name = crate::v1_std_core::authored_name_at( - source_indices.clone(), - elem_node.clone(), - ); - emit_rust_compile_error_expr(v1_rt::concat( - v1_rt::concat( - "Set element type ".to_string(), - elem_name.clone(), - ), - " is not Ord-eligible for BTreeSet".to_string(), - )) - } - } else { - crate::v1_compiler_emit::render_node_type( - n.clone(), - RenderTarget::Rust, - shared_types.clone(), - source_indices.clone(), + let val_node = match n + .children + .clone() + .iter() + .cloned() + .skip(1 as usize) + .next() + { + Some(val_child) => { + crate::v1_compiler_infer_types::child_type_node( + val_child.clone(), ) } - } - } - None => { - emit_rust_compile_error_expr("Set missing element type".to_string()) + None => type_variable_node("map_value".to_string()), + }; + let key_str = render_rust_type( + key_node.clone(), + shared_types.clone(), + source_indices.clone(), + emit_info.clone(), + ); + let val_str = render_rust_type( + val_node.clone(), + shared_types.clone(), + source_indices.clone(), + emit_info.clone(), + ); + let tn = crate::v1_std_core::authored_name_at( + source_indices.clone(), + n.clone(), + ); + let base = crate::v1_compiler_emit::emit_map_type( + key_str.clone(), + val_str.clone(), + RenderTarget::Rust, + ); + render_rust_shared_type_with_optional( + n.clone(), + tn.clone(), + base.clone(), + shared_types.clone(), + ) } + None => crate::v1_compiler_emit::render_node_type( + n.clone(), + RenderTarget::Rust, + shared_types.clone(), + source_indices.clone(), + ), } } else { - if crate::v1_compiler_infer_types::node_is_keyed_collection( + if crate::v1_compiler_infer_types::node_is_element_collection( n.clone(), source_indices.clone(), ) { match n.children.clone().first().cloned() { - Some(key_child) => { - let key_node = crate::v1_compiler_infer_types::child_type_node( - key_child.clone(), - ); - let val_node = match n - .children - .clone() - .iter() - .cloned() - .skip(1 as usize) - .next() - { - Some(val_child) => { - crate::v1_compiler_infer_types::child_type_node( - val_child.clone(), - ) - } - None => type_variable_node("map_value".to_string()), - }; - let key_str = render_rust_type( - key_node.clone(), - shared_types.clone(), - source_indices.clone(), - emit_info.clone(), + Some(elem_child) => { + let elem_node = crate::v1_compiler_infer_types::child_type_node( + elem_child.clone(), ); - let val_str = render_rust_type( - val_node.clone(), + let inner_str = render_rust_type( + elem_node.clone(), shared_types.clone(), source_indices.clone(), emit_info.clone(), @@ -564,9 +605,9 @@ pub fn render_rust_type_without_applied_binding( source_indices.clone(), n.clone(), ); - let base = crate::v1_compiler_emit::emit_map_type( - key_str.clone(), - val_str.clone(), + let base = crate::v1_compiler_emit::emit_container( + tn.clone(), + inner_str.clone(), RenderTarget::Rust, ); render_rust_shared_type_with_optional( @@ -584,74 +625,31 @@ pub fn render_rust_type_without_applied_binding( ), } } else { - if crate::v1_compiler_infer_types::node_is_element_collection( - n.clone(), - source_indices.clone(), - ) { - match n.children.clone().first().cloned() { - Some(elem_child) => { - let elem_node = - crate::v1_compiler_infer_types::child_type_node( - elem_child.clone(), - ); - let inner_str = render_rust_type( - elem_node.clone(), - shared_types.clone(), - source_indices.clone(), - emit_info.clone(), - ); - let tn = crate::v1_std_core::authored_name_at( - source_indices.clone(), - n.clone(), - ); - let base = crate::v1_compiler_emit::emit_container( - tn.clone(), - inner_str.clone(), - RenderTarget::Rust, - ); - render_rust_shared_type_with_optional( + { + let tn = crate::v1_std_core::authored_name_at( + source_indices.clone(), + n.clone(), + ); + if type_node_has_unbound_type_variable( + n.clone(), + emit_info.fn_generic_param_names.clone(), + source_indices.clone(), + ) { + "_".to_string() + } else { + if is_host_text_carrier_type(n.clone(), source_indices.clone()) + { + rust_carrier_optional_wrap( n.clone(), - tn.clone(), - base.clone(), - shared_types.clone(), + render_rust_text_carrier(shared_types.clone()), ) - } - None => crate::v1_compiler_emit::render_node_type( - n.clone(), - RenderTarget::Rust, - shared_types.clone(), - source_indices.clone(), - ), - } - } else { - { - let tn = crate::v1_std_core::authored_name_at( - source_indices.clone(), - n.clone(), - ); - if type_node_has_unbound_type_variable( - n.clone(), - emit_info.fn_generic_param_names.clone(), - source_indices.clone(), - ) { - "_".to_string() } else { - if is_host_text_carrier_type( + crate::v1_compiler_emit::render_node_type( n.clone(), + RenderTarget::Rust, + shared_types.clone(), source_indices.clone(), - ) { - rust_carrier_optional_wrap( - n.clone(), - render_rust_text_carrier(shared_types.clone()), - ) - } else { - crate::v1_compiler_emit::render_node_type( - n.clone(), - RenderTarget::Rust, - shared_types.clone(), - source_indices.clone(), - ) - } + ) } } } @@ -909,13 +907,22 @@ pub fn rust_opaque_kernel_alias_carrier(name: String) -> Option { } } -pub fn rust_opaque_kernel_alias_type_decl(name: String) -> String { +pub fn rust_opaque_kernel_alias_type_decl(name: String, module_path: String) -> String { { - let carrier = crate::v1_compiler_coercion::coerce_primitive_type( - RenderTarget::Rust, - name.clone(), - "".to_string(), - ); + let carrier = match rust_exact_binding_spelling( + Some(crate::std_decl_ref::decl_ref( + module_path.clone(), + name.clone(), + )), + true, + ) { + Some(exact) => exact.clone(), + None => crate::v1_compiler_coercion::coerce_primitive_type( + RenderTarget::Rust, + name.clone(), + "".to_string(), + ), + }; v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -1033,6 +1040,7 @@ pub fn rust_render_checkpoint_scalar_bare( n: Rc, source_indices: Rc>>, shared_types: Rc>, + env: Rc, ) -> Option { if ((n.children.clone().len() as i64) == 0) { None @@ -1042,57 +1050,143 @@ pub fn rust_render_checkpoint_scalar_bare( if crate::std_types::is_container_type(leaf.clone()) { return None; } - match crate::v1_compiler_coercion::rust_seed_host_numeric_alias( - leaf.clone(), - crate::v1_compiler_coercion::type_reference_decl_file(n.clone()), - ) { - Some(numeric) => Some(numeric.clone()), - None => match rust_scalar_checkpoint_reference_base( + match rust_exact_reference_spelling(n.clone(), source_indices.clone(), env.clone()) { + Some(exact) => Some(exact.clone()), + None => match crate::v1_compiler_coercion::rust_seed_host_numeric_alias( leaf.clone(), crate::v1_compiler_coercion::type_reference_decl_file(n.clone()), ) { - Some(scalar) => { - if (v1_rt::set_contains(&shared_types, leaf.clone()) - && !rust_type_is_rc_wrapped(scalar.clone())) - { - Some(crate::v1_compiler_languages::wrap_shared_type( - RenderTarget::Rust, - scalar.clone(), - )) - } else { - Some(scalar.clone()) + Some(numeric) => Some(numeric.clone()), + None => match rust_scalar_checkpoint_reference_base( + leaf.clone(), + crate::v1_compiler_coercion::type_reference_decl_file(n.clone()), + ) { + Some(scalar) => { + if (v1_rt::set_contains(&shared_types, leaf.clone()) + && !rust_type_is_rc_wrapped(scalar.clone())) + { + Some(crate::v1_compiler_languages::wrap_shared_type( + RenderTarget::Rust, + scalar.clone(), + )) + } else { + Some(scalar.clone()) + } } - } - None => None, + None => None, + }, }, } } } } -pub fn rust_seed_host_container_base(name: String) -> Option { - if ((name.clone() == "List".to_string()) || (name.clone() == "FreeMonoid".to_string())) { - Some("Vec".to_string()) - } else { - None +pub fn rust_exact_binding_spelling( + source: Option>, + grounding: bool, +) -> Option { + match (*crate::v1_compiler_coercion::rust_lookup_exact_binding(source.clone())).clone() { + ExactBindingResolution::ResolvedExactBinding { binding: b, .. } => { + match crate::extdeps_languages_rust_representation::rust_exact_type_checkpoint( + b.clone(), + ) { + Some(cp) => Some(if grounding.clone() { + cp.grounding_type.clone() + } else { + cp.target_type.clone() + }), + None => Some(emit_rust_compile_error_expr(v1_rt::concat( + v1_rt::concat( + "declaration '".to_string(), + b.source.clone().decl_name.clone(), + ), + "' is bound to a Rust representation with no realization row".to_string(), + ))), + } + } + ExactBindingResolution::ExactBindingAmbiguous { + candidate_count: k, .. + } => Some(emit_rust_compile_error_expr(v1_rt::concat( + v1_rt::concat( + "ambiguous exact Rust binding: ".to_string(), + crate::v1_compiler_emit_core_support::to_string(k.clone()), + ), + " rows for one declaration".to_string(), + ))), + ExactBindingResolution::ExactBindingAbsent => None, + ExactBindingResolution::ExactSourceIdentityUnavailable { cause: _, .. } => None, } } -pub fn rust_host_text_carrier_elem_name( +pub fn rust_exact_reference_spelling( n: Rc, source_indices: Rc>>, -) -> String { - match n.children.clone().first().cloned() { - Some(ch) => crate::v1_std_core::authored_name_at(source_indices.clone(), ch.clone()), - None => match crate::v1_std_core::find_property( - n.properties.clone(), - "__applied_type_args".to_string(), + env: Rc, +) -> Option { + rust_exact_binding_spelling( + crate::v1_compiler_infer_env::type_reference_declaration_ref( + n.clone(), source_indices.clone(), - ) { - Some(applied) => match applied.children.clone().first().cloned() { - Some(ach) => { - crate::v1_std_core::authored_name_at(source_indices.clone(), ach.clone()) - } + env.clone(), + ), + false, + ) +} + +pub fn rust_reference_checkpoint_spelling_at( + n: Rc, + source_indices: Rc>>, + env: Rc, +) -> Option { + match rust_exact_reference_spelling(n.clone(), source_indices.clone(), env.clone()) { + Some(exact) => Some(exact.clone()), + None => rust_scalar_checkpoint_reference_base( + rust_fn_sig_leaf_name(source_indices.clone(), n.clone()), + crate::v1_compiler_coercion::type_reference_decl_file(n.clone()), + ), + } +} + +pub fn rust_declaration_checkpoint_grounding_at( + module_path: String, + decl_name: String, + decl_file: String, +) -> Option { + match rust_exact_binding_spelling( + Some(crate::std_decl_ref::decl_ref( + module_path.clone(), + decl_name.clone(), + )), + true, + ) { + Some(exact) => Some(exact.clone()), + None => rust_scalar_checkpoint_grounding_base(decl_name.clone(), decl_file.clone()), + } +} + +pub fn rust_seed_host_container_base(name: String) -> Option { + if ((name.clone() == "List".to_string()) || (name.clone() == "FreeMonoid".to_string())) { + Some("Vec".to_string()) + } else { + None + } +} + +pub fn rust_host_text_carrier_elem_name( + n: Rc, + source_indices: Rc>>, +) -> String { + match n.children.clone().first().cloned() { + Some(ch) => crate::v1_std_core::authored_name_at(source_indices.clone(), ch.clone()), + None => match crate::v1_std_core::find_property( + n.properties.clone(), + "__applied_type_args".to_string(), + source_indices.clone(), + ) { + Some(applied) => match applied.children.clone().first().cloned() { + Some(ach) => { + crate::v1_std_core::authored_name_at(source_indices.clone(), ach.clone()) + } None => "".to_string(), }, None => "".to_string(), @@ -1843,6 +1937,7 @@ pub fn render_rust_applied_type_arg( n.clone(), source_indices.clone(), shared_types.clone(), + env.clone(), ) { Some(scalar) => scalar.clone(), None => render_rust_decl_type( @@ -1894,9 +1989,10 @@ pub fn render_rust_applied_type( ), } } else { - match rust_scalar_checkpoint_reference_base( - base_name.clone(), - crate::v1_compiler_coercion::type_reference_decl_file(n.clone()), + match rust_reference_checkpoint_spelling_at( + n.clone(), + source_indices.clone(), + env.clone(), ) { Some(scalar) => scalar.clone(), None => match closed_alias_peel_verdict(env.clone(), n.clone()) { @@ -2200,9 +2296,9 @@ pub fn render_rust_decl_type( } None => { let name = rust_fn_sig_leaf_name(source_indices.clone(), n.clone()); - if (((n.connective.clone() == Connective::NoConnective) + let exact_leaf = if (((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) == 0)) - && { + && !{ let mut __found = false; for g in generic_param_names.iter().cloned() { if (g.clone() == name.clone()) { @@ -2211,76 +2307,102 @@ pub fn render_rust_decl_type( } } __found - }) - { - crate::v1_compiler_emit_core_support::to_pascal(name.clone()) + }) { + rust_exact_reference_spelling(n.clone(), source_indices.clone(), env.clone()) } else { - if ((((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) == 0)) - && (applied_prop.clone() == None)) - && is_host_text_carrier_type(n.clone(), source_indices.clone())) - { - rust_carrier_optional_wrap( - n.clone(), - render_rust_text_carrier(shared_types.clone()), - ) - } else { - if ((((n.connective.clone() == Connective::NoConnective) + None + }; + match exact_leaf.clone() { + Some(exact) => rust_carrier_optional_wrap(n.clone(), exact.clone()), + None => { + if (((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) == 0)) - && (applied_prop.clone() == None)) - && v1_rt::set_contains(&shared_types, name.clone())) + && { + let mut __found = false; + for g in generic_param_names.iter().cloned() { + if (g.clone() == name.clone()) { + __found = true; + break; + } + } + __found + }) { - { - let rendered = rust_render_type_leaf_name( - name.clone(), - variant_to_enum.clone(), - ); - render_rust_shared_type_with_optional( - n.clone(), - name.clone(), - rendered.clone(), - shared_types.clone(), - ) - } + crate::v1_compiler_emit_core_support::to_pascal(name.clone()) } else { - if ((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) > 0)) + if ((((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) == 0)) + && (applied_prop.clone() == None)) + && is_host_text_carrier_type(n.clone(), source_indices.clone())) { - match rust_render_checkpoint_scalar_bare( + rust_carrier_optional_wrap( n.clone(), - source_indices.clone(), - shared_types.clone(), - ) { - Some(scalar) => render_rust_shared_type_with_optional( - n.clone(), - rust_fn_sig_leaf_name(source_indices.clone(), n.clone()), - scalar.clone(), - shared_types.clone(), - ), - None => { - if (!crate::std_types::is_container_type(name.clone()) - && closed_alias_peels_zero_param( - env.clone(), - n.clone(), - )) - { - render_rust_shared_type_with_optional( + render_rust_text_carrier(shared_types.clone()), + ) + } else { + if ((((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) == 0)) + && (applied_prop.clone() == None)) + && v1_rt::set_contains(&shared_types, name.clone())) + { + { + let rendered = rust_render_type_leaf_name( + name.clone(), + variant_to_enum.clone(), + ); + render_rust_shared_type_with_optional( + n.clone(), + name.clone(), + rendered.clone(), + shared_types.clone(), + ) + } + } else { + if ((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) > 0)) + { + match rust_render_checkpoint_scalar_bare( + n.clone(), + source_indices.clone(), + shared_types.clone(), + env.clone(), + ) { + Some(scalar) => render_rust_shared_type_with_optional( n.clone(), - name.clone(), - name.clone(), + rust_fn_sig_leaf_name( + source_indices.clone(), + n.clone(), + ), + scalar.clone(), shared_types.clone(), - ) - } else { - { - let base = rust_applied_type_base(name.clone(), crate::v1_compiler_coercion::type_reference_decl_file(n.clone())); - let peel = is_parametric_opaque_type_by_name( - env.clone(), + ), + None => { + if (!crate::std_types::is_container_type( name.clone(), - ); - let arg_list = Rc::new({ - let mut __result = Vec::new(); - for arg in n.children.clone().iter().cloned() { - __result.push({ + ) && closed_alias_peels_zero_param( + env.clone(), + n.clone(), + )) { + render_rust_shared_type_with_optional( + n.clone(), + name.clone(), + name.clone(), + shared_types.clone(), + ) + } else { + { + let base = rust_applied_type_base(name.clone(), crate::v1_compiler_coercion::type_reference_decl_file(n.clone())); + let peel = + is_parametric_opaque_type_by_name( + env.clone(), + name.clone(), + ); + let arg_list = Rc::new({ + let mut __result = Vec::new(); + for arg in + n.children.clone().iter().cloned() + { + __result.push({ let typed_arg = render_rust_decl_type_container_arg(arg.clone(), source_indices.clone(), env.clone()); if peel.clone() { render_rust_phantom_opaque_applied_decl_arg(typed_arg.clone(), generic_param_names.clone(), shared_types.clone(), source_indices.clone(), variant_to_enum.clone(), env.clone()) @@ -2288,25 +2410,22 @@ if peel.clone() { if rust_type_arg_renders_as_unit(typed_arg.clone(), generic_param_names.clone(), variant_to_enum.clone(), source_indices.clone()) { "()".to_string() } else { - match rust_render_checkpoint_scalar_bare(typed_arg.clone(), source_indices.clone(), shared_types.clone()) { + match rust_render_checkpoint_scalar_bare(typed_arg.clone(), source_indices.clone(), shared_types.clone(), env.clone()) { Some(scalar) => scalar.clone(), None => render_rust_decl_type(typed_arg.clone(), generic_param_names.clone(), shared_types.clone(), source_indices.clone(), variant_to_enum.clone(), env.clone()), } } } }); - } - __result - }); - let applied_ty = if (name.clone() - == tuple_type_name()) - { - crate::v1_compiler_emit::render_tuple_parts( - arg_list.clone(), - RenderTarget::Rust, - ) - } else { - if crate::v1_compiler_infer_types::node_is_keyed_collection(n.clone(), source_indices.clone()) { + } + __result + }); + let applied_ty = if (name.clone() + == tuple_type_name()) + { + crate::v1_compiler_emit::render_tuple_parts(arg_list.clone(), RenderTarget::Rust) + } else { + if crate::v1_compiler_infer_types::node_is_keyed_collection(n.clone(), source_indices.clone()) { match arg_list.clone().first().cloned() { Some(k) => match arg_list.clone().iter().cloned().skip(1 as usize).next() { Some(v) => crate::v1_compiler_emit::emit_map_type(k.clone(), v.clone(), RenderTarget::Rust), @@ -2324,33 +2443,35 @@ if peel.clone() { v1_rt::concat(v1_rt::concat(v1_rt::concat(base.clone(), "<".to_string()), arg_list.clone().join(&", ".to_string())), ">".to_string()) } } - }; - render_rust_shared_type_with_optional( - n.clone(), - name.clone(), - applied_ty.clone(), - shared_types.clone(), - ) + }; + render_rust_shared_type_with_optional( + n.clone(), + name.clone(), + applied_ty.clone(), + shared_types.clone(), + ) + } + } } } + } else { + if type_node_has_unbound_type_variable( + n.clone(), + generic_param_names.clone(), + source_indices.clone(), + ) { + "_".to_string() + } else { + render_rust_type_with_applied_binding_in_scope( + n.clone(), + generic_param_names.clone(), + shared_types.clone(), + source_indices.clone(), + env.clone(), + ) + } } } - } else { - if type_node_has_unbound_type_variable( - n.clone(), - generic_param_names.clone(), - source_indices.clone(), - ) { - "_".to_string() - } else { - render_rust_type_with_applied_binding_in_scope( - n.clone(), - generic_param_names.clone(), - shared_types.clone(), - source_indices.clone(), - env.clone(), - ) - } } } } @@ -2434,58 +2555,82 @@ pub fn render_rust_fn_sig_type( ); } let name = rust_fn_sig_leaf_name(source_indices.clone(), n.clone()); - if (((n.connective.clone() == Connective::NoConnective) + let exact_leaf = if (((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) == 0)) - && is_host_text_carrier_type(n.clone(), source_indices.clone())) - { - rust_carrier_optional_wrap(n.clone(), render_rust_text_carrier(shared_types.clone())) + && !{ + let mut __found = false; + for g in generic_param_names.iter().cloned() { + if (g.clone() == name.clone()) { + __found = true; + break; + } + } + __found + }) { + rust_exact_reference_spelling(n.clone(), source_indices.clone(), env.clone()) } else { - if (((((((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) == 0)) - && (name.clone() != "".to_string())) - && (name.clone() != "String".to_string())) - && !crate::std_types::is_container_type(name.clone())) - && closed_alias_peels_zero_param(env.clone(), n.clone())) - && rust_fn_sig_preserves_authored_alias_leaf( - name.clone(), - crate::v1_compiler_coercion::type_reference_decl_file(n.clone()), - )) - { - render_rust_shared_type_with_optional( - n.clone(), - name.clone(), - name.clone(), - shared_types.clone(), - ) - } else { - if ((((n.connective.clone() == Connective::NoConnective) - && ((n.children.clone().len() as i64) > 0)) - && !crate::std_types::is_container_type(name.clone())) - && closed_alias_peels_zero_param(env.clone(), n.clone())) + None + }; + match exact_leaf.clone() { + Some(exact) => rust_carrier_optional_wrap(n.clone(), exact.clone()), + None => { + if (((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) == 0)) + && is_host_text_carrier_type(n.clone(), source_indices.clone())) { - render_rust_shared_type_with_optional( + rust_carrier_optional_wrap( n.clone(), - name.clone(), - name.clone(), - shared_types.clone(), + render_rust_text_carrier(shared_types.clone()), ) } else { - if ((generic_param_names.clone().len() as i64) > 0) { - render_rust_decl_type( + if (((((((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) == 0)) + && (name.clone() != "".to_string())) + && (name.clone() != "String".to_string())) + && !crate::std_types::is_container_type(name.clone())) + && closed_alias_peels_zero_param(env.clone(), n.clone())) + && rust_fn_sig_preserves_authored_alias_leaf( + name.clone(), + crate::v1_compiler_coercion::type_reference_decl_file(n.clone()), + )) + { + render_rust_shared_type_with_optional( n.clone(), - generic_param_names.clone(), + name.clone(), + name.clone(), shared_types.clone(), - source_indices.clone(), - variant_to_enum.clone(), - env.clone(), ) } else { - render_rust_fn_sig_type_applied_binding( - n.clone(), - shared_types.clone(), - source_indices.clone(), - env.clone(), - ) + if ((((n.connective.clone() == Connective::NoConnective) + && ((n.children.clone().len() as i64) > 0)) + && !crate::std_types::is_container_type(name.clone())) + && closed_alias_peels_zero_param(env.clone(), n.clone())) + { + render_rust_shared_type_with_optional( + n.clone(), + name.clone(), + name.clone(), + shared_types.clone(), + ) + } else { + if ((generic_param_names.clone().len() as i64) > 0) { + render_rust_decl_type( + n.clone(), + generic_param_names.clone(), + shared_types.clone(), + source_indices.clone(), + variant_to_enum.clone(), + env.clone(), + ) + } else { + render_rust_fn_sig_type_applied_binding( + n.clone(), + shared_types.clone(), + source_indices.clone(), + env.clone(), + ) + } + } } } } @@ -2681,16 +2826,75 @@ pub fn alias_rhs_qualified_name_routing_note() -> String { CACHED.with(|c: &String| c.clone()) } -pub fn render_rust_alias_rhs_type( +pub fn rust_alias_rhs_applied_container_or_base( n: Rc, - generic_param_names: Rc>, - shared_types: Rc>, + leaf: String, + base: String, + arg_list: Rc>, source_indices: Rc>>, - scope: Rc, - imports: Rc>>, - registry: Rc>>, - module_name: String, - export_sets: Rc>>>, +) -> String { + if crate::v1_compiler_infer_types::node_is_keyed_collection(n.clone(), source_indices.clone()) { + match arg_list.clone().first().cloned() { + Some(k) => match arg_list.clone().iter().cloned().skip(1 as usize).next() { + Some(v) => { + crate::v1_compiler_emit::emit_map_type(k.clone(), v.clone(), RenderTarget::Rust) + } + None => v1_rt::concat( + v1_rt::concat( + v1_rt::concat(base.clone(), "<".to_string()), + arg_list.clone().join(&", ".to_string()), + ), + ">".to_string(), + ), + }, + None => v1_rt::concat( + v1_rt::concat( + v1_rt::concat(base.clone(), "<".to_string()), + arg_list.clone().join(&", ".to_string()), + ), + ">".to_string(), + ), + } + } else { + if (crate::v1_compiler_infer_types::node_is_collection(n.clone(), source_indices.clone()) + && ((arg_list.clone().len() as i64) == 1)) + { + match arg_list.clone().first().cloned() { + Some(inner) => crate::v1_compiler_emit::emit_container( + leaf.clone(), + inner.clone(), + RenderTarget::Rust, + ), + None => v1_rt::concat( + v1_rt::concat( + v1_rt::concat(base.clone(), "<".to_string()), + arg_list.clone().join(&", ".to_string()), + ), + ">".to_string(), + ), + } + } else { + v1_rt::concat( + v1_rt::concat( + v1_rt::concat(base.clone(), "<".to_string()), + arg_list.clone().join(&", ".to_string()), + ), + ">".to_string(), + ) + } + } +} + +pub fn render_rust_alias_rhs_type( + n: Rc, + generic_param_names: Rc>, + shared_types: Rc>, + source_indices: Rc>>, + scope: Rc, + imports: Rc>>, + registry: Rc>>, + module_name: String, + export_sets: Rc>>>, typed_modules: Rc>>, module_index: Rc, variant_to_enum: Rc>, @@ -2736,33 +2940,42 @@ pub fn render_rust_alias_rhs_type( if ((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) == 0)) { - match crate::v1_compiler_coercion::rust_seed_host_numeric_alias( - name.clone(), - crate::v1_compiler_coercion::type_reference_decl_file(n.clone()), + match rust_exact_reference_spelling( + n.clone(), + source_indices.clone(), + scope.type_env.clone(), ) { - Some(host) => host.clone(), - None => match rust_opaque_kernel_alias_carrier(name.clone()) { - Some(carrier) => carrier.clone(), - None => { - let leaf = crate::v1_std_core::qualified_last_segment(name.clone()); - match rust_scalar_checkpoint_reference_base( - leaf.clone(), - crate::v1_compiler_coercion::type_reference_decl_file(n.clone()), - ) { - Some(scalar) => scalar.clone(), - None => { - let rendered = rust_render_type_leaf_name( - leaf.clone(), - variant_to_enum.clone(), - ); - render_rust_shared_type_if_needed( - leaf.clone(), - rendered.clone(), - shared_types.clone(), - ) + Some(exact) => exact.clone(), + None => match crate::v1_compiler_coercion::rust_seed_host_numeric_alias( + name.clone(), + crate::v1_compiler_coercion::type_reference_decl_file(n.clone()), + ) { + Some(host) => host.clone(), + None => match rust_opaque_kernel_alias_carrier(name.clone()) { + Some(carrier) => carrier.clone(), + None => { + let leaf = crate::v1_std_core::qualified_last_segment(name.clone()); + match rust_scalar_checkpoint_reference_base( + leaf.clone(), + crate::v1_compiler_coercion::type_reference_decl_file( + n.clone(), + ), + ) { + Some(scalar) => scalar.clone(), + None => { + let rendered = rust_render_type_leaf_name( + leaf.clone(), + variant_to_enum.clone(), + ); + render_rust_shared_type_if_needed( + leaf.clone(), + rendered.clone(), + shared_types.clone(), + ) + } } } - } + }, }, } } else { @@ -2771,9 +2984,10 @@ pub fn render_rust_alias_rhs_type( { { let leaf = crate::v1_std_core::qualified_last_segment(name.clone()); - let numeric_host_alias = match rust_scalar_checkpoint_reference_base( - leaf.clone(), - crate::v1_compiler_coercion::type_reference_decl_file(n.clone()), + let numeric_host_alias = match rust_reference_checkpoint_spelling_at( + n.clone(), + source_indices.clone(), + scope.type_env.clone(), ) { Some(scalar) => Some(scalar.clone()), None => crate::v1_compiler_coercion::rust_seed_host_numeric_alias( @@ -2859,7 +3073,7 @@ pub fn render_rust_alias_rhs_type( source_indices.clone(), module_index.clone(), ); - let args = Rc::new({ + let arg_list = Rc::new({ let mut __result = Vec::new(); for arg in n.children.clone().iter().cloned() { __result.push(if peel.clone() { @@ -2898,14 +3112,14 @@ pub fn render_rust_alias_rhs_type( }); } __result - }) - .join(&", ".to_string()); - let applied_ty = v1_rt::concat( - v1_rt::concat( - v1_rt::concat(base.clone(), "<".to_string()), - args.clone(), - ), - ">".to_string(), + }); + let args = arg_list.clone().join(&", ".to_string()); + let applied_ty = rust_alias_rhs_applied_container_or_base( + n.clone(), + leaf.clone(), + base.clone(), + arg_list.clone(), + source_indices.clone(), ); if (v1_rt::set_contains(&shared_types, leaf.clone()) && !rust_type_is_rc_wrapped(applied_ty.clone())) @@ -2931,7 +3145,7 @@ pub fn render_rust_alias_rhs_type( source_indices.clone(), module_index.clone(), ); - let args = Rc::new({ + let arg_list = Rc::new({ let mut __result = Vec::new(); for arg in n.children.clone().iter().cloned() { __result.push(if peel.clone() { @@ -2970,14 +3184,14 @@ pub fn render_rust_alias_rhs_type( }); } __result - }) - .join(&", ".to_string()); - let applied_ty = v1_rt::concat( - v1_rt::concat( - v1_rt::concat(base.clone(), "<".to_string()), - args.clone(), - ), - ">".to_string(), + }); + let args = arg_list.clone().join(&", ".to_string()); + let applied_ty = rust_alias_rhs_applied_container_or_base( + n.clone(), + leaf.clone(), + base.clone(), + arg_list.clone(), + source_indices.clone(), ); if (v1_rt::set_contains(&shared_types, leaf.clone()) && !rust_type_is_rc_wrapped(applied_ty.clone())) @@ -13330,7 +13544,7 @@ pub fn emit_typed_item( if (((item.params.clone().len() as i64) == 0) && rust_opaque_kernel_alias_type_eligible(item_text.clone())) { - rust_opaque_kernel_alias_type_decl(item_text.clone()) + rust_opaque_kernel_alias_type_decl(item_text.clone(), module_name.clone()) } else { if is_zero_param_self_referential_opaque_decl( item.clone(), @@ -13345,7 +13559,8 @@ pub fn emit_typed_item( env.source_indices.clone(), ) } else { - match rust_scalar_checkpoint_grounding_base( + match rust_declaration_checkpoint_grounding_at( + module_name.clone(), item_text.clone(), decl_identity_file(item.clone()), ) { @@ -13411,7 +13626,7 @@ pub fn emit_typed_item( if (((item.params.clone().len() as i64) == 0) && rust_opaque_kernel_alias_type_eligible(item_text.clone())) { - rust_opaque_kernel_alias_type_decl(item_text.clone()) + rust_opaque_kernel_alias_type_decl(item_text.clone(), module_name.clone()) } else { match rust_seed_host_container_base(item_text.clone()) { Some(host) => { @@ -16207,6 +16422,7 @@ pub fn v1_fn_body_derived_clone_param_names( pub fn v1_fn_bounds_by_param( clone_param_names: Rc>, eq_param_names: Rc>, + map_key_param_names: Rc>, ) -> Rc>>> { { let with_clone = clone_param_names.iter().cloned().fold( @@ -16215,7 +16431,7 @@ pub fn v1_fn_bounds_by_param( v1_rt::rc_map_insert(m, n.clone(), Rc::new(vec!["Clone".to_string()])) }, ); - eq_param_names.iter().cloned().fold( + let with_eq = eq_param_names.iter().cloned().fold( with_clone.clone(), |m: Rc>>>, n: String| match v1_rt::map_get(&m, n.clone()) { @@ -16230,10 +16446,78 @@ pub fn v1_fn_bounds_by_param( Rc::new(vec!["PartialEq".to_string()]), ), }, + ); + map_key_param_names.iter().cloned().fold( + with_eq.clone(), + |m: Rc>>>, n: String| match v1_rt::map_get(&m, n.clone()) + { + Some(traits) => v1_rt::rc_map_insert( + m.clone(), + n.clone(), + v1_rt::concat(traits.clone(), rust_map_key_bound_traits()), + ), + None => v1_rt::rc_map_insert(m.clone(), n.clone(), rust_map_key_bound_traits()), + }, ) } } +pub fn rust_map_key_bound_traits() -> Rc> { + Rc::new(vec![ + "std::cmp::Eq".to_string(), + "std::hash::Hash".to_string(), + ]) +} + +pub fn v1_fn_signature_map_key_param_names( + value_params: Rc>>, + ret: Rc, + generic_param_names: Rc>, + source_indices: Rc>>, +) -> Rc> { + { + let from_params = Rc::new({ + let mut __result = Vec::new(); + for p in value_params.iter().cloned() { + __result.extend( + (*crate::v1_compiler_trait_derive_emit::v1_map_key_head_names_in_type_expr( + crate::v1_std_core::param_node_type_expr(p.clone()), + source_indices.clone(), + )) + .iter() + .cloned(), + ); + } + __result + }); + let from_ret = crate::v1_compiler_trait_derive_emit::v1_map_key_head_names_in_type_expr( + ret.clone(), + source_indices.clone(), + ); + crate::v1_compiler_emit_core_support::unique_strings(Rc::new({ + let mut __result = Vec::new(); + for n in v1_rt::concat(from_params.clone(), from_ret.clone()) + .iter() + .cloned() + { + if { + let mut __found = false; + for g in generic_param_names.iter().cloned() { + if (g.clone() == n.clone()) { + __found = true; + break; + } + } + __found + } { + __result.push(n); + } + } + __result + })) + } +} + pub fn v1_fn_body_equality_bound_param_names( body: Rc, generic_param_names: Rc>, @@ -16648,10 +16932,20 @@ pub fn emit_fn_def( self_eq_param_names.clone(), call_forwarding_eq_param_names.clone(), ); - let bounds_by_param = - v1_fn_bounds_by_param(clone_param_names.clone(), eq_param_names.clone()); - let needs_bound = (((clone_param_names.clone().len() as i64) > 0) - || ((eq_param_names.clone().len() as i64) > 0)); + let map_key_param_names = v1_fn_signature_map_key_param_names( + value_params.clone(), + inferred.clone(), + generic_param_names.clone(), + si.clone(), + ); + let bounds_by_param = v1_fn_bounds_by_param( + clone_param_names.clone(), + eq_param_names.clone(), + map_key_param_names.clone(), + ); + let needs_bound = ((((clone_param_names.clone().len() as i64) > 0) + || ((eq_param_names.clone().len() as i64) > 0)) + || ((map_key_param_names.clone().len() as i64) > 0)); let type_params_str = if needs_bound.clone() { crate::v1_compiler_trait_derive_emit::v1_emit_type_params_with_bounds( type_params.clone(), @@ -18444,7 +18738,7 @@ pub fn emit_variant_pattern( fb_pat.clone(), v1_rt::rc_list_push(path_prefix.clone(), rust_name.clone()), shared_types.clone(), - scrut_type.clone(), + "".to_string(), source_indices.clone(), emit_info.clone(), ); @@ -28965,133 +29259,370 @@ pub fn emit_typed_bin_op( RenderTarget::Rust, ) } else { - { - let op_str = crate::v1_compiler_emit::emit_bin_op_symbol( + match (*binop_operator_realization(op.clone(), left.clone(), scope.clone())).clone() { + OperatorRealization::OperatorRealizationRefused { cause: c, .. } => { + emit_rust_compile_error_expr( + crate::std_operator_realization::operator_realization_refusal_message( + c.clone(), + ), + ) + } + OperatorRealization::StructuralComparison { + binding: b, + test: t, + .. + } => emit_rust_structural_comparison( + l_str.clone(), + r_str.clone(), + b.clone(), + t.clone(), + ), + OperatorRealization::StructuralEquality { declaration: _, .. } => { + emit_rust_host_bin_op( + op.clone(), + algebra_field.clone(), + left.clone(), + right.clone(), + l_str.clone(), + r_str.clone(), + scope.clone(), + ) + } + OperatorRealization::HostOperator => emit_rust_host_bin_op( op.clone(), - RenderTarget::Rust, algebra_field.clone(), - ); - if is_string_comparison( - op.clone(), left.clone(), right.clone(), - scope.type_env.clone().source_indices.clone(), + l_str.clone(), + r_str.clone(), + scope.clone(), + ), + } + } + } +} + +pub fn rust_operand_realization( + operand: Rc, + scope: Rc, +) -> Rc { + rust_operand_realization_of_type( + crate::v1_compiler_infer_types::resolved_type(operand.clone()), + scope.clone(), + 8, + ) +} + +pub fn rust_operand_realization_of_type( + mut rt: Rc, + mut scope: Rc, + mut fuel: i64, +) -> Rc { + loop { + match crate::v1_compiler_infer_env::type_reference_declaration_ref( + rt.clone(), + scope.type_env.clone().source_indices.clone(), + scope.type_env.clone(), + ) { + None => { + break Rc::new(OperandRealization::OperandIdentityUnavailable); + } + Some(d) => { + if crate::v1_compiler_coercion::declaration_realizes_natively_on_rust( + d.clone(), + crate::v1_compiler_coercion::type_reference_decl_file(rt.clone()), ) { + break Rc::new(OperandRealization::HostNumericOperand); + } else { + let decl = match rt.inferred.clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: r, .. }) => r.clone(), + _ => rt.clone(), + }; + if ((fuel.clone() > 0) + && crate::v1_compiler_infer::is_where_refinement_type(rt.clone())) { - let l_optional = is_optional_typed_expr(left.clone()); - let r_optional = is_optional_typed_expr(right.clone()); - if (l_optional.clone() || r_optional.clone()) { + match rt.children.clone().first().cloned() { + Some(base) => { + let base_resolved = + match crate::v1_compiler_infer_env::lookup_type_for( + scope.type_env.clone(), + base.clone(), + ) { + Some(r) => r.clone(), + None => base.clone(), + }; + { + let __tco_0 = base_resolved.clone(); + let __tco_1 = (fuel - 1); + rt = __tco_0; + fuel = __tco_1; + continue; + } + } + None => { + break Rc::new(OperandRealization::StructuralOperand { + declaration: d.clone(), + }); + } + } + } else { + if ((fuel.clone() > 0) + && crate::v1_compiler_emit_core_support::is_type_alias_item( + decl.clone(), + scope.type_env.clone().source_indices.clone(), + )) + { { - let l_cmp = if l_optional.clone() { - v1_rt::concat(l_str.clone(), ".as_deref()".to_string()) - } else { - v1_rt::concat( - v1_rt::concat( - "Some(".to_string(), - emit_rust_dag_string_to_host_via_seam(l_str.clone()), - ), - ").as_deref()".to_string(), - ) - }; - let r_cmp = if r_optional.clone() { - v1_rt::concat(r_str.clone(), ".as_deref()".to_string()) - } else { - v1_rt::concat( - v1_rt::concat( - "Some(".to_string(), - emit_rust_dag_string_to_host_via_seam(r_str.clone()), - ), - ").as_deref()".to_string(), - ) - }; + let __tco_0 = + crate::v1_compiler_infer_types::resolved_type(decl.clone()); + let __tco_1 = (fuel - 1); + rt = __tco_0; + fuel = __tco_1; + continue; + } + } else { + break Rc::new(OperandRealization::StructuralOperand { + declaration: d.clone(), + }); + } + } + } + } + } + } +} + +pub fn binop_operator_realization( + op: BinOp, + left: Rc, + scope: Rc, +) -> Rc { + crate::std_operator_realization::operator_realization_for( + op.clone(), + rust_operand_realization(left.clone(), scope.clone()), + structural_ordering_rows(), + ) +} + +pub fn rust_declaration_path(module_path: String, decl_name: String) -> String { + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + "crate::".to_string(), + crate::v1_compiler_emit_core_support::module_to_filename(module_path.clone()), + ), + "::".to_string(), + ), + crate::v1_compiler_emit::emit_ident(decl_name.clone(), RenderTarget::Rust), + ) +} + +pub fn emit_rust_structural_comparison( + l_str: String, + r_str: String, + binding: Rc, + test: Rc, +) -> String { + { + let call = v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + rust_declaration_path( + binding.compare.clone().module_path.clone(), + binding.compare.clone().decl_name.clone(), + ), + "(".to_string(), + ), + l_str.clone(), + ), + ", ".to_string(), + ), + r_str.clone(), + ), + ")".to_string(), + ); + let ordering = v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + "crate::".to_string(), + crate::v1_compiler_emit_core_support::module_to_filename( + binding.ordering.clone().module_path.clone(), + ), + ), + "::".to_string(), + ), + binding.ordering.clone().decl_name.clone(), + ); + match (*test.clone()).clone() { + OrderingTest::OrderingIs { variant: v, .. } => v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat("(".to_string(), call.clone()), + " == ".to_string(), + ), + ordering.clone(), + ), + "::".to_string(), + ), + v.clone(), + ), + ")".to_string(), + ), + OrderingTest::OrderingIsNot { variant: v, .. } => v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat("(".to_string(), call.clone()), + " != ".to_string(), + ), + ordering.clone(), + ), + "::".to_string(), + ), + v.clone(), + ), + ")".to_string(), + ), + } + } +} + +pub fn emit_rust_host_bin_op( + op: BinOp, + algebra_field: Option, + left: Rc, + right: Rc, + l_str: String, + r_str: String, + scope: Rc, +) -> String { + { + let op_str = crate::v1_compiler_emit::emit_bin_op_symbol( + op.clone(), + RenderTarget::Rust, + algebra_field.clone(), + ); + if is_string_comparison( + op.clone(), + left.clone(), + right.clone(), + scope.type_env.clone().source_indices.clone(), + ) { + { + let l_optional = is_optional_typed_expr(left.clone()); + let r_optional = is_optional_typed_expr(right.clone()); + if (l_optional.clone() || r_optional.clone()) { + { + let l_cmp = if l_optional.clone() { + v1_rt::concat(l_str.clone(), ".as_deref()".to_string()) + } else { + v1_rt::concat( + v1_rt::concat( + "Some(".to_string(), + emit_rust_dag_string_to_host_via_seam(l_str.clone()), + ), + ").as_deref()".to_string(), + ) + }; + let r_cmp = if r_optional.clone() { + v1_rt::concat(r_str.clone(), ".as_deref()".to_string()) + } else { + v1_rt::concat( + v1_rt::concat( + "Some(".to_string(), + emit_rust_dag_string_to_host_via_seam(r_str.clone()), + ), + ").as_deref()".to_string(), + ) + }; + v1_rt::concat( + v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat("(".to_string(), l_cmp.clone()), - " ".to_string(), - ), - op_str.clone(), - ), + v1_rt::concat("(".to_string(), l_cmp.clone()), " ".to_string(), ), - r_cmp.clone(), + op_str.clone(), ), - ")".to_string(), - ) - } - } else { + " ".to_string(), + ), + r_cmp.clone(), + ), + ")".to_string(), + ) + } + } else { + v1_rt::concat( + v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - "(".to_string(), - emit_rust_dag_string_to_host_via_seam( - l_str.clone(), - ), - ), - " ".to_string(), - ), - op_str.clone(), + "(".to_string(), + emit_rust_dag_string_to_host_via_seam(l_str.clone()), ), " ".to_string(), ), - emit_rust_dag_string_to_host_via_seam(r_str.clone()), + op_str.clone(), ), - ")".to_string(), - ) - } - } - } else { - { - let both_string = (is_string_typed_expr( - left.clone(), - scope.type_env.clone().source_indices.clone(), - ) && is_string_typed_expr( - right.clone(), - scope.type_env.clone().source_indices.clone(), - )); - let is_str_concat = - ((op_str.clone() == "+".to_string()) && both_string.clone()); - if is_str_concat.clone() { + " ".to_string(), + ), + emit_rust_dag_string_to_host_via_seam(r_str.clone()), + ), + ")".to_string(), + ) + } + } + } else { + { + let both_string = (is_string_typed_expr( + left.clone(), + scope.type_env.clone().source_indices.clone(), + ) && is_string_typed_expr( + right.clone(), + scope.type_env.clone().source_indices.clone(), + )); + let is_str_concat = ((op_str.clone() == "+".to_string()) && both_string.clone()); + if is_str_concat.clone() { + v1_rt::concat( + v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat("(".to_string(), l_str.clone()), - " ".to_string(), - ), - op_str.clone(), - ), - " &".to_string(), + v1_rt::concat("(".to_string(), l_str.clone()), + " ".to_string(), ), - r_str.clone(), + op_str.clone(), ), - ")".to_string(), - ) - } else { + " &".to_string(), + ), + r_str.clone(), + ), + ")".to_string(), + ) + } else { + v1_rt::concat( + v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat("(".to_string(), l_str.clone()), - " ".to_string(), - ), - op_str.clone(), - ), + v1_rt::concat("(".to_string(), l_str.clone()), " ".to_string(), ), - r_str.clone(), + op_str.clone(), ), - ")".to_string(), - ) - } - } + " ".to_string(), + ), + r_str.clone(), + ), + ")".to_string(), + ) } } } diff --git a/src/v1/stage0/src/v1_compiler_infer.rs b/src/v1/stage0/src/v1_compiler_infer.rs index b0d7887e2c7..18c9b89bea6 100644 --- a/src/v1/stage0/src/v1_compiler_infer.rs +++ b/src/v1/stage0/src/v1_compiler_infer.rs @@ -7,10 +7,12 @@ use self::DescentSizeExpr::*; use self::InhabitanceRefusalReason::*; use self::InhabitanceUndecidableReason::*; use self::InhabitanceVerdict::*; +use self::LiteralBoundary::*; use self::ServiceConfigFieldJudgment::*; pub use crate::extdeps_container_oci_digest::{ oci_other_digest_algorithm, oci_other_digest_encoded, }; +pub use crate::gunbc_structural_realization_bindings::literal_homomorphism_rows; pub use crate::std_algebra::AlgebraFieldTemplate; use crate::std_algebra::CollectionSizeEffect::ShrinkEffect; pub use crate::std_algebra::{CollectionSizeEffect, FreeMonoid}; @@ -23,6 +25,7 @@ pub use crate::std_content_hash::{ content_hash_validate_lower_hex_length, }; pub use crate::std_content_hash::{ContentHash, Fnv1a64Structural}; +pub use crate::std_decl_ref::DeclarationRef; pub use crate::std_dissolution::DissolutionCondition; use crate::std_dissolution::DissolutionCondition::*; pub use crate::std_dissolution::{dissolution_description, unbound_dissolution}; @@ -41,14 +44,24 @@ pub use crate::std_induction::{InductiveField, RecursionShape, SubValueRelation} use crate::std_interface_summary::ExportKind::{ExportData, ExportFn, ExportService, ExportType}; pub use crate::std_interface_summary::{interface_summary_rollup, signature_contract}; pub use crate::std_interface_summary::{ExportEntry, ExportKind, InterfaceSummary}; +use crate::std_literal_elaboration::LiteralElaborationOutcome::{ + DirectLiteral, LiteralElaborationRefused, ViaHomomorphism, +}; +use crate::std_literal_elaboration::LiteralUnfolding::{BooleanUnfold, PeanoUnfold}; +pub use crate::std_literal_elaboration::{ + elaborate_literal_at, literal_elaboration_refusal_message, literal_source_kind_of, +}; +pub use crate::std_literal_elaboration::{ + LiteralElaboration, LiteralElaborationOutcome, LiteralHomomorphism, LiteralUnfolding, +}; pub use crate::std_node::{compiler_inductive_fields, compiler_recursive_types}; pub use crate::std_occurrence_identity::NodeOccurrenceIdentity; use crate::std_occurrence_identity::NodeOccurrenceIdentity::OccurrenceSynthetic; pub use crate::std_occurrence_identity::OccurrenceId; use crate::std_syntax::BinOp::Add; use crate::std_syntax::BinOp::{And, Div, Eq, Ge, Gt, Le, Lt, Mod, Mul, Ne, NullCoalesce, Or, Sub}; -use crate::std_syntax::LiteralValue::LitStr; -use crate::std_syntax::LiteralValue::{LitBool, LitFloat, LitInt, LitNull}; +use crate::std_syntax::LiteralValue::{LitBool, LitInt, LitStr}; +use crate::std_syntax::LiteralValue::{LitFloat, LitNull}; pub use crate::std_syntax::{BinOp, LiteralValue}; pub use crate::std_termination::PositiveDescentAmount; use crate::std_termination::PositiveDescentAmount::OneStep; @@ -86,7 +99,8 @@ pub use crate::v1_compiler_infer_env::{ node_with_inferred, put_inductive_field, put_inductive_field_cross, qualified_all_but_last, qualify_borrowed_inferred, qualify_borrowed_type_names, qualify_decl_reference_positions, str_bindings_from_bindings, symbol_index_insert, symbol_index_insert_decl, - symbol_index_insert_service, symbol_index_lookup, unit_variant_index_shadow_insert, + symbol_index_insert_service, symbol_index_lookup, type_reference_declaration_ref, + unit_variant_index_shadow_insert, }; pub use crate::v1_compiler_infer_env::{ GlobalBareCandidate, GlobalBareLookupState, GuardedTypeEnvCacheMerge, ServiceCensusEntry, @@ -206,9 +220,10 @@ use crate::v1_std_core::CompilerDiagnostic::{ }; use crate::v1_std_core::Connective::{Arrow, Conj, Disj, NoConnective}; use crate::v1_std_core::ExprData::{ - ExprBinOp, ExprBlock, ExprCall, ExprCast, ExprError, ExprFieldAccess, ExprForEach, ExprIf, - ExprIndex, ExprLambda, ExprLet, ExprListLit, ExprLiteral, ExprMatch, ExprMethodCall, - ExprRecordLit, ExprReturn, ExprSlice, ExprStringInterp, ExprUnaryOp, ExprVar, NoExprData, + ExprBinOp, ExprBlock, ExprCall, ExprCast, ExprElaboratedLiteral, ExprError, ExprFieldAccess, + ExprForEach, ExprIf, ExprIndex, ExprLambda, ExprLet, ExprListLit, ExprLiteral, ExprMatch, + ExprMethodCall, ExprRecordLit, ExprReturn, ExprSlice, ExprStringInterp, ExprUnaryOp, ExprVar, + NoExprData, }; use crate::v1_std_core::ExprErrorKind::{ CensusHeadsBodyStripped, InternalExprError, ParseRecoveryError, SemanticExprError, @@ -7772,6 +7787,246 @@ pub fn qualified_value_projection( } } +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[serde(tag = "_variant")] +pub enum LiteralBoundary { + LiteralBoundaryPlain, + LiteralBoundaryElaborated { + elaboration: Rc, + destination_type: Rc, + }, + LiteralBoundaryRefused { + message: String, + }, +} + +pub fn literal_boundary_elaboration( + lit: Rc, + expected: Option>, + scope: Rc, +) -> Rc { + match expected.clone() { + None => Rc::new(LiteralBoundary::LiteralBoundaryPlain), + Some(exp) => { + if (exp.return_cardinality.clone() == Cardinality::CardOptional) { + Rc::new(LiteralBoundary::LiteralBoundaryPlain) + } else { + match crate::v1_compiler_infer_env::type_reference_declaration_ref( + exp.clone(), + scope.type_env.clone().source_indices.clone(), + scope.type_env.clone(), + ) { + None => Rc::new(LiteralBoundary::LiteralBoundaryPlain), + Some(destination) => { + let kind = + crate::std_literal_elaboration::literal_source_kind_of(lit.clone()); + let natively = crate::v1_compiler_coercion::decl_file_realizes_natively( + crate::v1_compiler_coercion::type_reference_decl_file(exp.clone()), + ); + match (*crate::std_literal_elaboration::elaborate_literal_at(literal_homomorphism_rows(), kind.clone(), destination.clone(), natively.clone())).clone() { + LiteralElaborationOutcome::DirectLiteral => Rc::new(LiteralBoundary::LiteralBoundaryPlain), + LiteralElaborationOutcome::ViaHomomorphism { homomorphism: h, .. } => Rc::new(LiteralBoundary::LiteralBoundaryElaborated { + elaboration: Rc::new(LiteralElaboration { + source_kind: kind.clone(), + destination: destination.clone(), + homomorphism: h.clone(), +}), + destination_type: exp.clone(), +}), + LiteralElaborationOutcome::LiteralElaborationRefused { cause: c, .. } => Rc::new(LiteralBoundary::LiteralBoundaryRefused { + message: crate::std_literal_elaboration::literal_elaboration_refusal_message(c.clone()), +}), +} + } + } + } + } + } +} + +pub fn elaborated_span(name: String) -> Rc { + Rc::new(SourceSpan { + file: "".to_string(), + start: 0, + end: v1_rt::string_length(&name), + }) +} + +pub fn elaborated_expr_node( + name: String, + expr_data: Rc, + children: Rc>>, + destination_type: Rc, + span: Rc, +) -> Rc { + Rc::new(Node { + occurrence_identity: Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), + name: name.clone(), + span: span.clone(), + ident_span: Some(elaborated_span(name.clone())), + children: children.clone(), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: Some(Rc::new(InferredNode::Resolved { + node: destination_type.clone(), + })), + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: None, + transport: None, + properties: Rc::new(vec![]), + type_annotation: None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: None, + expr_data: expr_data.clone(), + ident: None, + }) +} + +pub fn unfold_peano_image( + n: i64, + zero: String, + succ: String, + prev_field: String, + parent: String, + destination_type: Rc, + span: Rc, +) -> Rc { + stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { + if (n.clone() <= 0) { + elaborated_expr_node( + zero.clone(), + Rc::new(ExprData::ExprVar { + binding_kind: Some(Rc::new(VarBindingKind::VariantValueBinding { + parent_enum: parent.clone(), + })), + }), + Rc::new(vec![]), + destination_type.clone(), + span.clone(), + ) + } else { + { + let prev = unfold_peano_image( + (n.clone() - 1), + zero.clone(), + succ.clone(), + prev_field.clone(), + parent.clone(), + destination_type.clone(), + span.clone(), + ); + let field = crate::v1_std_core::make_field_init_node( + Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), + prev_field.clone(), + prev.clone(), + span.clone(), + elaborated_span(prev_field.clone()), + ); + elaborated_expr_node( + succ.clone(), + Rc::new(ExprData::ExprRecordLit { + parent_enum: Some(parent.clone()), + }), + Rc::new(vec![field.clone()]), + destination_type.clone(), + span.clone(), + ) + } + } + }) +} + +pub fn unfold_literal_image( + lit: Rc, + elaboration: Rc, + destination_type: Rc, + span: Rc, +) -> Rc { + match (*elaboration.homomorphism.clone().producer.clone()).clone() { + LiteralUnfolding::PeanoUnfold { zero, succ, prev_field, .. } => match (*lit.clone()).clone() { + LiteralValue::LitInt { value: n, .. } => unfold_peano_image(n.clone(), zero.decl_name.clone(), succ.decl_name.clone(), prev_field.clone(), elaboration.destination.clone().decl_name.clone(), destination_type.clone(), span.clone()), + _ => crate::v1_std_core::make_expr_error_node(Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), ExprErrorKind::InternalExprError, "literal elaboration: a Peano unfolding row was selected for a non-integer literal (gunbc.structural_realization_bindings keys the row on KernelIntLiteral, so this row is malformed)".to_string(), span.clone()), +}, + LiteralUnfolding::BooleanUnfold { true_variant: t, false_variant: f, .. } => match (*lit.clone()).clone() { + LiteralValue::LitBool { value: b, .. } => elaborated_expr_node(if b.clone() { + t.decl_name.clone() + } else { + f.decl_name.clone() + }, Rc::new(ExprData::ExprVar { + binding_kind: Some(Rc::new(VarBindingKind::VariantValueBinding { + parent_enum: elaboration.destination.clone().decl_name.clone(), +})), +}), Rc::new(vec![]), destination_type.clone(), span.clone()), + _ => crate::v1_std_core::make_expr_error_node(Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), ExprErrorKind::InternalExprError, "literal elaboration: a Boolean unfolding row was selected for a non-boolean literal (gunbc.structural_realization_bindings keys the row on KernelBoolLiteral, so this row is malformed)".to_string(), span.clone()), +}, +} +} + +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct BinopOperands { + pub left: Rc, + pub right: Rc, +} + +pub fn infer_operand_literal( + lit_expr: Rc, + other: Rc, + scope: Rc, +) -> Rc { + { + let other_type = match other.inferred.clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: rt, .. }) => Some(rt.clone()), + _ => None, + }; + infer_expr_body(lit_expr.clone(), scope.clone(), other_type.clone()) + } +} + +pub fn infer_binop_operands( + left_expr: Rc, + right_expr: Rc, + scope: Rc, +) -> Rc { + { + let left_is_literal = expr_is_any_literal(left_expr.clone()); + let right_is_literal = expr_is_any_literal(right_expr.clone()); + if (right_is_literal.clone() && !left_is_literal.clone()) { + { + let l = infer_expr(left_expr.clone(), scope.clone(), None); + Rc::new(BinopOperands { + left: l.clone(), + right: infer_operand_literal( + right_expr.clone(), + l.typed.clone(), + scope.clone(), + ), + }) + } + } else { + if (left_is_literal.clone() && !right_is_literal.clone()) { + { + let r = infer_expr(right_expr.clone(), scope.clone(), None); + Rc::new(BinopOperands { + left: infer_operand_literal( + left_expr.clone(), + r.typed.clone(), + scope.clone(), + ), + right: r.clone(), + }) + } + } else { + Rc::new(BinopOperands { + left: infer_expr(left_expr.clone(), scope.clone(), None), + right: infer_expr(right_expr.clone(), scope.clone(), None), + }) + } + } + } +} + pub fn infer_expr_body( texpr: Rc, scope: Rc, @@ -7780,7 +8035,7 @@ pub fn infer_expr_body( match (*texpr.expr_data.clone()).clone() { ExprData::ExprLiteral { value: lit, .. } => { let span = texpr.span.clone(); - ok_infer(crate::v1_std_core::make_expr_node( + let plain = crate::v1_std_core::make_expr_node( texpr.occurrence_identity.clone(), Rc::new(ExprData::ExprLiteral { value: lit.clone() }), Rc::new(vec![]), @@ -7788,8 +8043,43 @@ pub fn infer_expr_body( node: crate::v1_compiler_infer_types::infer_literal_node(lit.clone()), })), span.clone(), - )) + ); + match (*literal_boundary_elaboration(lit.clone(), expected.clone(), scope.clone())) + .clone() + { + LiteralBoundary::LiteralBoundaryPlain => ok_infer(plain.clone()), + LiteralBoundary::LiteralBoundaryElaborated { + elaboration: e, + destination_type: dt, + .. + } => ok_infer(crate::v1_std_core::make_expr_node( + texpr.occurrence_identity.clone(), + Rc::new(ExprData::ExprElaboratedLiteral { + value: lit.clone(), + elaboration: e.clone(), + }), + Rc::new(vec![unfold_literal_image( + lit.clone(), + e.clone(), + dt.clone(), + span.clone(), + )]), + Some(Rc::new(InferredNode::Resolved { node: dt.clone() })), + span.clone(), + )), + LiteralBoundary::LiteralBoundaryRefused { message: m, .. } => { + Rc::new(InferResult { + typed: plain.clone(), + diagnostics: Rc::new(vec![inference_error( + m.clone(), + span.clone(), + scope.module_name.clone(), + )]), + }) + } + } } + ExprData::ExprElaboratedLiteral { .. } => ok_infer(texpr.clone()), ExprData::ExprError { kind, message, .. } => { let span = texpr.span.clone(); let diagnostics = match kind.clone() { @@ -9767,10 +10057,12 @@ crate::v1_compiler_infer_types::resolve_type_variables_from_template(t.clone(), let span = texpr.span.clone(); let left_expr = crate::v1_std_core::binop_left(texpr.clone()); let right_expr = crate::v1_std_core::binop_right(texpr.clone()); - let left_result = infer_expr(left_expr.clone(), scope.clone(), None); + let operands = + infer_binop_operands(left_expr.clone(), right_expr.clone(), scope.clone()); + let left_result = operands.left.clone(); let left_typed = left_result.typed.clone(); let left_diags = left_result.diagnostics.clone(); - let right_result = infer_expr(right_expr.clone(), scope.clone(), None); + let right_result = operands.right.clone(); let right_typed = right_result.typed.clone(); let right_diags = right_result.diagnostics.clone(); let binop_info = crate::v1_compiler_infer_types::infer_binop_type_node( diff --git a/src/v1/stage0/src/v1_compiler_infer_env.rs b/src/v1/stage0/src/v1_compiler_infer_env.rs index b2631f3e350..5c2b8912579 100644 --- a/src/v1/stage0/src/v1_compiler_infer_env.rs +++ b/src/v1/stage0/src/v1_compiler_infer_env.rs @@ -3,6 +3,8 @@ use self::GlobalBareLookupState::*; pub use crate::std_algebra::FreeMonoid; +pub use crate::std_decl_ref::decl_ref; +pub use crate::std_decl_ref::DeclarationRef; use crate::std_induction::RecursionShape::{ DirectRecursion, ListRecursion, MapValueRecursion, OptionalRecursion, SetRecursion, }; @@ -27,11 +29,11 @@ use crate::v1_std_core::Cardinality::*; use crate::v1_std_core::CompilerDiagnostic::{AmbiguousReference, UnresolvedType}; use crate::v1_std_core::Connective::*; use crate::v1_std_core::ExprData::*; -use crate::v1_std_core::InferredNode::*; +use crate::v1_std_core::InferredNode::Resolved; pub use crate::v1_std_core::{ authored_name_at, empty_intern_table, find_child_named, intern, intern_find, intern_str, kernel_span, merge_intern_tables, module_path_segments, param_node_name_at, - param_node_type_expr, source_text_at, + param_node_type_expr, qualified_last_segment, source_text_at, }; pub use crate::v1_std_core::{ Cardinality, CompilerDiagnostic, Connective, ExprData, InferredNode, InternTable, NewlineIndex, @@ -2220,3 +2222,73 @@ pub fn env_with_type_variable_bindings(env: Rc, tp_names: Rc, sp: Rc) -> bool { + match binding.resolved.clone().ident_span.clone() { + Some(s) => ((s.file.clone() == sp.file.clone()) && (s.start.clone() == sp.start.clone())), + None => false, + } +} + +pub fn type_reference_declaration_ref( + n: Rc, + source_indices: Rc>>, + env: Rc, +) -> Option> { + { + let rt = match n.inferred.clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: r, .. }) => r.clone(), + _ => n.clone(), + }; + let decl_name = crate::v1_std_core::qualified_last_segment( + crate::v1_std_core::authored_name_at(source_indices.clone(), rt.clone()), + ); + if (decl_name.clone() == "".to_string()) { + return None; + } + match rt.ident_span.clone() { + None => None, + Some(sp) => match v1_rt::map_get( + &env.symbol_index.clone().global_bare.clone(), + decl_name.clone(), + ) + .as_deref() + .cloned() + { + Some(GlobalBareLookupState::GlobalBareUniqueBinding { + module_path: mp, + binding: b, + .. + }) => { + if binding_declares_span(b.clone(), sp.clone()) { + Some(crate::std_decl_ref::decl_ref(mp.clone(), decl_name.clone())) + } else { + None + } + } + Some(GlobalBareLookupState::GlobalBareAmbiguousBinding { + candidates: cands, + .. + }) => match Rc::new({ + let mut __result = Vec::new(); + for c in cands.iter().cloned() { + if binding_declares_span(c.binding.clone(), sp.clone()) { + __result.push(c); + } + } + __result + }) + .first() + .cloned() + { + Some(c) => Some(crate::std_decl_ref::decl_ref( + c.module_path.clone(), + decl_name.clone(), + )), + None => None, + }, + None => None, + }, + } + } +} diff --git a/src/v1/stage0/src/v1_compiler_infer_resolve.rs b/src/v1/stage0/src/v1_compiler_infer_resolve.rs index 2e74db9a3e1..d684198f677 100644 --- a/src/v1/stage0/src/v1_compiler_infer_resolve.rs +++ b/src/v1/stage0/src/v1_compiler_infer_resolve.rs @@ -29,9 +29,10 @@ use crate::v1_std_core::CompilerDiagnostic::{ }; use crate::v1_std_core::Connective::{Arrow, Conj, Disj, NoConnective}; use crate::v1_std_core::ExprData::{ - ExprBinOp, ExprBlock, ExprCall, ExprCast, ExprError, ExprFieldAccess, ExprForEach, ExprIf, - ExprIndex, ExprLambda, ExprLet, ExprListLit, ExprLiteral, ExprMatch, ExprMethodCall, - ExprRecordLit, ExprReturn, ExprSlice, ExprStringInterp, ExprUnaryOp, ExprVar, NoExprData, + ExprBinOp, ExprBlock, ExprCall, ExprCast, ExprElaboratedLiteral, ExprError, ExprFieldAccess, + ExprForEach, ExprIf, ExprIndex, ExprLambda, ExprLet, ExprListLit, ExprLiteral, ExprMatch, + ExprMethodCall, ExprRecordLit, ExprReturn, ExprSlice, ExprStringInterp, ExprUnaryOp, ExprVar, + NoExprData, }; use crate::v1_std_core::ExprErrorKind::SemanticExprError; use crate::v1_std_core::InferredNode::{CompilerError, Resolved, TypeVariable}; @@ -2401,6 +2402,10 @@ pub fn resolve_expr_types( expr: texpr.clone(), diagnostics: Rc::new(vec![]), }), + ExprData::ExprElaboratedLiteral { .. } => Rc::new(ExprResolveResult { + expr: texpr.clone(), + diagnostics: Rc::new(vec![]), + }), ExprData::ExprError { kind, message, .. } => Rc::new(ExprResolveResult { expr: crate::v1_std_core::make_expr_error_node( Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), diff --git a/src/v1/stage0/src/v1_compiler_ownership.rs b/src/v1/stage0/src/v1_compiler_ownership.rs index dc89ef04d1f..40115b72501 100644 --- a/src/v1/stage0/src/v1_compiler_ownership.rs +++ b/src/v1/stage0/src/v1_compiler_ownership.rs @@ -8,8 +8,9 @@ use crate::v1_rt; use crate::v1_rt::{VecCompat, VecJoin}; use crate::v1_std_core::Cardinality::Required; use crate::v1_std_core::ExprData::{ - ExprBlock, ExprCall, ExprError, ExprFieldAccess, ExprForEach, ExprIf, ExprLambda, ExprLet, - ExprLiteral, ExprMatch, ExprMethodCall, ExprRecordLit, ExprReturn, ExprVar, NoExprData, + ExprBlock, ExprCall, ExprElaboratedLiteral, ExprError, ExprFieldAccess, ExprForEach, ExprIf, + ExprLambda, ExprLet, ExprLiteral, ExprMatch, ExprMethodCall, ExprRecordLit, ExprReturn, + ExprVar, NoExprData, }; use crate::v1_std_core::InferredNode::Resolved; use crate::v1_std_core::VarBindingKind::{FunctionValueBinding, LocalValueBinding}; @@ -309,6 +310,7 @@ pub fn walk_expr( } } ExprData::ExprLiteral { value: _, .. } => accum.clone(), + ExprData::ExprElaboratedLiteral { .. } => accum.clone(), ExprData::ExprFieldAccess { .. } => { let base_node = crate::v1_std_core::field_access_base(texpr.clone()); match (*base_node.expr_data.clone()).clone() { @@ -854,6 +856,7 @@ pub fn collect_callable_refs( _ => v1_rt::rc_empty_set::(), }, ExprData::ExprLiteral { value: _, .. } => v1_rt::rc_empty_set::(), + ExprData::ExprElaboratedLiteral { .. } => v1_rt::rc_empty_set::(), ExprData::ExprFieldAccess { .. } => collect_callable_refs( crate::v1_std_core::field_access_base(texpr.clone()), si.clone(), diff --git a/src/v1/stage0/src/v1_std_core.rs b/src/v1/stage0/src/v1_std_core.rs index cb83f6cf7c0..bcadba6cb09 100644 --- a/src/v1/stage0/src/v1_std_core.rs +++ b/src/v1/stage0/src/v1_std_core.rs @@ -29,6 +29,7 @@ use crate::std_algebra::CostShape::*; pub use crate::std_algebra::{AlgebraFieldTemplate, CollectionSizeEffect, CostShape}; pub use crate::std_induction::SubValueRelation; use crate::std_induction::SubValueRelation::*; +pub use crate::std_literal_elaboration::LiteralElaboration; use crate::std_occurrence_identity::NodeOccurrenceIdentity::OccurrenceSynthetic; pub use crate::std_occurrence_identity::OccurrenceId; use crate::std_occurrence_identity::OccurrenceTransportRefusal::{ @@ -301,6 +302,10 @@ pub enum ExprData { ExprLiteral { value: Rc, }, + ExprElaboratedLiteral { + value: Rc, + elaboration: Rc, + }, ExprError { kind: ExprErrorKind, message: String, @@ -2887,6 +2892,10 @@ pub fn expr_literal_int_optional(expr: Rc) -> Option { LiteralValue::LitInt { value: v, .. } => Some(v.clone()), _ => None, }, + ExprData::ExprElaboratedLiteral { value: lit, .. } => match (*lit.clone()).clone() { + LiteralValue::LitInt { value: v, .. } => Some(v.clone()), + _ => None, + }, ExprData::ExprUnaryOp { op: UnaryOpKind::Neg, .. @@ -2930,6 +2939,9 @@ pub fn expr_is_any_literal(mut expr: Rc) -> bool { break true; } }, + ExprData::ExprElaboratedLiteral { .. } => { + break true; + } ExprData::ExprUnaryOp { op: UnaryOpKind::Neg, .. @@ -3397,6 +3409,7 @@ pub fn expr_has_non_tail_self_call( binding_kind: _, .. } => false, ExprData::ExprLiteral { value: _, .. } => false, + ExprData::ExprElaboratedLiteral { .. } => false, ExprData::ExprFieldAccess { summary: _, .. } => { let mut __found = false; for child in texpr.children.clone().iter().cloned() { From 29fa01c2149751a18dd47a36e95088a13d19a3c4 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 10:39:09 +0000 Subject: [PATCH 55/75] XL-0N: register std.literal_elaboration and std.operator_realization in the std-core partition and gunbc.structural_realization_bindings in the v1-infer binding unit (v2.workflow.rust_crate_partition), with their module-dag edges Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_013koFunEtpLQCnvUiz85k7Y --- src/v2/workflow/rust_crate_partition.dag | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/v2/workflow/rust_crate_partition.dag b/src/v2/workflow/rust_crate_partition.dag index 76c24dd1f5b..9447b884128 100644 --- a/src/v2/workflow/rust_crate_partition.dag +++ b/src/v2/workflow/rust_crate_partition.dag @@ -238,6 +238,8 @@ fn stage0_std_core_modules() -> List { "std_occurrence_identity", "std_source_annotation", "std_target_representation", + "std_literal_elaboration", + "std_operator_realization", "v1_std_core" ]) } @@ -286,7 +288,7 @@ fn stage0_extdeps_modules() -> List { // the v1_compiler_* pipeline modules because the layer is a different one -- the // grouping is physical (one crate) while the name records what the module actually is. fn stage0_gunbc_binding_modules() -> List { - ["gunbc_rust_source_type_bindings"] + ["gunbc_rust_source_type_bindings", "gunbc_structural_realization_bindings"] } fn stage0_v1_infer_modules() -> List { @@ -434,6 +436,13 @@ fn stage0_cross_unit_import_edges() -> List { stage0_module_dag_edge(from: "extdeps_languages_rust_emit", to: "std_trait_derive_shape"), stage0_module_dag_edge(from: "std_source_annotation", to: "std_types"), stage0_module_dag_edge(from: "std_source_annotation", to: "std_occurrence_identity"), + stage0_module_dag_edge(from: "std_literal_elaboration", to: "std_decl_ref"), + stage0_module_dag_edge(from: "std_literal_elaboration", to: "std_syntax"), + stage0_module_dag_edge(from: "std_literal_elaboration", to: "std_types"), + stage0_module_dag_edge(from: "std_operator_realization", to: "std_decl_ref"), + stage0_module_dag_edge(from: "std_operator_realization", to: "std_syntax"), + stage0_module_dag_edge(from: "std_operator_realization", to: "std_types"), + stage0_module_dag_edge(from: "v1_std_core", to: "std_literal_elaboration"), stage0_module_dag_edge(from: "v1_std_core", to: "std_source_annotation"), stage0_module_dag_edge(from: "v1_std_core", to: "std_algebra"), stage0_module_dag_edge(from: "v1_std_core", to: "std_induction"), From e51aff94b41ab3907e46961f38b2e9581c246f51 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 10:47:47 +0000 Subject: [PATCH 56/75] XL-0N: type_reference_declaration_ref resolves an in-place (recursive) type reference through its env binding before matching the declaration span -- v2.std.nat.Nat is recursive and answered Absent, so its literal boundary and operand identity fell to the unavailable arms while v2.std.logic.Bool worked Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_013koFunEtpLQCnvUiz85k7Y --- src/v1/04_env.dag | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/v1/04_env.dag b/src/v1/04_env.dag index edb4cb01666..c2d8af4adc8 100644 --- a/src/v1/04_env.dag +++ b/src/v1/04_env.dag @@ -1238,10 +1238,21 @@ fn binding_declares_span(binding: TypeBinding, sp: SourceSpan) -> Bool { } } +// A reference the resolver leaves IN PLACE -- a recursive type such as v2.std.nat Nat, whose leaf arm +// answers `resolved: n` with no inferred node (v1.compiler.resolve resolve_node, is_recursive_type_for) +// -- still names its declaration: the env binding the resolver established for the reference's ident +// (lookup_type_for) carries the declaration's own ident_span, which is the span the global roster is +// matched on. Without this arm every recursive destination answered Absent here and fell to the +// identity-unavailable arms downstream (measured: the Peano literal and ordering rows passed for +// v2.std.logic Bool and failed for v2.std.nat Nat on the same compiler). fn type_reference_declaration_ref(n: Node, source_indices: Map, env: TypeEnv) -> DeclarationRef? { let rt = match n.inferred { Present { value: Resolved { node: r } } => r - _ => n + _ => + match lookup_type_for(env: env, node: n) { + Present { value: bound } => bound + Absent => n + } } let decl_name = qualified_last_segment(name: authored_name_at(source_indices: source_indices, node: rt)) if decl_name == "" { return none } From 155764c248f6b6b811add452b16d3ad976bbd892 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 12:10:49 +0000 Subject: [PATCH 57/75] XL-0N: regenerated stage0 mirrors at byte fixed point on e51aff9 (BuildBuddy regen round 3 first_generation_equal=true; includes the merged #9710 commit-3 null-keyword-by-path drift and the new-module mirrors) Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_013koFunEtpLQCnvUiz85k7Y --- .../src/extdeps_container_oci_digest.rs | 16 +- .../src/extdeps_languages_dag_syntax.rs | 36 +- .../stage0/src/extdeps_languages_go_syntax.rs | 26 +- .../src/extdeps_languages_python_syntax.rs | 24 +- .../stage0/src/extdeps_languages_rust_emit.rs | 2 +- .../extdeps_languages_rust_representation.rs | 4 +- .../src/extdeps_languages_rust_syntax.rs | 30 +- src/v1/stage0/src/extdeps_uri_path.rs | 4 +- .../stage0/src/gunbc_cli_dispatch_surface.rs | 30 +- src/v1/stage0/src/std_algebra.rs | 434 ++-- src/v1/stage0/src/std_checked_arithmetic.rs | 2 +- src/v1/stage0/src/std_computation.rs | 26 +- src/v1/stage0/src/std_content_hash.rs | 10 +- src/v1/stage0/src/std_induction.rs | 36 +- src/v1/stage0/src/std_integer.rs | 2 +- src/v1/stage0/src/std_keyed_roster.rs | 25 +- src/v1/stage0/src/std_keyed_row.rs | 9 +- src/v1/stage0/src/std_measure.rs | 90 +- .../src/std_occurrence_binding_candidates.rs | 56 +- .../src/std_occurrence_binding_resolve.rs | 6 +- src/v1/stage0/src/std_occurrence_identity.rs | 22 +- src/v1/stage0/src/std_operator_realization.rs | 22 +- src/v1/stage0/src/std_primitive_projection.rs | 8 +- src/v1/stage0/src/std_source_annotation.rs | 20 +- src/v1/stage0/src/std_termination.rs | 12 +- src/v1/stage0/src/std_types.rs | 2 +- .../stage0/src/v1_compiler_annotation_bind.rs | 18 +- src/v1/stage0/src/v1_compiler_coercion.rs | 28 +- src/v1/stage0/src/v1_compiler_compile.rs | 13 +- src/v1/stage0/src/v1_compiler_complexity.rs | 361 ++-- src/v1/stage0/src/v1_compiler_dag_collect.rs | 14 +- src/v1/stage0/src/v1_compiler_emit.rs | 66 +- .../src/v1_compiler_emit_core_support.rs | 33 +- src/v1/stage0/src/v1_compiler_emit_rust.rs | 1266 +++++++----- .../src/v1_compiler_frontend_observation.rs | 2 +- src/v1/stage0/src/v1_compiler_infer.rs | 1830 +++++++++++------ src/v1/stage0/src/v1_compiler_infer_access.rs | 6 +- .../stage0/src/v1_compiler_infer_emit_info.rs | 28 +- src/v1/stage0/src/v1_compiler_infer_env.rs | 50 +- src/v1/stage0/src/v1_compiler_infer_items.rs | 30 +- src/v1/stage0/src/v1_compiler_infer_lookup.rs | 97 +- src/v1/stage0/src/v1_compiler_infer_method.rs | 10 +- .../stage0/src/v1_compiler_infer_patterns.rs | 73 +- .../stage0/src/v1_compiler_infer_resolve.rs | 317 ++- .../stage0/src/v1_compiler_infer_service.rs | 36 +- src/v1/stage0/src/v1_compiler_infer_sigs.rs | 37 +- src/v1/stage0/src/v1_compiler_infer_types.rs | 324 +-- src/v1/stage0/src/v1_compiler_languages.rs | 88 +- src/v1/stage0/src/v1_compiler_ownership.rs | 10 +- src/v1/stage0/src/v1_compiler_parse.rs | 1510 +++++++------- src/v1/stage0/src/v1_compiler_resolve.rs | 2 +- src/v1/stage0/src/v1_compiler_tokenize.rs | 16 +- src/v1/stage0/src/v1_compiler_trace.rs | 2 +- .../src/v1_compiler_trait_derive_emit.rs | 44 +- ...v1_gunbc_occurrence_binding_parser_walk.rs | 8 +- src/v1/stage0/src/v1_std_core.rs | 386 ++-- ...checkpoint_identity_keying_witness_test.rs | 16 +- ...m_transport_roster_closure_witness_test.rs | 20 +- 58 files changed, 4319 insertions(+), 3376 deletions(-) diff --git a/src/v1/stage0/src/extdeps_container_oci_digest.rs b/src/v1/stage0/src/extdeps_container_oci_digest.rs index 6efcb734a5b..44c9c197588 100644 --- a/src/v1/stage0/src/extdeps_container_oci_digest.rs +++ b/src/v1/stage0/src/extdeps_container_oci_digest.rs @@ -96,7 +96,7 @@ pub fn oci_encoded_digest(text: String) -> Option { if oci_other_digest_encoded(text.clone()) { Some(text.clone()) } else { - None + std::option::Option::None } } @@ -240,7 +240,7 @@ pub fn oci_wire_digest_parts(raw: String) -> Option> { .collect::>(), ); if ((parts.clone().len() as i64) != 2) { - None + std::option::Option::None } else { Some(oci_wire_digest_parts_from_split(parts.clone().first().cloned().expect("fail-closed: an optional value flowed into non-optional parameter 0 of oci_wire_digest_parts_from_split (empty Optional at runtime)"), parts.clone().iter().cloned().skip(1 as usize).next().expect("fail-closed: an optional value flowed into non-optional parameter 1 of oci_wire_digest_parts_from_split (empty Optional at runtime)"))) } @@ -255,7 +255,7 @@ pub fn parse_oci_content_digest_wire(raw: String) -> Option Some(digest) => { Some(Rc::new(OciContentDigest::OciSha256Digest(digest.clone()))) } - None => None, + None => std::option::Option::None, } } else { if (parts.algorithm.clone() == "sha512".to_string()) { @@ -263,11 +263,11 @@ pub fn parse_oci_content_digest_wire(raw: String) -> Option Some(digest) => { Some(Rc::new(OciContentDigest::OciSha512Digest(digest.clone()))) } - None => None, + None => std::option::Option::None, } } else { if !oci_other_digest_algorithm(parts.algorithm.clone()) { - None + std::option::Option::None } else { match oci_encoded_digest(parts.encoded.clone()) { Some(encoded) => Some(Rc::new(OciContentDigest::OciOtherDigest( @@ -276,20 +276,20 @@ pub fn parse_oci_content_digest_wire(raw: String) -> Option encoded: encoded.clone(), }), ))), - None => None, + None => std::option::Option::None, } } } } } - None => None, + None => std::option::Option::None, } } pub fn oci_sha256_content_digest(hex: String) -> Option> { match crate::std_content_hash::sha256_hex_digest(hex.clone()) { Some(digest) => Some(oci_content_digest_from_validated_sha256(digest.clone())), - None => None, + None => std::option::Option::None, } } diff --git a/src/v1/stage0/src/extdeps_languages_dag_syntax.rs b/src/v1/stage0/src/extdeps_languages_dag_syntax.rs index 0f40790c7eb..333daa8f836 100644 --- a/src/v1/stage0/src/extdeps_languages_dag_syntax.rs +++ b/src/v1/stage0/src/extdeps_languages_dag_syntax.rs @@ -216,97 +216,97 @@ pub fn dag_operators() -> Rc>> { left_bp: 5, right_bp: 6, binop: Some(BinOp::Or), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "&&".to_string(), left_bp: 7, right_bp: 8, binop: Some(BinOp::And), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "??".to_string(), left_bp: 8, right_bp: 9, binop: Some(BinOp::NullCoalesce), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "==".to_string(), left_bp: 9, right_bp: 10, binop: Some(BinOp::Eq), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "!=".to_string(), left_bp: 9, right_bp: 10, binop: Some(BinOp::Ne), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "<".to_string(), left_bp: 11, right_bp: 12, binop: Some(BinOp::Lt), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: ">".to_string(), left_bp: 11, right_bp: 12, binop: Some(BinOp::Gt), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "<=".to_string(), left_bp: 11, right_bp: 12, binop: Some(BinOp::Le), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: ">=".to_string(), left_bp: 11, right_bp: 12, binop: Some(BinOp::Ge), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "+".to_string(), left_bp: 13, right_bp: 14, binop: Some(BinOp::Add), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "-".to_string(), left_bp: 13, right_bp: 14, binop: Some(BinOp::Sub), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "*".to_string(), left_bp: 15, right_bp: 16, binop: Some(BinOp::Mul), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "/".to_string(), left_bp: 15, right_bp: 16, binop: Some(BinOp::Div), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "%".to_string(), left_bp: 15, right_bp: 16, binop: Some(BinOp::Mod), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "|>".to_string(), left_bp: 17, right_bp: 18, - binop: None, - algebra_field: None, + binop: std::option::Option::None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: ".".to_string(), left_bp: 19, right_bp: 20, - binop: None, - algebra_field: None, + binop: std::option::Option::None, + algebra_field: std::option::Option::None, })]) }; } diff --git a/src/v1/stage0/src/extdeps_languages_go_syntax.rs b/src/v1/stage0/src/extdeps_languages_go_syntax.rs index e04e2673d44..8a827271b3f 100644 --- a/src/v1/stage0/src/extdeps_languages_go_syntax.rs +++ b/src/v1/stage0/src/extdeps_languages_go_syntax.rs @@ -95,79 +95,79 @@ pub fn go_operators() -> Rc>> { left_bp: 5, right_bp: 6, binop: Some(BinOp::Or), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "&&".to_string(), left_bp: 7, right_bp: 8, binop: Some(BinOp::And), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "==".to_string(), left_bp: 9, right_bp: 10, binop: Some(BinOp::Eq), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "!=".to_string(), left_bp: 9, right_bp: 10, binop: Some(BinOp::Ne), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "<".to_string(), left_bp: 11, right_bp: 12, binop: Some(BinOp::Lt), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: ">".to_string(), left_bp: 11, right_bp: 12, binop: Some(BinOp::Gt), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "<=".to_string(), left_bp: 11, right_bp: 12, binop: Some(BinOp::Le), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: ">=".to_string(), left_bp: 11, right_bp: 12, binop: Some(BinOp::Ge), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "+".to_string(), left_bp: 13, right_bp: 14, binop: Some(BinOp::Add), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "-".to_string(), left_bp: 13, right_bp: 14, binop: Some(BinOp::Sub), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "*".to_string(), left_bp: 15, right_bp: 16, binop: Some(BinOp::Mul), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "/".to_string(), left_bp: 15, right_bp: 16, binop: Some(BinOp::Div), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "%".to_string(), left_bp: 15, right_bp: 16, binop: Some(BinOp::Mod), - algebra_field: None, + algebra_field: std::option::Option::None, })]) }; } diff --git a/src/v1/stage0/src/extdeps_languages_python_syntax.rs b/src/v1/stage0/src/extdeps_languages_python_syntax.rs index 24cb732d945..996651b34eb 100644 --- a/src/v1/stage0/src/extdeps_languages_python_syntax.rs +++ b/src/v1/stage0/src/extdeps_languages_python_syntax.rs @@ -98,67 +98,67 @@ pub fn python_operators() -> Rc>> { left_bp: 5, right_bp: 6, binop: Some(BinOp::Or), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "and".to_string(), left_bp: 7, right_bp: 8, binop: Some(BinOp::And), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "==".to_string(), left_bp: 9, right_bp: 10, binop: Some(BinOp::Eq), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "!=".to_string(), left_bp: 9, right_bp: 10, binop: Some(BinOp::Ne), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "<".to_string(), left_bp: 11, right_bp: 12, binop: Some(BinOp::Lt), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: ">".to_string(), left_bp: 11, right_bp: 12, binop: Some(BinOp::Gt), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "<=".to_string(), left_bp: 11, right_bp: 12, binop: Some(BinOp::Le), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: ">=".to_string(), left_bp: 11, right_bp: 12, binop: Some(BinOp::Ge), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "+".to_string(), left_bp: 13, right_bp: 14, binop: Some(BinOp::Add), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "-".to_string(), left_bp: 13, right_bp: 14, binop: Some(BinOp::Sub), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "*".to_string(), left_bp: 15, right_bp: 16, binop: Some(BinOp::Mul), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "/".to_string(), left_bp: 15, @@ -176,7 +176,7 @@ pub fn python_operators() -> Rc>> { left_bp: 15, right_bp: 16, binop: Some(BinOp::Mod), - algebra_field: None, + algebra_field: std::option::Option::None, })]) }; } diff --git a/src/v1/stage0/src/extdeps_languages_rust_emit.rs b/src/v1/stage0/src/extdeps_languages_rust_emit.rs index aec272b370f..31ffd45960d 100644 --- a/src/v1/stage0/src/extdeps_languages_rust_emit.rs +++ b/src/v1/stage0/src/extdeps_languages_rust_emit.rs @@ -57,7 +57,7 @@ pub fn rust_keywords() -> Rc> { let mut __m = HashMap::new(); __m.insert("true".to_string(), "true".to_string()); __m.insert("false".to_string(), "false".to_string()); - __m.insert("null".to_string(), "None".to_string()); + __m.insert("null".to_string(), "std::option::Option::None".to_string()); __m.insert("and".to_string(), "&&".to_string()); __m.insert("or".to_string(), "||".to_string()); __m.insert("not".to_string(), "!".to_string()); diff --git a/src/v1/stage0/src/extdeps_languages_rust_representation.rs b/src/v1/stage0/src/extdeps_languages_rust_representation.rs index d9a1f710e5d..4afd623e027 100644 --- a/src/v1/stage0/src/extdeps_languages_rust_representation.rs +++ b/src/v1/stage0/src/extdeps_languages_rust_representation.rs @@ -96,7 +96,7 @@ pub fn rust_realization( pub fn rust_representation_realizations() -> Rc>> { thread_local! { static CACHED: Rc>> = { - Rc::new(vec![rust_realization(RustRepresentation::RustStdString, "std::string::String".to_string(), "std::string::String".to_string(), Some("std::string::String::new()".to_string()), false, Some(".to_string()".to_string())), rust_realization(RustRepresentation::RustI64, "i64".to_string(), "i64".to_string(), Some("0".to_string()), true, None), rust_realization(RustRepresentation::RustF64, "f64".to_string(), "f64".to_string(), Some("0.0".to_string()), true, None), rust_realization(RustRepresentation::RustBool, "bool".to_string(), "bool".to_string(), Some("false".to_string()), true, None), rust_realization(RustRepresentation::RustUnit, "()".to_string(), "()".to_string(), Some("()".to_string()), true, None), rust_realization(RustRepresentation::RustVecU8, "std::vec::Vec".to_string(), "std::vec::Vec".to_string(), Some("std::vec::Vec::new()".to_string()), false, None), rust_realization(RustRepresentation::RustSerdeJsonValue, "serde_json::Value".to_string(), "serde_json::Value".to_string(), Some("serde_json::Value::Null".to_string()), false, None)]) + Rc::new(vec![rust_realization(RustRepresentation::RustStdString, "std::string::String".to_string(), "std::string::String".to_string(), Some("std::string::String::new()".to_string()), false, Some(".to_string()".to_string())), rust_realization(RustRepresentation::RustI64, "i64".to_string(), "i64".to_string(), Some("0".to_string()), true, std::option::Option::None), rust_realization(RustRepresentation::RustF64, "f64".to_string(), "f64".to_string(), Some("0.0".to_string()), true, std::option::Option::None), rust_realization(RustRepresentation::RustBool, "bool".to_string(), "bool".to_string(), Some("false".to_string()), true, std::option::Option::None), rust_realization(RustRepresentation::RustUnit, "()".to_string(), "()".to_string(), Some("()".to_string()), true, std::option::Option::None), rust_realization(RustRepresentation::RustVecU8, "std::vec::Vec".to_string(), "std::vec::Vec".to_string(), Some("std::vec::Vec::new()".to_string()), false, std::option::Option::None), rust_realization(RustRepresentation::RustSerdeJsonValue, "serde_json::Value".to_string(), "serde_json::Value".to_string(), Some("serde_json::Value::Null".to_string()), false, std::option::Option::None)]) }; } CACHED.with(|c: &Rc>>| c.clone()) @@ -133,7 +133,7 @@ pub fn rust_exact_type_checkpoint( is_copy: Some(r.is_copy.clone()), literal_suffix: r.literal_suffix.clone(), })), - None => None, + None => std::option::Option::None, } } diff --git a/src/v1/stage0/src/extdeps_languages_rust_syntax.rs b/src/v1/stage0/src/extdeps_languages_rust_syntax.rs index 7db1741a986..9dfd9dc7e86 100644 --- a/src/v1/stage0/src/extdeps_languages_rust_syntax.rs +++ b/src/v1/stage0/src/extdeps_languages_rust_syntax.rs @@ -195,85 +195,85 @@ pub fn rust_operators() -> Rc>> { left_bp: 5, right_bp: 6, binop: Some(BinOp::Or), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "&&".to_string(), left_bp: 7, right_bp: 8, binop: Some(BinOp::And), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "==".to_string(), left_bp: 9, right_bp: 10, binop: Some(BinOp::Eq), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "!=".to_string(), left_bp: 9, right_bp: 10, binop: Some(BinOp::Ne), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "<".to_string(), left_bp: 11, right_bp: 12, binop: Some(BinOp::Lt), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: ">".to_string(), left_bp: 11, right_bp: 12, binop: Some(BinOp::Gt), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "<=".to_string(), left_bp: 11, right_bp: 12, binop: Some(BinOp::Le), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: ">=".to_string(), left_bp: 11, right_bp: 12, binop: Some(BinOp::Ge), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "+".to_string(), left_bp: 13, right_bp: 14, binop: Some(BinOp::Add), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "-".to_string(), left_bp: 13, right_bp: 14, binop: Some(BinOp::Sub), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "*".to_string(), left_bp: 15, right_bp: 16, binop: Some(BinOp::Mul), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "/".to_string(), left_bp: 15, right_bp: 16, binop: Some(BinOp::Div), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: "%".to_string(), left_bp: 15, right_bp: 16, binop: Some(BinOp::Mod), - algebra_field: None, + algebra_field: std::option::Option::None, }), Rc::new(OperatorSpec { symbol: ".".to_string(), left_bp: 19, right_bp: 20, - binop: None, - algebra_field: None, + binop: std::option::Option::None, + algebra_field: std::option::Option::None, })]) }; } diff --git a/src/v1/stage0/src/extdeps_uri_path.rs b/src/v1/stage0/src/extdeps_uri_path.rs index 2a4704a3c6c..38b51d57186 100644 --- a/src/v1/stage0/src/extdeps_uri_path.rs +++ b/src/v1/stage0/src/extdeps_uri_path.rs @@ -74,9 +74,9 @@ pub fn last_path_param(template: Rc) -> Option { match params.clone().last().cloned() { Some(tok) => match (*tok.clone()).clone() { UrlPathToken::ParamToken { name: n, .. } => Some(n.clone()), - UrlPathToken::LiteralToken { .. } => None, + UrlPathToken::LiteralToken { .. } => std::option::Option::None, }, - None => None, + None => std::option::Option::None, } } } diff --git a/src/v1/stage0/src/gunbc_cli_dispatch_surface.rs b/src/v1/stage0/src/gunbc_cli_dispatch_surface.rs index f1349a0925d..a058d2977a3 100644 --- a/src/v1/stage0/src/gunbc_cli_dispatch_surface.rs +++ b/src/v1/stage0/src/gunbc_cli_dispatch_surface.rs @@ -179,7 +179,7 @@ pub fn gunbc_cli_subcommands() -> Rc>> { field: "source_roots".to_string(), long: "source-root".to_string(), value: Rc::new(CliOptionValue::CliTextValue { - text_default: None, + text_default: std::option::Option::None, }), arity: CliOptionArity::CliRepeated, doc: Rc::new(vec!["Source root directories (searched recursively for .dag files).".to_string(), "Module imports are resolved transitively from these roots.".to_string()]), @@ -188,7 +188,7 @@ pub fn gunbc_cli_subcommands() -> Rc>> { field: "source_dir".to_string(), long: "source-dir".to_string(), value: Rc::new(CliOptionValue::CliTextValue { - text_default: None, + text_default: std::option::Option::None, }), arity: CliOptionArity::CliAtMostOne, doc: Rc::new(vec!["Legacy: single source directory (all .dag files loaded, no import resolution)".to_string()]), @@ -197,7 +197,7 @@ pub fn gunbc_cli_subcommands() -> Rc>> { field: "output_dir".to_string(), long: "output-dir".to_string(), value: Rc::new(CliOptionValue::CliTextValue { - text_default: None, + text_default: std::option::Option::None, }), arity: CliOptionArity::CliRequired, doc: Rc::new(vec![]), @@ -224,7 +224,7 @@ pub fn gunbc_cli_subcommands() -> Rc>> { field: "entry".to_string(), long: "entry".to_string(), value: Rc::new(CliOptionValue::CliTextValue { - text_default: None, + text_default: std::option::Option::None, }), arity: CliOptionArity::CliAtMostOne, doc: Rc::new(vec!["Entry `.dag` file: compile only this module and its transitive imports".to_string(), "(not every `.dag` file under the first --source-root). Scopes the compile".to_string(), "to a subtree so a small closure can be emitted without a whole-tree pass.".to_string()]), @@ -241,7 +241,7 @@ pub fn gunbc_cli_subcommands() -> Rc>> { field: "source_roots".to_string(), long: "source-root".to_string(), value: Rc::new(CliOptionValue::CliTextValue { - text_default: None, + text_default: std::option::Option::None, }), arity: CliOptionArity::CliRepeated, doc: Rc::new(vec!["Source root directories (searched recursively for .dag files)".to_string()]), @@ -259,7 +259,7 @@ pub fn gunbc_cli_subcommands() -> Rc>> { field: "entry".to_string(), long: "entry".to_string(), value: Rc::new(CliOptionValue::CliTextValue { - text_default: None, + text_default: std::option::Option::None, }), arity: CliOptionArity::CliAtMostOne, doc: Rc::new(vec!["Entry `.dag` file: load only this module and its transitive imports".to_string(), "(not every file under --source-root). Required for scoped TestClaim runs.".to_string()]), @@ -275,7 +275,7 @@ pub fn gunbc_cli_subcommands() -> Rc>> { field: "args".to_string(), long: "arg".to_string(), value: Rc::new(CliOptionValue::CliTextValue { - text_default: None, + text_default: std::option::Option::None, }), arity: CliOptionArity::CliRepeated, doc: Rc::new(vec!["Named argument for the entry function, repeatable: `--arg name=value`.".to_string(), "Values enter as String; a missing `=` refuses rather than guessing.".to_string()]), @@ -294,7 +294,7 @@ pub fn gunbc_cli_subcommands() -> Rc>> { field: "host".to_string(), long: "host".to_string(), value: Rc::new(CliOptionValue::CliTextValue { - text_default: None, + text_default: std::option::Option::None, }), arity: CliOptionArity::CliRequired, doc: Rc::new(vec!["Fleet host identity (e.g. \"srv1\") to converge".to_string()]), @@ -320,7 +320,7 @@ pub fn gunbc_cli_subcommands() -> Rc>> { field: "path".to_string(), long: "path".to_string(), value: Rc::new(CliOptionValue::CliTextValue { - text_default: None, + text_default: std::option::Option::None, }), arity: CliOptionArity::CliRequired, doc: Rc::new(vec!["Path to the repository document to read".to_string()]), @@ -339,7 +339,7 @@ pub fn gunbc_cli_subcommands() -> Rc>> { field: "source_roots".to_string(), long: "source-root".to_string(), value: Rc::new(CliOptionValue::CliTextValue { - text_default: None, + text_default: std::option::Option::None, }), arity: CliOptionArity::CliRepeated, doc: Rc::new(vec!["Source root directories (searched recursively for .dag files)".to_string()]), @@ -348,7 +348,7 @@ pub fn gunbc_cli_subcommands() -> Rc>> { field: "entry".to_string(), long: "entry".to_string(), value: Rc::new(CliOptionValue::CliTextValue { - text_default: None, + text_default: std::option::Option::None, }), arity: CliOptionArity::CliRequired, doc: Rc::new(vec!["Entry `.dag` file: load only this module and its transitive imports".to_string()]), @@ -357,7 +357,7 @@ pub fn gunbc_cli_subcommands() -> Rc>> { field: "function".to_string(), long: "function".to_string(), value: Rc::new(CliOptionValue::CliTextValue { - text_default: None, + text_default: std::option::Option::None, }), arity: CliOptionArity::CliRequired, doc: Rc::new(vec!["Handler function: fn(method: String, path: String, body: String) -> ServeWireResponse".to_string()]), @@ -384,7 +384,7 @@ pub fn gunbc_cli_subcommands() -> Rc>> { field: "release_revision".to_string(), long: "release-revision".to_string(), value: Rc::new(CliOptionValue::CliTextValue { - text_default: None, + text_default: std::option::Option::None, }), arity: CliOptionArity::CliRequired, doc: Rc::new(vec!["Release revision this process serves, bound ONCE at startup and".to_string(), "immutable for the process lifetime.".to_string()]), @@ -393,7 +393,7 @@ pub fn gunbc_cli_subcommands() -> Rc>> { field: "eval_budget_cpu_ms".to_string(), long: "eval-budget-cpu-ms".to_string(), value: Rc::new(CliOptionValue::CliMillisecondValue { - millisecond_default: None, + millisecond_default: std::option::Option::None, }), arity: CliOptionArity::CliAtMostOne, doc: Rc::new(vec!["Per-request THREAD-CPU evaluation budget in milliseconds.".to_string()]), @@ -402,7 +402,7 @@ pub fn gunbc_cli_subcommands() -> Rc>> { field: "eval_budget_wall_ms".to_string(), long: "eval-budget-wall-ms".to_string(), value: Rc::new(CliOptionValue::CliMillisecondValue { - millisecond_default: None, + millisecond_default: std::option::Option::None, }), arity: CliOptionArity::CliAtMostOne, doc: Rc::new(vec!["Per-request MONOTONIC-WALL evaluation budget in milliseconds.".to_string()]), diff --git a/src/v1/stage0/src/std_algebra.rs b/src/v1/stage0/src/std_algebra.rs index a2b8c0e1f4c..f76efa9f18f 100644 --- a/src/v1/stage0/src/std_algebra.rs +++ b/src/v1/stage0/src/std_algebra.rs @@ -822,25 +822,25 @@ pub fn ordered_ring_templates() -> Rc>> { Rc::new(AlgebraTypeTemplate::ReceiverSelf), ]), return_type: Rc::new(AlgebraTypeTemplate::ReceiverSelf), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "zero".to_string(), param_types: Rc::new(vec![]), return_type: Rc::new(AlgebraTypeTemplate::ReceiverSelf), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "negate".to_string(), param_types: Rc::new(vec![Rc::new(AlgebraTypeTemplate::ReceiverSelf)]), return_type: Rc::new(AlgebraTypeTemplate::ReceiverSelf), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "mul".to_string(), @@ -849,17 +849,17 @@ pub fn ordered_ring_templates() -> Rc>> { Rc::new(AlgebraTypeTemplate::ReceiverSelf), ]), return_type: Rc::new(AlgebraTypeTemplate::ReceiverSelf), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "one".to_string(), param_types: Rc::new(vec![]), return_type: Rc::new(AlgebraTypeTemplate::ReceiverSelf), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "compare".to_string(), @@ -870,9 +870,9 @@ pub fn ordered_ring_templates() -> Rc>> { return_type: Rc::new(AlgebraTypeTemplate::NamedTemplate { name: "Ordering".to_string(), }), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "clamp".to_string(), @@ -882,9 +882,9 @@ pub fn ordered_ring_templates() -> Rc>> { Rc::new(AlgebraTypeTemplate::ReceiverSelf), ]), return_type: Rc::new(AlgebraTypeTemplate::ReceiverSelf), - size_effect: None, + size_effect: std::option::Option::None, cost_shape: Some(CostShape::ShapeConstant), - callback_element_position: None, + callback_element_position: std::option::Option::None, }), ]) } @@ -898,25 +898,25 @@ pub fn approximate_field_templates() -> Rc>> { Rc::new(AlgebraTypeTemplate::ReceiverSelf), ]), return_type: Rc::new(AlgebraTypeTemplate::ReceiverSelf), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "zero".to_string(), param_types: Rc::new(vec![]), return_type: Rc::new(AlgebraTypeTemplate::ReceiverSelf), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "negate".to_string(), param_types: Rc::new(vec![Rc::new(AlgebraTypeTemplate::ReceiverSelf)]), return_type: Rc::new(AlgebraTypeTemplate::ReceiverSelf), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "mul".to_string(), @@ -925,25 +925,25 @@ pub fn approximate_field_templates() -> Rc>> { Rc::new(AlgebraTypeTemplate::ReceiverSelf), ]), return_type: Rc::new(AlgebraTypeTemplate::ReceiverSelf), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "one".to_string(), param_types: Rc::new(vec![]), return_type: Rc::new(AlgebraTypeTemplate::ReceiverSelf), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "reciprocal".to_string(), param_types: Rc::new(vec![Rc::new(AlgebraTypeTemplate::ReceiverSelf)]), return_type: Rc::new(AlgebraTypeTemplate::ReceiverSelf), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "compare".to_string(), @@ -954,9 +954,9 @@ pub fn approximate_field_templates() -> Rc>> { return_type: Rc::new(AlgebraTypeTemplate::NamedTemplate { name: "Ordering".to_string(), }), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), ]) } @@ -970,9 +970,9 @@ pub fn boolean_algebra_templates() -> Rc>> { Rc::new(AlgebraTypeTemplate::ReceiverSelf), ]), return_type: Rc::new(AlgebraTypeTemplate::ReceiverSelf), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "join".to_string(), @@ -981,33 +981,33 @@ pub fn boolean_algebra_templates() -> Rc>> { Rc::new(AlgebraTypeTemplate::ReceiverSelf), ]), return_type: Rc::new(AlgebraTypeTemplate::ReceiverSelf), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "complement".to_string(), param_types: Rc::new(vec![Rc::new(AlgebraTypeTemplate::ReceiverSelf)]), return_type: Rc::new(AlgebraTypeTemplate::ReceiverSelf), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "top".to_string(), param_types: Rc::new(vec![]), return_type: Rc::new(AlgebraTypeTemplate::ReceiverSelf), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "bottom".to_string(), param_types: Rc::new(vec![]), return_type: Rc::new(AlgebraTypeTemplate::ReceiverSelf), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), ]) } @@ -1021,9 +1021,9 @@ pub fn finite_power_set_templates() -> Rc>> { Rc::new(AlgebraTypeTemplate::ReceiverSelf), ]), return_type: Rc::new(AlgebraTypeTemplate::ReceiverSelf), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "intersect".to_string(), @@ -1032,9 +1032,9 @@ pub fn finite_power_set_templates() -> Rc>> { Rc::new(AlgebraTypeTemplate::ReceiverSelf), ]), return_type: Rc::new(AlgebraTypeTemplate::ReceiverSelf), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "diff".to_string(), @@ -1043,9 +1043,9 @@ pub fn finite_power_set_templates() -> Rc>> { Rc::new(AlgebraTypeTemplate::ReceiverSelf), ]), return_type: Rc::new(AlgebraTypeTemplate::ReceiverSelf), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "member".to_string(), @@ -1056,9 +1056,9 @@ pub fn finite_power_set_templates() -> Rc>> { return_type: Rc::new(AlgebraTypeTemplate::NamedTemplate { name: "Bool".to_string(), }), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "contains".to_string(), @@ -1069,9 +1069,9 @@ pub fn finite_power_set_templates() -> Rc>> { return_type: Rc::new(AlgebraTypeTemplate::NamedTemplate { name: "Bool".to_string(), }), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "filter".to_string(), @@ -1106,7 +1106,7 @@ pub fn finite_power_set_templates() -> Rc>> { id: "MappedElement".to_string(), }), }), - size_effect: None, + size_effect: std::option::Option::None, cost_shape: Some(CostShape::ShapeIterateBody), callback_element_position: Some(0), }), @@ -1130,7 +1130,7 @@ pub fn finite_power_set_templates() -> Rc>> { id: "MappedElement".to_string(), }), }), - size_effect: None, + size_effect: std::option::Option::None, cost_shape: Some(CostShape::ShapeIterateBody), callback_element_position: Some(0), }), @@ -1155,7 +1155,7 @@ pub fn finite_power_set_templates() -> Rc>> { return_type: Rc::new(AlgebraTypeTemplate::AlgebraTypeVariable { id: "FoldAccumulator".to_string(), }), - size_effect: None, + size_effect: std::option::Option::None, cost_shape: Some(CostShape::ShapeIterateBody), callback_element_position: Some(1), }), @@ -1173,7 +1173,7 @@ pub fn finite_power_set_templates() -> Rc>> { return_type: Rc::new(AlgebraTypeTemplate::NamedTemplate { name: "Bool".to_string(), }), - size_effect: None, + size_effect: std::option::Option::None, cost_shape: Some(CostShape::ShapeIterateBody), callback_element_position: Some(0), }), @@ -1191,7 +1191,7 @@ pub fn finite_power_set_templates() -> Rc>> { return_type: Rc::new(AlgebraTypeTemplate::NamedTemplate { name: "Bool".to_string(), }), - size_effect: None, + size_effect: std::option::Option::None, cost_shape: Some(CostShape::ShapeIterateBody), callback_element_position: Some(0), }), @@ -1201,9 +1201,9 @@ pub fn finite_power_set_templates() -> Rc>> { return_type: Rc::new(AlgebraTypeTemplate::NamedTemplate { name: "Int".to_string(), }), - size_effect: None, + size_effect: std::option::Option::None, cost_shape: Some(CostShape::ShapeLinearScan), - callback_element_position: None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "length".to_string(), @@ -1211,9 +1211,9 @@ pub fn finite_power_set_templates() -> Rc>> { return_type: Rc::new(AlgebraTypeTemplate::NamedTemplate { name: "Int".to_string(), }), - size_effect: None, + size_effect: std::option::Option::None, cost_shape: Some(CostShape::ShapeLinearScan), - callback_element_position: None, + callback_element_position: std::option::Option::None, }), ]) } @@ -1233,9 +1233,9 @@ pub fn pointwise_power_collection_templates() -> Rc name: "Bool".to_string(), }), }), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, })]) } @@ -1257,17 +1257,17 @@ pub fn free_monoid_scalar_templates() -> Rc>> { Rc::new(AlgebraTypeTemplate::ReceiverSelf), ]), return_type: Rc::new(AlgebraTypeTemplate::ReceiverSelf), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "empty".to_string(), param_types: Rc::new(vec![]), return_type: Rc::new(AlgebraTypeTemplate::ReceiverSelf), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "length".to_string(), @@ -1275,9 +1275,9 @@ pub fn free_monoid_scalar_templates() -> Rc>> { return_type: Rc::new(AlgebraTypeTemplate::NamedTemplate { name: "Int".to_string(), }), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "count".to_string(), @@ -1285,9 +1285,9 @@ pub fn free_monoid_scalar_templates() -> Rc>> { return_type: Rc::new(AlgebraTypeTemplate::NamedTemplate { name: "Int".to_string(), }), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "is_empty".to_string(), @@ -1295,9 +1295,9 @@ pub fn free_monoid_scalar_templates() -> Rc>> { return_type: Rc::new(AlgebraTypeTemplate::NamedTemplate { name: "Bool".to_string(), }), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "chars".to_string(), @@ -1310,9 +1310,9 @@ pub fn free_monoid_scalar_templates() -> Rc>> { name: "Int".to_string(), }), }), - size_effect: None, + size_effect: std::option::Option::None, cost_shape: Some(CostShape::ShapeLinearScan), - callback_element_position: None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "split".to_string(), @@ -1326,9 +1326,9 @@ pub fn free_monoid_scalar_templates() -> Rc>> { }), element: Rc::new(AlgebraTypeTemplate::ReceiverSelf), }), - size_effect: None, + size_effect: std::option::Option::None, cost_shape: Some(CostShape::ShapeLinearScan), - callback_element_position: None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "join".to_string(), @@ -1342,9 +1342,9 @@ pub fn free_monoid_scalar_templates() -> Rc>> { Rc::new(AlgebraTypeTemplate::ReceiverSelf), ]), return_type: Rc::new(AlgebraTypeTemplate::ReceiverSelf), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "contains".to_string(), @@ -1355,9 +1355,9 @@ pub fn free_monoid_scalar_templates() -> Rc>> { return_type: Rc::new(AlgebraTypeTemplate::NamedTemplate { name: "Bool".to_string(), }), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "starts_with".to_string(), @@ -1368,9 +1368,9 @@ pub fn free_monoid_scalar_templates() -> Rc>> { return_type: Rc::new(AlgebraTypeTemplate::NamedTemplate { name: "Bool".to_string(), }), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "ends_with".to_string(), @@ -1381,33 +1381,33 @@ pub fn free_monoid_scalar_templates() -> Rc>> { return_type: Rc::new(AlgebraTypeTemplate::NamedTemplate { name: "Bool".to_string(), }), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "trim".to_string(), param_types: Rc::new(vec![Rc::new(AlgebraTypeTemplate::ReceiverSelf)]), return_type: Rc::new(AlgebraTypeTemplate::ReceiverSelf), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "to_lower".to_string(), param_types: Rc::new(vec![Rc::new(AlgebraTypeTemplate::ReceiverSelf)]), return_type: Rc::new(AlgebraTypeTemplate::ReceiverSelf), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "to_upper".to_string(), param_types: Rc::new(vec![Rc::new(AlgebraTypeTemplate::ReceiverSelf)]), return_type: Rc::new(AlgebraTypeTemplate::ReceiverSelf), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "replace".to_string(), @@ -1417,9 +1417,9 @@ pub fn free_monoid_scalar_templates() -> Rc>> { Rc::new(AlgebraTypeTemplate::ReceiverSelf), ]), return_type: Rc::new(AlgebraTypeTemplate::ReceiverSelf), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "substring".to_string(), @@ -1433,9 +1433,9 @@ pub fn free_monoid_scalar_templates() -> Rc>> { }), ]), return_type: Rc::new(AlgebraTypeTemplate::ReceiverSelf), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "to_int".to_string(), @@ -1443,25 +1443,25 @@ pub fn free_monoid_scalar_templates() -> Rc>> { return_type: Rc::new(AlgebraTypeTemplate::NamedTemplate { name: "Int".to_string(), }), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "to_string".to_string(), param_types: Rc::new(vec![Rc::new(AlgebraTypeTemplate::ReceiverSelf)]), return_type: Rc::new(AlgebraTypeTemplate::ReceiverSelf), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "reverse".to_string(), param_types: Rc::new(vec![Rc::new(AlgebraTypeTemplate::ReceiverSelf)]), return_type: Rc::new(AlgebraTypeTemplate::ReceiverSelf), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), ]) } @@ -1485,7 +1485,7 @@ pub fn free_monoid_collection_templates() -> Rc>> { id: "MappedElement".to_string(), }), }), - size_effect: None, + size_effect: std::option::Option::None, cost_shape: Some(CostShape::ShapeIterateBody), callback_element_position: Some(0), }), @@ -1525,7 +1525,7 @@ pub fn free_monoid_collection_templates() -> Rc>> { id: "MappedElement".to_string(), }), }), - size_effect: None, + size_effect: std::option::Option::None, cost_shape: Some(CostShape::ShapeIterateBody), callback_element_position: Some(0), }), @@ -1550,7 +1550,7 @@ pub fn free_monoid_collection_templates() -> Rc>> { return_type: Rc::new(AlgebraTypeTemplate::AlgebraTypeVariable { id: "FoldAccumulator".to_string(), }), - size_effect: None, + size_effect: std::option::Option::None, cost_shape: Some(CostShape::ShapeIterateBody), callback_element_position: Some(1), }), @@ -1568,7 +1568,7 @@ pub fn free_monoid_collection_templates() -> Rc>> { return_type: Rc::new(AlgebraTypeTemplate::NamedTemplate { name: "Bool".to_string(), }), - size_effect: None, + size_effect: std::option::Option::None, cost_shape: Some(CostShape::ShapeIterateBody), callback_element_position: Some(0), }), @@ -1586,7 +1586,7 @@ pub fn free_monoid_collection_templates() -> Rc>> { return_type: Rc::new(AlgebraTypeTemplate::NamedTemplate { name: "Bool".to_string(), }), - size_effect: None, + size_effect: std::option::Option::None, cost_shape: Some(CostShape::ShapeIterateBody), callback_element_position: Some(0), }), @@ -1596,9 +1596,9 @@ pub fn free_monoid_collection_templates() -> Rc>> { return_type: Rc::new(AlgebraTypeTemplate::NamedTemplate { name: "Int".to_string(), }), - size_effect: None, + size_effect: std::option::Option::None, cost_shape: Some(CostShape::ShapeLinearScan), - callback_element_position: None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "first".to_string(), @@ -1608,7 +1608,7 @@ pub fn free_monoid_collection_templates() -> Rc>> { }), size_effect: Some(CollectionSizeEffect::ProjectionEffect), cost_shape: Some(CostShape::ShapeLinearScan), - callback_element_position: None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "last".to_string(), @@ -1618,7 +1618,7 @@ pub fn free_monoid_collection_templates() -> Rc>> { }), size_effect: Some(CollectionSizeEffect::ProjectionEffect), cost_shape: Some(CostShape::ShapeLinearScan), - callback_element_position: None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "get".to_string(), @@ -1633,7 +1633,7 @@ pub fn free_monoid_collection_templates() -> Rc>> { }), size_effect: Some(CollectionSizeEffect::ProjectionEffect), cost_shape: Some(CostShape::ShapeLinearScan), - callback_element_position: None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "skip".to_string(), @@ -1646,7 +1646,7 @@ pub fn free_monoid_collection_templates() -> Rc>> { return_type: Rc::new(AlgebraTypeTemplate::ReceiverSelf), size_effect: Some(CollectionSizeEffect::ShrinkEffect), cost_shape: Some(CostShape::ShapeIterateBody), - callback_element_position: None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "take".to_string(), @@ -1657,9 +1657,9 @@ pub fn free_monoid_collection_templates() -> Rc>> { }), ]), return_type: Rc::new(AlgebraTypeTemplate::ReceiverSelf), - size_effect: None, + size_effect: std::option::Option::None, cost_shape: Some(CostShape::ShapeIterateBody), - callback_element_position: None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "sort_by".to_string(), @@ -1684,9 +1684,9 @@ pub fn free_monoid_collection_templates() -> Rc>> { Rc::new(AlgebraTypeTemplate::ReceiverElement), ]), return_type: Rc::new(AlgebraTypeTemplate::ReceiverSelf), - size_effect: None, + size_effect: std::option::Option::None, cost_shape: Some(CostShape::ShapeConstant), - callback_element_position: None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "contains".to_string(), @@ -1697,9 +1697,9 @@ pub fn free_monoid_collection_templates() -> Rc>> { return_type: Rc::new(AlgebraTypeTemplate::NamedTemplate { name: "Bool".to_string(), }), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "enumerate".to_string(), @@ -1715,7 +1715,7 @@ pub fn free_monoid_collection_templates() -> Rc>> { }), size_effect: Some(CollectionSizeEffect::IdentityEffect), cost_shape: Some(CostShape::ShapeIterateBody), - callback_element_position: None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "reverse".to_string(), @@ -1723,7 +1723,7 @@ pub fn free_monoid_collection_templates() -> Rc>> { return_type: Rc::new(AlgebraTypeTemplate::ReceiverSelf), size_effect: Some(CollectionSizeEffect::IdentityEffect), cost_shape: Some(CostShape::ShapeLinearScan), - callback_element_position: None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "join".to_string(), @@ -1736,9 +1736,9 @@ pub fn free_monoid_collection_templates() -> Rc>> { return_type: Rc::new(AlgebraTypeTemplate::NamedTemplate { name: "String".to_string(), }), - size_effect: None, + size_effect: std::option::Option::None, cost_shape: Some(CostShape::ShapeLinearScan), - callback_element_position: None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "concat".to_string(), @@ -1747,9 +1747,9 @@ pub fn free_monoid_collection_templates() -> Rc>> { Rc::new(AlgebraTypeTemplate::ReceiverSelf), ]), return_type: Rc::new(AlgebraTypeTemplate::ReceiverSelf), - size_effect: None, + size_effect: std::option::Option::None, cost_shape: Some(CostShape::ShapeLinearScan), - callback_element_position: None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "list_push".to_string(), @@ -1758,9 +1758,9 @@ pub fn free_monoid_collection_templates() -> Rc>> { Rc::new(AlgebraTypeTemplate::ReceiverElement), ]), return_type: Rc::new(AlgebraTypeTemplate::ReceiverSelf), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "length".to_string(), @@ -1768,9 +1768,9 @@ pub fn free_monoid_collection_templates() -> Rc>> { return_type: Rc::new(AlgebraTypeTemplate::NamedTemplate { name: "Int".to_string(), }), - size_effect: None, + size_effect: std::option::Option::None, cost_shape: Some(CostShape::ShapeLinearScan), - callback_element_position: None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "is_empty".to_string(), @@ -1778,9 +1778,9 @@ pub fn free_monoid_collection_templates() -> Rc>> { return_type: Rc::new(AlgebraTypeTemplate::NamedTemplate { name: "Bool".to_string(), }), - size_effect: None, + size_effect: std::option::Option::None, cost_shape: Some(CostShape::ShapeLinearScan), - callback_element_position: None, + callback_element_position: std::option::Option::None, }), ]) } @@ -1796,9 +1796,9 @@ pub fn partial_function_templates() -> Rc>> { return_type: Rc::new(AlgebraTypeTemplate::OptionalOf { inner: Rc::new(AlgebraTypeTemplate::ReceiverValue), }), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "map_get".to_string(), @@ -1809,9 +1809,9 @@ pub fn partial_function_templates() -> Rc>> { return_type: Rc::new(AlgebraTypeTemplate::OptionalOf { inner: Rc::new(AlgebraTypeTemplate::ReceiverValue), }), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), Rc::new(AlgebraFieldTemplate { name: "lookup".to_string(), @@ -1822,9 +1822,9 @@ pub fn partial_function_templates() -> Rc>> { return_type: Rc::new(AlgebraTypeTemplate::OptionalOf { inner: Rc::new(AlgebraTypeTemplate::ReceiverValue), }), - size_effect: None, - cost_shape: None, - callback_element_position: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + callback_element_position: std::option::Option::None, }), ]) } @@ -1840,9 +1840,9 @@ pub fn finitely_supported_function_templates() -> Rc Rc Rc Rc Rc Rc Rc Rc Rc Rc Rc Rc Rc Rc { pub fn checked_int_optional(r: Rc) -> Option { match (*r.clone()).clone() { CheckedInt::CheckedIntReady { value: v, .. } => Some(v.clone()), - CheckedInt::CheckedIntOverflow { cause: _, .. } => None, + CheckedInt::CheckedIntOverflow { cause: _, .. } => std::option::Option::None, } } diff --git a/src/v1/stage0/src/std_computation.rs b/src/v1/stage0/src/std_computation.rs index 71b74560daf..4ad0ba58068 100644 --- a/src/v1/stage0/src/std_computation.rs +++ b/src/v1/stage0/src/std_computation.rs @@ -109,7 +109,7 @@ pub fn lower_call_pattern(pattern: Rc) -> Rc { primitive: IterationPrimitive::Descend, bound: Rc::new(SizeBound::SubtreeSize { param: a.clone() }), evidence: DescentEvidence::Strict, - factor: None, + factor: std::option::Option::None, }), CallPattern::CollectionShrinkCall { amount: p, @@ -147,13 +147,13 @@ pub fn lower_call_pattern(pattern: Rc) -> Rc { primitive: IterationPrimitive::Fold, bound: Rc::new(SizeBound::ParserStreamSize { witness: w.clone() }), evidence: DescentEvidence::Strict, - factor: None, + factor: std::option::Option::None, }), CallPattern::WorklistDrainCall { element: e, .. } => Rc::new(LoweringTarget { primitive: IterationPrimitive::Fold, bound: Rc::new(SizeBound::WorklistDrainSize { element: e.clone() }), evidence: DescentEvidence::Strict, - factor: None, + factor: std::option::Option::None, }), CallPattern::FoldBodyCall { outer_collection: oc, @@ -162,13 +162,13 @@ pub fn lower_call_pattern(pattern: Rc) -> Rc { primitive: IterationPrimitive::Fold, bound: Rc::new(SizeBound::CollectionSize { param: oc.clone() }), evidence: DescentEvidence::NonIncreasing, - factor: None, + factor: std::option::Option::None, }), CallPattern::SameArgumentCall => Rc::new(LoweringTarget { primitive: IterationPrimitive::Repeat, bound: Rc::new(SizeBound::Forever), evidence: DescentEvidence::NonIncreasing, - factor: None, + factor: std::option::Option::None, }), } } @@ -180,9 +180,9 @@ pub fn size_bound_param(bound: Rc) -> Option { SizeBound::ParserStreamSize { witness: w, .. } => Some(w.clone()), SizeBound::WorklistDrainSize { element: e, .. } => Some(e.clone()), SizeBound::ArithmeticParam { param: p, .. } => Some(p.clone()), - SizeBound::ExplicitCountZero => None, - SizeBound::ExplicitCountPositive { steps: _, .. } => None, - SizeBound::Forever => None, + SizeBound::ExplicitCountZero => std::option::Option::None, + SizeBound::ExplicitCountPositive { steps: _, .. } => std::option::Option::None, + SizeBound::Forever => std::option::Option::None, } } @@ -206,7 +206,7 @@ pub fn constant_bound_value(bound: Rc) -> Option { Some(crate::std_termination::positive_descent_count(s.clone())) } SizeBound::Forever => Some(forever_iteration_bound()), - _ => None, + _ => std::option::Option::None, } } @@ -228,11 +228,11 @@ pub fn algebra_profile_to_dimension(profile: AlgebraProfile) -> Option { Some(IterationDimension::CollectionFold) } - AlgebraProfile::PointwisePowerCollectionProfile => None, - AlgebraProfile::PartialFunctionProfile => None, + AlgebraProfile::PointwisePowerCollectionProfile => std::option::Option::None, + AlgebraProfile::PartialFunctionProfile => std::option::Option::None, AlgebraProfile::OrderedRingProfile => Some(IterationDimension::ArithmeticRepeat), AlgebraProfile::ApproximateFieldProfile => Some(IterationDimension::ArithmeticRepeat), - AlgebraProfile::BooleanAlgebraProfile => None, + AlgebraProfile::BooleanAlgebraProfile => std::option::Option::None, } } @@ -242,7 +242,7 @@ pub fn type_iteration_dimension(type_name: String) -> Option } else { match v1_rt::map_get(&kernel_algebra_profile(), type_name.clone()) { Some(p) => algebra_profile_to_dimension(p.clone()), - None => None, + None => std::option::Option::None, } } } diff --git a/src/v1/stage0/src/std_content_hash.rs b/src/v1/stage0/src/std_content_hash.rs index b0b7e25a376..2f0264451b2 100644 --- a/src/v1/stage0/src/std_content_hash.rs +++ b/src/v1/stage0/src/std_content_hash.rs @@ -132,7 +132,7 @@ pub fn sha256_hex_digest(hex: String) -> Option> { if content_hash_validate_lower_hex_length(hex.clone(), 64) { Some(Rc::new(Sha256Digest { hex: hex.clone() })) } else { - None + std::option::Option::None } } @@ -140,7 +140,7 @@ pub fn sha1_hex_digest(hex: String) -> Option> { if content_hash_validate_lower_hex_length(hex.clone(), 40) { Some(Rc::new(Sha1Digest { hex: hex.clone() })) } else { - None + std::option::Option::None } } @@ -148,7 +148,7 @@ pub fn sha512_hex_digest(hex: String) -> Option> { if content_hash_validate_lower_hex_length(hex.clone(), 128) { Some(Rc::new(Sha512Digest { hex: hex.clone() })) } else { - None + std::option::Option::None } } @@ -156,7 +156,7 @@ pub fn fnv1a64_structural_hex_digest(hex: String) -> Option Rc { pub fn content_hash_from_structural_digest(digest: String) -> Option> { match fnv1a64_structural_hex_digest(digest.clone()) { Some(structural) => Some(as_content_hash_structural(structural.clone())), - None => None, + None => std::option::Option::None, } } diff --git a/src/v1/stage0/src/std_induction.rs b/src/v1/stage0/src/std_induction.rs index 7d032f647e3..36cc4024693 100644 --- a/src/v1/stage0/src/std_induction.rs +++ b/src/v1/stage0/src/std_induction.rs @@ -459,10 +459,10 @@ pub fn sub_value_to_call_pattern(relation: Rc) -> Option Some(Rc::new(CallPattern::SameArgumentCall)), - SubValueRelation::NonIncreasingValue => None, - SubValueRelation::StrictAxisErased => None, - SubValueRelation::MixedTop => None, - SubValueRelation::SubValueUnknown => None, + SubValueRelation::NonIncreasingValue => std::option::Option::None, + SubValueRelation::StrictAxisErased => std::option::Option::None, + SubValueRelation::MixedTop => std::option::Option::None, + SubValueRelation::SubValueUnknown => std::option::Option::None, } } @@ -484,7 +484,7 @@ pub fn sub_value_to_lowering_target(relation: Rc) -> Option) -> Option Some(Rc::new(LoweringTarget { primitive: IterationPrimitive::Repeat, bound: Rc::new(SizeBound::Forever), evidence: DescentEvidence::NonIncreasing, - factor: None, + factor: std::option::Option::None, })), - SubValueRelation::StrictAxisErased => None, - SubValueRelation::MixedTop => None, - SubValueRelation::SubValueUnknown => None, + SubValueRelation::StrictAxisErased => std::option::Option::None, + SubValueRelation::MixedTop => std::option::Option::None, + SubValueRelation::SubValueUnknown => std::option::Option::None, } } @@ -713,10 +713,10 @@ pub struct RecurrenceForm { pub fn bounded_int_pow_exponent(k: i64) -> Option { if (k.clone() < 0) { - None + std::option::Option::None } else { if (k.clone() > crate::std_termination::peano_literal_materialization_cap()) { - None + std::option::Option::None } else { Some(k.clone()) } @@ -728,7 +728,7 @@ pub fn int_pow_bounded(base: i64, exp: i64) -> Option { 512 * 1024, 2 * 1024 * 1024, || match bounded_int_pow_exponent(exp.clone()) { - None => None, + None => std::option::Option::None, Some(e) => { if (e.clone() == 0) { Some(1) @@ -758,10 +758,10 @@ pub fn int_pow_bounded(base: i64, exp: i64) -> Option { ), ) { Some(prod) => Some(prod.clone()), - None => None, + None => std::option::Option::None, } } - None => None, + None => std::option::Option::None, } } } @@ -774,7 +774,7 @@ pub fn int_pow_bounded(base: i64, exp: i64) -> Option { pub fn ceil_log(base: i64, argument: i64) -> Option { if ((base.clone() < 2) || (argument.clone() < 1)) { - None + std::option::Option::None } else { ceil_log_iter(base.clone(), argument.clone(), 0, 1) } @@ -789,14 +789,14 @@ pub fn ceil_log_iter(mut base: i64, mut argument: i64, mut k: i64, mut power: i6 crate::std_checked_arithmetic::checked_int_multiply(power.clone(), base.clone()), ) { None => { - break None; + break std::option::Option::None; } Some(next_power) => { match crate::std_checked_arithmetic::checked_int_optional( crate::std_checked_arithmetic::checked_int_add(k.clone(), 1), ) { None => { - break None; + break std::option::Option::None; } Some(k1) => { let __tco_0 = k1.clone(); diff --git a/src/v1/stage0/src/std_integer.rs b/src/v1/stage0/src/std_integer.rs index fbc53cc1e6f..ae3951a33aa 100644 --- a/src/v1/stage0/src/std_integer.rs +++ b/src/v1/stage0/src/std_integer.rs @@ -118,7 +118,7 @@ pub fn uint8_channel_bit_width_int() -> Int { pub fn uint8_channel_inclusive_max_value_derived() -> Option { match crate::std_induction::int_pow_bounded(2, uint8_channel_bit_width_int()) { Some(two_pow) => Some((two_pow.clone() - 1)), - None => None, + None => std::option::Option::None, } } diff --git a/src/v1/stage0/src/std_keyed_roster.rs b/src/v1/stage0/src/std_keyed_roster.rs index 24fe3b627d4..96618013beb 100644 --- a/src/v1/stage0/src/std_keyed_roster.rs +++ b/src/v1/stage0/src/std_keyed_roster.rs @@ -116,8 +116,10 @@ pub fn keyed_roster_locate_second_row( KeyedRosterSecondRowScan::KeyedRosterSecondRowScanFound { row: row, .. } => { Some(row.clone()) } - KeyedRosterSecondRowScan::KeyedRosterSecondRowScanAbsent => None, - KeyedRosterSecondRowScan::KeyedRosterSecondRowScanAwaitingSecond => None, + KeyedRosterSecondRowScan::KeyedRosterSecondRowScanAbsent => std::option::Option::None, + KeyedRosterSecondRowScan::KeyedRosterSecondRowScanAwaitingSecond => { + std::option::Option::None + } } } @@ -126,9 +128,9 @@ pub fn keyed_roster_locate_first_row( wanted_key: K, key_eq: impl Fn(K, K) -> bool + Clone, ) -> Option>> { - rows.iter() - .cloned() - .fold(None, |acc: _, row: Rc>| match acc.clone() { + rows.iter().cloned().fold( + std::option::Option::None, + |acc: _, row: Rc>| match acc.clone() { Some(_) => acc.clone(), None => { if key_eq(row.row_key.clone(), wanted_key.clone()) { @@ -137,17 +139,17 @@ pub fn keyed_roster_locate_first_row( acc.clone() } } - }) + }, + ) } pub fn keyed_roster_locate_duplicate( rows: Rc>>>, key_eq: impl Fn(K, K) -> bool + Clone, ) -> Option>> { - rows.clone() - .iter() - .cloned() - .fold(None, |acc: _, row: Rc>| match acc.clone() { + rows.clone().iter().cloned().fold( + std::option::Option::None, + |acc: _, row: Rc>| match acc.clone() { Some(_) => acc.clone(), None => { if (keyed_occurrence_count(rows.clone(), row.row_key.clone(), key_eq.clone()) > 1) { @@ -176,7 +178,8 @@ pub fn keyed_roster_locate_duplicate( acc.clone() } } - }) + }, + ) } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] diff --git a/src/v1/stage0/src/std_keyed_row.rs b/src/v1/stage0/src/std_keyed_row.rs index 928f5690977..af6289abe68 100644 --- a/src/v1/stage0/src/std_keyed_row.rs +++ b/src/v1/stage0/src/std_keyed_row.rs @@ -30,13 +30,14 @@ pub fn keyed_row_find( wanted_key: K, key_eq: impl Fn(K, K) -> bool + Clone, ) -> Option>> { - rows.iter() - .cloned() - .fold(None, |acc: _, row: Rc>| { + rows.iter().cloned().fold( + std::option::Option::None, + |acc: _, row: Rc>| { if key_eq(row.row_key.clone(), wanted_key.clone()) { Some(row.clone()) } else { acc.clone() } - }) + }, + ) } diff --git a/src/v1/stage0/src/std_measure.rs b/src/v1/stage0/src/std_measure.rs index 6e7b4b2db16..0c2d14f0395 100644 --- a/src/v1/stage0/src/std_measure.rs +++ b/src/v1/stage0/src/std_measure.rs @@ -109,12 +109,12 @@ pub fn scale_exponent(s: Scale) -> Option { Scale::Micro => Some(-6), Scale::Milli => Some(-3), Scale::One => Some(0), - Scale::ArcsecondAngle => None, - Scale::DegreeAngle => None, - Scale::TurnAngle => None, - Scale::Sixty => None, - Scale::RackUnitHeight => None, - Scale::SquareFootArea => None, + Scale::ArcsecondAngle => std::option::Option::None, + Scale::DegreeAngle => std::option::Option::None, + Scale::TurnAngle => std::option::Option::None, + Scale::Sixty => std::option::Option::None, + Scale::RackUnitHeight => std::option::Option::None, + Scale::SquareFootArea => std::option::Option::None, Scale::Kilo => Some(3), Scale::Mega => Some(6), Scale::Giga => Some(9), @@ -170,28 +170,28 @@ pub fn mega_factor() -> Nat { pub fn time_scale_factor_seconds(s: Scale) -> Option { match s.clone() { Scale::One => Some(1), - Scale::ArcsecondAngle => None, - Scale::DegreeAngle => None, - Scale::TurnAngle => None, + Scale::ArcsecondAngle => std::option::Option::None, + Scale::DegreeAngle => std::option::Option::None, + Scale::TurnAngle => std::option::Option::None, Scale::Sixty => Some(seconds_per_minute()), - Scale::RackUnitHeight => None, - Scale::SquareFootArea => None, - Scale::Atto => None, - Scale::Femto => None, - Scale::Pico => None, - Scale::Nano => None, - Scale::Micro => None, - Scale::Milli => None, - Scale::Kilo => None, - Scale::Mega => None, - Scale::Giga => None, - Scale::Tera => None, - Scale::Peta => None, - Scale::Exa => None, - Scale::Kibi => None, - Scale::Mebi => None, - Scale::Gibi => None, - Scale::Tebi => None, + Scale::RackUnitHeight => std::option::Option::None, + Scale::SquareFootArea => std::option::Option::None, + Scale::Atto => std::option::Option::None, + Scale::Femto => std::option::Option::None, + Scale::Pico => std::option::Option::None, + Scale::Nano => std::option::Option::None, + Scale::Micro => std::option::Option::None, + Scale::Milli => std::option::Option::None, + Scale::Kilo => std::option::Option::None, + Scale::Mega => std::option::Option::None, + Scale::Giga => std::option::Option::None, + Scale::Tera => std::option::Option::None, + Scale::Peta => std::option::Option::None, + Scale::Exa => std::option::Option::None, + Scale::Kibi => std::option::Option::None, + Scale::Mebi => std::option::Option::None, + Scale::Gibi => std::option::Option::None, + Scale::Tebi => std::option::Option::None, } } @@ -202,24 +202,24 @@ pub fn memory_scale_factor_bytes(s: Scale) -> Option { Scale::Mebi => Some((kibi_factor() * kibi_factor())), Scale::Gibi => Some(gibibyte_scale_factor_bytes()), Scale::Tebi => Some((gibibyte_scale_factor_bytes() * kibi_factor())), - Scale::Atto => None, - Scale::Femto => None, - Scale::Pico => None, - Scale::Nano => None, - Scale::Micro => None, - Scale::Milli => None, - Scale::ArcsecondAngle => None, - Scale::DegreeAngle => None, - Scale::TurnAngle => None, - Scale::Sixty => None, - Scale::RackUnitHeight => None, - Scale::SquareFootArea => None, - Scale::Kilo => None, - Scale::Mega => None, - Scale::Giga => None, - Scale::Tera => None, - Scale::Peta => None, - Scale::Exa => None, + Scale::Atto => std::option::Option::None, + Scale::Femto => std::option::Option::None, + Scale::Pico => std::option::Option::None, + Scale::Nano => std::option::Option::None, + Scale::Micro => std::option::Option::None, + Scale::Milli => std::option::Option::None, + Scale::ArcsecondAngle => std::option::Option::None, + Scale::DegreeAngle => std::option::Option::None, + Scale::TurnAngle => std::option::Option::None, + Scale::Sixty => std::option::Option::None, + Scale::RackUnitHeight => std::option::Option::None, + Scale::SquareFootArea => std::option::Option::None, + Scale::Kilo => std::option::Option::None, + Scale::Mega => std::option::Option::None, + Scale::Giga => std::option::Option::None, + Scale::Tera => std::option::Option::None, + Scale::Peta => std::option::Option::None, + Scale::Exa => std::option::Option::None, } } diff --git a/src/v1/stage0/src/std_occurrence_binding_candidates.rs b/src/v1/stage0/src/std_occurrence_binding_candidates.rs index 33c23274f37..6697c7d959a 100644 --- a/src/v1/stage0/src/std_occurrence_binding_candidates.rs +++ b/src/v1/stage0/src/std_occurrence_binding_candidates.rs @@ -241,7 +241,7 @@ pub fn module_by_occurrence_fold_step( row.occurrence.clone().value.clone(), row.module_path.clone(), ), - refusal: None, + refusal: std::option::Option::None, }), } } @@ -254,7 +254,7 @@ pub fn module_by_occurrence_build( rows.iter().cloned().fold( Rc::new(OccurrenceModulePathIndexBuild { module_by_occurrence: v1_rt::rc_empty_map::(), - refusal: None, + refusal: std::option::Option::None, }), |build: Rc, row: Rc| { module_by_occurrence_fold_step(build, row.clone()) @@ -355,7 +355,7 @@ pub fn occurrence_containment_parent_scope( { let __fm = v1_rt::reverse(ancestors.clone()); if __fm.is_empty() { - None + std::option::Option::None } else { let parent_terminal = (*__fm)[0].clone(); let parent_ancestors_reversed: Rc> = @@ -478,7 +478,7 @@ pub fn declaration_exposure_fold_step( row.occurrence.clone().value.clone(), row.exposure.clone(), ), - refusal: None, + refusal: std::option::Option::None, }), }, } @@ -490,7 +490,7 @@ pub fn exposure_by_occurrence_build( rows.iter().cloned().fold( Rc::new(DeclarationExposureIndexBuild { exposure_by_occurrence: v1_rt::rc_empty_map::>(), - refusal: None, + refusal: std::option::Option::None, }), |build: Rc, row: Rc| { declaration_exposure_fold_step(build, row.clone()) @@ -564,7 +564,7 @@ pub fn authored_order_fold_step( row.occurrence.clone().value.clone(), row.ordinal.clone(), ), - refusal: None, + refusal: std::option::Option::None, }), }, } @@ -576,7 +576,7 @@ pub fn authored_order_by_occurrence_build( rows.iter().cloned().fold( Rc::new(AuthoredOrderIndexBuild { order_by_occurrence: v1_rt::rc_empty_map::(), - refusal: None, + refusal: std::option::Option::None, }), |build: Rc, row: Rc| { authored_order_fold_step(build, row.clone()) @@ -607,7 +607,7 @@ pub fn module_exposure_declaration_missing_path_refusal( &exposure_by_occurrence, declaration.occurrence.clone().value.clone(), ) { - None => None, + None => std::option::Option::None, Some(exposure) => match (*exposure.clone()).clone() { DeclarationExposure::ModuleExposure { module: _, .. } => match v1_rt::map_get( &module_by_occurrence, @@ -618,12 +618,12 @@ pub fn module_exposure_declaration_missing_path_refusal( occurrence: declaration.occurrence.clone(), }, )), - Some(_) => None, + Some(_) => std::option::Option::None, }, DeclarationExposure::LexicalExposure { exposing_scope: _, .. - } => None, - DeclarationExposure::RootExposure => None, + } => std::option::Option::None, + DeclarationExposure::RootExposure => std::option::Option::None, }, } } @@ -641,7 +641,7 @@ pub fn reference_missing_module_path_refusal( occurrence: reference.occurrence.clone(), }, )), - Some(_) => None, + Some(_) => std::option::Option::None, } } @@ -652,7 +652,7 @@ pub fn module_paths_validate_transport( ) -> Option> { { let declaration_refusal = transport.declarations.clone().iter().cloned().fold( - None, + std::option::Option::None, |refusal: _, declaration: Rc| match refusal.clone() { Some(_) => refusal.clone(), None => module_exposure_declaration_missing_path_refusal( @@ -665,7 +665,7 @@ pub fn module_paths_validate_transport( match declaration_refusal.clone() { Some(refusal) => Some(refusal.clone()), None => transport.references.clone().iter().cloned().fold( - None, + std::option::Option::None, |refusal: _, reference: Rc| match refusal.clone() { Some(_) => refusal.clone(), None => reference_missing_module_path_refusal( @@ -690,14 +690,14 @@ pub fn exposure_validate_transport_declarations( exposure_by_occurrence: Rc>>, ) -> Option> { declarations.iter().cloned().fold( - None, + std::option::Option::None, |refusal: _, declaration: Rc| match refusal.clone() { Some(_) => refusal.clone(), None => match v1_rt::map_get( &exposure_by_occurrence, declaration.occurrence.clone().value.clone(), ) { - Some(_) => None, + Some(_) => std::option::Option::None, None => Some(Rc::new( DeclarationExposureIndexRefusal::MissingDeclarationExposure { occurrence: declaration.occurrence.clone(), @@ -713,7 +713,7 @@ pub fn authored_order_validate_transport_occurrence( occurrence: OccurrenceId, ) -> Option> { match v1_rt::map_get(&order_by_occurrence, occurrence.value.clone()) { - Some(_) => None, + Some(_) => std::option::Option::None, None => Some(Rc::new( AuthoredOrderIndexRefusal::MissingAuthoredOrderRow { occurrence: occurrence.clone(), @@ -728,7 +728,7 @@ pub fn authored_order_validate_transport( ) -> Option> { { let declaration_refusal = transport.declarations.clone().iter().cloned().fold( - None, + std::option::Option::None, |refusal: _, declaration: Rc| match refusal.clone() { Some(_) => refusal.clone(), None => authored_order_validate_transport_occurrence( @@ -740,7 +740,7 @@ pub fn authored_order_validate_transport( match declaration_refusal.clone() { Some(refusal) => Some(refusal.clone()), None => transport.references.clone().iter().cloned().fold( - None, + std::option::Option::None, |refusal: _, reference: Rc| match refusal.clone() { Some(_) => refusal.clone(), None => authored_order_validate_transport_occurrence( @@ -1433,7 +1433,7 @@ pub fn bound_reference_population_from_projections( let build = projections.iter().cloned().fold( Rc::new(BoundReferencePopulationBuild { providers_reversed: Rc::new(vec![]), - first_failure: None, + first_failure: std::option::Option::None, more_failures_reversed: Rc::new(vec![]), }), |acc: Rc, projection: Rc| { @@ -1574,7 +1574,7 @@ pub fn module_path_file_index_fold_step( key.clone(), row.file_path.clone(), ), - refusal: None, + refusal: std::option::Option::None, }), Some(existing) => { if (existing.clone() == row.file_path.clone()) { @@ -1612,7 +1612,7 @@ pub fn module_path_file_index_from_rows( let build = rows.iter().cloned().fold( Rc::new(ModulePathFileIndexBuild { entries: v1_rt::rc_empty_map::(), - refusal: None, + refusal: std::option::Option::None, }), |acc: Rc, row: Rc| { module_path_file_index_fold_step(acc, row.clone()) @@ -1801,7 +1801,7 @@ pub fn cross_file_binding_provenance_from_bound_population( Rc::new(CrossFileBindingProvenanceBuild { module_files: module_files.clone(), provenances_reversed: Rc::new(vec![]), - first_failure: None, + first_failure: std::option::Option::None, more_failures_reversed: Rc::new(vec![]), }), |acc: Rc, provider: Rc| { @@ -3490,7 +3490,7 @@ pub fn section13_first_duplicate_law( rows: Rc>>, ) -> Option { rows.clone().iter().cloned().fold( - None, + std::option::Option::None, |found: _, row: Rc| match found.clone() { Some(_) => found.clone(), None => { @@ -3506,7 +3506,7 @@ pub fn section13_first_duplicate_law( { Some(row.law.clone()) } else { - None + std::option::Option::None } } }, @@ -3549,7 +3549,7 @@ pub fn section13_first_uncovered_law( if !section13_roster_has_law(rows.clone(), Section13PopulationLawId::Section13RepeatedDiscoverySameIdentityCollapse) { Some(Section13PopulationLawId::Section13RepeatedDiscoverySameIdentityCollapse) } else { - None + std::option::Option::None } } } @@ -3564,7 +3564,7 @@ pub fn section13_observation_joins_receipt( required_head: String, ) -> Option { observations.iter().cloned().fold( - None, + std::option::Option::None, |found: _, observation: Rc| match found.clone() { Some(_) => found.clone(), None => { @@ -3575,7 +3575,7 @@ pub fn section13_observation_joins_receipt( { Some(observation.passed.clone()) } else { - None + std::option::Option::None } } }, diff --git a/src/v1/stage0/src/std_occurrence_binding_resolve.rs b/src/v1/stage0/src/std_occurrence_binding_resolve.rs index c3b6d577e60..17dfae3b459 100644 --- a/src/v1/stage0/src/std_occurrence_binding_resolve.rs +++ b/src/v1/stage0/src/std_occurrence_binding_resolve.rs @@ -239,7 +239,7 @@ pub fn binding_candidates_from_supplied_declarations( supplied_candidates.iter().cloned().fold(Rc::new(OccurrenceCandidatePopulationBuild { candidates: Rc::new(vec![]), seen_candidate_ids: v1_rt::rc_empty_map::(), - refusal: None, + refusal: std::option::Option::None, }), |build: Rc, candidate_occurrence: OccurrenceId| match build.refusal.clone() { Some(_) => build.clone(), None => match v1_rt::map_get(&validated.entries_by_id.clone(), candidate_occurrence.value.clone()) { @@ -285,12 +285,12 @@ match (*occurrence_category_binding_verdict(reference.category.clone(), declarat OccurrenceCategoryBindingVerdict::OccurrenceCategoryBindingAdmissible => Rc::new(OccurrenceCandidatePopulationBuild { candidates: v1_rt::concat(build.candidates.clone(), Rc::new(vec![binding_candidate_from_declaration(declaration.clone())])), seen_candidate_ids: seen_candidate_ids.clone(), - refusal: None, + refusal: std::option::Option::None, }), OccurrenceCategoryBindingVerdict::OccurrenceCategoryBindingInadmissible { .. } => Rc::new(OccurrenceCandidatePopulationBuild { candidates: build.candidates.clone(), seen_candidate_ids: seen_candidate_ids.clone(), - refusal: None, + refusal: std::option::Option::None, }), } }, diff --git a/src/v1/stage0/src/std_occurrence_identity.rs b/src/v1/stage0/src/std_occurrence_identity.rs index c80abce547c..b28205158f7 100644 --- a/src/v1/stage0/src/std_occurrence_identity.rs +++ b/src/v1/stage0/src/std_occurrence_identity.rs @@ -616,7 +616,7 @@ pub fn occurrence_transport_index_build( index.entries.clone().iter().cloned().fold( Rc::new(OccurrenceTransportIndexBuild { entries_by_id: v1_rt::rc_empty_map::>(), - refusal: None, + refusal: std::option::Option::None, }), |build: Rc, entry: Rc| match build .refusal @@ -647,7 +647,7 @@ pub fn occurrence_transport_index_build( entry.projection.clone().occurrence.clone().value.clone(), entry.clone(), ), - refusal: None, + refusal: std::option::Option::None, }) } else { Rc::new(OccurrenceTransportIndexBuild { @@ -686,7 +686,7 @@ pub fn occurrence_transport_role_index_build( Rc::new(OccurrenceTransportRoleIndexBuild { declarations_by_id: v1_rt::rc_empty_map::>(), references_by_id: v1_rt::rc_empty_map::>(), - refusal: None, + refusal: std::option::Option::None, }), |build: Rc, declaration: Rc| match build.refusal.clone() { @@ -712,7 +712,7 @@ pub fn occurrence_transport_role_index_build( declaration.clone(), ), references_by_id: build.references_by_id.clone(), - refusal: None, + refusal: std::option::Option::None, }), }, }, @@ -745,7 +745,7 @@ pub fn occurrence_transport_role_index_build( reference.occurrence.clone().value.clone(), reference.clone(), ), - refusal: None, + refusal: std::option::Option::None, }), }, }, @@ -782,7 +782,7 @@ pub fn declaration_occurrence_refusal( diagnostic_span: declaration.diagnostic_span.clone(), })) } - None => None, + None => std::option::Option::None, } } else { Some(Rc::new( @@ -824,7 +824,7 @@ pub fn reference_occurrence_refusal( diagnostic_span: reference.diagnostic_span.clone(), })) } - None => None, + None => std::option::Option::None, } } else { Some(Rc::new( @@ -890,7 +890,7 @@ pub fn occurrence_transport_validate( None => { let declaration_refusal = transport.declarations.clone().iter().cloned().fold( - None, + std::option::Option::None, |refusal: _, declaration: Rc| match refusal .clone() { @@ -911,7 +911,7 @@ pub fn occurrence_transport_validate( None => { let reference_refusal = transport.references.clone().iter().cloned().fold( - None, + std::option::Option::None, |refusal: _, reference: Rc| { match refusal.clone() { Some(_) => refusal.clone(), @@ -953,7 +953,9 @@ pub fn occurrence_transport_refusal( OccurrenceTransportValidation::OccurrenceTransportRefused { refusal: refusal, .. } => Some(refusal.clone()), - OccurrenceTransportValidation::OccurrenceTransportValidated { transport: _, .. } => None, + OccurrenceTransportValidation::OccurrenceTransportValidated { transport: _, .. } => { + std::option::Option::None + } } } diff --git a/src/v1/stage0/src/std_operator_realization.rs b/src/v1/stage0/src/std_operator_realization.rs index 6ebc5313f2e..11611aab1b4 100644 --- a/src/v1/stage0/src/std_operator_realization.rs +++ b/src/v1/stage0/src/std_operator_realization.rs @@ -120,16 +120,16 @@ pub fn ordering_test_for(op: BinOp) -> Option> { BinOp::Ge => Some(Rc::new(OrderingTest::OrderingIsNot { variant: "Less".to_string(), })), - BinOp::Add => None, - BinOp::Sub => None, - BinOp::Mul => None, - BinOp::Div => None, - BinOp::Mod => None, - BinOp::Eq => None, - BinOp::Ne => None, - BinOp::And => None, - BinOp::Or => None, - BinOp::NullCoalesce => None, + BinOp::Add => std::option::Option::None, + BinOp::Sub => std::option::Option::None, + BinOp::Mul => std::option::Option::None, + BinOp::Div => std::option::Option::None, + BinOp::Mod => std::option::Option::None, + BinOp::Eq => std::option::Option::None, + BinOp::Ne => std::option::Option::None, + BinOp::And => std::option::Option::None, + BinOp::Or => std::option::Option::None, + BinOp::NullCoalesce => std::option::Option::None, } } @@ -153,7 +153,7 @@ pub fn binop_is_equality(op: BinOp) -> bool { } pub fn binop_is_ordering(op: BinOp) -> bool { - (ordering_test_for(op.clone()) != None) + (ordering_test_for(op.clone()) != std::option::Option::None) } pub fn binop_label(op: BinOp) -> String { diff --git a/src/v1/stage0/src/std_primitive_projection.rs b/src/v1/stage0/src/std_primitive_projection.rs index c1493ae0e3e..eed15cd6d7d 100644 --- a/src/v1/stage0/src/std_primitive_projection.rs +++ b/src/v1/stage0/src/std_primitive_projection.rs @@ -278,12 +278,6 @@ pub fn primitive_projection_roster() -> Rc>> { "empty_map_primitive_delegate".to_string(), Rc::new(ProjectionFidelity::HostRealizedSeam), ), - primitive_projection_row( - primitive_map_insert(), - "v2.std.collection".to_string(), - "map_insert_primitive_delegate".to_string(), - Rc::new(ProjectionFidelity::HostRealizedSeam), - ), primitive_projection_row( primitive_symbol_lexeme(), "v2.std.compilers.lexing".to_string(), @@ -331,7 +325,7 @@ pub fn primitive_projection_row_for_declaration( declaration: Rc, ) -> Option> { primitive_projection_roster().iter().cloned().fold( - None, + std::option::Option::None, |acc: _, row: Rc| match acc.clone() { Some(_) => acc.clone(), None => { diff --git a/src/v1/stage0/src/std_source_annotation.rs b/src/v1/stage0/src/std_source_annotation.rs index baedb4c51e6..433d3cbb0bf 100644 --- a/src/v1/stage0/src/std_source_annotation.rs +++ b/src/v1/stage0/src/std_source_annotation.rs @@ -283,12 +283,10 @@ pub fn module_root_pick_step( pub fn module_root_subject( subjects: Rc>>, ) -> Option> { - subjects - .iter() - .cloned() - .fold(None, |acc: _, row: Rc| { - module_root_pick_step(acc.clone(), row.clone()) - }) + subjects.iter().cloned().fold( + std::option::Option::None, + |acc: _, row: Rc| module_root_pick_step(acc.clone(), row.clone()), + ) } pub fn earliest_member_start_after( @@ -317,10 +315,10 @@ pub fn module_header_gap_subject( preceded_by_annotation_line: bool, ) -> Option> { if (preceded_by_blank_line.clone() || preceded_by_annotation_line.clone()) { - None + std::option::Option::None } else { match module_root_subject(subjects.clone()) { - None => None, + None => std::option::Option::None, Some(mod_subject) => { let first_member_start = earliest_member_start_after( subjects.clone(), @@ -332,7 +330,7 @@ pub fn module_header_gap_subject( { Some(mod_subject.clone()) } else { - None + std::option::Option::None } } } @@ -358,7 +356,7 @@ pub fn annotation_subject_pick( None => subjects.iter().cloned().fold( Rc::new(AnnotationSubjectPick { contained: false, - following: None, + following: std::option::Option::None, }), |acc: Rc, subject: Rc| { if ((origin.start.clone() >= subject.span.clone().start.clone()) @@ -626,7 +624,7 @@ pub fn attach_annotations( Rc::new(AnnotationAttachAcc { rows: Rc::new(vec![]), refusals: Rc::new(vec![]), - pending: None, + pending: std::option::Option::None, pending_adjacent: false, }), |acc: Rc, capture: Rc| { diff --git a/src/v1/stage0/src/std_termination.rs b/src/v1/stage0/src/std_termination.rs index 8d5128fc977..1535bdccb42 100644 --- a/src/v1/stage0/src/std_termination.rs +++ b/src/v1/stage0/src/std_termination.rs @@ -191,10 +191,10 @@ pub fn peano_literal_materialization_cap() -> i64 { pub fn positive_descent_amount_from_positive_int(k: i64) -> Option> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { if (k.clone() <= 0) { - None + std::option::Option::None } else { if (k.clone() > peano_literal_materialization_cap()) { - None + std::option::Option::None } else { if (k.clone() == 1) { Some(Rc::new(PositiveDescentAmount::OneStep)) @@ -203,7 +203,7 @@ pub fn positive_descent_amount_from_positive_int(k: i64) -> Option Some(Rc::new(PositiveDescentAmount::AdditionalStep { previous: prev.clone(), })), - None => None, + None => std::option::Option::None, } } } @@ -214,10 +214,10 @@ pub fn positive_descent_amount_from_positive_int(k: i64) -> Option Option> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { if (k.clone() < 2) { - None + std::option::Option::None } else { if (k.clone() > peano_literal_materialization_cap()) { - None + std::option::Option::None } else { if (k.clone() == 2) { Some(Rc::new(ProportionalDivisor::DivideByTwo)) @@ -226,7 +226,7 @@ pub fn proportional_divisor_from_int_at_least_two(k: i64) -> Option Some(Rc::new(ProportionalDivisor::StrictlyLarger { inner: prev.clone(), })), - None => None, + None => std::option::Option::None, } } } diff --git a/src/v1/stage0/src/std_types.rs b/src/v1/stage0/src/std_types.rs index 46b60b226c8..b6840159bc7 100644 --- a/src/v1/stage0/src/std_types.rs +++ b/src/v1/stage0/src/std_types.rs @@ -111,7 +111,7 @@ pub fn container_param_name(kind_name: String, index: i64) -> Option { .cloned() { Some(name) => Some(name.clone()), - None => None, + None => std::option::Option::None, } } } diff --git a/src/v1/stage0/src/v1_compiler_annotation_bind.rs b/src/v1/stage0/src/v1_compiler_annotation_bind.rs index 0f0747b0285..c7be4dadef9 100644 --- a/src/v1/stage0/src/v1_compiler_annotation_bind.rs +++ b/src/v1/stage0/src/v1_compiler_annotation_bind.rs @@ -237,7 +237,7 @@ pub fn render_subject_annotation_blocks( }, ); if ((texts.clone().len() as i64) == 0) { - None + std::option::Option::None } else { Some( Rc::new({ @@ -279,16 +279,16 @@ pub fn authored_name_among( entries: Rc>>, id: OccurrenceId, ) -> Option { - entries - .iter() - .cloned() - .fold(None, |acc: _, entry: Rc| { + entries.iter().cloned().fold( + std::option::Option::None, + |acc: _, entry: Rc| { if (entry.projection.clone().occurrence.clone().value.clone() == id.value.clone()) { Some(entry.projection.clone().authored_name.clone()) } else { acc.clone() } - }) + }, + ) } pub fn eligible_name_count(entries: Rc>>, name: String) -> i64 { @@ -328,7 +328,7 @@ pub fn keyed_annotation_rows( { let eligible = eligible_key_entries(transport.clone()); if !eligible_names_unique(eligible.clone()) { - None + std::option::Option::None } else { crate::std_source_annotation::source_annotation_graph_rows(graph.clone()) .iter() @@ -337,10 +337,10 @@ pub fn keyed_annotation_rows( Some(empty_keyed_rows()), |acc: Option>>>, row: Rc| match acc.clone() { - None => None, + None => std::option::Option::None, Some(rows) => { match authored_name_among(eligible.clone(), row.subject.clone()) { - None => None, + None => std::option::Option::None, Some(name) => Some(v1_rt::rc_list_push( rows.clone(), Rc::new(KeyedAnnotationRow { diff --git a/src/v1/stage0/src/v1_compiler_coercion.rs b/src/v1/stage0/src/v1_compiler_coercion.rs index 647f4e4821f..a4cf840e7b5 100644 --- a/src/v1/stage0/src/v1_compiler_coercion.rs +++ b/src/v1/stage0/src/v1_compiler_coercion.rs @@ -73,7 +73,7 @@ pub fn target_callable(target: RenderTarget) -> Rc { template: "fn({params}) -> {return}".to_string(), param_separator: ", ".to_string(), return_separator: " -> ".to_string(), - import_path: None, + import_path: std::option::Option::None, }), } } @@ -92,7 +92,7 @@ pub fn target_cast_syntax(target: RenderTarget) -> Option> { RenderTarget::Rust => Some(rust_cast_syntax()), RenderTarget::Python => Some(python_cast_syntax()), RenderTarget::Go => Some(go_cast_syntax()), - RenderTarget::Dag => None, + RenderTarget::Dag => std::option::Option::None, } } @@ -248,7 +248,7 @@ pub fn rust_seed_host_numeric_alias(name: String, decl_file: String) -> Option Rc::new(TypeRealizationDecision::Realized { @@ -299,9 +299,9 @@ pub fn type_realization_decision( dag_name: dag_name.clone(), target_type: host.clone(), grounding_type: host.clone(), - default_expr: None, - is_copy: None, - literal_suffix: None, + default_expr: std::option::Option::None, + is_copy: std::option::Option::None, + literal_suffix: std::option::Option::None, }), }), None => Rc::new(TypeRealizationDecision::Unrealized), @@ -335,8 +335,8 @@ pub fn lookup_checkpoint( .clone() { TypeRealizationDecision::Realized { checkpoint: cp, .. } => Some(cp.clone()), - TypeRealizationDecision::Unrealized => None, - TypeRealizationDecision::Refused { cause: _, .. } => None, + TypeRealizationDecision::Unrealized => std::option::Option::None, + TypeRealizationDecision::Refused { cause: _, .. } => std::option::Option::None, } } } @@ -383,7 +383,7 @@ pub fn declaration_realizes_natively_on_rust( RenderTarget::Rust, declaration.decl_name.clone(), decl_file.clone(), - ) != None) + ) != std::option::Option::None) } } } @@ -423,7 +423,7 @@ pub fn coerce_primitive_type(target: RenderTarget, dag_name: String, decl_file: pub fn is_copy(target: RenderTarget, dag_name: String, decl_file: String) -> Option { match lookup_checkpoint(target.clone(), dag_name.clone(), decl_file.clone()) { Some(cp) => cp.is_copy.clone(), - None => None, + None => std::option::Option::None, } } @@ -433,7 +433,7 @@ pub fn literal_suffix(target: RenderTarget, dag_name: String, decl_file: String) Some(s) => Some(s.clone()), None => Some("".to_string()), }, - None => None, + None => std::option::Option::None, } } @@ -455,9 +455,9 @@ pub fn coerce_container_template(target: RenderTarget, container_name: String) - match crate::std_types::container_template_algebra(container_name.clone()) { Some(algebra) => match lookup_inhabitant(target.clone(), algebra.clone()) { Some(inh) => Some(inh.template.clone()), - None => None, + None => std::option::Option::None, }, - None => None, + None => std::option::Option::None, } } diff --git a/src/v1/stage0/src/v1_compiler_compile.rs b/src/v1/stage0/src/v1_compiler_compile.rs index 6f74b2c6da7..40f151eefc0 100644 --- a/src/v1/stage0/src/v1_compiler_compile.rs +++ b/src/v1/stage0/src/v1_compiler_compile.rs @@ -2025,7 +2025,8 @@ pub fn serialize_param( pub fn is_import_statement_node(n: Rc) -> bool { (crate::v1_std_core::import_is_all(n.clone()) - || (((((n.children.clone().len() as i64) > 0) && (n.body.clone() == None)) + || (((((n.children.clone().len() as i64) > 0) + && (n.body.clone() == std::option::Option::None)) && (n.expr_data.clone() == Rc::new(ExprData::NoExprData))) && ((n.params.clone().len() as i64) == 0))) } @@ -2378,13 +2379,13 @@ pub fn emittable_graph(resolved: Rc) -> Option 0) { - None + std::option::Option::None } else { match resolved.graph.clone() { Some(typed) => Some(Rc::new(EmittableGraph { graph: typed.clone(), })), - None => None, + None => std::option::Option::None, } } } @@ -2463,7 +2464,7 @@ pub fn resolve_frontend_occurrence_transport( match crate::std_occurrence_identity::occurrence_transport_refusal(occurrence_transport.clone()) { Some(refusal) => Rc::new(FrontendOccurrenceResolution { - graph: None, + graph: std::option::Option::None, diagnostics: Rc::new(vec![crate::v1_std_core::make_error_node( Rc::new(CompilerDiagnostic::OccurrenceTransportViolation { refusal: refusal.clone(), @@ -2871,7 +2872,7 @@ pub fn stage0_self_compile_refusal_message( " emitted no files".to_string(), )) } else { - None + std::option::Option::None } } } @@ -2908,7 +2909,7 @@ pub fn compile_to_resolved_with_options( let newline_indices = frontend.newline_indices.clone(); match frontend.graph.clone() { None => Rc::new(ResolvedPipelineResult { - graph: None, + graph: std::option::Option::None, diagnostics: frontend.diagnostics.clone(), source_indices: v1_rt::rc_empty_map::>(), complexity: crate::v1_compiler_complexity::empty_complexity_report(), diff --git a/src/v1/stage0/src/v1_compiler_complexity.rs b/src/v1/stage0/src/v1_compiler_complexity.rs index debb3ca2029..abb4f925579 100644 --- a/src/v1/stage0/src/v1_compiler_complexity.rs +++ b/src/v1/stage0/src/v1_compiler_complexity.rs @@ -331,7 +331,7 @@ pub fn method_size_effect( Some(MethodSemantics::AlgebraMethodSemantics { size_effect: se, .. }) => se.clone(), - _ => None, + _ => std::option::Option::None, } } @@ -344,9 +344,9 @@ pub fn method_callback_element_position( .. }) => match at.clone() { Some(template) => template.callback_element_position.clone(), - None => None, + None => std::option::Option::None, }, - _ => None, + _ => std::option::Option::None, } } @@ -364,7 +364,7 @@ pub fn iteration_element_name( .cloned() .skip(pos.clone() as usize) .next(), - None => None, + None => std::option::Option::None, } } } @@ -378,7 +378,7 @@ pub fn proof_has_non_descending_cycle( } pub fn set_has(m: Rc>, key: String) -> bool { - (v1_rt::map_get(&m, key.clone()) != None) + (v1_rt::map_get(&m, key.clone()) != std::option::Option::None) } pub fn strict_after_parser_witness(input: DescentEvidence) -> DescentEvidence { @@ -410,28 +410,31 @@ pub fn parser_state_param( ) .iter() .cloned() - .fold(None, |acc: _, pair: (i64, Rc)| { - if (acc.clone() != None) { - acc.clone() - } else { - { - let idx = pair.0.clone(); - let param = pair.1.clone(); - if (crate::v1_std_core::authored_name_at( - si.clone(), - crate::v1_std_core::param_node_type_expr(param.clone()), - ) == "ParserState".to_string()) + .fold( + std::option::Option::None, + |acc: _, pair: (i64, Rc)| { + if (acc.clone() != std::option::Option::None) { + acc.clone() + } else { { - Some(Rc::new(ParserStateParam { - name: crate::v1_std_core::param_node_name_at(param.clone(), si.clone()), - index: idx.clone(), - })) - } else { - None + let idx = pair.0.clone(); + let param = pair.1.clone(); + if (crate::v1_std_core::authored_name_at( + si.clone(), + crate::v1_std_core::param_node_type_expr(param.clone()), + ) == "ParserState".to_string()) + { + Some(Rc::new(ParserStateParam { + name: crate::v1_std_core::param_node_name_at(param.clone(), si.clone()), + index: idx.clone(), + })) + } else { + std::option::Option::None + } } } - } - }) + }, + ) } pub fn parser_state_base_var( @@ -447,11 +450,11 @@ pub fn parser_state_base_var( base.clone(), si.clone(), )), - _ => None, + _ => std::option::Option::None, }, - None => None, + None => std::option::Option::None, }, - _ => None, + _ => std::option::Option::None, } } @@ -506,30 +509,35 @@ pub fn parser_state_arg_expr( ) .iter() .cloned() - .fold(None, |acc: _, pair: (i64, Rc)| { - if (acc.clone() != None) { - acc.clone() - } else { - { - let idx = pair.0.clone(); - let arg_node = pair.1.clone(); - let matches_state = - if (crate::v1_std_core::arg_name_at(arg_node.clone(), si.clone()).as_deref() - != Some("".to_string()).as_deref()) - { - (crate::v1_std_core::arg_name_at(arg_node.clone(), si.clone()).as_deref() - == Some(state_param.name.clone()).as_deref()) + .fold( + std::option::Option::None, + |acc: _, pair: (i64, Rc)| { + if (acc.clone() != std::option::Option::None) { + acc.clone() + } else { + { + let idx = pair.0.clone(); + let arg_node = pair.1.clone(); + let matches_state = + if (crate::v1_std_core::arg_name_at(arg_node.clone(), si.clone()) + .as_deref() + != Some("".to_string()).as_deref()) + { + (crate::v1_std_core::arg_name_at(arg_node.clone(), si.clone()) + .as_deref() + == Some(state_param.name.clone()).as_deref()) + } else { + (idx.clone() == state_param.index.clone()) + }; + if matches_state.clone() { + Some(crate::v1_std_core::arg_value(arg_node.clone())) } else { - (idx.clone() == state_param.index.clone()) - }; - if matches_state.clone() { - Some(crate::v1_std_core::arg_value(arg_node.clone())) - } else { - None + std::option::Option::None + } } } - } - }) + }, + ) } pub fn parser_state_expr_progress( @@ -1572,7 +1580,10 @@ pub fn parser_function_names( let mut __result = Vec::new(); for name in Rc::new(v1_rt::map_keys(&func_index)).iter().cloned() { if match v1_rt::map_get(&func_index, name.clone()) { - Some(entry) => (parser_state_param(entry.params.clone(), si.clone()) != None), + Some(entry) => { + (parser_state_param(entry.params.clone(), si.clone()) + != std::option::Option::None) + } None => false, } { __result.push(name); @@ -1708,7 +1719,10 @@ pub fn collect_parser_edges_for_scc( let mut __all = true; for name in members.iter().cloned() { if !(match v1_rt::map_get(&func_index, name.clone()) { - Some(entry) => (parser_state_param(entry.params.clone(), si.clone()) != None), + Some(entry) => { + (parser_state_param(entry.params.clone(), si.clone()) + != std::option::Option::None) + } None => false, }) { __all = false; @@ -1779,7 +1793,7 @@ pub fn classify_parser_scc_recursion_pattern( si.clone(), ); if ((edges.clone().len() as i64) == 0) { - None + std::option::Option::None } else { { let all_known = { @@ -1801,7 +1815,7 @@ pub fn classify_parser_scc_recursion_pattern( }, ))) } else { - None + std::option::Option::None } } } @@ -2344,7 +2358,7 @@ pub fn target_call_has_arithmetic_descent( (v1_rt::map_get( &callee_measure_params, param_name.clone(), - ) != None) + ) != std::option::Option::None) } None => false, }) @@ -2461,11 +2475,11 @@ pub fn expr_descending_witness_source( continue; } _ => { - break None; + break std::option::Option::None; } }, _ => { - break None; + break std::option::Option::None; } } } @@ -3019,7 +3033,7 @@ pub fn list_passthrough_inner( } pub fn is_list_passthrough_call(expr: Rc, si: Rc>>) -> bool { - (list_passthrough_inner(expr.clone(), si.clone()) != None) + (list_passthrough_inner(expr.clone(), si.clone()) != std::option::Option::None) } pub fn list_passthrough_inner_arg( @@ -3053,23 +3067,22 @@ pub fn consuming_tokens_arg( expr: Rc, si: Rc>>, ) -> Option> { - expr.children - .clone() - .iter() - .cloned() - .fold(None, |acc: _, child: Rc| match acc.clone() { + expr.children.clone().iter().cloned().fold( + std::option::Option::None, + |acc: _, child: Rc| match acc.clone() { Some(_) => acc.clone(), None => match crate::v1_std_core::arg_name_at(child.clone(), si.clone()) { Some(name) => { if (name.clone() == "tokens".to_string()) { Some(crate::v1_std_core::arg_value(child.clone())) } else { - None + std::option::Option::None } } - None => None, + None => std::option::Option::None, }, - }) + }, + ) } pub fn is_tokens_input_expr( @@ -4243,7 +4256,7 @@ pub fn unwrap_to_match(mut body: Rc) -> Option> { continue; } None => { - break None; + break std::option::Option::None; } }, ExprData::ExprBlock => match body.children.clone().last().cloned() { @@ -4253,11 +4266,11 @@ pub fn unwrap_to_match(mut body: Rc) -> Option> { continue; } None => { - break None; + break std::option::Option::None; } }, _ => { - break None; + break std::option::Option::None; } } } @@ -4606,7 +4619,7 @@ pub fn collect_evidence_incremental( ) -> Option { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match (*body.expr_data.clone()).clone() { - ExprData::ExprLambda => None, + ExprData::ExprLambda => std::option::Option::None, ExprData::ExprLet => { let val = crate::v1_std_core::let_value(body.clone()); let val_ev = collect_evidence_incremental( @@ -4813,7 +4826,7 @@ pub fn collect_evidence_incremental( branching_only.clone(), si.clone(), ), - None => None, + None => std::option::Option::None, }; merge_optional_evidence(val_ev.clone(), body_ev.clone()) } @@ -4850,7 +4863,7 @@ pub fn collect_evidence_incremental( let arms_ev = crate::v1_std_core::match_arm_nodes(body.clone()) .iter() .cloned() - .fold(None, |acc: _, arm_node: Rc| { + .fold(std::option::Option::None, |acc: _, arm_node: Rc| { let is_base_case = if branching_only.clone() { (max_path_self_calls( crate::v1_std_core::arm_body(arm_node.clone()), @@ -4940,7 +4953,7 @@ pub fn collect_evidence_incremental( 0 }; let then_ev = if (branching_only.clone() && (then_path.clone() == 0)) { - None + std::option::Option::None } else { collect_evidence_incremental( then_branch.clone(), @@ -4954,7 +4967,7 @@ pub fn collect_evidence_incremental( ) }; let else_ev = if (branching_only.clone() && (else_path.clone() == 0)) { - None + std::option::Option::None } else { match else_opt.clone() { Some(eb) => collect_evidence_incremental( @@ -4967,7 +4980,7 @@ pub fn collect_evidence_incremental( branching_only.clone(), si.clone(), ), - None => None, + None => std::option::Option::None, } }; merge_optional_evidence( @@ -5002,32 +5015,30 @@ pub fn collect_evidence_incremental( Some(arg_evidence.clone()) } } else { - None + std::option::Option::None }; - let child_evidence = - body.children - .clone() - .iter() - .cloned() - .fold(None, |acc: _, child: Rc| { - let ce = collect_evidence_incremental( - child.clone(), - func_name.clone(), - param_name.clone(), - vars.clone(), - check_child.clone(), - check_list.clone(), - branching_only.clone(), - si.clone(), - ); - merge_optional_evidence(acc.clone(), ce.clone()) - }); + let child_evidence = body.children.clone().iter().cloned().fold( + std::option::Option::None, + |acc: _, child: Rc| { + let ce = collect_evidence_incremental( + child.clone(), + func_name.clone(), + param_name.clone(), + vars.clone(), + check_child.clone(), + check_list.clone(), + branching_only.clone(), + si.clone(), + ); + merge_optional_evidence(acc.clone(), ce.clone()) + }, + ); merge_optional_evidence(own_evidence.clone(), child_evidence.clone()) } ExprData::ExprBlock => { let result = body.children.clone().iter().cloned().fold( Rc::new(EvidenceBlockAcc { - evidence: None, + evidence: std::option::Option::None, vars: vars.clone(), }), |acc: Rc, stmt: Rc| { @@ -5087,7 +5098,7 @@ pub fn collect_evidence_incremental( let args_ev = crate::v1_std_core::method_arg_nodes(body.clone()) .iter() .cloned() - .fold(None, |acc: _, arg_node: Rc| { + .fold(std::option::Option::None, |acc: _, arg_node: Rc| { let arg_val = crate::v1_std_core::arg_value(arg_node.clone()); let ev = match (*arg_val.expr_data.clone()).clone() { ExprData::ExprLambda => match iteration_element_name( @@ -5112,7 +5123,7 @@ pub fn collect_evidence_incremental( si.clone(), ) } - None => None, + None => std::option::Option::None, }, _ => collect_evidence_incremental( arg_val.clone(), @@ -5130,11 +5141,9 @@ pub fn collect_evidence_incremental( merge_optional_evidence(recv_ev.clone(), args_ev.clone()) } } else { - body.children - .clone() - .iter() - .cloned() - .fold(None, |acc: _, child: Rc| { + body.children.clone().iter().cloned().fold( + std::option::Option::None, + |acc: _, child: Rc| { let ce = collect_evidence_incremental( child.clone(), func_name.clone(), @@ -5146,15 +5155,13 @@ pub fn collect_evidence_incremental( si.clone(), ); merge_optional_evidence(acc.clone(), ce.clone()) - }) + }, + ) } } - _ => body - .children - .clone() - .iter() - .cloned() - .fold(None, |acc: _, child: Rc| { + _ => body.children.clone().iter().cloned().fold( + std::option::Option::None, + |acc: _, child: Rc| { let ce = collect_evidence_incremental( child.clone(), func_name.clone(), @@ -5166,7 +5173,8 @@ pub fn collect_evidence_incremental( si.clone(), ); merge_optional_evidence(acc.clone(), ce.clone()) - }), + }, + ), } }) } @@ -5192,7 +5200,7 @@ pub fn try_type_directed_dimension( param: param_name.clone(), })]), })), - _ => None, + _ => std::option::Option::None, }, IterationDimension::CollectionFold => match try_dimension_for_param( body.clone(), @@ -5207,7 +5215,7 @@ pub fn try_type_directed_dimension( param: param_name.clone(), })]), })), - _ => None, + _ => std::option::Option::None, }, IterationDimension::ArithmeticRepeat => match try_dimension_for_param( body.clone(), @@ -5222,7 +5230,7 @@ pub fn try_type_directed_dimension( param: param_name.clone(), })]), })), - _ => None, + _ => std::option::Option::None, }, } } @@ -5235,10 +5243,9 @@ pub fn construct_termination_proof( si: Rc>>, ) -> Option> { { - let structural_proof = params - .iter() - .cloned() - .fold(None, |best: _, p: Rc| match best.clone() { + let structural_proof = params.iter().cloned().fold( + std::option::Option::None, + |best: _, p: Rc| match best.clone() { Some(_) => best.clone(), None => { let pname = crate::v1_std_core::param_node_name_at(p.clone(), si.clone()); @@ -5309,7 +5316,7 @@ pub fn construct_termination_proof( )]), })) } - _ => None, + _ => std::option::Option::None, } } } @@ -5318,7 +5325,8 @@ pub fn construct_termination_proof( } } } - }); + }, + ); let single_dim_proof = match structural_proof.clone() { Some(_) => structural_proof.clone(), None => match parser_state_param(params.clone(), si.clone()) { @@ -5350,10 +5358,10 @@ pub fn construct_termination_proof( })]), })) } else { - None + std::option::Option::None } } - None => None, + None => std::option::Option::None, }, }; match single_dim_proof.clone() { @@ -5385,10 +5393,9 @@ pub fn construct_branching_termination_proof( params: Rc>>, si: Rc>>, ) -> Option> { - params - .iter() - .cloned() - .fold(None, |best: _, p: Rc| match best.clone() { + params.iter().cloned().fold( + std::option::Option::None, + |best: _, p: Rc| match best.clone() { Some(_) => best.clone(), None => { let pname = crate::v1_std_core::param_node_name_at(p.clone(), si.clone()); @@ -5411,7 +5418,7 @@ pub fn construct_branching_termination_proof( param: pname.clone(), })]), })), - _ => None, + _ => std::option::Option::None, } } Some(IterationDimension::CollectionFold) => { @@ -5428,10 +5435,10 @@ pub fn construct_branching_termination_proof( param: pname.clone(), })]), })), - _ => None, + _ => std::option::Option::None, } } - Some(IterationDimension::ArithmeticRepeat) => None, + Some(IterationDimension::ArithmeticRepeat) => std::option::Option::None, None => { let tree_ev = try_branching_dimension_for_param( body.clone(), @@ -5466,14 +5473,15 @@ pub fn construct_branching_termination_proof( )]), })) } - _ => None, + _ => std::option::Option::None, } } } } } } - }) + }, + ) } pub fn proof_to_call_pattern(proof: Rc) -> Rc { @@ -5751,7 +5759,7 @@ pub fn classify_recursion_pattern( si.clone(), ) } else { - None + std::option::Option::None }; let branching_proof_safe = match branching_proof.clone() { Some(bp) => { @@ -6246,7 +6254,8 @@ pub fn collect_scc_child_edges( si.clone(), ) { Some(aname) => { - (v1_rt::map_get(&callee_params, aname.clone()) != None) + (v1_rt::map_get(&callee_params, aname.clone()) + != std::option::Option::None) } None => false, }; @@ -7484,7 +7493,7 @@ pub fn construct_scc_termination_proof( { Some(tp_proof.clone()) } else { - None + std::option::Option::None } } } @@ -7822,9 +7831,9 @@ pub fn cost_account_space_from_summary( match summary.peak_space.clone() { Some(ps) => match eval_cost_expr_concrete(ps.clone(), size_env.clone()) { Some(bytes) => Some(crate::std_measure::byte_size(bytes.clone())), - None => None, + None => std::option::Option::None, }, - None => None, + None => std::option::Option::None, } } @@ -7849,9 +7858,9 @@ pub fn cost_expr_degree(e: Rc) -> Option { } else { rd.clone() }), - None => None, + None => std::option::Option::None, }, - None => None, + None => std::option::Option::None, }, CostExpr::CostMax { left: l, right: r, .. @@ -7862,26 +7871,26 @@ pub fn cost_expr_degree(e: Rc) -> Option { } else { rd.clone() }), - None => None, + None => std::option::Option::None, }, - None => None, + None => std::option::Option::None, }, CostExpr::CostMul { left: l, right: r, .. } => match cost_expr_degree(l.clone()) { Some(ld) => match cost_expr_degree(r.clone()) { Some(rd) => Some((ld.clone() + rd.clone())), - None => None, + None => std::option::Option::None, }, - None => None, + None => std::option::Option::None, }, CostExpr::CostSum { body: bd, .. } => match cost_expr_degree(bd.clone()) { Some(bdeg) => Some((1 + bdeg.clone())), - None => None, + None => std::option::Option::None, }, CostExpr::CostLog { .. } => Some(0), - CostExpr::CostExtern { name: _, .. } => None, - CostExpr::CostUnknown { reason: _, .. } => None, + CostExpr::CostExtern { name: _, .. } => std::option::Option::None, + CostExpr::CostUnknown { reason: _, .. } => std::option::Option::None, }) } @@ -7917,9 +7926,9 @@ pub fn eval_size_expr_concrete(s: Rc, env: Rc>) - } => match eval_size_expr_concrete(l.clone(), env.clone()) { Some(lv) => match eval_size_expr_concrete(r.clone(), env.clone()) { Some(rv) => Some((lv.clone() + rv.clone())), - None => None, + None => std::option::Option::None, }, - None => None, + None => std::option::Option::None, }, SizeExpr::SizeMax { left: l, right: r, .. @@ -7930,9 +7939,9 @@ pub fn eval_size_expr_concrete(s: Rc, env: Rc>) - } else { rv.clone() }), - None => None, + None => std::option::Option::None, }, - None => None, + None => std::option::Option::None, }, }) } @@ -7953,27 +7962,27 @@ pub fn eval_cost_expr_concrete(e: Rc, env: Rc>) - } => match eval_cost_expr_concrete(l.clone(), env.clone()) { Some(lv) => match eval_cost_expr_concrete(r.clone(), env.clone()) { Some(rv) => Some((lv.clone() + rv.clone())), - None => None, + None => std::option::Option::None, }, - None => None, + None => std::option::Option::None, }, CostExpr::CostMul { left: l, right: r, .. } => match eval_cost_expr_concrete(l.clone(), env.clone()) { Some(lv) => match eval_cost_expr_concrete(r.clone(), env.clone()) { Some(rv) => Some((lv.clone() * rv.clone())), - None => None, + None => std::option::Option::None, }, - None => None, + None => std::option::Option::None, }, CostExpr::CostMax { left: l, right: r, .. } => match eval_cost_expr_concrete(l.clone(), env.clone()) { Some(lv) => match eval_cost_expr_concrete(r.clone(), env.clone()) { Some(rv) => Some(int_max2(lv.clone(), rv.clone())), - None => None, + None => std::option::Option::None, }, - None => None, + None => std::option::Option::None, }, CostExpr::CostSum { upper: up, @@ -7982,13 +7991,13 @@ pub fn eval_cost_expr_concrete(e: Rc, env: Rc>) - } => match eval_size_expr_concrete(up.clone(), env.clone()) { Some(n) => match eval_cost_expr_concrete(bd.clone(), env.clone()) { Some(bv) => Some((n.clone() * bv.clone())), - None => None, + None => std::option::Option::None, }, - None => None, + None => std::option::Option::None, }, - CostExpr::CostLog { .. } => None, - CostExpr::CostExtern { name: _, .. } => None, - CostExpr::CostUnknown { reason: _, .. } => None, + CostExpr::CostLog { .. } => std::option::Option::None, + CostExpr::CostExtern { name: _, .. } => std::option::Option::None, + CostExpr::CostUnknown { reason: _, .. } => std::option::Option::None, }) } @@ -8011,7 +8020,7 @@ pub fn scalar_output() -> Rc>> { } pub fn method_preserves_collection_size(method_semantics: Option>) -> bool { - if (method_semantics.clone() == None) { + if (method_semantics.clone() == std::option::Option::None) { false } else { match (*method_semantics.clone().unwrap()).clone() { @@ -9304,8 +9313,8 @@ pub fn cost_of_expr( ); let size = receiver_size_var(recv.clone(), si.clone()); let binder = size_binder_name(size.clone()); - let method_cost_result = if (ms.clone() == None) { - None + let method_cost_result = if (ms.clone() == std::option::Option::None) { + std::option::Option::None } else { match (*ms.clone().unwrap()).clone() { MethodSemantics::AlgebraMethodSemantics { @@ -9349,7 +9358,7 @@ pub fn cost_of_expr( })), } } - _ => None, + _ => std::option::Option::None, } }; match method_cost_result.clone() { @@ -9810,9 +9819,9 @@ pub fn get_or_compute_summary( Some(entry) => { let target = match v1_rt::map_get(&scc_index, func_name.clone()) { Some(info) => Some(info.pattern.clone()), - None => None, + None => std::option::Option::None, }; - let is_recursive = (target.clone() != None); + let is_recursive = (target.clone() != std::option::Option::None); let zero_placeholder = Rc::new(ComplexitySummary { work: Rc::new(CostExpr::CostConst { value: 0 }), span: Rc::new(CostExpr::CostConst { value: 0 }), @@ -9896,7 +9905,8 @@ pub fn get_or_compute_summary( }) } None => { - let is_unexpected_miss = (v1_rt::map_get(&scc_index, func_name.clone()) != None); + let is_unexpected_miss = + (v1_rt::map_get(&scc_index, func_name.clone()) != std::option::Option::None); if is_unexpected_miss.clone() { { let miss_summary = Rc::new(ComplexitySummary { @@ -9957,14 +9967,15 @@ pub fn collect_call_evidence( .. } => { let callee = crate::v1_std_core::expr_call_func_at(body.clone(), si.clone()); - let own = if (v1_rt::map_get(&target_set, callee.clone()) != None) { - match de.clone() { - Some(evidence) => Rc::new(vec![evidence.clone()]), - None => Rc::new(vec![]), - } - } else { - Rc::new(vec![]) - }; + let own = + if (v1_rt::map_get(&target_set, callee.clone()) != std::option::Option::None) { + match de.clone() { + Some(evidence) => Rc::new(vec![evidence.clone()]), + None => Rc::new(vec![]), + } + } else { + Rc::new(vec![]) + }; let from_children = body.children.clone().iter().cloned().fold( Rc::new(vec![]), |acc: _, child: Rc| { @@ -10071,7 +10082,7 @@ pub fn extract_shrink_factor( |acc: Option>, call_evidence: Rc>>| match acc .clone() { - None => None, + None => std::option::Option::None, Some(prev) => match call_evidence .clone() .iter() @@ -10087,7 +10098,7 @@ pub fn extract_shrink_factor( if (prev.clone() == f.clone()) { acc.clone() } else { - None + std::option::Option::None } } } @@ -10099,7 +10110,7 @@ pub fn extract_shrink_factor( if (prev.clone() == f.clone()) { acc.clone() } else { - None + std::option::Option::None } } } diff --git a/src/v1/stage0/src/v1_compiler_dag_collect.rs b/src/v1/stage0/src/v1_compiler_dag_collect.rs index 3a91dee1b61..fae770a5480 100644 --- a/src/v1/stage0/src/v1_compiler_dag_collect.rs +++ b/src/v1/stage0/src/v1_compiler_dag_collect.rs @@ -22,17 +22,18 @@ use std::rc::Rc; pub fn is_import_slot_node(n: Rc) -> bool { (crate::v1_std_core::import_is_all(n.clone()) - || (((((n.params.clone().len() as i64) == 0) && (n.ident_span.clone() != None)) - && (n.body.clone() == None)) + || (((((n.params.clone().len() as i64) == 0) + && (n.ident_span.clone() != std::option::Option::None)) + && (n.body.clone() == std::option::Option::None)) && (n.expr_data.clone() == Rc::new(ExprData::NoExprData)))) } pub fn is_module_shell_node(n: Rc) -> bool { - (((((((n.inferred.clone() == None) + (((((((n.inferred.clone() == std::option::Option::None) && (n.expr_data.clone() == Rc::new(ExprData::NoExprData))) && (n.connective.clone() == Connective::NoConnective)) - && (n.body.clone() == None)) - && (n.transport.clone() == None)) + && (n.body.clone() == std::option::Option::None)) + && (n.transport.clone() == std::option::Option::None)) && ((n.uses.clone().len() as i64) == 0)) && { let mut __all = true; @@ -50,7 +51,8 @@ pub fn dag_node_is_resolved_identity_shell(node: Rc) -> bool { match (*node.expr_data.clone()).clone() { ExprData::NoExprData => match node.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: _, .. }) => { - ((((node.body.clone() == None) && (node.transport.clone() == None)) + ((((node.body.clone() == std::option::Option::None) + && (node.transport.clone() == std::option::Option::None)) && ((node.children.clone().len() as i64) == 0)) && ((node.params.clone().len() as i64) == 0)) } diff --git a/src/v1/stage0/src/v1_compiler_emit.rs b/src/v1/stage0/src/v1_compiler_emit.rs index 8555a301869..7da56f5fecd 100644 --- a/src/v1/stage0/src/v1_compiler_emit.rs +++ b/src/v1/stage0/src/v1_compiler_emit.rs @@ -261,7 +261,7 @@ pub fn collect_type_names_from_node( source_indices: Rc>>, ) -> Rc> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let self_name = if (n.ident_span.clone() != None) { + let self_name = if (n.ident_span.clone() != std::option::Option::None) { Rc::new(vec![crate::v1_std_core::authored_name_at( source_indices.clone(), n.clone(), @@ -694,7 +694,7 @@ pub fn order_typed_call_args( if (crate::v1_std_core::arg_name_at( arg.clone(), scope.type_env.clone().source_indices.clone(), - ) == None) + ) == std::option::Option::None) { __found = true; break; @@ -715,7 +715,7 @@ pub fn order_typed_call_args( arg.clone(), scope.type_env.clone().source_indices.clone(), ); - if (n.clone() != None) { + if (n.clone() != std::option::Option::None) { v1_rt::rc_map_insert(acc.clone(), n.clone().unwrap(), arg.clone()) } else { acc.clone() @@ -789,7 +789,7 @@ pub fn order_typed_call_args( arg.clone(), scope.type_env.clone().source_indices.clone(), ); - if (n.clone() == None) { + if (n.clone() == std::option::Option::None) { true } else { (crate::v1_compiler_infer_types::emit_map_has( @@ -1560,12 +1560,12 @@ pub fn render_node_type( ) -> String { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let tn = crate::v1_std_core::authored_name_at(source_indices.clone(), n.clone()); - let n_is_error = if (n.inferred.clone() != None) { + let n_is_error = if (n.inferred.clone() != std::option::Option::None) { crate::v1_std_core::is_compiler_error(n.inferred.clone().clone().unwrap()) } else { false }; - let n_is_type_var = if (n.inferred.clone() != None) { + let n_is_type_var = if (n.inferred.clone() != std::option::Option::None) { is_type_variable(n.inferred.clone().clone().unwrap()) } else { false @@ -1690,7 +1690,7 @@ pub fn render_node_type( ); if is_disj.clone() { { - let base = if (n.ident_span.clone() != None) { + let base = if (n.ident_span.clone() != std::option::Option::None) { render_named_type_base(n.clone(), target.clone(), source_indices.clone()) } else { { @@ -1712,7 +1712,7 @@ pub fn render_node_type( } if is_conj.clone() { { - if (n.type_annotation.clone() != None) { + if (n.type_annotation.clone() != std::option::Option::None) { { let refined_str = match n.children.clone().first().cloned() { Some(base) => render_node_type( @@ -1731,13 +1731,13 @@ pub fn render_node_type( } } let is_pair = (((n.connective.clone() == Connective::Conj) - && (n.ident_span.clone() == None)) + && (n.ident_span.clone() == std::option::Option::None)) && ((n.children.clone().len() as i64) == 2)); if is_pair.clone() { { let first_child = match n.children.clone().first().cloned() { Some(c) => { - if (c.inferred.clone() != None) { + if (c.inferred.clone() != std::option::Option::None) { render_node_type( crate::v1_compiler_infer_types::resolved_type(c.clone()), target.clone(), @@ -1758,7 +1758,7 @@ pub fn render_node_type( let second_child = match n.children.clone().iter().cloned().skip(1 as usize).next() { Some(c) => { - if (c.inferred.clone() != None) { + if (c.inferred.clone() != std::option::Option::None) { render_node_type( crate::v1_compiler_infer_types::resolved_type( c.clone(), @@ -1785,7 +1785,7 @@ pub fn render_node_type( return tuple_str; } } - if (n.ident_span.clone() != None) { + if (n.ident_span.clone() != std::option::Option::None) { { let snake = crate::v1_compiler_emit_core_support::to_snake(tn.clone()); let has_template = @@ -2093,7 +2093,7 @@ pub fn has_service_items(typed: Rc) -> bool { } pub fn service_fallback_transport(item: Rc) -> Rc { - if (item.transport.clone() == None) { + if (item.transport.clone() == std::option::Option::None) { crate::v1_std_core::local_transport_node( Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), item.span.clone(), @@ -2123,7 +2123,7 @@ pub fn service_has_rest( let from_ops = { let mut __found = false; for op in op_children.iter().cloned() { - if if (op.transport.clone() != None) { + if if (op.transport.clone() != std::option::Option::None) { crate::v1_std_core::is_rest_transport( op.transport.clone().clone().unwrap(), source_indices.clone(), @@ -2147,7 +2147,7 @@ pub fn service_has_shell(fallback_transport: Rc, op_children: Rc Option { { Some(FileResultChannel::FileChanContent) } else { - None + std::option::Option::None } } } @@ -2498,7 +2498,7 @@ pub fn bind_file_result_field( channel: c.clone(), optional: (ch.return_cardinality.clone() == Cardinality::CardOptional), })), - None => None, + None => std::option::Option::None, } } @@ -4610,16 +4610,16 @@ pub fn child_from_key( }; Some(s.clone()) } - _ => None, + _ => std::option::Option::None, }, - None => None, + None => std::option::Option::None, } } pub fn unwrap_single_field_product(n: Rc) -> Rc { { let is_product = crate::v1_compiler_infer_types::is_product_type(n.clone()); - if ((is_product.clone() && (n.ident_span.clone() == None)) + if ((is_product.clone() && (n.ident_span.clone() == std::option::Option::None)) && ((n.children.clone().len() as i64) == 1)) { match n.children.clone().first().cloned() { @@ -4697,9 +4697,9 @@ pub fn file_transport_declared_verb( }; Some(s.clone()) } - _ => None, + _ => std::option::Option::None, }, - None => None, + None => std::option::Option::None, } } @@ -4796,11 +4796,11 @@ pub fn file_emission_verb_refusal( if ((v.clone() == file_transport_verb_delete()) || (v.clone() == file_transport_verb_list())) { - None + std::option::Option::None } else { if (v.clone() == file_transport_verb_write_owner_only()) { if file_operation_has_content_input(op_node.clone(), source_indices.clone()) { - None + std::option::Option::None } else { Some(Rc::new(FileEmissionRefusal::FileWriteMissingContentInput { verb: v.clone(), @@ -4813,7 +4813,7 @@ pub fn file_emission_verb_refusal( } } } - None => None, + None => std::option::Option::None, } } @@ -4870,7 +4870,7 @@ pub fn file_binding_refusal( key: k.clone(), })) } - None => None, + None => std::option::Option::None, } } } @@ -5888,7 +5888,7 @@ pub fn method_template_emit_for_target( Some(crate::extdeps_languages_python_emit::python_method_templates_flat()) } RenderTarget::Go => Some(crate::extdeps_languages_go_emit::go_method_templates_flat()), - RenderTarget::Dag => None, + RenderTarget::Dag => std::option::Option::None, } } @@ -5911,9 +5911,9 @@ pub fn emit_algebra_method_template( bindings.clone(), )) } - None => None, + None => std::option::Option::None, }, - None => None, + None => std::option::Option::None, } } @@ -6368,7 +6368,7 @@ pub fn emit_typed_method_call_unified( { let spec = crate::v1_compiler_emit_core_support::language_spec(target.clone()); let source_indices = scope.type_env.clone().source_indices.clone(); - if (method_semantics.clone() != None) { + if (method_semantics.clone() != std::option::Option::None) { match (*method_semantics.clone().unwrap()).clone() { MethodSemantics::ServiceMethodSemantics { service_name: svc_name, @@ -7074,7 +7074,7 @@ pub fn emit_unified_typed_expr( IfValueForm::IfStatement => { Some(crate::v1_compiler_infer_types::resolved_type(expr.clone())) } - _ => None, + _ => std::option::Option::None, }; emit_typed_if_shared( cond_str.clone(), diff --git a/src/v1/stage0/src/v1_compiler_emit_core_support.rs b/src/v1/stage0/src/v1_compiler_emit_core_support.rs index 108542fc4e8..d2e7255a4f7 100644 --- a/src/v1/stage0/src/v1_compiler_emit_core_support.rs +++ b/src/v1/stage0/src/v1_compiler_emit_core_support.rs @@ -754,17 +754,20 @@ pub fn is_type_alias_return_node( } pub fn is_service_item(item: Rc) -> bool { - ((item.transport.clone() != None) && ((item.children.clone().len() as i64) > 0)) + ((item.transport.clone() != std::option::Option::None) + && ((item.children.clone().len() as i64) > 0)) } pub fn is_type_def_item(item: Rc) -> bool { - ((item.connective.clone() != Connective::NoConnective) && (item.transport.clone() == None)) + ((item.connective.clone() != Connective::NoConnective) + && (item.transport.clone() == std::option::Option::None)) } pub fn is_bare_leaf_item(item: Rc) -> bool { - (((((item.connective.clone() == Connective::NoConnective) && (item.body.clone() == None)) + (((((item.connective.clone() == Connective::NoConnective) + && (item.body.clone() == std::option::Option::None)) && ((item.params.clone().len() as i64) == 0)) - && (item.transport.clone() == None)) + && (item.transport.clone() == std::option::Option::None)) && ((item.children.clone().len() as i64) == 0)) } @@ -788,26 +791,32 @@ pub fn is_type_decl_item( crate::v1_compiler_infer_types::resolved_type(item.clone()), source_indices.clone(), )) - || (((((item.params.clone().len() as i64) > 0) && (item.body.clone() == None)) - && (item.transport.clone() == None)) + || (((((item.params.clone().len() as i64) > 0) + && (item.body.clone() == std::option::Option::None)) + && (item.transport.clone() == std::option::Option::None)) && ((item.children.clone().len() as i64) == 0))) } pub fn is_function_item(item: Rc) -> bool { - ((item.body.clone() != None) && (item.type_annotation.clone() == None)) + ((item.body.clone() != std::option::Option::None) + && (item.type_annotation.clone() == std::option::Option::None)) } pub fn is_data_def_item(item: Rc) -> bool { - ((item.body.clone() != None) && (item.type_annotation.clone() != None)) + ((item.body.clone() != std::option::Option::None) + && (item.type_annotation.clone() != std::option::Option::None)) } pub fn is_service_def_item(item: Rc) -> bool { - ((item.transport.clone() != None) && ((item.children.clone().len() as i64) > 0)) + ((item.transport.clone() != std::option::Option::None) + && ((item.children.clone().len() as i64) > 0)) } pub fn is_resource_def_item(item: Rc) -> bool { - (((item.transport.clone() == None) && ((item.children.clone().len() as i64) > 0)) - || ((((item.transport.clone() == None) && ((item.children.clone().len() as i64) == 0)) + (((item.transport.clone() == std::option::Option::None) + && ((item.children.clone().len() as i64) > 0)) + || ((((item.transport.clone() == std::option::Option::None) + && ((item.children.clone().len() as i64) == 0)) && ((item.properties.clone().len() as i64) > 0)) - && (item.body.clone() == None))) + && (item.body.clone() == std::option::Option::None))) } diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index c6ef91580a3..96efe947dca 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -35,6 +35,7 @@ pub use crate::gunbc_stage0_emitted_population_manifest::{ emitted_population_manifest_basename, emitted_population_manifest_line_prefix, emitted_population_manifest_line_separator, }; +pub use crate::gunbc_structural_realization_bindings::structural_ordering_rows; pub use crate::std_algebra::trim; pub use crate::std_coercion::TypeCheckpoint; pub use crate::std_content_hash::Fnv1a64Structural; @@ -46,9 +47,26 @@ pub use crate::std_measure::millisecond_count; pub use crate::std_nat::Nat; pub use crate::std_occurrence_identity::NodeOccurrenceIdentity; use crate::std_occurrence_identity::NodeOccurrenceIdentity::OccurrenceSynthetic; +use crate::std_operator_realization::OperandRealization::{ + HostNumericOperand, OperandIdentityUnavailable, StructuralOperand, +}; +use crate::std_operator_realization::OperatorRealization::{ + HostOperator, OperatorRealizationRefused, StructuralComparison, StructuralEquality, +}; +use crate::std_operator_realization::OrderingTest::{OrderingIs, OrderingIsNot}; +pub use crate::std_operator_realization::{ + operator_realization_for, operator_realization_refusal_message, +}; +pub use crate::std_operator_realization::{ + OperandRealization, OperatorRealization, OrderingTest, StructuralOrderingBinding, +}; pub use crate::std_primitive_projection::{ primitive_identity_runtime_name, primitive_projection_row_for_declaration, }; +pub use crate::std_repair_input_origin::{ + qualified_item_emit_surface_compatibility_names, repair_input_origin_candidates, + repair_input_origin_compatibility_names, +}; use crate::std_serialization::VariantEncoding::*; use crate::std_serialization::VariantNaming::*; pub use crate::std_serialization::{CoproductWireContract, VariantEncoding, VariantNaming}; @@ -68,8 +86,9 @@ pub use crate::v1_compiler_closure_stub_v2_std_integer_rust::closure_stub_v2_std pub use crate::v1_compiler_closure_stub_v2_std_text_rust::closure_stub_v2_std_text_source; pub use crate::v1_compiler_coercion::decl_identity_file; pub use crate::v1_compiler_coercion::{ - coerce_primitive_type, is_copy, lookup_checkpoint, rust_lookup_exact_binding, - rust_seed_host_numeric_alias, target_callable, type_reference_decl_file, + coerce_primitive_type, declaration_realizes_natively_on_rust, is_copy, lookup_checkpoint, + rust_lookup_exact_binding, rust_seed_host_numeric_alias, target_callable, + type_reference_decl_file, }; pub use crate::v1_compiler_compiler_tests_rust::compiler_tests_source; use crate::v1_compiler_emit::BoundOperation::{ @@ -129,7 +148,8 @@ use crate::v1_compiler_infer_env::GlobalBareLookupState::{ GlobalBareAmbiguousBinding, GlobalBareUniqueBinding, }; pub use crate::v1_compiler_infer_env::{ - authored_name, empty_symbol_index, lookup_type_by_name, lookup_type_for, + authored_name, binding_declares_span, empty_symbol_index, lookup_type_by_name, lookup_type_for, + type_reference_declaration_ref, }; pub use crate::v1_compiler_infer_env::{GlobalBareLookupState, TypeBinding, TypeEnv}; pub use crate::v1_compiler_infer_items::item_kind; @@ -463,11 +483,12 @@ pub fn render_rust_type_without_applied_binding( Some(elem_child) => { let elem_node = crate::v1_compiler_infer_types::child_type_node(elem_child.clone()); - let elem_is_type_var = if (elem_node.inferred.clone() != None) { - is_type_variable(elem_node.inferred.clone().clone().unwrap()) - } else { - false - }; + let elem_is_type_var = + if (elem_node.inferred.clone() != std::option::Option::None) { + is_type_variable(elem_node.inferred.clone().clone().unwrap()) + } else { + false + }; if elem_is_type_var.clone() { emit_rust_compile_error_expr( "Set element type unresolved".to_string(), @@ -829,7 +850,7 @@ pub fn rust_host_string_seam_fn_emit(name: String) -> Option { if (name.clone() == "host_string_text_to_rust_host".to_string()) { Some(v1_rt::concat(v1_rt::concat("pub fn host_string_text_to_rust_host(text: String) -> String {\n".to_string(), " v1_rt::fold_list(text, String::new(), |acc, cp| v1_rt::concat(acc, v1_rt::from_code_point(cp)))\n".to_string()), "}\n".to_string())) } else { - None + std::option::Option::None } } } @@ -862,7 +883,7 @@ pub fn rust_host_string_op_fn_emit(name: String) -> Option { "}\n".to_string(), )) } else { - None + std::option::Option::None } } } @@ -883,7 +904,7 @@ pub fn rust_opaque_kernel_alias_carrier(name: String) -> Option { "".to_string(), )) } else { - None + std::option::Option::None } } @@ -993,7 +1014,7 @@ pub fn rust_scalar_checkpoint_spelling( decl_file.clone(), ) { Some(host) => Some(host.clone()), - None => None, + None => std::option::Option::None, }, } } @@ -1023,12 +1044,12 @@ pub fn rust_render_checkpoint_scalar_bare( env: Rc, ) -> Option { if ((n.children.clone().len() as i64) == 0) { - None + std::option::Option::None } else { { let leaf = rust_fn_sig_leaf_name(source_indices.clone(), n.clone()); if crate::std_types::is_container_type(leaf.clone()) { - return None; + return std::option::Option::None; } match rust_exact_reference_spelling(n.clone(), source_indices.clone(), env.clone()) { Some(exact) => Some(exact.clone()), @@ -1053,7 +1074,7 @@ pub fn rust_render_checkpoint_scalar_bare( Some(scalar.clone()) } } - None => None, + None => std::option::Option::None, }, }, } @@ -1061,76 +1082,6 @@ pub fn rust_render_checkpoint_scalar_bare( } } -pub fn binding_declares_span(binding: Rc, sp: Rc) -> bool { - match binding.resolved.clone().ident_span.clone() { - Some(s) => ((s.file.clone() == sp.file.clone()) && (s.start.clone() == sp.start.clone())), - None => false, - } -} - -pub fn type_reference_declaration_ref( - n: Rc, - source_indices: Rc>>, - env: Rc, -) -> Option> { - { - let rt = match n.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: r, .. }) => r.clone(), - _ => n.clone(), - }; - let decl_name = crate::v1_std_core::qualified_last_segment( - crate::v1_std_core::authored_name_at(source_indices.clone(), rt.clone()), - ); - if (decl_name.clone() == "".to_string()) { - return None; - } - match rt.ident_span.clone() { - None => None, - Some(sp) => match v1_rt::map_get( - &env.symbol_index.clone().global_bare.clone(), - decl_name.clone(), - ) - .as_deref() - .cloned() - { - Some(GlobalBareLookupState::GlobalBareUniqueBinding { - module_path: mp, - binding: b, - .. - }) => { - if binding_declares_span(b.clone(), sp.clone()) { - Some(crate::std_decl_ref::decl_ref(mp.clone(), decl_name.clone())) - } else { - None - } - } - Some(GlobalBareLookupState::GlobalBareAmbiguousBinding { - candidates: cands, - .. - }) => match Rc::new({ - let mut __result = Vec::new(); - for c in cands.iter().cloned() { - if binding_declares_span(c.binding.clone(), sp.clone()) { - __result.push(c); - } - } - __result - }) - .first() - .cloned() - { - Some(c) => Some(crate::std_decl_ref::decl_ref( - c.module_path.clone(), - decl_name.clone(), - )), - None => None, - }, - None => None, - }, - } - } -} - pub fn rust_exact_binding_spelling( source: Option>, grounding: bool, @@ -1163,8 +1114,10 @@ pub fn rust_exact_binding_spelling( ), " rows for one declaration".to_string(), ))), - ExactBindingResolution::ExactBindingAbsent => None, - ExactBindingResolution::ExactSourceIdentityUnavailable { cause: _, .. } => None, + ExactBindingResolution::ExactBindingAbsent => std::option::Option::None, + ExactBindingResolution::ExactSourceIdentityUnavailable { cause: _, .. } => { + std::option::Option::None + } } } @@ -1174,7 +1127,11 @@ pub fn rust_exact_reference_spelling( env: Rc, ) -> Option { rust_exact_binding_spelling( - type_reference_declaration_ref(n.clone(), source_indices.clone(), env.clone()), + crate::v1_compiler_infer_env::type_reference_declaration_ref( + n.clone(), + source_indices.clone(), + env.clone(), + ), false, ) } @@ -1214,7 +1171,7 @@ pub fn rust_seed_host_container_base(name: String) -> Option { if ((name.clone() == "List".to_string()) || (name.clone() == "FreeMonoid".to_string())) { Some("Vec".to_string()) } else { - None + std::option::Option::None } } @@ -1262,7 +1219,7 @@ pub fn is_host_text_carrier_type( pub fn rust_seed_host_freemonoid_empty(carrier_name: String) -> Option { match rust_seed_host_container_base(carrier_name.clone()) { Some(_) => Some(rust_shared_wrap_ctor("vec![]".to_string())), - None => None, + None => std::option::Option::None, } } @@ -1345,7 +1302,7 @@ pub fn rust_witness_type_arg_admit_rendered( emit_info: Rc, ) -> Option { if ((rendered.clone() == "_".to_string()) || (rendered.clone() == "".to_string())) { - None + std::option::Option::None } else { if (((v1_rt::string_length(&rendered) == 1) && rust_is_uppercase_letter(rendered.clone())) && !type_var_in_fn_generic_scope( @@ -1353,13 +1310,13 @@ pub fn rust_witness_type_arg_admit_rendered( emit_info.fn_generic_param_names.clone(), )) { - None + std::option::Option::None } else { if rust_fold_rendered_type_has_any_spurious_generic( rendered.clone(), emit_info.fn_generic_param_names.clone(), ) { - None + std::option::Option::None } else { Some(rendered.clone()) } @@ -1380,9 +1337,9 @@ pub fn rust_witness_applied_type_arg_node( ) { Some(applied) => match applied.children.clone().first().cloned() { Some(child) => Some(child.clone()), - None => None, + None => std::option::Option::None, }, - None => None, + None => std::option::Option::None, }, } } @@ -1394,17 +1351,17 @@ pub fn rust_witness_carrier_from_type_node( source_indices: Rc>>, ) -> Option { { - if ((type_node.inferred.clone() != None) + if ((type_node.inferred.clone() != std::option::Option::None) && crate::v1_std_core::is_compiler_error(type_node.inferred.clone().clone().unwrap())) { - return None; + return std::option::Option::None; } if type_node_has_unbound_type_variable( type_node.clone(), emit_info.fn_generic_param_names.clone(), source_indices.clone(), ) { - return None; + return std::option::Option::None; } let peeled = rust_peel_all_rc_type_node(type_node.clone(), source_indices.clone()); if (crate::v1_std_core::qualified_last_segment(peeled.name.clone()) @@ -1420,7 +1377,7 @@ pub fn rust_witness_carrier_from_type_node( ), emit_info.clone(), ), - None => None, + None => std::option::Option::None, } } else { rust_witness_type_arg_admit_rendered( @@ -1488,7 +1445,7 @@ pub fn rust_witness_type_arg_from_holds_value_field( ), } } - None => None, + None => std::option::Option::None, } } @@ -1504,7 +1461,7 @@ pub fn rust_witness_type_arg_from_fn_return( emit_info.clone(), source_indices.clone(), ), - None => None, + None => std::option::Option::None, } } @@ -2271,10 +2228,10 @@ pub fn render_rust_decl_type( if ((applied.children.clone().len() as i64) > 0) { Some(applied.clone()) } else { - None + std::option::Option::None } } - None => None, + None => std::option::Option::None, }; match applied_overlay.clone() { Some(applied) => { @@ -2356,7 +2313,7 @@ pub fn render_rust_decl_type( }) { rust_exact_reference_spelling(n.clone(), source_indices.clone(), env.clone()) } else { - None + std::option::Option::None }; match exact_leaf.clone() { Some(exact) => rust_carrier_optional_wrap(n.clone(), exact.clone()), @@ -2378,7 +2335,7 @@ pub fn render_rust_decl_type( } else { if ((((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) == 0)) - && (applied_prop.clone() == None)) + && (applied_prop.clone() == std::option::Option::None)) && is_host_text_carrier_type(n.clone(), source_indices.clone())) { rust_carrier_optional_wrap( @@ -2388,7 +2345,7 @@ pub fn render_rust_decl_type( } else { if ((((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) == 0)) - && (applied_prop.clone() == None)) + && (applied_prop.clone() == std::option::Option::None)) && v1_rt::set_contains(&shared_types, name.clone())) { { @@ -2540,7 +2497,7 @@ pub fn rust_fn_sig_preserves_authored_alias_leaf(name: String, decl_file: String (crate::v1_compiler_coercion::rust_seed_host_numeric_alias( name.clone(), decl_file.clone(), - ) == None) + ) == std::option::Option::None) } } } @@ -2615,7 +2572,7 @@ pub fn render_rust_fn_sig_type( }) { rust_exact_reference_spelling(n.clone(), source_indices.clone(), env.clone()) } else { - None + std::option::Option::None }; match exact_leaf.clone() { Some(exact) => rust_carrier_optional_wrap(n.clone(), exact.clone()), @@ -2794,7 +2751,7 @@ pub fn rust_decl_type_container_arg_needs_resolved_overlay( source_indices.clone(), ) { Some(applied) => Some((applied.children.clone().len() as i64)), - None => None, + None => std::option::Option::None, }; let resolved_child_count = match arg.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => (rt.children.clone().len() as i64), @@ -3041,7 +2998,7 @@ pub fn render_rust_alias_rhs_type( crate::v1_compiler_coercion::type_reference_decl_file(n.clone()), ), }; - if (numeric_host_alias.clone() != None) { + if (numeric_host_alias.clone() != std::option::Option::None) { return match numeric_host_alias.clone() { Some(host) => host.clone(), None => "".to_string(), @@ -3274,20 +3231,20 @@ pub fn type_variable_node(id: String) -> Rc { occurrence_identity: Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), name: "".to_string(), span: crate::v1_std_core::no_span(), - ident_span: None, + ident_span: std::option::Option::None, children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), inferred: Some(Rc::new(InferredNode::TypeVariable { id: id.clone() })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }) @@ -3479,7 +3436,7 @@ pub fn type_leaf_is_unbound_in_closure_scope( } else { match crate::v1_compiler_infer_env::lookup_type_by_name(env.clone(), name.clone()) { Some(resolved_node) => { - if ((resolved_node.inferred.clone() != None) + if ((resolved_node.inferred.clone() != std::option::Option::None) && is_type_variable(resolved_node.inferred.clone().clone().unwrap())) { true @@ -3509,7 +3466,7 @@ pub fn type_node_has_closure_unbound_generic_atom( return true; } } - if (n.inferred.clone() != None) { + if (n.inferred.clone() != std::option::Option::None) { match (*n.inferred.clone().clone().unwrap()).clone() { InferredNode::TypeVariable { id: tv, .. } => { if !type_var_in_fn_generic_scope(tv.clone(), generic_param_names.clone()) { @@ -3578,7 +3535,7 @@ pub fn type_node_has_unbound_type_variable( source_indices: Rc>>, ) -> bool { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - if (n.inferred.clone() != None) { + if (n.inferred.clone() != std::option::Option::None) { match (*n.inferred.clone().clone().unwrap()).clone() { InferredNode::TypeVariable { id: tv, .. } => { if !type_var_in_fn_generic_scope(tv.clone(), generic_param_names.clone()) { @@ -3808,26 +3765,36 @@ pub fn rust_serde_policy( rename_prefix: rename_prefix.clone(), rename_suffix: rename_suffix.clone(), rename_style: rename_style.clone(), - error_message: None, + error_message: std::option::Option::None, }) } pub fn rust_serde_policy_error(message: String) -> Rc { Rc::new(RustEnumWireSerde { enum_attr: "".to_string(), - rename_prefix: None, - rename_suffix: None, - rename_style: None, + rename_prefix: std::option::Option::None, + rename_suffix: std::option::Option::None, + rename_style: std::option::Option::None, error_message: Some(message.clone()), }) } pub fn rust_tagged_object_policy() -> Rc { - rust_serde_policy(rust_serde_tag_attr(), None, None, None) + rust_serde_policy( + rust_serde_tag_attr(), + std::option::Option::None, + std::option::Option::None, + std::option::Option::None, + ) } pub fn rust_untagged_policy() -> Rc { - rust_serde_policy("#[serde(untagged)]".to_string(), None, None, None) + rust_serde_policy( + "#[serde(untagged)]".to_string(), + std::option::Option::None, + std::option::Option::None, + std::option::Option::None, + ) } pub fn rust_serde_error_policy(message: String) -> Rc { @@ -3835,19 +3802,29 @@ pub fn rust_serde_error_policy(message: String) -> Rc { } pub fn rust_string_as_authored_policy() -> Rc { - rust_serde_policy("".to_string(), None, None, None) + rust_serde_policy( + "".to_string(), + std::option::Option::None, + std::option::Option::None, + std::option::Option::None, + ) } pub fn rust_snake_string_policy() -> Rc { - rust_serde_policy(rust_serde_rename_all_snake_case(), None, None, None) + rust_serde_policy( + rust_serde_rename_all_snake_case(), + std::option::Option::None, + std::option::Option::None, + std::option::Option::None, + ) } pub fn rust_screaming_snake_string_policy() -> Rc { rust_serde_policy( rust_serde_rename_all_screaming_snake_case(), - None, - None, - None, + std::option::Option::None, + std::option::Option::None, + std::option::Option::None, ) } @@ -3871,7 +3848,7 @@ pub fn field_value_by_name( .cloned() { Some(fi) => Some(crate::v1_std_core::field_init_node_value(fi.clone())), - None => None, + None => std::option::Option::None, } } @@ -3879,9 +3856,9 @@ pub fn literal_string_value(n: Rc) -> Option { match (*n.expr_data.clone()).clone() { ExprData::ExprLiteral { value: lv, .. } => match (*lv.clone()).clone() { LiteralValue::LitStr { value: s, .. } => Some(s.clone()), - _ => None, + _ => std::option::Option::None, }, - _ => None, + _ => std::option::Option::None, } } @@ -3892,7 +3869,7 @@ pub fn record_string_field( ) -> Option { match field_value_by_name(record.clone(), field_name.clone(), source_indices.clone()) { Some(value_node) => literal_string_value(value_node.clone()), - None => None, + None => std::option::Option::None, } } @@ -3921,7 +3898,7 @@ pub fn coproduct_decl_ref_decl_name( "decl_name".to_string(), source_indices.clone(), ), - None => None, + None => std::option::Option::None, } } @@ -3932,7 +3909,7 @@ pub fn optional_string_record_field( ) -> Option { match field_value_by_name(record.clone(), field_name.clone(), source_indices.clone()) { Some(n) => literal_string_value(n.clone()), - None => None, + None => std::option::Option::None, } } @@ -3943,7 +3920,7 @@ pub fn required_literal_string_policy_field( ) -> Option { match field_value_by_name(record.clone(), field_name.clone(), source_indices.clone()) { Some(n) => literal_string_value(n.clone()), - None => None, + None => std::option::Option::None, } } @@ -3972,7 +3949,7 @@ pub fn rust_string_policy_for_naming( Some(prefix) => rust_serde_policy( "".to_string(), Some(prefix.clone()), - None, + std::option::Option::None, Some("StripAffixAndSnakeCase".to_string()), ), None => rust_serde_error_policy( @@ -3988,7 +3965,7 @@ pub fn rust_string_policy_for_naming( ) { Some(suffix) => rust_serde_policy( "".to_string(), - None, + std::option::Option::None, Some(suffix.clone()), Some("StripAffixAndSnakeCase".to_string()), ), @@ -4034,9 +4011,9 @@ pub fn rust_internal_policy_for_naming( v1_rt::concat("#[serde(tag = \"".to_string(), tag_field.clone()), "\")]".to_string(), ), - None, - None, - None, + std::option::Option::None, + std::option::Option::None, + std::option::Option::None, ) } else { if (naming_name.clone() == "SnakeCase".to_string()) { @@ -4045,9 +4022,9 @@ pub fn rust_internal_policy_for_naming( v1_rt::concat("#[serde(tag = \"".to_string(), tag_field.clone()), "\", rename_all = \"snake_case\")]".to_string(), ), - None, - None, - None, + std::option::Option::None, + std::option::Option::None, + std::option::Option::None, ) } else { if (naming_name.clone() == "ScreamingSnakeCase".to_string()) { @@ -4056,9 +4033,9 @@ pub fn rust_internal_policy_for_naming( v1_rt::concat("#[serde(tag = \"".to_string(), tag_field.clone()), "\", rename_all = \"SCREAMING_SNAKE_CASE\")]".to_string(), ), - None, - None, - None, + std::option::Option::None, + std::option::Option::None, + std::option::Option::None, ) } else { if (naming_name.clone() == "StripPrefixAndSnakeCase".to_string()) { @@ -4076,7 +4053,7 @@ pub fn rust_internal_policy_for_naming( "\")]".to_string(), ), Some(prefix.clone()), - None, + std::option::Option::None, Some("StripAffixAndSnakeCase".to_string()), ), None => rust_serde_error_policy( @@ -4098,7 +4075,7 @@ pub fn rust_internal_policy_for_naming( ), "\")]".to_string(), ), - None, + std::option::Option::None, Some(suffix.clone()), Some("StripAffixAndSnakeCase".to_string()), ), @@ -4246,7 +4223,7 @@ pub fn resolve_wire_serde_policy_for_coproduct_seen( Some(init) => { match (*init.expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => { break resolve_wire_serde_policy(init.clone(), source_indices.clone()); }, ExprData::ExprVar { binding_kind: _, .. } => { let alias_name = crate::v1_std_core::expr_var_name_at(init.clone(), source_indices.clone()); -if (v1_rt::map_get(&seen_aliases, alias_name.clone()) != None) { +if (v1_rt::map_get(&seen_aliases, alias_name.clone()) != std::option::Option::None) { break rust_serde_error_policy(v1_rt::concat("wire_contract: cyclic VariantEncoding alias: ".to_string(), alias_name.clone())); } else { match v1_rt::map_get(&data_items, alias_name.clone()) { @@ -4325,7 +4302,7 @@ pub fn coproduct_wire_contract_encoding( Some(body) => { field_value_by_name(body.clone(), "encoding".to_string(), source_indices.clone()) } - None => None, + None => std::option::Option::None, } } @@ -4472,12 +4449,12 @@ pub fn is_coproduct_wire_contract_row( body.clone(), "coproduct".to_string(), source_indices.clone(), - ) != None) + ) != std::option::Option::None) && (field_value_by_name( body.clone(), "encoding".to_string(), source_indices.clone(), - ) != None)) + ) != std::option::Option::None)) } None => false, } @@ -4602,7 +4579,7 @@ pub fn resolve_local_coproduct_wire_policy( __result }); if ((contracts.clone().len() as i64) == 0) { - None + std::option::Option::None } else { if ((contracts.clone().len() as i64) == 1) { match contracts.clone().first().cloned() { @@ -4629,7 +4606,7 @@ pub fn resolve_local_coproduct_wire_policy( coproduct_name.clone(), ))), }, - None => None, + None => std::option::Option::None, } } else { Some(rust_serde_error_policy(v1_rt::concat( @@ -5798,7 +5775,7 @@ pub fn build_emit_rust_context(typed: Rc) -> Rc clone_impl_required_type_params: clone_impl_required.clone(), fn_generic_param_names: base_info.fn_generic_param_names.clone(), fn_type_env: base_info.fn_type_env.clone(), - fn_return_type: None, + fn_return_type: std::option::Option::None, }); let registry = merge_item_registries( typed.item_registry.clone(), @@ -6472,7 +6449,7 @@ pub fn emit_module( clone_impl_required_type_params: clone_impl_required.clone(), fn_generic_param_names: base_info.fn_generic_param_names.clone(), fn_type_env: base_info.fn_type_env.clone(), - fn_return_type: None, + fn_return_type: std::option::Option::None, }); let shared_types = emit_info.shared_types.clone(); let export_sets = build_module_export_sets(Rc::new(vec![typed_module.clone()])); @@ -6591,7 +6568,7 @@ pub fn anonymous_record_lit_surface_name( let rt = crate::v1_compiler_infer_types::resolved_type(n.clone()); let rt_name = crate::v1_std_core::authored_name_at(source_indices.clone(), rt.clone()); - if ((rt.ident_span.clone() != None) + if ((rt.ident_span.clone() != std::option::Option::None) && v1_rt::map_contains_key(&type_summaries, rt_name.clone())) { rt_name.clone() @@ -7002,11 +6979,11 @@ pub fn collect_items_field_import_surface_names( Some(summary) => Some(summary.clone()), None => match v1_rt::map_get(&variant_to_enum, type_name.clone()) { Some(enum_name) => if (enum_name.clone() == "".to_string()) { - None + std::option::Option::None } else { v1_rt::map_get(&type_summaries, crate::v1_compiler_infer_emit_info::variant_summary_key(enum_name.clone(), type_name.clone())) }, - None => None, + None => std::option::Option::None, }, }; match summary_lookup.clone() { @@ -7987,7 +7964,8 @@ pub fn host_realized_builtin_needs_no_import_note() -> String { } pub fn reference_is_host_realized_builtin(name: String) -> bool { - ((crate::v1_compiler_infer_method::infer_builtin_call_type(name.clone()) != None) + ((crate::v1_compiler_infer_method::infer_builtin_call_type(name.clone()) + != std::option::Option::None) || crate::std_types::is_container_type(name.clone())) } @@ -8658,25 +8636,26 @@ pub fn reference_derived_use_line_plan( v1_rt::rc_empty_map::(), |acc: Rc>, t: String| v1_rt::rc_map_insert(acc, t.clone(), true), ); + let origin_candidates = crate::std_repair_input_origin::repair_input_origin_candidates( + this_module_name.clone(), + unlisted_type_names.clone(), + value_names.clone(), + type_surface_names.clone(), + field_surface_names.clone(), + variant_payload_structs.clone(), + realized_surface_names.clone(), + ); let candidates = Rc::new({ let mut __result = Vec::new(); for name in Rc::new({ let mut __result = Vec::new(); for name in Rc::new({ let mut __result = Vec::new(); - for name in crate::v1_compiler_emit_core_support::unique_strings(v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat(unlisted_type_names.clone(), value_names.clone()), - type_surface_names.clone(), - ), - field_surface_names.clone(), - ), - variant_payload_structs.clone(), + for name in crate::v1_compiler_emit_core_support::unique_strings( + crate::std_repair_input_origin::repair_input_origin_compatibility_names( + origin_candidates.clone(), ), - realized_surface_names.clone(), - )) + ) .iter() .cloned() { @@ -8870,7 +8849,13 @@ v1_rt::concat(block_lines.clone(), fallback.clone()) let qualified_rows = qualified_type_reference_rows( Rc::new({ let mut __result = Vec::new(); - for nm in type_surface_names.iter().cloned() { + for nm in + crate::std_repair_input_origin::qualified_item_emit_surface_compatibility_names( + origin_candidates.clone(), + ) + .iter() + .cloned() + { if crate::v1_compiler_infer_types::emit_map_has( emitted_source_token_set.clone(), crate::v1_std_core::qualified_last_segment(nm.clone()), @@ -9760,7 +9745,7 @@ pub fn module_name_from_filename( }) .first() .cloned(), - None => None, + None => std::option::Option::None, } } @@ -10759,11 +10744,11 @@ pub fn reexport_variant_parent_in_import_module( continue; } } else { - break None; + break std::option::Option::None; } } None => { - break None; + break std::option::Option::None; } } } @@ -11055,9 +11040,9 @@ pub fn type_item_by_name_in_module_filename( }) .first() .cloned(), - None => None, + None => std::option::Option::None, }, - None => None, + None => std::option::Option::None, } } @@ -11318,7 +11303,7 @@ pub fn alias_rhs_nominal_shell_has_rust_authority( if ((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) == 0)) { - if ((n.inferred.clone() != None) + if ((n.inferred.clone() != std::option::Option::None) && is_type_variable(n.inferred.clone().clone().unwrap())) { true @@ -11400,8 +11385,9 @@ pub fn is_parametric_opaque_type_decl_item( item: Rc, source_indices: Rc>>, ) -> bool { - ((((((item.params.clone().len() as i64) > 0) && (item.body.clone() == None)) - && (item.transport.clone() == None)) + ((((((item.params.clone().len() as i64) > 0) + && (item.body.clone() == std::option::Option::None)) + && (item.transport.clone() == std::option::Option::None)) && ((item.children.clone().len() as i64) == 0)) && (!crate::v1_compiler_emit_core_support::is_type_alias_return_node( crate::v1_compiler_infer_types::resolved_type(item.clone()), @@ -11457,7 +11443,7 @@ pub fn is_emittable_parametric_type_alias_item( } else { { let rhs = crate::v1_compiler_infer_types::resolved_type(item.clone()); - if ((rhs.inferred.clone() != None) + if ((rhs.inferred.clone() != std::option::Option::None) && crate::v1_std_core::is_compiler_error(rhs.inferred.clone().clone().unwrap())) { false @@ -14163,6 +14149,7 @@ pub fn emit_item_header_clone_param_names( item.clone(), generic_param_names.clone(), emit_info.clone_bounded_type_params.clone(), + emit_info.type_decl_items.clone(), source_indices.clone(), ) } else { @@ -15087,7 +15074,7 @@ pub fn render_rust_field_type_with_applied_binding( field.properties.clone(), "__applied_type_args".to_string(), source_indices.clone(), - ) != None) + ) != std::option::Option::None) { render_rust_type_with_applied_binding( field.clone(), @@ -15100,7 +15087,7 @@ pub fn render_rust_field_type_with_applied_binding( authored_type.properties.clone(), "__applied_type_args".to_string(), source_indices.clone(), - ) != None) + ) != std::option::Option::None) { render_rust_type_with_applied_binding( authored_type.clone(), @@ -15199,7 +15186,7 @@ pub fn emit_struct_field_from_child( child.properties.clone(), "__applied_type_args".to_string(), env.source_indices.clone(), - ) != None) + ) != std::option::Option::None) { render_rust_type_with_applied_binding( child.clone(), @@ -15212,7 +15199,7 @@ pub fn emit_struct_field_from_child( authored_child_type.properties.clone(), "__applied_type_args".to_string(), env.source_indices.clone(), - ) != None) + ) != std::option::Option::None) { render_rust_type_with_applied_binding( authored_child_type.clone(), @@ -15225,7 +15212,7 @@ pub fn emit_struct_field_from_child( rt_child.properties.clone(), "__applied_type_args".to_string(), env.source_indices.clone(), - ) != None) + ) != std::option::Option::None) { render_rust_type_with_applied_binding( rt_child.clone(), @@ -15235,7 +15222,7 @@ pub fn emit_struct_field_from_child( ) } else { if ((crate::v1_compiler_infer_types::is_product_type(rt_child.clone()) - && (rt_child.ident_span.clone() != None)) + && (rt_child.ident_span.clone() != std::option::Option::None)) && ((rt_child.children.clone().len() as i64) > 2)) { { @@ -15464,7 +15451,12 @@ pub fn emit_enum_from_children( env.source_indices.clone(), ); let effective_serde_policy = if has_fn_fields.clone() { - rust_serde_policy("".to_string(), None, None, None) + rust_serde_policy( + "".to_string(), + std::option::Option::None, + std::option::Option::None, + std::option::Option::None, + ) } else { serde_policy.clone() }; @@ -15741,13 +15733,34 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::con }); let fns_str = accessor_fns.clone().join(&"\n".to_string()); let type_application_params = emit_bare_type_params(generic_param_names.clone()); + let impl_params = if ((generic_param_names.clone().len() as i64) == 0) { + type_params.clone() + } else { + v1_rt::concat( + v1_rt::concat( + "<".to_string(), + Rc::new({ + let mut __result = Vec::new(); + for g in generic_param_names.iter().cloned() { + __result.push(v1_rt::concat( + crate::v1_compiler_emit_core_support::to_pascal(g.clone()), + ": Clone".to_string(), + )); + } + __result + }) + .join(&", ".to_string()), + ), + ">".to_string(), + ) + }; v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat("impl".to_string(), type_params.clone()), + v1_rt::concat("impl".to_string(), impl_params.clone()), " ".to_string(), ), name.clone(), @@ -15765,7 +15778,7 @@ v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::con pub fn string_without_prefix(value: String, prefix: String) -> Option { if (v1_rt::string_length(&prefix) == 0) { - None + std::option::Option::None } else { if ((v1_rt::string_length(&value) >= v1_rt::string_length(&prefix)) && (v1_rt::substring(&value, 0, v1_rt::string_length(&prefix)) == prefix.clone())) @@ -15776,14 +15789,14 @@ pub fn string_without_prefix(value: String, prefix: String) -> Option { v1_rt::string_length(&value), )) } else { - None + std::option::Option::None } } } pub fn string_without_suffix(value: String, suffix: String) -> Option { if (v1_rt::string_length(&suffix) == 0) { - None + std::option::Option::None } else { if ((v1_rt::string_length(&value) >= v1_rt::string_length(&suffix)) && (v1_rt::substring( @@ -15798,7 +15811,7 @@ pub fn string_without_suffix(value: String, suffix: String) -> Option { (v1_rt::string_length(&value) - v1_rt::string_length(&suffix)), )) } else { - None + std::option::Option::None } } } @@ -15806,7 +15819,7 @@ pub fn string_without_suffix(value: String, suffix: String) -> Option { pub fn string_index_of_from(mut haystack: String, mut needle: String, mut pos: i64) -> Option { loop { if ((pos.clone() + v1_rt::string_length(&needle)) > v1_rt::string_length(&haystack)) { - break None; + break std::option::Option::None; } else { if (v1_rt::substring( &haystack, @@ -15834,8 +15847,8 @@ pub fn wire_variant_tag_for_policy( authored: String, policy: Rc, ) -> Option { - if (policy.error_message.clone() != None) { - None + if (policy.error_message.clone() != std::option::Option::None) { + std::option::Option::None } else { match policy.rename_style.clone() { Some(style) => { @@ -15845,7 +15858,7 @@ pub fn wire_variant_tag_for_policy( Some(prefix) => { match string_without_prefix(authored.clone(), prefix.clone()) { Some(stripped) => stripped.clone(), - None => return None, + None => return std::option::Option::None, } } None => authored.clone(), @@ -15855,7 +15868,7 @@ pub fn wire_variant_tag_for_policy( match string_without_suffix(without_prefix.clone(), suffix.clone()) { Some(stripped) => stripped.clone(), - None => return None, + None => return std::option::Option::None, } } None => without_prefix.clone(), @@ -15865,7 +15878,7 @@ pub fn wire_variant_tag_for_policy( )) } } else { - None + std::option::Option::None } } None => { @@ -15878,12 +15891,12 @@ pub fn wire_variant_tag_for_policy( )) } else { if (((policy.enum_attr.clone() == "".to_string()) - && (policy.rename_prefix.clone() == None)) - && (policy.rename_suffix.clone() == None)) + && (policy.rename_prefix.clone() == std::option::Option::None)) + && (policy.rename_suffix.clone() == std::option::Option::None)) { Some(authored.clone()) } else { - None + std::option::Option::None } } } @@ -15907,10 +15920,10 @@ pub fn policy_serde_tag_field(policy: Rc) -> Option { after.clone(), end.clone(), )), - None => None, + None => std::option::Option::None, } } - None => None, + None => std::option::Option::None, } } } @@ -15921,9 +15934,9 @@ pub fn policy_is_untagged(policy: Rc) -> bool { pub fn policy_is_string_variant(policy: Rc) -> bool { (((!v1_rt::contains(policy.enum_attr.clone(), "tag =".to_string()) - && (policy.rename_prefix.clone() == None)) - && (policy.rename_suffix.clone() == None)) - && (policy.rename_style.clone() == None)) + && (policy.rename_prefix.clone() == std::option::Option::None)) + && (policy.rename_suffix.clone() == std::option::Option::None)) + && (policy.rename_style.clone() == std::option::Option::None)) } pub fn wire_variant_rename_attr_for_policy( @@ -16048,7 +16061,7 @@ pub fn enum_variant_field_type_node( source_indices.clone(), ) { Some(field) => { - if (field.inferred.clone() != None) { + if (field.inferred.clone() != std::option::Option::None) { crate::v1_compiler_infer_types::resolved_type(field.clone()) } else { fallback @@ -16193,7 +16206,7 @@ pub fn emit_variant_from_child( type_node.properties.clone(), "__applied_type_args".to_string(), env.source_indices.clone(), - ) != None) + ) != std::option::Option::None) { render_rust_type_with_applied_binding( type_node.clone(), @@ -16462,6 +16475,7 @@ pub fn v1_fn_bounds_by_param( clone_param_names: Rc>, eq_param_names: Rc>, map_key_param_names: Rc>, + static_param_names: Rc>, ) -> Rc>>> { { let with_clone = clone_param_names.iter().cloned().fold( @@ -16486,7 +16500,7 @@ pub fn v1_fn_bounds_by_param( ), }, ); - map_key_param_names.iter().cloned().fold( + let with_key = map_key_param_names.iter().cloned().fold( with_eq.clone(), |m: Rc>>>, n: String| match v1_rt::map_get(&m, n.clone()) { @@ -16497,6 +16511,20 @@ pub fn v1_fn_bounds_by_param( ), None => v1_rt::rc_map_insert(m.clone(), n.clone(), rust_map_key_bound_traits()), }, + ); + static_param_names.iter().cloned().fold( + with_key.clone(), + |m: Rc>>>, n: String| match v1_rt::map_get(&m, n.clone()) + { + Some(traits) => v1_rt::rc_map_insert( + m.clone(), + n.clone(), + v1_rt::concat(traits.clone(), Rc::new(vec!["'static".to_string()])), + ), + None => { + v1_rt::rc_map_insert(m.clone(), n.clone(), Rc::new(vec!["'static".to_string()])) + } + }, ) } } @@ -16679,10 +16707,10 @@ pub fn v1_call_forwarding_clone_bound_param_names( let lb = crate::v1_std_core::lambda_body(body.clone()); match (*lb.expr_data.clone()).clone() { ExprData::ExprCall { .. } => Some(lb.clone()), - _ => None, + _ => std::option::Option::None, } } - _ => None, + _ => std::option::Option::None, }; match call_node.clone() { None => Rc::new(vec![]), @@ -16863,7 +16891,7 @@ pub fn emit_fn_def( { let si = scope.type_env.clone().source_indices.clone(); let host_text_op = rust_host_string_op_fn_emit(name.clone()); - if (host_text_op.clone() != None) { + if (host_text_op.clone() != std::option::Option::None) { return match host_text_op.clone() { Some(op_fn) => op_fn.clone(), None => "".to_string(), @@ -16977,14 +17005,28 @@ pub fn emit_fn_def( generic_param_names.clone(), si.clone(), ); + let returns_fn_field_record = type_has_fn_fields( + rust_fn_sig_leaf_name(si.clone(), inferred.clone()), + emit_info.clone(), + ); + let returns_arrow_or_fn_field_record = (((inferred.params.clone().len() as i64) + > 0) + || returns_fn_field_record.clone()); + let static_param_names = if returns_fn_field_record.clone() { + generic_param_names.clone() + } else { + Rc::new(vec![]) + }; let bounds_by_param = v1_fn_bounds_by_param( clone_param_names.clone(), eq_param_names.clone(), map_key_param_names.clone(), + static_param_names.clone(), ); - let needs_bound = ((((clone_param_names.clone().len() as i64) > 0) + let needs_bound = (((((clone_param_names.clone().len() as i64) > 0) || ((eq_param_names.clone().len() as i64) > 0)) - || ((map_key_param_names.clone().len() as i64) > 0)); + || ((map_key_param_names.clone().len() as i64) > 0)) + || ((static_param_names.clone().len() as i64) > 0)); let type_params_str = if needs_bound.clone() { crate::v1_compiler_trait_derive_emit::v1_emit_type_params_with_bounds( type_params.clone(), @@ -17002,7 +17044,7 @@ pub fn emit_fn_def( emit_info.read_only_params.clone(), emit_info.variant_to_enum.clone(), scope.type_env.clone(), - ((inferred.params.clone().len() as i64) > 0), + returns_arrow_or_fn_field_record.clone(), ); let ret_str = emit_inferred( inferred.clone(), @@ -18555,7 +18597,7 @@ pub fn pattern_parent_enum( { let scrut_is_known_enum = ((scrut_type.clone() != "".to_string()) && is_enum_type_name(scrut_type.clone(), type_summaries.clone())); - if (parent_enum.clone() != None) { + if (parent_enum.clone() != std::option::Option::None) { parent_enum.clone() } else { if scrut_is_known_enum.clone() { @@ -18593,7 +18635,7 @@ pub fn unique_variant_parent( if ((parent_matches.clone().len() as i64) == 1) { parent_matches.clone().first().cloned() } else { - None + std::option::Option::None } } } @@ -18748,7 +18790,8 @@ pub fn emit_variant_pattern( emit_info.type_summaries.clone(), ); let optional_variant = (is_optional_variant_name(bare_name.clone()) - && (is_optional_parent(resolved_parent.clone()) || (resolved_parent.clone() == None))); + && (is_optional_parent(resolved_parent.clone()) + || (resolved_parent.clone() == std::option::Option::None))); let rust_name = if optional_variant.clone() { if is_some_like_variant_name(bare_name.clone()) { "Some".to_string() @@ -19090,7 +19133,13 @@ pub fn analyze_rc_pattern( Some(enum_name) => { v1_rt::set_contains(&shared_types, enum_name.clone()) } - None => false, + None => match v1_rt::map_get( + &emit_info.type_summaries.clone(), + bare_n.clone(), + ) { + Some(_) => v1_rt::set_contains(&shared_types, bare_n.clone()), + None => false, + }, }; let ref_bound_fields = Rc::new({ let mut __result = Vec::new(); @@ -19380,7 +19429,8 @@ pub fn emit_variant_pattern_rc_aware( emit_info.type_summaries.clone(), ); let optional_variant = (is_optional_variant_name(bare_name.clone()) - && (is_optional_parent(resolved_parent.clone()) || (resolved_parent.clone() == None))); + && (is_optional_parent(resolved_parent.clone()) + || (resolved_parent.clone() == std::option::Option::None))); let rust_name = if optional_variant.clone() { if is_some_like_variant_name(bare_name.clone()) { "Some".to_string() @@ -19693,7 +19743,8 @@ pub fn variant_pattern_shape_for( emit_info.type_summaries.clone(), ); let optional_variant = (is_optional_variant_name(bare_name.clone()) - && (is_optional_parent(resolved_parent.clone()) || (resolved_parent.clone() == None))); + && (is_optional_parent(resolved_parent.clone()) + || (resolved_parent.clone() == std::option::Option::None))); let rust_name = if optional_variant.clone() { if is_some_like_variant_name(bare_name.clone()) { "Some".to_string() @@ -19997,7 +20048,9 @@ pub fn explicit_record_struct_name( } } let has_structure = (inferred_node.connective.clone() != Connective::NoConnective); - let n = if ((inferred_node.type_annotation.clone() != None) && has_structure.clone()) { + let n = if ((inferred_node.type_annotation.clone() != std::option::Option::None) + && has_structure.clone()) + { match inferred_node.children.clone().first().cloned() { Some(base) => base.clone(), None => inferred_node.clone(), @@ -20007,7 +20060,7 @@ pub fn explicit_record_struct_name( }; let is_product = crate::v1_compiler_infer_types::is_product_type(n.clone()); let is_coproduct = crate::v1_compiler_infer_types::is_coproduct_type(n.clone()); - let n_is_error = if (n.inferred.clone() != None) { + let n_is_error = if (n.inferred.clone() != std::option::Option::None) { crate::v1_std_core::is_compiler_error(n.inferred.clone().clone().unwrap()) } else { false @@ -20020,7 +20073,7 @@ pub fn explicit_record_struct_name( type_name.clone() } else { if is_product.clone() { - if (n.ident_span.clone() == None) { + if (n.ident_span.clone() == std::option::Option::None) { type_name.clone() } else { Some(nname.clone()) @@ -20030,7 +20083,7 @@ pub fn explicit_record_struct_name( type_name.clone() } else { if (((n.children.clone().len() as i64) == 0) - && (n.ident_span.clone() != None)) + && (n.ident_span.clone() != std::option::Option::None)) { Some(nname.clone()) } else { @@ -20058,7 +20111,7 @@ pub fn variant_parent_from_binding_kind( parent_enum: parent_enum, .. }) => Some(parent_enum.clone()), - _ => None, + _ => std::option::Option::None, } } @@ -20125,7 +20178,8 @@ pub fn effective_variant_parent_from_enum_lookup( ) -> Option { { let rt_name = crate::v1_std_core::authored_name_at(source_indices.clone(), rt.clone()); - if (((rt.ident_span.clone() != None) && (rt_name.clone() != leaf_name.clone())) + if (((rt.ident_span.clone() != std::option::Option::None) + && (rt_name.clone() != leaf_name.clone())) && crate::v1_compiler_infer_emit_info::variant_belongs_to_enum( emit_info.type_summaries.clone(), leaf_name.clone(), @@ -20184,10 +20238,10 @@ pub fn effective_variant_parent( if (p.clone() != "".to_string()) { Some(p.clone()) } else { - None + std::option::Option::None } } - None => None, + None => std::option::Option::None, }; match cached.clone() { Some(parent) => Some(parent.clone()), @@ -20320,7 +20374,7 @@ pub fn emit_var_ref( ); if (((leaf_name.clone() == "none".to_string()) || (leaf_name.clone() == "None".to_string())) - && (variant_parent.clone() == None)) + && (variant_parent.clone() == std::option::Option::None)) { emit_none_keyword_for_resolved_type(resolved_type.clone()) } else { @@ -20471,7 +20525,7 @@ pub fn emit_typed_expr_base( ); if (((leaf_name.clone() == "none".to_string()) || (leaf_name.clone() == "None".to_string())) - && (variant_parent.clone() == None)) + && (variant_parent.clone() == std::option::Option::None)) { emit_none_keyword_for_resolved_type(texpr.inferred.clone()) } else { @@ -20602,7 +20656,7 @@ pub fn field_access_field_is_boxed( (crate::v1_compiler_coercion::rust_seed_host_numeric_alias( field_ty_name.clone(), crate::v1_compiler_coercion::type_reference_decl_file(field_ty.clone()), - ) != None); + ) != std::option::Option::None); if grounds_to_host_scalar.clone() { false } else { @@ -20798,7 +20852,7 @@ pub fn emit_typed_field_access( let base_is_anon_record = match base.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: bt, .. }) => { let is_product = crate::v1_compiler_infer_types::is_product_type(bt.clone()); - if (is_product.clone() && (bt.ident_span.clone() == None)) { + if (is_product.clone() && (bt.ident_span.clone() == std::option::Option::None)) { true } else { false @@ -21032,7 +21086,7 @@ pub fn type_needs_rc_seen( } else { let canonical = crate::v1_std_core::authored_name_at(source_indices.clone(), normed.clone()); - if (normed.inferred.clone() != None) { + if (normed.inferred.clone() != std::option::Option::None) { let next_seen = if (canonical.clone() == "".to_string()) { seen.clone() } else { @@ -21160,7 +21214,7 @@ pub fn rust_empty_map_kv_type_str( pub fn type_node_child_is_type_variable(c: Rc) -> bool { { let ch = crate::v1_compiler_infer_types::child_type_node(c.clone()); - if (ch.inferred.clone() != None) { + if (ch.inferred.clone() != std::option::Option::None) { is_type_variable(ch.inferred.clone().clone().unwrap()) } else { false @@ -21210,12 +21264,12 @@ pub fn rust_empty_set_element_type_str( match set_type.children.clone().first().cloned() { Some(elem_child) => { let elem_node = crate::v1_compiler_infer_types::child_type_node(elem_child.clone()); - let elem_is_type_var = if (elem_node.inferred.clone() != None) { + let elem_is_type_var = if (elem_node.inferred.clone() != std::option::Option::None) { is_type_variable(elem_node.inferred.clone().clone().unwrap()) } else { false }; - let elem_is_error = if (elem_node.inferred.clone() != None) { + let elem_is_error = if (elem_node.inferred.clone() != std::option::Option::None) { crate::v1_std_core::is_compiler_error(elem_node.inferred.clone().clone().unwrap()) } else { false @@ -21252,7 +21306,7 @@ pub fn emit_rust_empty_set_expr( match set_type.children.clone().first().cloned() { Some(elem_child) => { let elem_node = crate::v1_compiler_infer_types::child_type_node(elem_child.clone()); - let elem_is_type_var = if (elem_node.inferred.clone() != None) { + let elem_is_type_var = if (elem_node.inferred.clone() != std::option::Option::None) { is_type_variable(elem_node.inferred.clone().clone().unwrap()) } else { false @@ -21441,13 +21495,13 @@ pub fn call_target_runtime_primitive_name(target: Rc) -> Opt CallTargetIdentity::RuntimePrimitiveCall { primitive_name, .. } => { Some(primitive_name.clone()) } - CallTargetIdentity::SourceDeclarationCall { .. } => None, - CallTargetIdentity::CallableTargetUndetermined => None, + CallTargetIdentity::SourceDeclarationCall { .. } => std::option::Option::None, + CallTargetIdentity::CallableTargetUndetermined => std::option::Option::None, } } pub fn call_target_is_runtime_primitive(target: Rc) -> bool { - (call_target_runtime_primitive_name(target.clone()) != None) + (call_target_runtime_primitive_name(target.clone()) != std::option::Option::None) } pub fn call_target_projected_declaration( @@ -21455,8 +21509,8 @@ pub fn call_target_projected_declaration( ) -> Option> { match (*target.clone()).clone() { CallTargetIdentity::RuntimePrimitiveCall { projected_from, .. } => projected_from.clone(), - CallTargetIdentity::SourceDeclarationCall { .. } => None, - CallTargetIdentity::CallableTargetUndetermined => None, + CallTargetIdentity::SourceDeclarationCall { .. } => std::option::Option::None, + CallTargetIdentity::CallableTargetUndetermined => std::option::Option::None, } } @@ -21684,9 +21738,9 @@ pub fn emit_rust_expr_record_lit( variant_name.clone(), crate::v1_std_core::authored_name_at(si.clone(), expanded_rt.clone()), )); - let peeled_type_name = if ((((parent_enum.clone() == None) + let peeled_type_name = if ((((parent_enum.clone() == std::option::Option::None) && (expanded_rt.connective.clone() == Connective::Conj)) - && (expanded_rt.ident_span.clone() != None)) + && (expanded_rt.ident_span.clone() != std::option::Option::None)) && !concrete_peel_would_erase_optional_ctor.clone()) { { @@ -21727,7 +21781,7 @@ pub fn emit_rust_expr_record_lit( None => { let expanded_name = crate::v1_std_core::authored_name_at(si.clone(), expanded_rt.clone()); - if ((((expanded_rt.ident_span.clone() != None) + if ((((expanded_rt.ident_span.clone() != std::option::Option::None) && (expanded_name.clone() != "".to_string())) && (expanded_name.clone() != variant_name.clone())) && v1_rt::set_contains(&shared_types, expanded_name.clone())) @@ -22201,7 +22255,7 @@ pub fn contextual_variant_parent_from_type_name( { let rt_name = crate::v1_std_core::authored_name_at(source_indices.clone(), resolved_type.clone()); - if (((resolved_type.ident_span.clone() != None) + if (((resolved_type.ident_span.clone() != std::option::Option::None) && (rt_name.clone() != variant_name.clone())) && crate::v1_compiler_infer_emit_info::variant_belongs_to_enum( emit_info.type_summaries.clone(), @@ -22211,7 +22265,7 @@ pub fn contextual_variant_parent_from_type_name( { Some(rt_name.clone()) } else { - None + std::option::Option::None } } } @@ -22260,7 +22314,7 @@ pub fn contextual_variant_parent( ) { Some(explicit_parent.clone()) } else { - None + std::option::Option::None } } None => contextual_variant_parent_absent( @@ -22307,7 +22361,7 @@ pub fn discriminant_zero_field_variant_tag( match (*arg.expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => { if ((arg.children.clone().len() as i64) != 0) { - None + std::option::Option::None } else { match crate::v1_std_core::record_lit_type_name_at( arg.clone(), @@ -22323,14 +22377,14 @@ pub fn discriminant_zero_field_variant_tag( { Some(last.clone()) } else { - None + std::option::Option::None } } - None => None, + None => std::option::Option::None, } } } - _ => None, + _ => std::option::Option::None, } } @@ -22555,6 +22609,7 @@ pub fn rust_call_arg_fail_closed_unwrap( callee: Option>, idx: i64, func: String, + source_indices: Rc>>, ) -> String { match callee.clone() { Some(info) => match function_value_params(info.params.clone()) @@ -22564,10 +22619,10 @@ pub fn rust_call_arg_fail_closed_unwrap( .next() { Some(param) => { - let param_required = (crate::v1_std_core::param_node_type_expr(param.clone()) - .return_cardinality - .clone() - != Cardinality::CardOptional); + let param_type = crate::v1_std_core::param_node_type_expr(param.clone()); + let param_required = ((param_type.return_cardinality.clone() + != Cardinality::CardOptional) + && !is_host_optional_carrier_type(param_type.clone(), source_indices.clone())); let arg_optional = (crate::v1_compiler_infer_types::resolved_type(arg.clone()) .return_cardinality .clone() @@ -22833,7 +22888,7 @@ pub fn emit_typed_call( emit_info.clone(), 1024, ); - let type_name = if (base_arg.inferred.clone() != None) { + let type_name = if (base_arg.inferred.clone() != std::option::Option::None) { crate::v1_std_core::qualified_last_segment( crate::v1_std_core::authored_name_at( scope.type_env.clone().source_indices.clone(), @@ -22997,7 +23052,7 @@ pub fn emit_typed_call( registry.clone(), v1_rt::concat(v1_rt::concat(owner.clone(), ".".to_string()), decl.clone()), ), - _ => None, + _ => std::option::Option::None, }; let filled_args = fill_default_args( ordered_args.clone(), @@ -23068,6 +23123,7 @@ pub fn emit_typed_call( callee.clone(), idx.clone(), func.clone(), + scope.type_env.clone().source_indices.clone(), ); rust_call_arg_function_value_adapt( unwrapped.clone(), @@ -23287,7 +23343,8 @@ pub fn fill_default_args( if is_provided.clone() { false } else { - (crate::v1_std_core::param_node_default_value(p.clone()) != None) + (crate::v1_std_core::param_node_default_value(p.clone()) + != std::option::Option::None) } } { __result.push(p); @@ -23343,7 +23400,9 @@ pub fn fill_op_default_args( let unnamed_args = Rc::new({ let mut __result = Vec::new(); for a in ordered.iter().cloned() { - if (crate::v1_std_core::arg_name_at(a.clone(), si.clone()) == None) { + if (crate::v1_std_core::arg_name_at(a.clone(), si.clone()) + == std::option::Option::None) + { __result.push(a); } } @@ -23358,7 +23417,8 @@ pub fn fill_op_default_args( match v1_rt::map_get(&arg_map, pname.clone()) { Some(arg) => Rc::new(vec![arg.clone()]), None => { - if (crate::v1_std_core::param_node_default_value(p.clone()) != None) + if (crate::v1_std_core::param_node_default_value(p.clone()) + != std::option::Option::None) { Rc::new(vec![crate::v1_std_core::make_arg_node( Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), @@ -23736,18 +23796,20 @@ pub fn collection_element_type( Some(elem_child) => { let elem_node = crate::v1_compiler_infer_types::child_type_node(elem_child.clone()); - let elem_is_error = if (elem_node.inferred.clone() != None) { - crate::v1_std_core::is_compiler_error( - elem_node.inferred.clone().clone().unwrap(), - ) - } else { - false - }; - let elem_is_type_var = if (elem_node.inferred.clone() != None) { - is_type_variable(elem_node.inferred.clone().clone().unwrap()) - } else { - false - }; + let elem_is_error = + if (elem_node.inferred.clone() != std::option::Option::None) { + crate::v1_std_core::is_compiler_error( + elem_node.inferred.clone().clone().unwrap(), + ) + } else { + false + }; + let elem_is_type_var = + if (elem_node.inferred.clone() != std::option::Option::None) { + is_type_variable(elem_node.inferred.clone().clone().unwrap()) + } else { + false + }; if ((elem_is_error.clone() || elem_is_type_var.clone()) || type_node_has_closure_unbound_generic_atom( elem_node.clone(), @@ -23848,7 +23910,7 @@ pub fn lambda_param_type_strs( let idx = pair.0.clone(); let param_name = pair.1.clone(); let inferred_type = if (fold_acc_uses_fallback.clone() && (idx.clone() == 0)) { - None + std::option::Option::None } else { match param_nodes .clone() @@ -23861,20 +23923,23 @@ pub fn lambda_param_type_strs( Some(InferredNode::Resolved { node: param_type, .. }) => { - let param_is_error = if (param_type.inferred.clone() != None) { - crate::v1_std_core::is_compiler_error( - param_type.inferred.clone().clone().unwrap(), - ) - } else { - false - }; - let param_is_type_var = if (param_type.inferred.clone() != None) { + let param_is_error = + if (param_type.inferred.clone() != std::option::Option::None) { + crate::v1_std_core::is_compiler_error( + param_type.inferred.clone().clone().unwrap(), + ) + } else { + false + }; + let param_is_type_var = if (param_type.inferred.clone() + != std::option::Option::None) + { is_type_variable(param_type.inferred.clone().clone().unwrap()) } else { false }; if (param_is_type_var.clone() || param_is_error.clone()) { - None + std::option::Option::None } else { if type_node_has_closure_unbound_generic_atom( param_type.clone(), @@ -23882,7 +23947,7 @@ pub fn lambda_param_type_strs( type_env.clone(), source_indices.clone(), ) { - None + std::option::Option::None } else { { let rendered = render_rust_type( @@ -23895,7 +23960,7 @@ pub fn lambda_param_type_strs( rendered.clone(), emit_info.fn_generic_param_names.clone(), ) { - None + std::option::Option::None } else { Some(rendered.clone()) } @@ -23903,9 +23968,9 @@ pub fn lambda_param_type_strs( } } } - _ => None, + _ => std::option::Option::None, }, - None => None, + None => std::option::Option::None, } }; let fallback_type = match fallback_types @@ -24197,7 +24262,7 @@ pub fn emit_rust_fold_method_call( node: method_result_type, .. }) => Some(method_result_type.clone()), - _ => None, + _ => std::option::Option::None, }; let acc_type_node = match fold_accumulator_type.clone() { Some(acc_type) => { @@ -24205,7 +24270,7 @@ pub fn emit_rust_fold_method_call( let mut __found = false; for c in acc_type.children.clone().iter().cloned() { if (crate::v1_compiler_infer_types::is_unit_like(c.clone()) - || (c.ident_span.clone() == None)) + || (c.ident_span.clone() == std::option::Option::None)) { __found = true; break; @@ -24219,7 +24284,7 @@ pub fn emit_rust_fold_method_call( let mut __found = false; for gc in c.children.clone().iter().cloned() { if (crate::v1_compiler_infer_types::is_unit_like(gc.clone()) - || (gc.ident_span.clone() == None)) + || (gc.ident_span.clone() == std::option::Option::None)) { __found = true; break; @@ -24283,7 +24348,7 @@ pub fn emit_rust_fold_method_call( if (crate::v1_std_core::arg_value(init_arg.clone()) .inferred .clone() - != None) + != std::option::Option::None) { crate::v1_compiler_infer_types::resolved_type( crate::v1_std_core::arg_value(init_arg.clone()), @@ -24427,7 +24492,8 @@ pub fn emit_rust_fold_method_call( scope.type_env.clone().source_indices.clone(), fold_emit_info.clone(), ); - let acc_type_is_type_var = if (acc_type_node.inferred.clone() != None) { + let acc_type_is_type_var = if (acc_type_node.inferred.clone() != std::option::Option::None) + { is_type_variable(acc_type_node.inferred.clone().clone().unwrap()) } else { false @@ -24483,7 +24549,7 @@ pub fn emit_rust_fold_method_call( let mut __found = false; for c in acc_type_node.children.clone().iter().cloned() { if (crate::v1_compiler_infer_types::is_unit_like(c.clone()) - || (c.ident_span.clone() == None)) + || (c.ident_span.clone() == std::option::Option::None)) { __found = true; break; @@ -24497,7 +24563,7 @@ pub fn emit_rust_fold_method_call( let mut __found = false; for gc in c.children.clone().iter().cloned() { if (crate::v1_compiler_infer_types::is_unit_like(gc.clone()) - || (gc.ident_span.clone() == None)) + || (gc.ident_span.clone() == std::option::Option::None)) { __found = true; break; @@ -24702,12 +24768,14 @@ pub fn emit_rust_sort_by_method_call( resolved.clone(), scope.type_env.clone().source_indices.clone(), ); - let elem_is_type_var = if (elem.inferred.clone() != None) { + let elem_is_type_var = if (elem.inferred.clone() != std::option::Option::None) { is_type_variable(elem.inferred.clone().clone().unwrap()) } else { false }; - if ((elem.ident_span.clone() != None) && !elem_is_type_var.clone()) { + if ((elem.ident_span.clone() != std::option::Option::None) + && !elem_is_type_var.clone()) + { render_rust_type( elem.clone(), shared_types.clone(), @@ -25221,12 +25289,12 @@ pub fn emit_rust_with_method_call( ); let type_name = match receiver.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { - let rt_is_error = if (rt.inferred.clone() != None) { + let rt_is_error = if (rt.inferred.clone() != std::option::Option::None) { crate::v1_std_core::is_compiler_error(rt.inferred.clone().clone().unwrap()) } else { false }; - if (rt_is_error.clone() || (rt.ident_span.clone() == None)) { + if (rt_is_error.clone() || (rt.ident_span.clone() == std::option::Option::None)) { "compile_error!(\"with method missing resolved record type\")".to_string() } else { crate::v1_std_core::qualified_last_segment( @@ -25555,7 +25623,7 @@ pub fn emit_typed_method_call( shared_types: Rc>, emit_info: Rc, ) -> String { - if (method_semantics.clone() != None) { + if (method_semantics.clone() != std::option::Option::None) { match (*method_semantics.clone().unwrap()).clone() { MethodSemantics::ServiceMethodSemantics { service_name: svc_name, @@ -25756,7 +25824,7 @@ pub fn emit_typed_method_call( shared_types.clone(), emit_info.clone(), ); - if (algebra_field_call.clone() != None) { + if (algebra_field_call.clone() != std::option::Option::None) { match algebra_field_call.clone() { Some(field_call) => field_call.clone(), None => "".to_string(), @@ -25963,7 +26031,7 @@ if rust_method_template_result_wraps_in_rc(method_name.clone()) { depth.clone(), shared_types.clone(), emit_info.clone(), - ) != None) + ) != std::option::Option::None) { match rust_callable_field_method_call( method.clone(), @@ -26176,7 +26244,7 @@ pub fn arm_resolved_parent_enum( scrut_type.clone(), type_summaries.clone(), ), - _ => None, + _ => std::option::Option::None, } } @@ -26489,7 +26557,7 @@ pub fn variant_pattern_field_binding_named( }) .first() .cloned(), - _ => None, + _ => std::option::Option::None, } } @@ -26550,9 +26618,10 @@ pub fn rc_grouped_arm_plan( let single_field = if ((rc.ref_bound_fields.clone().len() as i64) == 1) { rc.ref_bound_fields.clone().first().cloned() } else { - None + std::option::Option::None }; - let has_authored_guard = (crate::v1_std_core::arm_guard(arm.clone()) != None); + let has_authored_guard = + (crate::v1_std_core::arm_guard(arm.clone()) != std::option::Option::None); let string_guards = collect_pattern_string_guards(arm_pat.clone(), Rc::new(vec![]), si.clone()); match single_field.clone() { @@ -27059,7 +27128,9 @@ pub fn emit_typed_match_arm_body_str( .. } => { let body_name = crate::v1_std_core::expr_var_name_at(arm_b.clone(), si.clone()); - if (variant_parent_from_binding_kind(body_binding_kind.clone()) != None) { + if (variant_parent_from_binding_kind(body_binding_kind.clone()) + != std::option::Option::None) + { emit_var_ref( body_name.clone(), body_binding_kind.clone(), @@ -27301,7 +27372,7 @@ pub fn emit_typed_if( cond_str.clone(), then_branch.clone(), else_branch.clone(), - None, + std::option::Option::None, depth.clone(), RenderTarget::Rust, scope.type_env.clone().source_indices.clone(), @@ -27523,9 +27594,9 @@ pub fn rust_callable_field_value_wrap( let lambda = match value_node.clone() { Some(vn) => match (*vn.expr_data.clone()).clone() { ExprData::ExprLambda => Some(vn.clone()), - _ => None, + _ => std::option::Option::None, }, - None => None, + None => std::option::Option::None, }; match lambda.clone() { None => rust_shared_wrap_ctor(raw.clone()), @@ -27568,7 +27639,7 @@ pub fn rust_struct_field_type_node( field_name.clone(), scope.type_env.clone().source_indices.clone(), ), - None => None, + None => std::option::Option::None, } } @@ -27655,7 +27726,7 @@ pub fn rust_callable_field_method_call( )) } } else { - None + std::option::Option::None } } @@ -27692,7 +27763,7 @@ pub fn rust_struct_field_type_node_variant_aware( None => match v1_rt::map_get(&emit_info.variant_to_enum.clone(), struct_name.clone()) { Some(enum_name) => { if (enum_name.clone() == "".to_string()) { - None + std::option::Option::None } else { match crate::v1_compiler_infer_env::lookup_type_by_name( scope.type_env.clone(), @@ -27708,13 +27779,13 @@ pub fn rust_struct_field_type_node_variant_aware( field_name.clone(), scope.type_env.clone().source_indices.clone(), ), - None => None, + None => std::option::Option::None, }, - None => None, + None => std::option::Option::None, } } } - None => None, + None => std::option::Option::None, }, } } @@ -27732,7 +27803,7 @@ pub fn rust_struct_field_type_node_from_container( Some(field_node) => Some(crate::v1_compiler_infer_types::resolved_type( field_node.clone(), )), - None => None, + None => std::option::Option::None, } } @@ -27926,29 +27997,32 @@ pub fn lookup_struct_field_type_name( source_indices.clone(), ) { Some(field_child) => { - if (field_child.inferred.clone() != None) { + if (field_child.inferred.clone() != std::option::Option::None) { { let field_type = crate::v1_compiler_infer_types::resolved_type(field_child.clone()); - let ft_is_type_var = if (field_type.inferred.clone() != None) { - is_type_variable(field_type.inferred.clone().clone().unwrap()) - } else { - false - }; - if ((field_type.ident_span.clone() != None) && !ft_is_type_var.clone()) { + let ft_is_type_var = + if (field_type.inferred.clone() != std::option::Option::None) { + is_type_variable(field_type.inferred.clone().clone().unwrap()) + } else { + false + }; + if ((field_type.ident_span.clone() != std::option::Option::None) + && !ft_is_type_var.clone()) + { Some(crate::v1_std_core::authored_name_at( source_indices.clone(), field_type.clone(), )) } else { - None + std::option::Option::None } } } else { - None + std::option::Option::None } } - None => None, + None => std::option::Option::None, }; match direct.clone() { Some(_) => direct.clone(), @@ -27964,19 +28038,22 @@ pub fn lookup_struct_field_type_name( source_indices.clone(), ) { Some(field_child) => { - if (field_child.inferred.clone() != None) { + if (field_child.inferred.clone() != std::option::Option::None) { { let field_type = crate::v1_compiler_infer_types::resolved_type( field_child.clone(), ); - let ft_is_type_var = if (field_type.inferred.clone() != None) { + let ft_is_type_var = if (field_type.inferred.clone() + != std::option::Option::None) + { is_type_variable( field_type.inferred.clone().clone().unwrap(), ) } else { false }; - if ((field_type.ident_span.clone() != None) + if ((field_type.ident_span.clone() + != std::option::Option::None) && !ft_is_type_var.clone()) { Some(crate::v1_std_core::authored_name_at( @@ -27984,18 +28061,18 @@ pub fn lookup_struct_field_type_name( field_type.clone(), )) } else { - None + std::option::Option::None } } } else { - None + std::option::Option::None } } - None => None, + None => std::option::Option::None, }, - None => None, + None => std::option::Option::None, }, - None => None, + None => std::option::Option::None, }, } } @@ -28032,7 +28109,7 @@ pub fn emit_field_value_with_context( let expected_type = match node_lookup.clone() { Some(_) => node_lookup.clone(), None => { - if (struct_node.ident_span.clone() != None) { + if (struct_node.ident_span.clone() != std::option::Option::None) { match crate::v1_compiler_infer_emit_info::lookup_emit_type_summary( emit_info.clone(), crate::v1_std_core::authored_name_at( @@ -28044,10 +28121,10 @@ pub fn emit_field_value_with_context( &summary.field_type_map.clone(), field_name.clone(), ), - None => None, + None => std::option::Option::None, } } else { - None + std::option::Option::None } } }; @@ -28226,7 +28303,7 @@ pub fn ambiguous_anonymous_record_literal_diagnostics( let resolved = crate::v1_compiler_infer_types::resolved_type(n.clone()); if ((((n.children.clone().len() as i64) > 1) && crate::v1_compiler_infer_types::is_product_type(resolved.clone())) - && (resolved.ident_span.clone() == None)) + && (resolved.ident_span.clone() == std::option::Option::None)) { { let field_names = Rc::new({ @@ -28407,10 +28484,10 @@ pub fn find_struct_name_by_fields( if ((candidates.clone().len() as i64) == 1) { match candidates.clone().first().cloned() { Some(s) => Some(s.name.clone()), - None => None, + None => std::option::Option::None, } } else { - None + std::option::Option::None } } } @@ -28425,10 +28502,10 @@ pub fn find_unique_struct_name_by_fields( if ((candidates.clone().len() as i64) == 1) { match candidates.clone().first().cloned() { Some(s) => Some(s.name.clone()), - None => None, + None => std::option::Option::None, } } else { - None + std::option::Option::None } } } @@ -28458,22 +28535,22 @@ pub fn emit_typed_record_lit( scope.type_env.clone().source_indices.clone(), resolved_type.clone(), ); - if ((resolved_type.ident_span.clone() != None) + if ((resolved_type.ident_span.clone() != std::option::Option::None) && v1_rt::map_contains_key(&emit_info.type_summaries.clone(), rt_name.clone())) { Some(rt_name.clone()) } else { - None + std::option::Option::None } } }; let bare_qualified_name = match qualified_name.clone() { Some(qn) => Some(crate::v1_std_core::qualified_last_segment(qn.clone())), - None => None, + None => std::option::Option::None, }; let bare_parent_enum = match parent_enum.clone() { Some(pe) => Some(crate::v1_std_core::qualified_last_segment(pe.clone())), - None => None, + None => std::option::Option::None, }; let variant_surface_name = match type_name.clone() { Some(n) => n.clone(), @@ -28486,7 +28563,9 @@ pub fn emit_typed_record_lit( None => { let is_product = crate::v1_compiler_infer_types::is_product_type(resolved_type.clone()); - if (is_product.clone() && (resolved_type.ident_span.clone() == None)) { + if (is_product.clone() + && (resolved_type.ident_span.clone() == std::option::Option::None)) + { if ((fields.clone().len() as i64) == 1) { match fields.clone().first().cloned() { Some(f) => { @@ -28775,15 +28854,16 @@ pub fn emit_typed_record_lit( let effective_parent = match context_lookup.clone() { Some(context_parent) => Some(context_parent.clone()), None => { - let rt_is_type_var = if (resolved_type.inferred.clone() != None) { - is_type_variable(resolved_type.inferred.clone().clone().unwrap()) - } else { - false - }; + let rt_is_type_var = + if (resolved_type.inferred.clone() != std::option::Option::None) { + is_type_variable(resolved_type.inferred.clone().clone().unwrap()) + } else { + false + }; let rt_name = crate::v1_std_core::qualified_last_segment( crate::v1_std_core::authored_name_at(si.clone(), resolved_type.clone()), ); - if (((((resolved_type.ident_span.clone() != None) + if (((((resolved_type.ident_span.clone() != std::option::Option::None) && (rt_name.clone() != variant_surface_name.clone())) && !rt_is_type_var.clone()) && (rt_name.clone() != "Error".to_string())) @@ -29157,7 +29237,7 @@ pub fn emit_typed_record_lit( for fname in missing.iter().cloned() { __result.extend((*if is_optional_struct_field(emit_info.clone(), variant_summary_name.clone(), fname.clone()) { { - let wrapped_none = wrap_rust_record_field_value("None".to_string(), None, scope.clone(), emit_info.clone(), shared_types.clone(), ctor_name.clone(), fname.clone()); + let wrapped_none = wrap_rust_record_field_value("None".to_string(), std::option::Option::None, scope.clone(), emit_info.clone(), shared_types.clone(), ctor_name.clone(), fname.clone()); Rc::new(vec![v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(" ".to_string(), crate::v1_compiler_emit::emit_ident(fname.clone(), RenderTarget::Rust)), ": ".to_string()), wrapped_none.clone()), ",".to_string())]) } } else { @@ -29255,7 +29335,7 @@ pub fn rust_zero_value(type_name: String) -> Option { if (type_name.clone() == "String".to_string()) { Some("\"\".to_string()".to_string()) } else { - None + std::option::Option::None } } } @@ -29298,133 +29378,370 @@ pub fn emit_typed_bin_op( RenderTarget::Rust, ) } else { - { - let op_str = crate::v1_compiler_emit::emit_bin_op_symbol( + match (*binop_operator_realization(op.clone(), left.clone(), scope.clone())).clone() { + OperatorRealization::OperatorRealizationRefused { cause: c, .. } => { + emit_rust_compile_error_expr( + crate::std_operator_realization::operator_realization_refusal_message( + c.clone(), + ), + ) + } + OperatorRealization::StructuralComparison { + binding: b, + test: t, + .. + } => emit_rust_structural_comparison( + l_str.clone(), + r_str.clone(), + b.clone(), + t.clone(), + ), + OperatorRealization::StructuralEquality { declaration: _, .. } => { + emit_rust_host_bin_op( + op.clone(), + algebra_field.clone(), + left.clone(), + right.clone(), + l_str.clone(), + r_str.clone(), + scope.clone(), + ) + } + OperatorRealization::HostOperator => emit_rust_host_bin_op( op.clone(), - RenderTarget::Rust, algebra_field.clone(), - ); - if is_string_comparison( - op.clone(), left.clone(), right.clone(), - scope.type_env.clone().source_indices.clone(), + l_str.clone(), + r_str.clone(), + scope.clone(), + ), + } + } + } +} + +pub fn rust_operand_realization( + operand: Rc, + scope: Rc, +) -> Rc { + rust_operand_realization_of_type( + crate::v1_compiler_infer_types::resolved_type(operand.clone()), + scope.clone(), + 8, + ) +} + +pub fn rust_operand_realization_of_type( + mut rt: Rc, + mut scope: Rc, + mut fuel: i64, +) -> Rc { + loop { + match crate::v1_compiler_infer_env::type_reference_declaration_ref( + rt.clone(), + scope.type_env.clone().source_indices.clone(), + scope.type_env.clone(), + ) { + None => { + break Rc::new(OperandRealization::OperandIdentityUnavailable); + } + Some(d) => { + if crate::v1_compiler_coercion::declaration_realizes_natively_on_rust( + d.clone(), + crate::v1_compiler_coercion::type_reference_decl_file(rt.clone()), ) { + break Rc::new(OperandRealization::HostNumericOperand); + } else { + let decl = match rt.inferred.clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: r, .. }) => r.clone(), + _ => rt.clone(), + }; + if ((fuel.clone() > 0) + && crate::v1_compiler_infer::is_where_refinement_type(rt.clone())) { - let l_optional = is_optional_typed_expr(left.clone()); - let r_optional = is_optional_typed_expr(right.clone()); - if (l_optional.clone() || r_optional.clone()) { + match rt.children.clone().first().cloned() { + Some(base) => { + let base_resolved = + match crate::v1_compiler_infer_env::lookup_type_for( + scope.type_env.clone(), + base.clone(), + ) { + Some(r) => r.clone(), + None => base.clone(), + }; + { + let __tco_0 = base_resolved.clone(); + let __tco_1 = (fuel - 1); + rt = __tco_0; + fuel = __tco_1; + continue; + } + } + None => { + break Rc::new(OperandRealization::StructuralOperand { + declaration: d.clone(), + }); + } + } + } else { + if ((fuel.clone() > 0) + && crate::v1_compiler_emit_core_support::is_type_alias_item( + decl.clone(), + scope.type_env.clone().source_indices.clone(), + )) + { { - let l_cmp = if l_optional.clone() { - v1_rt::concat(l_str.clone(), ".as_deref()".to_string()) - } else { - v1_rt::concat( - v1_rt::concat( - "Some(".to_string(), - emit_rust_dag_string_to_host_via_seam(l_str.clone()), - ), - ").as_deref()".to_string(), - ) - }; - let r_cmp = if r_optional.clone() { - v1_rt::concat(r_str.clone(), ".as_deref()".to_string()) - } else { - v1_rt::concat( - v1_rt::concat( - "Some(".to_string(), - emit_rust_dag_string_to_host_via_seam(r_str.clone()), - ), - ").as_deref()".to_string(), - ) - }; + let __tco_0 = + crate::v1_compiler_infer_types::resolved_type(decl.clone()); + let __tco_1 = (fuel - 1); + rt = __tco_0; + fuel = __tco_1; + continue; + } + } else { + break Rc::new(OperandRealization::StructuralOperand { + declaration: d.clone(), + }); + } + } + } + } + } + } +} + +pub fn binop_operator_realization( + op: BinOp, + left: Rc, + scope: Rc, +) -> Rc { + crate::std_operator_realization::operator_realization_for( + op.clone(), + rust_operand_realization(left.clone(), scope.clone()), + structural_ordering_rows(), + ) +} + +pub fn rust_declaration_path(module_path: String, decl_name: String) -> String { + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + "crate::".to_string(), + crate::v1_compiler_emit_core_support::module_to_filename(module_path.clone()), + ), + "::".to_string(), + ), + crate::v1_compiler_emit::emit_ident(decl_name.clone(), RenderTarget::Rust), + ) +} + +pub fn emit_rust_structural_comparison( + l_str: String, + r_str: String, + binding: Rc, + test: Rc, +) -> String { + { + let call = v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + rust_declaration_path( + binding.compare.clone().module_path.clone(), + binding.compare.clone().decl_name.clone(), + ), + "(".to_string(), + ), + l_str.clone(), + ), + ", ".to_string(), + ), + r_str.clone(), + ), + ")".to_string(), + ); + let ordering = v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + "crate::".to_string(), + crate::v1_compiler_emit_core_support::module_to_filename( + binding.ordering.clone().module_path.clone(), + ), + ), + "::".to_string(), + ), + binding.ordering.clone().decl_name.clone(), + ); + match (*test.clone()).clone() { + OrderingTest::OrderingIs { variant: v, .. } => v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat("(".to_string(), call.clone()), + " == ".to_string(), + ), + ordering.clone(), + ), + "::".to_string(), + ), + v.clone(), + ), + ")".to_string(), + ), + OrderingTest::OrderingIsNot { variant: v, .. } => v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat("(".to_string(), call.clone()), + " != ".to_string(), + ), + ordering.clone(), + ), + "::".to_string(), + ), + v.clone(), + ), + ")".to_string(), + ), + } + } +} + +pub fn emit_rust_host_bin_op( + op: BinOp, + algebra_field: Option, + left: Rc, + right: Rc, + l_str: String, + r_str: String, + scope: Rc, +) -> String { + { + let op_str = crate::v1_compiler_emit::emit_bin_op_symbol( + op.clone(), + RenderTarget::Rust, + algebra_field.clone(), + ); + if is_string_comparison( + op.clone(), + left.clone(), + right.clone(), + scope.type_env.clone().source_indices.clone(), + ) { + { + let l_optional = is_optional_typed_expr(left.clone()); + let r_optional = is_optional_typed_expr(right.clone()); + if (l_optional.clone() || r_optional.clone()) { + { + let l_cmp = if l_optional.clone() { + v1_rt::concat(l_str.clone(), ".as_deref()".to_string()) + } else { + v1_rt::concat( + v1_rt::concat( + "Some(".to_string(), + emit_rust_dag_string_to_host_via_seam(l_str.clone()), + ), + ").as_deref()".to_string(), + ) + }; + let r_cmp = if r_optional.clone() { + v1_rt::concat(r_str.clone(), ".as_deref()".to_string()) + } else { + v1_rt::concat( + v1_rt::concat( + "Some(".to_string(), + emit_rust_dag_string_to_host_via_seam(r_str.clone()), + ), + ").as_deref()".to_string(), + ) + }; + v1_rt::concat( + v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat("(".to_string(), l_cmp.clone()), - " ".to_string(), - ), - op_str.clone(), - ), + v1_rt::concat("(".to_string(), l_cmp.clone()), " ".to_string(), ), - r_cmp.clone(), + op_str.clone(), ), - ")".to_string(), - ) - } - } else { + " ".to_string(), + ), + r_cmp.clone(), + ), + ")".to_string(), + ) + } + } else { + v1_rt::concat( + v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - "(".to_string(), - emit_rust_dag_string_to_host_via_seam( - l_str.clone(), - ), - ), - " ".to_string(), - ), - op_str.clone(), + "(".to_string(), + emit_rust_dag_string_to_host_via_seam(l_str.clone()), ), " ".to_string(), ), - emit_rust_dag_string_to_host_via_seam(r_str.clone()), + op_str.clone(), ), - ")".to_string(), - ) - } - } - } else { - { - let both_string = (is_string_typed_expr( - left.clone(), - scope.type_env.clone().source_indices.clone(), - ) && is_string_typed_expr( - right.clone(), - scope.type_env.clone().source_indices.clone(), - )); - let is_str_concat = - ((op_str.clone() == "+".to_string()) && both_string.clone()); - if is_str_concat.clone() { + " ".to_string(), + ), + emit_rust_dag_string_to_host_via_seam(r_str.clone()), + ), + ")".to_string(), + ) + } + } + } else { + { + let both_string = (is_string_typed_expr( + left.clone(), + scope.type_env.clone().source_indices.clone(), + ) && is_string_typed_expr( + right.clone(), + scope.type_env.clone().source_indices.clone(), + )); + let is_str_concat = ((op_str.clone() == "+".to_string()) && both_string.clone()); + if is_str_concat.clone() { + v1_rt::concat( + v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat("(".to_string(), l_str.clone()), - " ".to_string(), - ), - op_str.clone(), - ), - " &".to_string(), + v1_rt::concat("(".to_string(), l_str.clone()), + " ".to_string(), ), - r_str.clone(), + op_str.clone(), ), - ")".to_string(), - ) - } else { + " &".to_string(), + ), + r_str.clone(), + ), + ")".to_string(), + ) + } else { + v1_rt::concat( + v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat("(".to_string(), l_str.clone()), - " ".to_string(), - ), - op_str.clone(), - ), + v1_rt::concat("(".to_string(), l_str.clone()), " ".to_string(), ), - r_str.clone(), + op_str.clone(), ), - ")".to_string(), - ) - } - } + " ".to_string(), + ), + r_str.clone(), + ), + ")".to_string(), + ) } } } @@ -32270,7 +32587,7 @@ pub fn operation_response_200_resolved_type( crate::v1_compiler_infer_types::normalize_access_type_node(v.clone()), ); if (type_name.clone() == "".to_string()) { - None + std::option::Option::None } else { crate::v1_compiler_infer_env::lookup_type_by_name( env.clone(), @@ -32280,7 +32597,7 @@ pub fn operation_response_200_resolved_type( } } } - None => None, + None => std::option::Option::None, } } @@ -32370,7 +32687,7 @@ pub fn wire_child_for_segment( .cloned() { Some(ch) => Some(ch.clone()), - None => None, + None => std::option::Option::None, } } } @@ -32391,7 +32708,7 @@ pub fn advance_wire_path_projection( n.clone(), source_indices.clone(), )), - None => None, + None => std::option::Option::None, }; Rc::new(WirePathProjection { expr: v1_rt::concat( @@ -32444,14 +32761,14 @@ pub fn advance_wire_path_projection( }), None => Rc::new(WirePathProjection { expr: state.expr.clone(), - node: None, + node: std::option::Option::None, ok: false, }), } } None => Rc::new(WirePathProjection { expr: state.expr.clone(), - node: None, + node: std::option::Option::None, ok: false, }), } @@ -33393,10 +33710,10 @@ pub fn emit_shell_return( Some(ch) => { crate::v1_compiler_emit::child_from_key(ch.clone(), source_indices.clone()) } - None => None, + None => std::option::Option::None, } } else { - None + std::option::Option::None }; match single_from.clone() { Some(channel) => { @@ -33961,7 +34278,8 @@ pub fn data_def_annotation_is_named_refinement( { let ann_name = crate::v1_std_core::authored_name_at(source_indices.clone(), annotation.clone()); - ((((ann_name.clone() != "".to_string()) && (annotation.type_annotation.clone() != None)) + ((((ann_name.clone() != "".to_string()) + && (annotation.type_annotation.clone() != std::option::Option::None)) && !crate::std_types::is_container_type(ann_name.clone())) && !is_host_text_carrier_type(annotation.clone(), source_indices.clone())) } @@ -34196,7 +34514,7 @@ pub fn emit_data_def_body( "meet".to_string(), scope.type_env.clone().source_indices.clone(), ), - None => None, + None => std::option::Option::None, }, }; let join_value = match field_value_by_name( @@ -34211,7 +34529,7 @@ pub fn emit_data_def_body( "join".to_string(), scope.type_env.clone().source_indices.clone(), ), - None => None, + None => std::option::Option::None, }, }; let meet_str = match meet_value.clone() { @@ -34857,9 +35175,9 @@ pub fn extract_literal_string(expr: Rc) -> Option { } else { "false".to_string() }), - _ => None, + _ => std::option::Option::None, }, - _ => None, + _ => std::option::Option::None, } } @@ -34995,7 +35313,7 @@ pub fn data_decl_in_module( ) -> Option> { match v1_rt::map_get(&index.by_module.clone(), module_path.clone()) { Some(m) => v1_rt::map_get(&m, name.clone()), - None => None, + None => std::option::Option::None, } } @@ -35503,7 +35821,7 @@ pub fn is_workflow_item( registry: Rc>>, source_indices: Rc>>, ) -> bool { - if (item.body.clone() == None) { + if (item.body.clone() == std::option::Option::None) { false } else { if ((item.uses.clone().len() as i64) > 0) { @@ -35588,10 +35906,10 @@ pub fn cli_default_literal_value(expr: Rc) -> Option { } else { crate::v1_compiler_emit::emit_keyword("false".to_string(), RenderTarget::Rust) }), - LiteralValue::LitNull => None, + LiteralValue::LitNull => std::option::Option::None, LiteralValue::LitSymbol { value: s, .. } => Some(s.clone()), }, - _ => None, + _ => std::option::Option::None, } } @@ -36241,12 +36559,12 @@ pub fn cli_option_default_literal(value: Rc) -> Option { CliOptionValue::CliTextValue { text_default: d, .. } => d.clone(), - CliOptionValue::CliToggleValue => None, + CliOptionValue::CliToggleValue => std::option::Option::None, CliOptionValue::CliPortValue { port_default: d, .. } => match d.clone() { Some(p) => Some(crate::v1_compiler_emit_core_support::to_string(p.clone())), - None => None, + None => std::option::Option::None, }, CliOptionValue::CliMillisecondValue { millisecond_default: d, @@ -36255,7 +36573,7 @@ pub fn cli_option_default_literal(value: Rc) -> Option { Some(ms) => Some(crate::v1_compiler_emit_core_support::to_string( crate::std_measure::millisecond_count(ms.clone()), )), - None => None, + None => std::option::Option::None, }, } } diff --git a/src/v1/stage0/src/v1_compiler_frontend_observation.rs b/src/v1/stage0/src/v1_compiler_frontend_observation.rs index a9075da9eff..6ad2ff557b0 100644 --- a/src/v1/stage0/src/v1_compiler_frontend_observation.rs +++ b/src/v1/stage0/src/v1_compiler_frontend_observation.rs @@ -55,7 +55,7 @@ pub fn frontend_phase_receipt(frontend: Rc) -> FrontendPhaseRece .references .clone() .len() as i64), - graph_present: (frontend.graph.clone() != None), + graph_present: (frontend.graph.clone() != std::option::Option::None), } } diff --git a/src/v1/stage0/src/v1_compiler_infer.rs b/src/v1/stage0/src/v1_compiler_infer.rs index b608364f232..277e165f623 100644 --- a/src/v1/stage0/src/v1_compiler_infer.rs +++ b/src/v1/stage0/src/v1_compiler_infer.rs @@ -7,10 +7,12 @@ use self::DescentSizeExpr::*; use self::InhabitanceRefusalReason::*; use self::InhabitanceUndecidableReason::*; use self::InhabitanceVerdict::*; +use self::LiteralBoundary::*; use self::ServiceConfigFieldJudgment::*; pub use crate::extdeps_container_oci_digest::{ oci_other_digest_algorithm, oci_other_digest_encoded, }; +pub use crate::gunbc_structural_realization_bindings::literal_homomorphism_rows; pub use crate::std_algebra::AlgebraFieldTemplate; use crate::std_algebra::CollectionSizeEffect::ShrinkEffect; pub use crate::std_algebra::{CollectionSizeEffect, FreeMonoid}; @@ -23,6 +25,7 @@ pub use crate::std_content_hash::{ content_hash_validate_lower_hex_length, }; pub use crate::std_content_hash::{ContentHash, Fnv1a64Structural}; +pub use crate::std_decl_ref::DeclarationRef; pub use crate::std_dissolution::DissolutionCondition; use crate::std_dissolution::DissolutionCondition::*; pub use crate::std_dissolution::{dissolution_description, unbound_dissolution}; @@ -41,14 +44,24 @@ pub use crate::std_induction::{InductiveField, RecursionShape, SubValueRelation} use crate::std_interface_summary::ExportKind::{ExportData, ExportFn, ExportService, ExportType}; pub use crate::std_interface_summary::{interface_summary_rollup, signature_contract}; pub use crate::std_interface_summary::{ExportEntry, ExportKind, InterfaceSummary}; +use crate::std_literal_elaboration::LiteralElaborationOutcome::{ + DirectLiteral, LiteralElaborationRefused, ViaHomomorphism, +}; +use crate::std_literal_elaboration::LiteralUnfolding::{BooleanUnfold, PeanoUnfold}; +pub use crate::std_literal_elaboration::{ + elaborate_literal_at, literal_elaboration_refusal_message, literal_source_kind_of, +}; +pub use crate::std_literal_elaboration::{ + LiteralElaboration, LiteralElaborationOutcome, LiteralHomomorphism, LiteralUnfolding, +}; pub use crate::std_node::{compiler_inductive_fields, compiler_recursive_types}; pub use crate::std_occurrence_identity::NodeOccurrenceIdentity; use crate::std_occurrence_identity::NodeOccurrenceIdentity::OccurrenceSynthetic; pub use crate::std_occurrence_identity::OccurrenceId; use crate::std_syntax::BinOp::Add; use crate::std_syntax::BinOp::{And, Div, Eq, Ge, Gt, Le, Lt, Mod, Mul, Ne, NullCoalesce, Or, Sub}; -use crate::std_syntax::LiteralValue::LitStr; -use crate::std_syntax::LiteralValue::{LitBool, LitFloat, LitInt, LitNull}; +use crate::std_syntax::LiteralValue::{LitBool, LitInt, LitStr}; +use crate::std_syntax::LiteralValue::{LitFloat, LitNull}; pub use crate::std_syntax::{BinOp, LiteralValue}; pub use crate::std_termination::PositiveDescentAmount; use crate::std_termination::PositiveDescentAmount::OneStep; @@ -86,7 +99,8 @@ pub use crate::v1_compiler_infer_env::{ node_with_inferred, put_inductive_field, put_inductive_field_cross, qualified_all_but_last, qualify_borrowed_inferred, qualify_borrowed_type_names, qualify_decl_reference_positions, str_bindings_from_bindings, symbol_index_insert, symbol_index_insert_decl, - symbol_index_insert_service, symbol_index_lookup, unit_variant_index_shadow_insert, + symbol_index_insert_service, symbol_index_lookup, type_reference_declaration_ref, + unit_variant_index_shadow_insert, }; pub use crate::v1_compiler_infer_env::{ GlobalBareCandidate, GlobalBareLookupState, GuardedTypeEnvCacheMerge, ServiceCensusEntry, @@ -173,13 +187,16 @@ pub use crate::v1_compiler_infer_types::{ template_return_is_receiver_self, }; pub use crate::v1_compiler_resolve::{ModuleGraph, ResolvedImport, ResolvedModule}; -pub use crate::v1_compiler_type_head_exposure::type_declaration_identity_key; use crate::v1_compiler_type_head_exposure::TypeHeadExposure::{ ExposedTypeHead, MalformedApplicationHead, OpaqueTypeHead, StuckTypeHead, }; use crate::v1_compiler_type_head_exposure::TypeHeadView::{ ApplicationHead, CallableHead, CoproductHead, KernelScalarHead, ProductHead, }; +pub use crate::v1_compiler_type_head_exposure::{ + type_declaration_identity_key, type_head_exposure_is_coproduct, + type_head_exposure_is_kernel_scalar, type_head_exposure_is_product, +}; pub use crate::v1_compiler_type_head_exposure::{TypeHeadExposure, TypeHeadView}; use crate::v1_rt; use crate::v1_rt::{VecCompat, VecJoin}; @@ -203,9 +220,10 @@ use crate::v1_std_core::CompilerDiagnostic::{ }; use crate::v1_std_core::Connective::{Arrow, Conj, Disj, NoConnective}; use crate::v1_std_core::ExprData::{ - ExprBinOp, ExprBlock, ExprCall, ExprCast, ExprError, ExprFieldAccess, ExprForEach, ExprIf, - ExprIndex, ExprLambda, ExprLet, ExprListLit, ExprLiteral, ExprMatch, ExprMethodCall, - ExprRecordLit, ExprReturn, ExprSlice, ExprStringInterp, ExprUnaryOp, ExprVar, NoExprData, + ExprBinOp, ExprBlock, ExprCall, ExprCast, ExprElaboratedLiteral, ExprError, ExprFieldAccess, + ExprForEach, ExprIf, ExprIndex, ExprLambda, ExprLet, ExprListLit, ExprLiteral, ExprMatch, + ExprMethodCall, ExprRecordLit, ExprReturn, ExprSlice, ExprStringInterp, ExprUnaryOp, ExprVar, + NoExprData, }; use crate::v1_std_core::ExprErrorKind::{ CensusHeadsBodyStripped, InternalExprError, ParseRecoveryError, SemanticExprError, @@ -364,7 +382,7 @@ pub fn infer_block_stmts( let stmt_expected = if is_last.clone() { expected.clone() } else { - None + std::option::Option::None }; let stmt_result = infer_expr(stmt.clone(), scope.clone(), stmt_expected.clone()); let stmt_typed = stmt_result.typed.clone(); @@ -501,7 +519,7 @@ pub fn merge_scope_from_imports( let parent_result = typed_parent.items.clone().iter().cloned().fold(Rc::new(InferScopeComponents { svc_registry: svc_registry.clone(), svc_locals: svc_locals.clone(), -}), |acc: Rc, titem: Rc| if ((titem.transport.clone() != None) && ((titem.children.clone().len() as i64) > 0)) { +}), |acc: Rc, titem: Rc| if ((titem.transport.clone() != std::option::Option::None) && ((titem.children.clone().len() as i64) > 0)) { { let entries = Rc::new({ let mut __result = Vec::new(); for c in titem.children.clone().iter().cloned() { __result.push(Rc::new(OpEntry { name: crate::v1_std_core::authored_name_at(env.source_indices.clone(), c.clone()), @@ -515,7 +533,7 @@ Rc::new(InferScopeComponents { }) } } else { - if (((((titem.body.clone() != None) && ((titem.params.clone().len() as i64) == 0)) && (titem.transport.clone() == None)) && (titem.connective.clone() == Connective::NoConnective)) && (titem.inferred.clone() != None)) { + if (((((titem.body.clone() != std::option::Option::None) && ((titem.params.clone().len() as i64) == 0)) && (titem.transport.clone() == std::option::Option::None)) && (titem.connective.clone() == Connective::NoConnective)) && (titem.inferred.clone() != std::option::Option::None)) { Rc::new(InferScopeComponents { svc_registry: acc.svc_registry.clone(), svc_locals: v1_rt::rc_map_insert(acc.svc_locals.clone(), crate::v1_std_core::authored_name_at(env.source_indices.clone(), titem.clone()), Rc::new(TypeBinding { @@ -646,11 +664,11 @@ pub fn classify_field_recursion( shape: RecursionShape::MapValueRecursion, element_type: elem.clone(), })), - _ => None, + _ => std::option::Option::None, } } } else { - None + std::option::Option::None } } } else { @@ -666,7 +684,7 @@ pub fn classify_field_recursion( })), } } else { - None + std::option::Option::None } } } @@ -783,13 +801,13 @@ pub fn nominal_ref_node( })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }) @@ -909,15 +927,15 @@ pub fn lookup_variant_parent_enum(scope: Rc, name: String) -> Option binding.resolved.clone(), )) } else { - None + std::option::Option::None } } else { - None + std::option::Option::None } } - None => None, + None => std::option::Option::None, }, - None => None, + None => std::option::Option::None, } } @@ -938,10 +956,10 @@ pub fn expected_variant_owner_instantiation( scope.type_env.clone().source_indices.clone(), ) { Some(_) => Some(exp_enum.clone()), - None => None, + None => std::option::Option::None, } } - None => None, + None => std::option::Option::None, } } @@ -992,10 +1010,10 @@ pub fn variant_owner_node(scope: Rc, name: String) -> Option None, + None => std::option::Option::None, } } else { match v1_rt::map_get(&scope.locals.clone(), name.clone()) { @@ -1013,15 +1031,15 @@ pub fn variant_owner_node(scope: Rc, name: String) -> Option None, + None => std::option::Option::None, }, - None => None, + None => std::option::Option::None, } } } @@ -1138,7 +1156,7 @@ pub fn decl_ref_coords_equal(a: Rc, b: Rc) -> bool pub fn caller_decl_coords(scope: Rc) -> Option> { if (scope.caller_decl_name.clone() == "".to_string()) { - None + std::option::Option::None } else { Some(Rc::new(DeclRefCoords { module_path: scope.module_name.clone(), @@ -1242,7 +1260,7 @@ pub fn constructor_reference_admission_unshadowed( scope: Rc, ) -> Option> { if v1_rt::map_has(&scope.body_locals.clone(), callee_name.clone()) { - None + std::option::Option::None } else { constructor_reference_admission_early_refusal( callee_name.clone(), @@ -1763,7 +1781,7 @@ pub fn record_lit_expanded_from_expected( { Some(expanded.clone()) } else { - None + std::option::Option::None } } _ => { @@ -1775,15 +1793,15 @@ pub fn record_lit_expanded_from_expected( { Some(rt.clone()) } else { - None + std::option::Option::None } } } } } - None => None, + None => std::option::Option::None, }, - None => None, + None => std::option::Option::None, } } @@ -1815,7 +1833,7 @@ pub fn record_lit_expected_coproduct( None => Some(elem_ty.clone()), } } - None => None, + None => std::option::Option::None, } } else { Some(resolved.clone()) @@ -1825,13 +1843,13 @@ pub fn record_lit_expected_coproduct( if (n.connective.clone() == Connective::Disj) { Some(n.clone()) } else { - None + std::option::Option::None } } - None => None, + None => std::option::Option::None, } } - None => None, + None => std::option::Option::None, } } @@ -1847,9 +1865,9 @@ pub fn record_lit_parent_enum_from_expected( scope.type_env.clone().source_indices.clone(), coproduct.clone(), )), - None => None, + None => std::option::Option::None, }, - None => None, + None => std::option::Option::None, } } @@ -1875,9 +1893,9 @@ pub fn record_lit_variant_from_expected( }) .first() .cloned(), - None => None, + None => std::option::Option::None, }, - None => None, + None => std::option::Option::None, } } @@ -1893,10 +1911,10 @@ pub fn record_lit_fields_from_expected( { Some(expanded.children.clone()) } else { - None + std::option::Option::None } } - None => None, + None => std::option::Option::None, } } @@ -1945,10 +1963,10 @@ pub fn record_lit_instantiated_fields( tn.clone(), ) == false) { - None + std::option::Option::None } else { if ((exp.children.clone().len() as i64) == 0) { - None + std::option::Option::None } else { match crate::v1_compiler_infer_env::lookup_type_for( scope.type_env.clone(), @@ -1958,7 +1976,7 @@ pub fn record_lit_instantiated_fields( if ((decl.params.clone().len() as i64) != (exp.children.clone().len() as i64)) { - None + std::option::Option::None } else { { let subst = Rc::new(decl.params.clone().iter().cloned().enumerate().map(|(i, v)| (i as i64, v)).collect::>()).iter().cloned().fold(v1_rt::rc_empty_map::>(), |acc: Rc>>, pair: (i64, Rc)| { @@ -2001,15 +2019,15 @@ match exp.children.clone().iter().cloned().skip(pair.0.clone() as usize).next() } } } - None => None, + None => std::option::Option::None, } } } } - None => None, + None => std::option::Option::None, } } - None => None, + None => std::option::Option::None, } } @@ -2092,7 +2110,7 @@ pub fn set_element_type_from_receiver( Some(elem_slot) => Some(crate::v1_compiler_infer_types::child_type_node( elem_slot.clone(), )), - None => None, + None => std::option::Option::None, } } @@ -2162,7 +2180,7 @@ pub fn brand_grounds_transparently_to( Some(resolved) => { ((((resolved.connective.clone() == Connective::NoConnective) && ((resolved.children.clone().len() as i64) == 0)) - && (resolved.inferred.clone() != None)) + && (resolved.inferred.clone() != std::option::Option::None)) && match resolved.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { let target_name = crate::v1_std_core::authored_name_at( @@ -2236,7 +2254,8 @@ pub fn nominal_call_arg_brand_mismatch( } pub fn is_where_refinement_type(ty: Rc) -> bool { - (((ty.connective.clone() == Connective::Conj) && (ty.type_annotation.clone() != None)) + (((ty.connective.clone() == Connective::Conj) + && (ty.type_annotation.clone() != std::option::Option::None)) && ((ty.children.clone().len() as i64) == 1)) } @@ -2327,7 +2346,7 @@ pub fn where_predicate_named_int_arg( source_indices.clone(), ) { Some(field_expr) => crate::v1_std_core::expr_literal_int_optional(field_expr.clone()), - None => None, + None => std::option::Option::None, } } @@ -2487,7 +2506,7 @@ pub fn where_predicate_guaranteed_min_length(pred_name: String) -> Option { if (pred_name.clone() == "lower_hex_128".to_string()) { Some(128) } else { - None + std::option::Option::None } } } @@ -2499,7 +2518,7 @@ pub fn where_predicate_required_min_length(pred_name: String) -> Option { if (pred_name.clone() == "non_empty".to_string()) { Some(1) } else { - None + std::option::Option::None } } @@ -2589,7 +2608,7 @@ pub fn decidable_where_int_predicate_holds( Some(field_expr) => { match crate::v1_std_core::expr_literal_int_optional(field_expr.clone()) { Some(lo) => Some((value.clone() >= lo.clone())), - None => None, + None => std::option::Option::None, } } }; @@ -2602,20 +2621,20 @@ pub fn decidable_where_int_predicate_holds( Some(field_expr) => { match crate::v1_std_core::expr_literal_int_optional(field_expr.clone()) { Some(hi) => Some((value.clone() <= hi.clone())), - None => None, + None => std::option::Option::None, } } }; match passes_min.clone() { Some(min_ok) => match passes_max.clone() { Some(max_ok) => Some((min_ok.clone() && max_ok.clone())), - None => None, + None => std::option::Option::None, }, - None => None, + None => std::option::Option::None, } } } else { - None + std::option::Option::None } } } @@ -2699,7 +2718,7 @@ pub fn decidable_where_string_predicate_holds(pred_name: String, value: String) ), ) } else { - None + std::option::Option::None } } } @@ -2726,11 +2745,11 @@ pub fn where_predicate_range_non_literal_bound_reason( ) { Some(max_expr) => { match crate::v1_std_core::expr_literal_int_optional(max_expr.clone()) { - Some(_) => None, + Some(_) => std::option::Option::None, None => Some("predicate argument is not an int literal".to_string()), } } - None => None, + None => std::option::Option::None, }, None => Some("predicate argument is not an int literal".to_string()), }, @@ -2741,10 +2760,10 @@ pub fn where_predicate_range_non_literal_bound_reason( ) { Some(max_expr) => match crate::v1_std_core::expr_literal_int_optional(max_expr.clone()) { - Some(_) => None, + Some(_) => std::option::Option::None, None => Some("predicate argument is not an int literal".to_string()), }, - None => None, + None => std::option::Option::None, }, } } @@ -3193,7 +3212,8 @@ pub fn kernel_value_declared_type_mismatch_bounded( let decl_is_refinement_over_actual = (((decl.connective.clone() == Connective::Conj) && ((decl.children.clone().len() as i64) == 1)) - && ((decl.type_annotation.clone() != None) + && ((decl.type_annotation.clone() + != std::option::Option::None) || match decl.children.clone().first().cloned() { Some(refinement_child) => { (crate::v1_std_core::authored_name_at( @@ -3672,6 +3692,7 @@ pub enum DeclaredTypePosition { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct DeclaredTypeObligation { pub position: DeclaredTypePosition, + pub subject: String, pub declared: Rc, pub produced: Rc, pub span: Rc, @@ -3711,7 +3732,7 @@ pub enum InhabitanceVerdict { }, } -pub fn declared_type_position_label(position: DeclaredTypePosition) -> String { +pub fn declared_type_position_label(position: DeclaredTypePosition, subject: String) -> String { match position.clone() { DeclaredTypePosition::PositionRecordLiteralField => "record literal field".to_string(), DeclaredTypePosition::PositionListElement => "list element".to_string(), @@ -3724,7 +3745,19 @@ pub fn declared_type_position_label(position: DeclaredTypePosition) -> String { DeclaredTypePosition::PositionCastTarget => "cast target".to_string(), DeclaredTypePosition::PositionParameterDefault => "parameter default".to_string(), DeclaredTypePosition::PositionCallableReturn => "callable return".to_string(), - DeclaredTypePosition::PositionDirectCallArgument => "direct call argument".to_string(), + DeclaredTypePosition::PositionDirectCallArgument => { + if (subject.clone() == "".to_string()) { + "direct call argument".to_string() + } else { + v1_rt::concat( + v1_rt::concat( + "direct call argument for parameter '".to_string(), + subject.clone(), + ), + "'".to_string(), + ) + } + } } } @@ -3770,36 +3803,67 @@ pub fn declared_type_inhabitance( ) { Rc::new(InhabitanceVerdict::Inhabits) } else { - if kernel_value_declared_type_mismatch( + if collection_at_scalar_declared_type( declared.clone(), produced.clone(), - scope.type_env.clone(), - source_indices.clone(), + scope.clone(), ) { Rc::new(InhabitanceVerdict::InhabitanceRefused { reason: InhabitanceRefusalReason::RefusedKernelAtStructured, }) } else { - if coproduct_payload_where_parent_required( + if record_at_scalar_needs_identity( declared.clone(), produced.clone(), scope.clone(), ) { - Rc::new(InhabitanceVerdict::InhabitanceRefused { - reason: InhabitanceRefusalReason::RefusedPayloadAtParent, - }) + Rc::new(InhabitanceVerdict::InhabitanceUndecidable { + reason: InhabitanceUndecidableReason::UndecidableProducedIdentityErased, +}) } else { - match nominal_product_inhabitance_refusal( + if coproduct_at_record_declared_type( declared.clone(), produced.clone(), scope.clone(), ) { - Some(r) => { + Rc::new(InhabitanceVerdict::InhabitanceRefused { + reason: + InhabitanceRefusalReason::RefusedKernelAtStructured, + }) + } else { + if kernel_value_declared_type_mismatch( + declared.clone(), + produced.clone(), + scope.type_env.clone(), + source_indices.clone(), + ) { Rc::new(InhabitanceVerdict::InhabitanceRefused { - reason: r.clone(), - }) + reason: InhabitanceRefusalReason::RefusedKernelAtStructured, +}) + } else { + if coproduct_payload_where_parent_required( + declared.clone(), + produced.clone(), + scope.clone(), + ) { + Rc::new(InhabitanceVerdict::InhabitanceRefused { + reason: InhabitanceRefusalReason::RefusedPayloadAtParent, +}) + } else { + match nominal_product_inhabitance_refusal( + declared.clone(), + produced.clone(), + scope.clone(), + ) { + Some(r) => Rc::new( + InhabitanceVerdict::InhabitanceRefused { + reason: r.clone(), + }, + ), + None => Rc::new(InhabitanceVerdict::Inhabits), + } + } } - None => Rc::new(InhabitanceVerdict::Inhabits), } } } @@ -3811,6 +3875,97 @@ pub fn declared_type_inhabitance( } } +pub fn collection_at_scalar_declared_type( + declared: Rc, + produced: Rc, + scope: Rc, +) -> bool { + if (crate::v1_compiler_infer_types::node_is_collection( + produced.clone(), + scope.type_env.clone().source_indices.clone(), + ) == false) + { + false + } else { + { + let peeled = crate::v1_compiler_infer_resolve::peel_nominal_alias_identity( + declared.clone(), + scope.type_env.clone(), + scope.module_name.clone(), + ); + let peeled_is_kernel = + crate::std_types::is_kernel_type(crate::v1_std_core::authored_name_at( + scope.type_env.clone().source_indices.clone(), + peeled.clone(), + )); + let refinement_base_is_kernel = if is_where_refinement_type(declared.clone()) { + match declared.children.clone().first().cloned() { + Some(base) => { + crate::std_types::is_kernel_type(crate::v1_std_core::authored_name_at( + scope.type_env.clone().source_indices.clone(), + crate::v1_compiler_infer_types::child_type_node(base.clone()), + )) + } + None => false, + } + } else { + false + }; + (peeled_is_kernel.clone() || refinement_base_is_kernel.clone()) + } + } +} + +pub fn record_at_scalar_needs_identity( + declared: Rc, + produced: Rc, + scope: Rc, +) -> bool { + (crate::v1_compiler_type_head_exposure::type_head_exposure_is_kernel_scalar( + expected_type_head_exposure(declared.clone(), scope.clone()), + ) && crate::v1_compiler_type_head_exposure::type_head_exposure_is_product( + expected_type_head_exposure(produced.clone(), scope.clone()), + )) +} + +pub fn coproduct_at_record_declared_type( + declared: Rc, + produced: Rc, + scope: Rc, +) -> bool { + { + let declared_name = crate::v1_std_core::authored_name_at( + scope.type_env.clone().source_indices.clone(), + declared.clone(), + ); + let produced_name = crate::v1_std_core::authored_name_at( + scope.type_env.clone().source_indices.clone(), + produced.clone(), + ); + let declared_head = expected_type_head_exposure(declared.clone(), scope.clone()); + let produced_head = expected_type_head_exposure(produced.clone(), scope.clone()); + if (application_type_names_compatible( + declared_name.clone(), + produced_name.clone(), + scope.type_env.clone(), + scope.module_name.clone(), + scope.type_env.clone().source_indices.clone(), + ) || transparent_alias_identity_agrees( + scope.type_env.clone().symbol_index.clone(), + declared_name.clone(), + produced_name.clone(), + )) { + false + } else { + (crate::v1_compiler_type_head_exposure::type_head_exposure_is_product( + declared_head.clone(), + ) && crate::v1_compiler_type_head_exposure::type_head_exposure_is_coproduct( + produced_head.clone(), + )) + } + } +} + pub fn declared_realizes_as_kernel_numeric( declared: Rc, produced: Rc, @@ -3841,7 +3996,7 @@ pub fn nominal_product_inhabitance_refusal( let produced_head = nominal_product_head_name(produced.clone(), scope.clone()); if ((declared_head.clone() == "".to_string()) || (produced_head.clone() == "".to_string())) { - None + std::option::Option::None } else { if (nominal_product_head_names_agree( declared_head.clone(), @@ -3858,7 +4013,7 @@ pub fn nominal_product_inhabitance_refusal( ) { Some(InhabitanceRefusalReason::RefusedDistinctAppliedTypeArgument) } else { - None + std::option::Option::None } } } @@ -4110,7 +4265,10 @@ pub fn declared_type_obligation_diags( InhabitanceVerdict::InhabitanceUndecidable { reason: r, .. } => { Rc::new(vec![crate::v1_std_core::make_error_node( Rc::new(CompilerDiagnostic::DeclaredTypeInhabitanceUndecided { - position: declared_type_position_label(obligation.position.clone()), + position: declared_type_position_label( + obligation.position.clone(), + obligation.subject.clone(), + ), reason: inhabitance_undecidable_reason_label(r.clone()), span: obligation.span.clone(), }), @@ -4120,7 +4278,10 @@ pub fn declared_type_obligation_diags( InhabitanceVerdict::InhabitanceRefused { reason: _, .. } => { Rc::new(vec![crate::v1_std_core::make_error_node( Rc::new(CompilerDiagnostic::DeclaredTypeNotInhabited { - position: declared_type_position_label(obligation.position.clone()), + position: declared_type_position_label( + obligation.position.clone(), + obligation.subject.clone(), + ), expected: crate::v1_compiler_infer_types::node_type_shape( obligation.declared.clone(), scope.type_env.clone().source_indices.clone(), @@ -4350,7 +4511,7 @@ match formal_decl.clone() { }, } } else { - if ((crate::v1_compiler_infer_env::lookup_type_by_name(scope.type_env.clone(), lit_name.clone()) != None) && (crate::v1_compiler_infer_env::lookup_type_by_name(scope.type_env.clone(), formal_name.clone()) != None)) { + if ((crate::v1_compiler_infer_env::lookup_type_by_name(scope.type_env.clone(), lit_name.clone()) != std::option::Option::None) && (crate::v1_compiler_infer_env::lookup_type_by_name(scope.type_env.clone(), formal_name.clone()) != std::option::Option::None)) { true } else { false @@ -4826,7 +4987,7 @@ pub fn build_call_application_plan( .cloned() { Some(bound) => Some(bound.1.clone()), - None => None, + None => std::option::Option::None, }, }) }); @@ -4890,6 +5051,7 @@ pub fn direct_call_argument_inhabitance_diags( declared_type_obligation_diags( Rc::new(DeclaredTypeObligation { position: DeclaredTypePosition::PositionDirectCallArgument, + subject: app.param_name.clone(), declared: app.formal_subst.clone(), produced: crate::v1_compiler_infer_types::resolved_type( actual_expr.clone(), @@ -5158,7 +5320,7 @@ pub fn call_arg_bound_param_at( .cloned() .fold( Rc::new(CallArgBoundParamAccum { - bound: None, + bound: std::option::Option::None, pos: 0, }), |acc: Rc, ta: Rc| match crate::v1_std_core::arg_name_at( @@ -5203,16 +5365,18 @@ pub fn scan_call_shape_arity( positional_slot: 0, required_count: 0, supplied_count: 0, - deficit_param: None, + deficit_param: std::option::Option::None, }), |st: Rc, param: Rc| { - if (st.deficit_param.clone() != None) { + if (st.deficit_param.clone() != std::option::Option::None) { st.clone() } else { if param_is_generic_decl(param.clone(), source_indices.clone()) { st.clone() } else { - if (crate::v1_std_core::param_node_default_value(param.clone()) != None) { + if (crate::v1_std_core::param_node_default_value(param.clone()) + != std::option::Option::None) + { st.clone() } else { { @@ -5245,7 +5409,7 @@ pub fn scan_call_shape_arity( positional_slot: st.positional_slot.clone(), required_count: next_required.clone(), supplied_count: (st.supplied_count.clone() + 1), - deficit_param: None, + deficit_param: std::option::Option::None, }) } else { if param_binds_positionally(param.clone(), source_indices.clone()) { @@ -5256,7 +5420,7 @@ pub fn scan_call_shape_arity( positional_slot: (st.positional_slot.clone() + 1), required_count: next_required.clone(), supplied_count: (st.supplied_count.clone() + 1), - deficit_param: None, + deficit_param: std::option::Option::None, }) } else { Rc::new(CallShapeArityScan { @@ -5374,7 +5538,9 @@ pub fn direct_call_shape_diags( let positional_args = Rc::new({ let mut __result = Vec::new(); for ta in typed_args.iter().cloned() { - if (crate::v1_std_core::arg_name_at(ta.clone(), source_indices.clone()) == None) { + if (crate::v1_std_core::arg_name_at(ta.clone(), source_indices.clone()) + == std::option::Option::None) + { __result.push(ta); } } @@ -5841,21 +6007,21 @@ pub fn infer_tier2b_builtin_with_kernel_diags( Some(InferredNode::Resolved { node: elem, .. }) => { Some(elem.clone()) } - _ => None, + _ => std::option::Option::None, } } - None => None, + None => std::option::Option::None, } } else { match typed_args.clone().iter().cloned().skip(1 as usize).next() { Some(other_arg) => match crate::v1_std_core::arg_value(other_arg.clone()).inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: other_type, .. }) => match crate::v1_compiler_infer_lookup::set_element_type_in_env(other_type.clone(), scope.type_env.clone()) { Some(elem_slot) => Some(crate::v1_compiler_infer_types::child_type_node(elem_slot.clone())), - None => None, + None => std::option::Option::None, }, - _ => None, + _ => std::option::Option::None, }, - None => None, + None => std::option::Option::None, } }; let recv_is_set = match typed_args.clone().first().cloned() { @@ -5890,10 +6056,10 @@ pub fn infer_tier2b_builtin_with_kernel_diags( receiver_type.clone(), scope.clone(), ), - _ => None, + _ => std::option::Option::None, } } - None => None, + None => std::option::Option::None, }; let elem_mismatch = match recv_elem.clone() { Some(re) => match operand_elem.clone() { @@ -6038,7 +6204,7 @@ pub fn method_existence_decision( scope.type_env.clone().source_indices.clone(), recv_rt.clone(), ), - ) != None); + ) != std::option::Option::None); if recv_surface_established.clone() { Rc::new(MethodPipeFallback { result_ty: error_type(), @@ -6075,7 +6241,7 @@ pub fn method_existence_decision( scope.type_env.clone().source_indices.clone(), peeled.clone(), ), - ) != None); + ) != std::option::Option::None); if peeled_surface_established.clone() { Rc::new(MethodPipeFallback { result_ty: error_type(), @@ -6416,7 +6582,7 @@ pub fn unresolved_method_frontier_trigger( .cloned() { Some(row) => Some(row.dissolution.clone()), - None => None, + None => std::option::Option::None, } } @@ -6456,19 +6622,19 @@ pub fn validate_cast( let source_name = crate::v1_std_core::authored_name_at(source_indices.clone(), src_node.clone()); if (source_name.clone() == target_name.clone()) { - None + std::option::Option::None } else { if !crate::std_coercion::is_dag_cast_domain_type(source_name.clone()) { - None + std::option::Option::None } else { if !crate::std_coercion::is_dag_cast_domain_type(target_name.clone()) { - None + std::option::Option::None } else { if crate::std_coercion::dag_can_cast( source_name.clone(), target_name.clone(), ) { - None + std::option::Option::None } else { { let msg = v1_rt::concat( @@ -6495,7 +6661,7 @@ pub fn validate_cast( } } } - _ => None, + _ => std::option::Option::None, } } @@ -6541,20 +6707,20 @@ pub fn type_variable_node(id: String) -> Rc { occurrence_identity: Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), name: "".to_string(), span: crate::v1_std_core::no_span(), - ident_span: None, + ident_span: std::option::Option::None, children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), inferred: Some(Rc::new(InferredNode::TypeVariable { id: id.clone() })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }) @@ -6658,14 +6824,14 @@ pub fn annotate_pattern_parent_enums( if is_coproduct.clone() { Some(scrutinee_name.clone()) } else { - None + std::option::Option::None } } } } } - PatternSubject::PatternDynamic { span: _, .. } => None, - PatternSubject::PatternLookupBlocked => None, + PatternSubject::PatternDynamic { span: _, .. } => std::option::Option::None, + PatternSubject::PatternLookupBlocked => std::option::Option::None, }; let annotated_variant_name = variant_name.clone(); let variant_lookup = crate::v1_compiler_infer_patterns::lookup_variant_in_type( @@ -6722,7 +6888,7 @@ pub fn annotate_pattern_parent_enums( }), None => Rc::new(MatchPattern::VariantPattern { name: variant_name.clone(), - parent_enum: None, + parent_enum: std::option::Option::None, field_bindings: annotated_bindings.clone(), }), } @@ -7084,7 +7250,7 @@ pub fn extend_scope_with_pattern_node( } pub fn method_name_is(opt: Option, expected: String) -> bool { - if (opt.clone() == None) { + if (opt.clone() == std::option::Option::None) { false } else { (opt.clone().unwrap() == expected.clone()) @@ -7098,7 +7264,7 @@ pub fn arg_has_name( ) -> bool { { let n = crate::v1_std_core::arg_name_at(arg.clone(), source_indices.clone()); - if (n.clone() == None) { + if (n.clone() == std::option::Option::None) { false } else { (n.clone().unwrap() == name.clone()) @@ -7157,11 +7323,11 @@ pub fn extract_fold_init_info( diagnostics: init_result.diagnostics.clone(), })) } - None => None, + None => std::option::Option::None, } } } else { - None + std::option::Option::None } } } @@ -7247,34 +7413,34 @@ pub fn infer_method_args_with_fold( __result.push({ let a = idx_pair.1.clone(); let idx = idx_pair.0.clone(); -let is_init_arg = (arg_has_name(a.clone(), "init".to_string(), scope.type_env.clone().source_indices.clone()) || ((crate::v1_std_core::arg_name_at(a.clone(), scope.type_env.clone().source_indices.clone()) == None) && (idx.clone() == 0))); -if ((is_fold.clone() && (fold_info.clone() != None)) && is_init_arg.clone()) { +let is_init_arg = (arg_has_name(a.clone(), "init".to_string(), scope.type_env.clone().source_indices.clone()) || ((crate::v1_std_core::arg_name_at(a.clone(), scope.type_env.clone().source_indices.clone()) == std::option::Option::None) && (idx.clone() == 0))); +if ((is_fold.clone() && (fold_info.clone() != std::option::Option::None)) && is_init_arg.clone()) { match fold_info.clone() { Some(fi) => fi.clone(), None => infer_arg_with_element_type(a.clone(), element_type.clone(), scope.clone()), } } else { - if (is_fold.clone() && (fold_info.clone() != None)) { + if (is_fold.clone() && (fold_info.clone() != std::option::Option::None)) { { - let fold_params = Rc::new(vec![crate::v1_std_core::make_param_node(Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), "acc".to_string(), fold_acc_type.clone(), None, crate::v1_std_core::no_span(), crate::v1_std_core::no_span()), crate::v1_std_core::make_param_node(Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), "elem".to_string(), element_type.clone(), None, crate::v1_std_core::no_span(), crate::v1_std_core::no_span())]); + let fold_params = Rc::new(vec![crate::v1_std_core::make_param_node(Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), "acc".to_string(), fold_acc_type.clone(), std::option::Option::None, crate::v1_std_core::no_span(), crate::v1_std_core::no_span()), crate::v1_std_core::make_param_node(Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), "elem".to_string(), element_type.clone(), std::option::Option::None, crate::v1_std_core::no_span(), crate::v1_std_core::no_span())]); let fold_callable = Rc::new(Node { occurrence_identity: Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), name: "".to_string(), span: crate::v1_std_core::no_span(), - ident_span: None, + ident_span: std::option::Option::None, children: Rc::new(vec![]), connective: Connective::NoConnective, params: fold_params.clone(), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -7327,7 +7493,7 @@ let nf_scope = if is_lambda_expr(nf_lam_value.clone()) { match (*arg_contract.clone()).clone() { DeclaredArgContract::MethodUnresolved => infer_arg_with_element_type(a.clone(), element_type.clone(), nf_scope.clone()), DeclaredArgContract::ContractUnavailable => { - let ar = infer_expr(nf_lam_value.clone(), nf_scope.clone(), None); + let ar = infer_expr(nf_lam_value.clone(), nf_scope.clone(), std::option::Option::None); let contract_diag = categorized_error("no declared argument contract is available for this method call; refusing rather than substituting the receiver element type".to_string(), a.span.clone(), nf_scope.module_name.clone(), "method-arg-contract-unavailable".to_string()); Rc::new(ArgInferResult { typed_arg: crate::v1_std_core::make_arg_node(a.occurrence_identity.clone(), crate::v1_std_core::arg_name_at(a.clone(), nf_scope.type_env.clone().source_indices.clone()), ar.typed.clone(), a.span.clone(), a.span.clone()), @@ -7337,7 +7503,7 @@ Rc::new(ArgInferResult { DeclaredArgContract::ContractKnown { types: declared_types, .. } => match declared_types.clone().iter().cloned().skip(idx.clone() as usize).next() { Some(declared_type) => infer_arg_with_element_type(a.clone(), declared_type.clone(), nf_scope.clone()), None => { - let ar = infer_expr(nf_lam_value.clone(), nf_scope.clone(), None); + let ar = infer_expr(nf_lam_value.clone(), nf_scope.clone(), std::option::Option::None); let contract_diag = categorized_error("no declared argument contract is available at this parameter position; refusing rather than substituting the receiver element type".to_string(), a.span.clone(), nf_scope.module_name.clone(), "method-arg-contract-unavailable".to_string()); Rc::new(ArgInferResult { typed_arg: crate::v1_std_core::make_arg_node(a.occurrence_identity.clone(), crate::v1_std_core::arg_name_at(a.clone(), nf_scope.type_env.clone().source_indices.clone()), ar.typed.clone(), a.span.clone(), a.span.clone()), @@ -7455,7 +7621,7 @@ pub fn infer_call_arguments_generic_pass( let expected = if has_formal.clone() { Some(formal_param_type.clone()) } else { - None + std::option::Option::None }; let ar = infer_expr( crate::v1_std_core::arg_value(a.clone()), @@ -7579,14 +7745,14 @@ pub fn qualified_value_projection( texpr.clone(), scope.type_env.clone().source_indices.clone(), ) { - None => None, + None => std::option::Option::None, Some(spine) => match spine_root_is_shadowed(scope.clone(), spine.root.clone()) { - true => None, + true => std::option::Option::None, false => match crate::v1_compiler_infer_env::symbol_index_lookup( scope.type_env.clone().symbol_index.clone(), spine.dotted.clone(), ) { - None => None, + None => std::option::Option::None, Some(decl) => { let raw_value_type = match decl.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => rt.clone(), @@ -7620,6 +7786,247 @@ pub fn qualified_value_projection( } } +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[serde(tag = "_variant")] +pub enum LiteralBoundary { + LiteralBoundaryPlain, + LiteralBoundaryElaborated { + elaboration: Rc, + destination_type: Rc, + }, + LiteralBoundaryRefused { + message: String, + }, +} + +pub fn literal_boundary_elaboration( + lit: Rc, + expected: Option>, + scope: Rc, +) -> Rc { + match expected.clone() { + None => Rc::new(LiteralBoundary::LiteralBoundaryPlain), + Some(exp) => { + if (exp.return_cardinality.clone() == Cardinality::CardOptional) { + Rc::new(LiteralBoundary::LiteralBoundaryPlain) + } else { + match crate::v1_compiler_infer_env::type_reference_declaration_ref( + exp.clone(), + scope.type_env.clone().source_indices.clone(), + scope.type_env.clone(), + ) { + None => Rc::new(LiteralBoundary::LiteralBoundaryPlain), + Some(destination) => { + let kind = + crate::std_literal_elaboration::literal_source_kind_of(lit.clone()); + let natively = crate::v1_compiler_coercion::decl_file_realizes_natively( + crate::v1_compiler_coercion::type_reference_decl_file(exp.clone()), + ); + match (*crate::std_literal_elaboration::elaborate_literal_at(literal_homomorphism_rows(), kind.clone(), destination.clone(), natively.clone())).clone() { + LiteralElaborationOutcome::DirectLiteral => Rc::new(LiteralBoundary::LiteralBoundaryPlain), + LiteralElaborationOutcome::ViaHomomorphism { homomorphism: h, .. } => Rc::new(LiteralBoundary::LiteralBoundaryElaborated { + elaboration: Rc::new(LiteralElaboration { + source_kind: kind.clone(), + destination: destination.clone(), + homomorphism: h.clone(), +}), + destination_type: exp.clone(), +}), + LiteralElaborationOutcome::LiteralElaborationRefused { cause: c, .. } => Rc::new(LiteralBoundary::LiteralBoundaryRefused { + message: crate::std_literal_elaboration::literal_elaboration_refusal_message(c.clone()), +}), +} + } + } + } + } + } +} + +pub fn elaborated_span(name: String) -> Rc { + Rc::new(SourceSpan { + file: "".to_string(), + start: 0, + end: v1_rt::string_length(&name), + }) +} + +pub fn elaborated_expr_node( + name: String, + expr_data: Rc, + children: Rc>>, + destination_type: Rc, + span: Rc, +) -> Rc { + Rc::new(Node { + occurrence_identity: Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), + name: name.clone(), + span: span.clone(), + ident_span: Some(elaborated_span(name.clone())), + children: children.clone(), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: Some(Rc::new(InferredNode::Resolved { + node: destination_type.clone(), + })), + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: std::option::Option::None, + transport: std::option::Option::None, + properties: Rc::new(vec![]), + type_annotation: std::option::Option::None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: std::option::Option::None, + expr_data: expr_data.clone(), + ident: None, + }) +} + +pub fn unfold_peano_image( + n: i64, + zero: String, + succ: String, + prev_field: String, + parent: String, + destination_type: Rc, + span: Rc, +) -> Rc { + stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { + if (n.clone() <= 0) { + elaborated_expr_node( + zero.clone(), + Rc::new(ExprData::ExprVar { + binding_kind: Some(Rc::new(VarBindingKind::VariantValueBinding { + parent_enum: parent.clone(), + })), + }), + Rc::new(vec![]), + destination_type.clone(), + span.clone(), + ) + } else { + { + let prev = unfold_peano_image( + (n.clone() - 1), + zero.clone(), + succ.clone(), + prev_field.clone(), + parent.clone(), + destination_type.clone(), + span.clone(), + ); + let field = crate::v1_std_core::make_field_init_node( + Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), + prev_field.clone(), + prev.clone(), + span.clone(), + elaborated_span(prev_field.clone()), + ); + elaborated_expr_node( + succ.clone(), + Rc::new(ExprData::ExprRecordLit { + parent_enum: Some(parent.clone()), + }), + Rc::new(vec![field.clone()]), + destination_type.clone(), + span.clone(), + ) + } + } + }) +} + +pub fn unfold_literal_image( + lit: Rc, + elaboration: Rc, + destination_type: Rc, + span: Rc, +) -> Rc { + match (*elaboration.homomorphism.clone().producer.clone()).clone() { + LiteralUnfolding::PeanoUnfold { zero, succ, prev_field, .. } => match (*lit.clone()).clone() { + LiteralValue::LitInt { value: n, .. } => unfold_peano_image(n.clone(), zero.decl_name.clone(), succ.decl_name.clone(), prev_field.clone(), elaboration.destination.clone().decl_name.clone(), destination_type.clone(), span.clone()), + _ => crate::v1_std_core::make_expr_error_node(Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), ExprErrorKind::InternalExprError, "literal elaboration: a Peano unfolding row was selected for a non-integer literal (gunbc.structural_realization_bindings keys the row on KernelIntLiteral, so this row is malformed)".to_string(), span.clone()), +}, + LiteralUnfolding::BooleanUnfold { true_variant: t, false_variant: f, .. } => match (*lit.clone()).clone() { + LiteralValue::LitBool { value: b, .. } => elaborated_expr_node(if b.clone() { + t.decl_name.clone() + } else { + f.decl_name.clone() + }, Rc::new(ExprData::ExprVar { + binding_kind: Some(Rc::new(VarBindingKind::VariantValueBinding { + parent_enum: elaboration.destination.clone().decl_name.clone(), +})), +}), Rc::new(vec![]), destination_type.clone(), span.clone()), + _ => crate::v1_std_core::make_expr_error_node(Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), ExprErrorKind::InternalExprError, "literal elaboration: a Boolean unfolding row was selected for a non-boolean literal (gunbc.structural_realization_bindings keys the row on KernelBoolLiteral, so this row is malformed)".to_string(), span.clone()), +}, +} +} + +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct BinopOperands { + pub left: Rc, + pub right: Rc, +} + +pub fn infer_operand_literal( + lit_expr: Rc, + other: Rc, + scope: Rc, +) -> Rc { + { + let other_type = match other.inferred.clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: rt, .. }) => Some(rt.clone()), + _ => std::option::Option::None, + }; + infer_expr_body(lit_expr.clone(), scope.clone(), other_type.clone()) + } +} + +pub fn infer_binop_operands( + left_expr: Rc, + right_expr: Rc, + scope: Rc, +) -> Rc { + { + let left_is_literal = expr_is_any_literal(left_expr.clone()); + let right_is_literal = expr_is_any_literal(right_expr.clone()); + if (right_is_literal.clone() && !left_is_literal.clone()) { + { + let l = infer_expr(left_expr.clone(), scope.clone(), std::option::Option::None); + Rc::new(BinopOperands { + left: l.clone(), + right: infer_operand_literal( + right_expr.clone(), + l.typed.clone(), + scope.clone(), + ), + }) + } + } else { + if (left_is_literal.clone() && !right_is_literal.clone()) { + { + let r = + infer_expr(right_expr.clone(), scope.clone(), std::option::Option::None); + Rc::new(BinopOperands { + left: infer_operand_literal( + left_expr.clone(), + r.typed.clone(), + scope.clone(), + ), + right: r.clone(), + }) + } + } else { + Rc::new(BinopOperands { + left: infer_expr(left_expr.clone(), scope.clone(), std::option::Option::None), + right: infer_expr(right_expr.clone(), scope.clone(), std::option::Option::None), + }) + } + } + } +} + pub fn infer_expr_body( texpr: Rc, scope: Rc, @@ -7628,7 +8035,7 @@ pub fn infer_expr_body( match (*texpr.expr_data.clone()).clone() { ExprData::ExprLiteral { value: lit, .. } => { let span = texpr.span.clone(); - ok_infer(crate::v1_std_core::make_expr_node( + let plain = crate::v1_std_core::make_expr_node( texpr.occurrence_identity.clone(), Rc::new(ExprData::ExprLiteral { value: lit.clone() }), Rc::new(vec![]), @@ -7636,8 +8043,43 @@ pub fn infer_expr_body( node: crate::v1_compiler_infer_types::infer_literal_node(lit.clone()), })), span.clone(), - )) + ); + match (*literal_boundary_elaboration(lit.clone(), expected.clone(), scope.clone())) + .clone() + { + LiteralBoundary::LiteralBoundaryPlain => ok_infer(plain.clone()), + LiteralBoundary::LiteralBoundaryElaborated { + elaboration: e, + destination_type: dt, + .. + } => ok_infer(crate::v1_std_core::make_expr_node( + texpr.occurrence_identity.clone(), + Rc::new(ExprData::ExprElaboratedLiteral { + value: lit.clone(), + elaboration: e.clone(), + }), + Rc::new(vec![unfold_literal_image( + lit.clone(), + e.clone(), + dt.clone(), + span.clone(), + )]), + Some(Rc::new(InferredNode::Resolved { node: dt.clone() })), + span.clone(), + )), + LiteralBoundary::LiteralBoundaryRefused { message: m, .. } => { + Rc::new(InferResult { + typed: plain.clone(), + diagnostics: Rc::new(vec![inference_error( + m.clone(), + span.clone(), + scope.module_name.clone(), + )]), + }) + } + } } + ExprData::ExprElaboratedLiteral { .. } => ok_infer(texpr.clone()), ExprData::ExprError { kind, message, .. } => { let span = texpr.span.clone(); let diagnostics = match kind.clone() { @@ -7698,7 +8140,7 @@ ok_infer(crate::v1_std_core::make_named_expr_node(texpr.occurrence_identity.clon call_semantics: Some(Rc::new(CallSemantics::PlainCallSemantics { target: crate::v1_compiler_infer_lookup::resolved_declaration_call_target(fsig_declared.clone()), })), - descent_evidence: None, + descent_evidence: std::option::Option::None, }), Rc::new(vec![]), Some(Rc::new(InferredNode::Resolved { node: fsig.inferred.clone(), })), span.clone(), span.clone())), @@ -7753,7 +8195,7 @@ if ((var_ambiguity_cands.clone().len() as i64) > 0) { } else { { let err_texpr = crate::v1_std_core::make_named_expr_node(texpr.occurrence_identity.clone(), name.clone(), Rc::new(ExprData::ExprVar { - binding_kind: None, + binding_kind: std::option::Option::None, }), Rc::new(vec![]), Some(Rc::new(InferredNode::Resolved { node: error_type(), })), span.clone(), span.clone()); @@ -7781,7 +8223,8 @@ Rc::new(InferResult { match qualified_value_projection(texpr.clone(), scope.clone(), span.clone()) { Some(proj) => proj.clone(), None => { - let base_result = infer_expr(base_expr.clone(), scope.clone(), None); + let base_result = + infer_expr(base_expr.clone(), scope.clone(), std::option::Option::None); let base_typed = base_result.typed.clone(); let base_diags = base_result.diagnostics.clone(); let base_rt = crate::v1_compiler_infer_types::resolved_type(base_typed.clone()); @@ -7800,13 +8243,14 @@ Rc::new(InferResult { }; let resolved_base = base_expansion.resolved.clone(); let resolved_base_diags = base_expansion.diagnostics.clone(); - let resolved_base_is_error = if (resolved_base.inferred.clone() != None) { - crate::v1_std_core::is_compiler_error( - resolved_base.inferred.clone().clone().unwrap(), - ) - } else { - false - }; + let resolved_base_is_error = + if (resolved_base.inferred.clone() != std::option::Option::None) { + crate::v1_std_core::is_compiler_error( + resolved_base.inferred.clone().clone().unwrap(), + ) + } else { + false + }; if resolved_base_is_error.clone() { Rc::new(InferResult { typed: crate::v1_std_core::make_expr_error_node( @@ -8002,7 +8446,7 @@ Rc::new(InferResult { }; let arg_call = if ((has_lambda.clone() && ((call_args.clone().len() as i64) >= 2)) - && (sig.clone() == None)) + && (sig.clone() == std::option::Option::None)) { Rc::new(ArgGenericFoldState { subst: v1_rt::rc_empty_map::>(), @@ -8011,7 +8455,7 @@ Rc::new(InferResult { let first_result = infer_expr( crate::v1_std_core::arg_value(first_arg.clone()), scope.clone(), - None, + std::option::Option::None, ); let first_type = crate::v1_compiler_infer_types::resolved_type( @@ -8112,7 +8556,7 @@ Rc::new(InferResult { ), ); let typed_arg_nodes = typed_args.clone(); - if (sig.clone() != None) { + if (sig.clone() != std::option::Option::None) { { let resolved_type = match sig.clone() { Some(s) => substitute_generics( @@ -8165,7 +8609,7 @@ Rc::new(InferResult { call_semantics: Some(Rc::new(CallSemantics::PlainCallSemantics { target: crate::v1_compiler_infer_lookup::resolved_plain_call_target(func_name.clone(), call_sig_lookup.clone()), })), - descent_evidence: None, + descent_evidence: std::option::Option::None, }), typed_arg_nodes.clone(), Some(Rc::new(InferredNode::Resolved { node: resolved_type.clone(), })), span.clone(), crate::v1_std_core::node_name_span(texpr.clone())), @@ -8194,7 +8638,7 @@ Rc::new(InferResult { scope.type_env.clone().source_indices.clone(), ); let refined_call_fold_acc_type = if ((call_fold_info.clone() - != None) + != std::option::Option::None) && call_acc_is_under_resolved.clone()) { match Rc::new({ @@ -8225,15 +8669,15 @@ Rc::new(InferResult { }; let method_resolution = if crate::v1_compiler_infer_env::listed_import_required_bare_call_blocked(scope.type_env.clone(), func_name.clone()) { Rc::new(KnownMethodResolution { - semantics: None, - result_type: None, + semantics: std::option::Option::None, + result_type: std::option::Option::None, diagnostics: Rc::new(vec![]), }) } else { - crate::v1_compiler_infer_lookup::resolve_known_method_node(method_receiver.clone(), crate::v1_compiler_infer_lookup::resolve_method_receiver_type(first_arg_type.clone(), scope.type_env.clone()), func_name.clone(), if (call_fold_info.clone() != None) { + crate::v1_compiler_infer_lookup::resolve_known_method_node(method_receiver.clone(), crate::v1_compiler_infer_lookup::resolve_method_receiver_type(first_arg_type.clone(), scope.type_env.clone()), func_name.clone(), if (call_fold_info.clone() != std::option::Option::None) { Some(refined_call_fold_acc_type.clone()) } else { - None + std::option::Option::None }, scope.service_registry.clone(), scope.type_env.clone().source_indices.clone()) }; let callee_is_body_binding = v1_rt::map_has( @@ -8241,7 +8685,8 @@ Rc::new(InferResult { func_name.clone(), ); let is_known_method = (!callee_is_body_binding.clone() - && (method_resolution.result_type.clone() != None)); + && (method_resolution.result_type.clone() + != std::option::Option::None)); if (is_known_method.clone() && ((typed_args.clone().len() as i64) > 0)) { @@ -8261,7 +8706,7 @@ Rc::new(InferResult { None => error_type(), }; let method_tv = if (method_resolution.semantics.clone() - == None) + == std::option::Option::None) { Rc::new(KernelTypeBuild { ty: base_result_type.clone(), @@ -8273,7 +8718,7 @@ Rc::new(InferResult { Some(t) => if (crate::v1_compiler_infer_types::template_return_has_variables(t.clone()) || !crate::v1_compiler_infer_types::is_fully_resolved(base_result_type.clone(), scope.type_env.clone().source_indices.clone())) { { let call_arg_types = Rc::new({ let mut __result = Vec::new(); for a in remaining.iter().cloned() { __result.push(crate::v1_compiler_infer_types::resolved_type(crate::v1_std_core::arg_value(a.clone()))); } __result }); -let fold_overrides = if (call_fold_info.clone() != None) { +let fold_overrides = if (call_fold_info.clone() != std::option::Option::None) { fold_override_map("FoldAccumulator".to_string(), refined_call_fold_acc_type.clone()) } else { empty_override_map() @@ -8303,7 +8748,7 @@ crate::v1_compiler_infer_types::resolve_type_variables_from_template(t.clone(), let returns_receiver_self = if (method_resolution .semantics .clone() - == None) + == std::option::Option::None) { false } else { @@ -8410,10 +8855,10 @@ crate::v1_compiler_infer_types::resolve_type_variables_from_template(t.clone(), call_semantics: Some(Rc::new(CallSemantics::PlainCallSemantics { target: Rc::new(CallTargetIdentity::RuntimePrimitiveCall { primitive_name: "empty_map".to_string(), - projected_from: None, + projected_from: std::option::Option::None, }), })), - descent_evidence: None, + descent_evidence: std::option::Option::None, }), typed_arg_nodes.clone(), Some(Rc::new(InferredNode::Resolved { node: exp.clone(), })), span.clone(), crate::v1_std_core::node_name_span(texpr.clone())), @@ -8428,10 +8873,10 @@ match bare_m.clone() { call_semantics: Some(Rc::new(CallSemantics::PlainCallSemantics { target: Rc::new(CallTargetIdentity::RuntimePrimitiveCall { primitive_name: "empty_map".to_string(), - projected_from: None, + projected_from: std::option::Option::None, }), })), - descent_evidence: None, + descent_evidence: std::option::Option::None, }), typed_arg_nodes.clone(), Some(Rc::new(InferredNode::Resolved { node: map_t.clone(), })), span.clone(), crate::v1_std_core::node_name_span(texpr.clone())), @@ -8442,10 +8887,10 @@ match bare_m.clone() { call_semantics: Some(Rc::new(CallSemantics::PlainCallSemantics { target: Rc::new(CallTargetIdentity::RuntimePrimitiveCall { primitive_name: "empty_map".to_string(), - projected_from: None, + projected_from: std::option::Option::None, }), })), - descent_evidence: None, + descent_evidence: std::option::Option::None, }), typed_arg_nodes.clone(), Some(Rc::new(InferredNode::CompilerError { message: "empty_map(): Map kernel container profile missing (compiler misconfigured)".to_string(), span: span.clone(), @@ -8461,10 +8906,10 @@ match bare_m.clone() { call_semantics: Some(Rc::new(CallSemantics::PlainCallSemantics { target: Rc::new(CallTargetIdentity::RuntimePrimitiveCall { primitive_name: "empty_map".to_string(), - projected_from: None, + projected_from: std::option::Option::None, }), })), - descent_evidence: None, + descent_evidence: std::option::Option::None, }), typed_arg_nodes.clone(), Some(Rc::new(InferredNode::Resolved { node: map_t.clone(), })), span.clone(), crate::v1_std_core::node_name_span(texpr.clone())), @@ -8475,10 +8920,10 @@ match bare_m.clone() { call_semantics: Some(Rc::new(CallSemantics::PlainCallSemantics { target: Rc::new(CallTargetIdentity::RuntimePrimitiveCall { primitive_name: "empty_map".to_string(), - projected_from: None, + projected_from: std::option::Option::None, }), })), - descent_evidence: None, + descent_evidence: std::option::Option::None, }), typed_arg_nodes.clone(), Some(Rc::new(InferredNode::CompilerError { message: "empty_map(): Map kernel container profile missing (compiler misconfigured)".to_string(), span: span.clone(), @@ -8501,7 +8946,7 @@ match bare_m.clone() { call_semantics: Some(Rc::new(CallSemantics::PlainCallSemantics { target: crate::v1_compiler_infer_lookup::resolved_plain_call_target(func_name.clone(), call_sig_lookup.clone()), })), - descent_evidence: None, + descent_evidence: std::option::Option::None, }), typed_arg_nodes.clone(), Some(Rc::new(InferredNode::Resolved { node: exp.clone(), })), span.clone(), crate::v1_std_core::node_name_span(texpr.clone())), @@ -8516,7 +8961,7 @@ match bare_s.clone() { call_semantics: Some(Rc::new(CallSemantics::PlainCallSemantics { target: crate::v1_compiler_infer_lookup::resolved_plain_call_target(func_name.clone(), call_sig_lookup.clone()), })), - descent_evidence: None, + descent_evidence: std::option::Option::None, }), typed_arg_nodes.clone(), Some(Rc::new(InferredNode::Resolved { node: set_t.clone(), })), span.clone(), crate::v1_std_core::node_name_span(texpr.clone())), @@ -8527,7 +8972,7 @@ match bare_s.clone() { call_semantics: Some(Rc::new(CallSemantics::PlainCallSemantics { target: crate::v1_compiler_infer_lookup::resolved_plain_call_target(func_name.clone(), call_sig_lookup.clone()), })), - descent_evidence: None, + descent_evidence: std::option::Option::None, }), typed_arg_nodes.clone(), Some(Rc::new(InferredNode::CompilerError { message: "empty_set(): Set kernel container profile missing (compiler misconfigured)".to_string(), span: span.clone(), @@ -8543,7 +8988,7 @@ match bare_s.clone() { call_semantics: Some(Rc::new(CallSemantics::PlainCallSemantics { target: crate::v1_compiler_infer_lookup::resolved_plain_call_target(func_name.clone(), call_sig_lookup.clone()), })), - descent_evidence: None, + descent_evidence: std::option::Option::None, }), typed_arg_nodes.clone(), Some(Rc::new(InferredNode::Resolved { node: set_t.clone(), })), span.clone(), crate::v1_std_core::node_name_span(texpr.clone())), @@ -8554,7 +8999,7 @@ match bare_s.clone() { call_semantics: Some(Rc::new(CallSemantics::PlainCallSemantics { target: crate::v1_compiler_infer_lookup::resolved_plain_call_target(func_name.clone(), call_sig_lookup.clone()), })), - descent_evidence: None, + descent_evidence: std::option::Option::None, }), typed_arg_nodes.clone(), Some(Rc::new(InferredNode::CompilerError { message: "empty_set(): Set kernel container profile missing (compiler misconfigured)".to_string(), span: span.clone(), @@ -8565,7 +9010,7 @@ match bare_s.clone() { } } } else { - if (!callee_is_body_binding.clone() && (crate::v1_compiler_infer_method::infer_builtin_call_type(func_name.clone()) != None)) { + if (!callee_is_body_binding.clone() && (crate::v1_compiler_infer_method::infer_builtin_call_type(func_name.clone()) != std::option::Option::None)) { { let tier2b = infer_tier2b_builtin_with_kernel_diags(func_name.clone(), typed_args.clone(), scope.clone(), span.clone()); let bt = tier2b.bt.clone(); @@ -8573,7 +9018,7 @@ let call_semantics = if (func_name.clone() == "lookup".to_string()) { Some(Rc::new(CallSemantics::LookupCallSemantics { target: Rc::new(CallTargetIdentity::RuntimePrimitiveCall { primitive_name: func_name.clone(), - projected_from: None, + projected_from: std::option::Option::None, }), })) } else { @@ -8584,7 +9029,7 @@ let call_semantics = if (func_name.clone() == "lookup".to_string()) { Rc::new(InferResult { typed: crate::v1_std_core::make_named_expr_node(texpr.occurrence_identity.clone(), func_name.clone(), Rc::new(ExprData::ExprCall { call_semantics: call_semantics.clone(), - descent_evidence: None, + descent_evidence: std::option::Option::None, }), typed_arg_nodes.clone(), Some(Rc::new(InferredNode::Resolved { node: bt.clone(), })), span.clone(), crate::v1_std_core::node_name_span(texpr.clone())), @@ -8597,11 +9042,11 @@ Rc::new(InferResult { Some(binding) => if ((binding.resolved.clone().params.clone().len() as i64) > 0) { Some(binding.resolved.clone()) } else { - None + std::option::Option::None }, - None => None, + None => std::option::Option::None, }; -if (callable_local.clone() != None) { +if (callable_local.clone() != std::option::Option::None) { { let callable_type = match callable_local.clone() { Some(ct) => ct.clone(), @@ -8620,7 +9065,7 @@ Rc::new(InferResult { target: crate::v1_compiler_infer_lookup::resolved_plain_call_target(func_name.clone(), call_sig_lookup.clone()), }) }), - descent_evidence: None, + descent_evidence: std::option::Option::None, }), typed_arg_nodes.clone(), Some(Rc::new(InferredNode::Resolved { node: resolved_type.clone(), })), span.clone(), crate::v1_std_core::node_name_span(texpr.clone())), @@ -8633,7 +9078,7 @@ Rc::new(InferResult { None => { let type_match = crate::v1_compiler_infer_env::lookup_type_by_name(scope.type_env.clone(), func_name.clone()); let global_bare_callable = match type_match.clone() { - Some(_) => None, + Some(_) => std::option::Option::None, None => crate::v1_compiler_infer_lookup::global_bare_callable_node(scope.type_env.clone(), func_name.clone()), }; let resolved_type = match type_match.clone() { @@ -8670,7 +9115,7 @@ Rc::new(InferResult { call_semantics: Some(Rc::new(CallSemantics::PlainCallSemantics { target: crate::v1_compiler_infer_lookup::resolved_plain_call_target(func_name.clone(), call_sig_lookup.clone()), })), - descent_evidence: None, + descent_evidence: std::option::Option::None, }), typed_arg_nodes.clone(), Some(Rc::new(InferredNode::Resolved { node: resolved_type.clone(), })), span.clone(), crate::v1_std_core::node_name_span(texpr.clone())), @@ -8706,23 +9151,23 @@ Rc::new(InferResult { recv.clone(), scope.type_env.clone().source_indices.clone(), ) { - None => None, + None => std::option::Option::None, Some(recv_spine) => { match spine_root_is_shadowed(scope.clone(), recv_spine.root.clone()) { - true => None, + true => std::option::Option::None, false => { let dotted = v1_rt::concat( v1_rt::concat(recv_spine.dotted.clone(), ".".to_string()), method_name.clone(), ); match crate::v1_compiler_infer_env::symbol_index_lookup(scope.type_env.clone().symbol_index.clone(), dotted.clone()) { - None => None, + None => std::option::Option::None, Some(_) => Some(infer_expr(crate::v1_std_core::make_named_expr_node(texpr.occurrence_identity.clone(), dotted.clone(), Rc::new(ExprData::ExprCall { call_semantics: Some(Rc::new(CallSemantics::PlainCallSemantics { target: Rc::new(CallTargetIdentity::CallableTargetUndetermined), })), - descent_evidence: None, -}), mc_args.clone(), None, span.clone(), kernel_span(dotted.clone())), scope.clone(), expected.clone())), + descent_evidence: std::option::Option::None, +}), mc_args.clone(), std::option::Option::None, span.clone(), kernel_span(dotted.clone())), scope.clone(), expected.clone())), } } } @@ -8731,7 +9176,8 @@ Rc::new(InferResult { match qualified_direct_call.clone() { Some(qdc) => qdc.clone(), None => { - let recv_result = infer_expr(recv.clone(), scope.clone(), None); + let recv_result = + infer_expr(recv.clone(), scope.clone(), std::option::Option::None); let recv_typed = recv_result.typed.clone(); let recv_diags = recv_result.diagnostics.clone(); let recv_rt = crate::v1_compiler_infer_lookup::resolve_method_receiver_type( @@ -8805,37 +9251,39 @@ Rc::new(InferResult { fold_acc_type.clone(), scope.type_env.clone().source_indices.clone(), ); - let refined_fold_acc_type = - if ((fold_info.clone() != None) && mc_acc_is_under_resolved.clone()) { - match Rc::new({ - let mut __result = Vec::new(); - for a in typed_mc_args.iter().cloned() { - if is_lambda_expr(crate::v1_std_core::arg_value(a.clone())) { - __result.push(a); - } + let refined_fold_acc_type = if ((fold_info.clone() + != std::option::Option::None) + && mc_acc_is_under_resolved.clone()) + { + match Rc::new({ + let mut __result = Vec::new(); + for a in typed_mc_args.iter().cloned() { + if is_lambda_expr(crate::v1_std_core::arg_value(a.clone())) { + __result.push(a); } - __result - }) - .first() - .cloned() - { - Some(lambda_arg) => crate::v1_compiler_infer_types::resolved_type( - crate::v1_std_core::arg_value(lambda_arg.clone()), - ), - None => fold_acc_type.clone(), } - } else { - fold_acc_type.clone() - }; + __result + }) + .first() + .cloned() + { + Some(lambda_arg) => crate::v1_compiler_infer_types::resolved_type( + crate::v1_std_core::arg_value(lambda_arg.clone()), + ), + None => fold_acc_type.clone(), + } + } else { + fold_acc_type.clone() + }; let method_resolution = crate::v1_compiler_infer_lookup::resolve_known_method_node( recv_typed.clone(), recv_rt.clone(), method_name.clone(), - if (fold_info.clone() != None) { + if (fold_info.clone() != std::option::Option::None) { Some(refined_fold_acc_type.clone()) } else { - None + std::option::Option::None }, scope.service_registry.clone(), scope.type_env.clone().source_indices.clone(), @@ -8853,7 +9301,9 @@ Rc::new(InferResult { ), }; let base_result_type = pipe_fb.result_ty.clone(); - let method_tv_mc = if (method_resolution.semantics.clone() == None) { + let method_tv_mc = if (method_resolution.semantics.clone() + == std::option::Option::None) + { Rc::new(KernelTypeBuild { ty: base_result_type.clone(), diagnostics: Rc::new(vec![]), @@ -8864,7 +9314,7 @@ Rc::new(InferResult { Some(t) => if (crate::v1_compiler_infer_types::template_return_has_variables(t.clone()) || !crate::v1_compiler_infer_types::is_fully_resolved(base_result_type.clone(), scope.type_env.clone().source_indices.clone())) { { let mc_arg_types = Rc::new({ let mut __result = Vec::new(); for a in typed_mc_args.iter().cloned() { __result.push(crate::v1_compiler_infer_types::resolved_type(crate::v1_std_core::arg_value(a.clone()))); } __result }); -let mc_fold_overrides = if (fold_info.clone() != None) { +let mc_fold_overrides = if (fold_info.clone() != std::option::Option::None) { fold_override_map("FoldAccumulator".to_string(), refined_fold_acc_type.clone()) } else { empty_override_map() @@ -8890,11 +9340,12 @@ crate::v1_compiler_infer_types::resolve_type_variables_from_template(t.clone(), }; let result_type = method_tv_mc.ty.clone(); let mc_template_diags = method_tv_mc.diagnostics.clone(); - let method_semantics = if (method_resolution.semantics.clone() != None) { - method_resolution.semantics.clone() - } else { - Some(Rc::new(MethodSemantics::PlainMethodSemantics)) - }; + let method_semantics = + if (method_resolution.semantics.clone() != std::option::Option::None) { + method_resolution.semantics.clone() + } else { + Some(Rc::new(MethodSemantics::PlainMethodSemantics)) + }; let typed_mc_arg_nodes = typed_mc_args.clone(); let mc_texpr = crate::v1_std_core::make_named_expr_node( texpr.occurrence_identity.clone(), @@ -8932,7 +9383,7 @@ crate::v1_compiler_infer_types::resolve_type_variables_from_template(t.clone(), let span = texpr.span.clone(); let scrut = crate::v1_std_core::match_scrutinee(texpr.clone()); let arm_nodes = crate::v1_std_core::match_arm_nodes(texpr.clone()); - let scrut_result = infer_expr(scrut.clone(), scope.clone(), None); + let scrut_result = infer_expr(scrut.clone(), scope.clone(), std::option::Option::None); let scrut_typed = scrut_result.typed.clone(); let scrut_diags = scrut_result.diagnostics.clone(); let scrut_rt = crate::v1_compiler_infer_types::resolved_type(scrut_typed.clone()); @@ -8960,10 +9411,14 @@ crate::v1_compiler_infer_types::resolve_type_variables_from_template(t.clone(), ); let arm_scope = pattern_result.scope.clone(); let pattern_diags = pattern_result.diagnostics.clone(); - let guard_result = if (arm_g.clone() != None) { - Some(infer_expr(arm_g.clone().unwrap(), arm_scope.clone(), None)) + let guard_result = if (arm_g.clone() != std::option::Option::None) { + Some(infer_expr( + arm_g.clone().unwrap(), + arm_scope.clone(), + std::option::Option::None, + )) } else { - None + std::option::Option::None }; let body_result = infer_expr(arm_b.clone(), arm_scope.clone(), expected.clone()); @@ -8976,7 +9431,7 @@ crate::v1_compiler_infer_types::resolve_type_variables_from_template(t.clone(), diagnostics: Rc::new(vec![]), }), }; - let guard_diags = if (guard_result.clone() != None) { + let guard_diags = if (guard_result.clone() != std::option::Option::None) { guard_unwrapped.diagnostics.clone() } else { Rc::new(vec![]) @@ -8985,10 +9440,10 @@ crate::v1_compiler_infer_types::resolve_type_variables_from_template(t.clone(), typed_arm: crate::v1_std_core::make_arm_node( arm_node.occurrence_identity.clone(), typed_pattern.clone(), - if (guard_result.clone() != None) { + if (guard_result.clone() != std::option::Option::None) { Some(guard_unwrapped.typed.clone()) } else { - None + std::option::Option::None }, body_typed.clone(), span.clone(), @@ -9111,15 +9566,16 @@ crate::v1_compiler_infer_types::resolve_type_variables_from_template(t.clone(), ); let arm_scope = pattern_result.scope.clone(); let pattern_diags = pattern_result.diagnostics.clone(); - let guard_result = if (arm_g.clone() != None) { - Some(infer_expr( - arm_g.clone().unwrap(), - arm_scope.clone(), - None, - )) - } else { - None - }; + let guard_result = + if (arm_g.clone() != std::option::Option::None) { + Some(infer_expr( + arm_g.clone().unwrap(), + arm_scope.clone(), + std::option::Option::None, + )) + } else { + std::option::Option::None + }; let body_result = infer_expr( arm_b.clone(), arm_scope.clone(), @@ -9134,19 +9590,20 @@ crate::v1_compiler_infer_types::resolve_type_variables_from_template(t.clone(), diagnostics: Rc::new(vec![]), }), }; - let guard_diags = if (guard_result.clone() != None) { - guard_unwrapped.diagnostics.clone() - } else { - Rc::new(vec![]) - }; + let guard_diags = + if (guard_result.clone() != std::option::Option::None) { + guard_unwrapped.diagnostics.clone() + } else { + Rc::new(vec![]) + }; Rc::new(ArmInferResult { typed_arm: crate::v1_std_core::make_arm_node( arm_node.occurrence_identity.clone(), typed_pattern.clone(), - if (guard_result.clone() != None) { + if (guard_result.clone() != std::option::Option::None) { Some(guard_unwrapped.typed.clone()) } else { - None + std::option::Option::None }, body_typed.clone(), span.clone(), @@ -9234,7 +9691,7 @@ crate::v1_compiler_infer_types::resolve_type_variables_from_template(t.clone(), let cond = crate::v1_std_core::if_condition(texpr.clone()); let then_expr = crate::v1_std_core::if_then_branch(texpr.clone()); let else_expr = crate::v1_std_core::if_else_branch(texpr.clone()); - let cond_result = infer_expr(cond.clone(), scope.clone(), None); + let cond_result = infer_expr(cond.clone(), scope.clone(), std::option::Option::None); let cond_typed = cond_result.typed.clone(); let cond_diags = cond_result.diagnostics.clone(); let then_result = infer_expr(then_expr.clone(), scope.clone(), expected.clone()); @@ -9370,7 +9827,7 @@ crate::v1_compiler_infer_types::resolve_type_variables_from_template(t.clone(), }, None => false, }; - let val_expected = if ((texpr.type_annotation.clone() != None) + let val_expected = if ((texpr.type_annotation.clone() != std::option::Option::None) && crate::v1_compiler_infer_types::is_type_expr_annotation( texpr.type_annotation.clone().clone().unwrap(), )) { @@ -9379,13 +9836,14 @@ crate::v1_compiler_infer_types::resolve_type_variables_from_template(t.clone(), if is_tail_return.clone() { expected.clone() } else { - None + std::option::Option::None } }; let val_result = infer_expr(val_expr.clone(), scope.clone(), val_expected.clone()); let val_typed = val_result.typed.clone(); let val_type = crate::v1_compiler_infer_types::resolved_type(val_typed.clone()); - let val_annotation_diags = if ((texpr.type_annotation.clone() != None) + let val_annotation_diags = if ((texpr.type_annotation.clone() + != std::option::Option::None) && crate::v1_compiler_infer_types::is_type_expr_annotation( texpr.type_annotation.clone().clone().unwrap(), )) { @@ -9400,7 +9858,7 @@ crate::v1_compiler_infer_types::resolve_type_variables_from_template(t.clone(), }; let val_diags = v1_rt::concat(val_result.diagnostics.clone(), val_annotation_diags.clone()); - if (body_expr.clone() == None) { + if (body_expr.clone() == std::option::Option::None) { { let let_texpr = crate::v1_std_core::make_named_expr_node( texpr.occurrence_identity.clone(), @@ -9478,13 +9936,13 @@ crate::v1_compiler_infer_types::resolve_type_variables_from_template(t.clone(), Some(elem) => Some(crate::v1_compiler_infer_types::child_type_node( elem.clone(), )), - None => None, + None => std::option::Option::None, } } else { - None + std::option::Option::None } } - None => None, + None => std::option::Option::None, }; let elem_results = Rc::new({ let mut __result = Vec::new(); @@ -9512,6 +9970,7 @@ crate::v1_compiler_infer_types::resolve_type_variables_from_template(t.clone(), (*declared_type_obligation_diags( Rc::new(DeclaredTypeObligation { position: DeclaredTypePosition::PositionListElement, + subject: "".to_string(), declared: declared_elem.clone(), produced: crate::v1_compiler_infer_types::resolved_type( te.clone(), @@ -9614,10 +10073,12 @@ crate::v1_compiler_infer_types::resolve_type_variables_from_template(t.clone(), let span = texpr.span.clone(); let left_expr = crate::v1_std_core::binop_left(texpr.clone()); let right_expr = crate::v1_std_core::binop_right(texpr.clone()); - let left_result = infer_expr(left_expr.clone(), scope.clone(), None); + let operands = + infer_binop_operands(left_expr.clone(), right_expr.clone(), scope.clone()); + let left_result = operands.left.clone(); let left_typed = left_result.typed.clone(); let left_diags = left_result.diagnostics.clone(); - let right_result = infer_expr(right_expr.clone(), scope.clone(), None); + let right_result = operands.right.clone(); let right_typed = right_result.typed.clone(); let right_diags = right_result.diagnostics.clone(); let binop_info = crate::v1_compiler_infer_types::infer_binop_type_node( @@ -9645,7 +10106,11 @@ crate::v1_compiler_infer_types::resolve_type_variables_from_template(t.clone(), ExprData::ExprUnaryOp { op: op, .. } => { let span = texpr.span.clone(); let operand_expr = crate::v1_std_core::unaryop_operand(texpr.clone()); - let operand_result = infer_expr(operand_expr.clone(), scope.clone(), None); + let operand_result = infer_expr( + operand_expr.clone(), + scope.clone(), + std::option::Option::None, + ); let operand_typed = operand_result.typed.clone(); let operand_diags = operand_result.diagnostics.clone(); let result_type = match op.clone() { @@ -9689,7 +10154,7 @@ crate::v1_compiler_infer_types::resolve_type_variables_from_template(t.clone(), Some(p) => p.clone(), None => Rc::new(SubValueRelation::SubValueUnknown), }; - let lam_scope = if (expected.clone() != None) { + let lam_scope = if (expected.clone() != std::option::Option::None) { { let exp = expected.clone().unwrap(); if ((exp.params.clone().len() as i64) > 0) { @@ -9809,7 +10274,7 @@ crate::v1_compiler_infer_types::resolve_type_variables_from_template(t.clone(), } else { extend_scope_with_params(scope.clone(), lam_params.clone()) }; - let body_expected = if (expected.clone() != None) { + let body_expected = if (expected.clone() != std::option::Option::None) { { let exp = expected.clone().unwrap(); if ((exp.params.clone().len() as i64) > 0) { @@ -9826,17 +10291,17 @@ crate::v1_compiler_infer_types::resolve_type_variables_from_template(t.clone(), )) { Some(declared_ret.clone()) } else { - None + std::option::Option::None } } - _ => None, + _ => std::option::Option::None, } } else { - None + std::option::Option::None } } } else { - None + std::option::Option::None }; let body_scope = Rc::new(InferScope { type_env: lam_scope.type_env.clone(), @@ -9885,7 +10350,7 @@ crate::v1_compiler_infer_types::resolve_type_variables_from_template(t.clone(), Some(binding) => Some(Rc::new(InferredNode::Resolved { node: binding.resolved.clone(), })), - None => None, + None => std::option::Option::None, }; Rc::new(Node { occurrence_identity: Rc::new( @@ -9935,7 +10400,11 @@ crate::v1_compiler_infer_types::resolve_type_variables_from_template(t.clone(), ExprData::ExprLiteral { value: _, .. } => part_node.clone(), _ => match part_node.children.clone().first().cloned() { Some(inner) => { - let r = infer_expr(inner.clone(), scope.clone(), None); + let r = infer_expr( + inner.clone(), + scope.clone(), + std::option::Option::None, + ); crate::v1_std_core::make_interp_part_node( part_node.occurrence_identity.clone(), r.typed.clone(), @@ -9956,7 +10425,11 @@ crate::v1_compiler_infer_types::resolve_type_variables_from_template(t.clone(), ExprData::ExprLiteral { value: _, .. } => Rc::new(vec![]), _ => match part_node.children.clone().first().cloned() { Some(inner) => { - let r = infer_expr(inner.clone(), scope.clone(), None); + let r = infer_expr( + inner.clone(), + scope.clone(), + std::option::Option::None, + ); r.diagnostics.clone() } None => Rc::new(vec![]), @@ -10030,7 +10503,8 @@ crate::v1_compiler_infer_types::resolve_type_variables_from_template(t.clone(), let span = texpr.span.clone(); let cast_inner = crate::v1_std_core::cast_expr(texpr.clone()); let target_type = crate::v1_std_core::cast_target(texpr.clone()); - let inner_result = infer_expr(cast_inner.clone(), scope.clone(), None); + let inner_result = + infer_expr(cast_inner.clone(), scope.clone(), std::option::Option::None); let inner_typed = inner_result.typed.clone(); let inner_diags = inner_result.diagnostics.clone(); let si = scope.type_env.clone().source_indices.clone(); @@ -10096,7 +10570,7 @@ crate::v1_compiler_infer_types::resolve_type_variables_from_template(t.clone(), let span = texpr.span.clone(); let coll = crate::v1_std_core::foreach_collection(texpr.clone()); let body_expr = crate::v1_std_core::foreach_body(texpr.clone()); - let coll_result = infer_expr(coll.clone(), scope.clone(), None); + let coll_result = infer_expr(coll.clone(), scope.clone(), std::option::Option::None); let coll_typed = coll_result.typed.clone(); let coll_diags = coll_result.diagnostics.clone(); let elem_type_node = crate::v1_compiler_infer_types::for_each_element_type_node( @@ -10114,7 +10588,11 @@ crate::v1_compiler_infer_types::resolve_type_variables_from_template(t.clone(), elem_type_node.clone(), elem_provenance.clone(), ); - let body_result = infer_expr(body_expr.clone(), body_scope.clone(), None); + let body_result = infer_expr( + body_expr.clone(), + body_scope.clone(), + std::option::Option::None, + ); let body_typed = body_result.typed.clone(); let body_diags = body_result.diagnostics.clone(); let fe_texpr = crate::v1_std_core::make_named_expr_node( @@ -10135,10 +10613,12 @@ crate::v1_compiler_infer_types::resolve_type_variables_from_template(t.clone(), let span = texpr.span.clone(); let base_expr = crate::v1_std_core::index_base(texpr.clone()); let idx_key = crate::v1_std_core::index_expr(texpr.clone()); - let base_result = infer_expr(base_expr.clone(), scope.clone(), None); + let base_result = + infer_expr(base_expr.clone(), scope.clone(), std::option::Option::None); let base_typed = base_result.typed.clone(); let base_diags = base_result.diagnostics.clone(); - let index_result = infer_expr(idx_key.clone(), scope.clone(), None); + let index_result = + infer_expr(idx_key.clone(), scope.clone(), std::option::Option::None); let index_typed = index_result.typed.clone(); let index_diags = index_result.diagnostics.clone(); let index_check = match base_typed.inferred.clone().as_deref().cloned() { @@ -10154,9 +10634,9 @@ crate::v1_compiler_infer_types::resolve_type_variables_from_template(t.clone(), scope.module_name.clone(), scope.type_env.clone().source_indices.clone(), )), - _ => None, + _ => std::option::Option::None, }, - _ => None, + _ => std::option::Option::None, }; let access_failure_inferred = match base_typed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: _, .. }) => index_typed.inferred.clone(), @@ -10194,13 +10674,15 @@ crate::v1_compiler_infer_types::resolve_type_variables_from_template(t.clone(), let base_expr = crate::v1_std_core::slice_base(texpr.clone()); let start_expr = crate::v1_std_core::slice_start(texpr.clone()); let end_expr = crate::v1_std_core::slice_end(texpr.clone()); - let base_result = infer_expr(base_expr.clone(), scope.clone(), None); + let base_result = + infer_expr(base_expr.clone(), scope.clone(), std::option::Option::None); let base_typed = base_result.typed.clone(); let base_diags = base_result.diagnostics.clone(); - let start_result = infer_expr(start_expr.clone(), scope.clone(), None); + let start_result = + infer_expr(start_expr.clone(), scope.clone(), std::option::Option::None); let start_typed = start_result.typed.clone(); let start_diags = start_result.diagnostics.clone(); - let end_result = infer_expr(end_expr.clone(), scope.clone(), None); + let end_result = infer_expr(end_expr.clone(), scope.clone(), std::option::Option::None); let end_typed = end_result.typed.clone(); let end_diags = end_result.diagnostics.clone(); let slice_check = match base_typed.inferred.clone().as_deref().cloned() { @@ -10220,11 +10702,11 @@ crate::v1_compiler_infer_types::resolve_type_variables_from_template(t.clone(), scope.type_env.clone().source_indices.clone(), )) } - _ => None, + _ => std::option::Option::None, }, - _ => None, + _ => std::option::Option::None, }, - _ => None, + _ => std::option::Option::None, }; let access_failure_inferred = match base_typed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: _, .. }) => { @@ -10313,7 +10795,7 @@ pub fn infer_variant_constructor_call( scope: Rc, ) -> Option> { match lookup_variant_parent_enum(scope.clone(), func_name.clone()) { - None => None, + None => std::option::Option::None, Some(parent_enum) => { let si = scope.type_env.clone().source_indices.clone(); match crate::v1_compiler_infer_env::lookup_type_by_name( @@ -10366,12 +10848,12 @@ pub fn infer_variant_constructor_call( span.clone(), name_span.clone(), scope.clone(), - None, + std::option::Option::None, )) } } } - None => None, + None => std::option::Option::None, } } else { { @@ -10396,24 +10878,26 @@ pub fn infer_variant_constructor_call( } } } else { - None + std::option::Option::None } } - None => None, + None => std::option::Option::None, }, - None => None, + None => std::option::Option::None, } } } } pub fn is_deferred_field_access_base(n: Rc, env: Rc) -> bool { - if ((n.inferred.clone() != None) && is_type_variable(n.inferred.clone().clone().unwrap())) { + if ((n.inferred.clone() != std::option::Option::None) + && is_type_variable(n.inferred.clone().clone().unwrap())) + { true } else { if (((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) == 0)) - && (n.inferred.clone() == None)) + && (n.inferred.clone() == std::option::Option::None)) { { let name = @@ -10440,7 +10924,7 @@ pub fn needs_alias_field_expansion(n: Rc, env: Rc) -> bool { } else { if (((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) > 0)) - && (n.inferred.clone() == None)) + && (n.inferred.clone() == std::option::Option::None)) { crate::v1_compiler_infer_resolve::is_user_generic_use_site(n.clone(), env.clone()) } else { @@ -10454,7 +10938,7 @@ pub fn needs_alias_field_expansion(n: Rc, env: Rc) -> bool { } else { if (((binding.connective.clone() == Connective::NoConnective) && ((binding.children.clone().len() as i64) == 0)) - && (binding.inferred.clone() != None)) + && (binding.inferred.clone() != std::option::Option::None)) { true } else { @@ -10464,7 +10948,7 @@ pub fn needs_alias_field_expansion(n: Rc, env: Rc) -> bool { (crate::v1_compiler_infer_resolve::is_user_generic_use_site( binding.clone(), env.clone(), - ) || (binding.inferred.clone() != None)) + ) || (binding.inferred.clone() != std::option::Option::None)) } else { false } @@ -10515,7 +10999,7 @@ pub fn peel_alias_once_for_field_access( } else { if (((resolved_once.connective.clone() == Connective::NoConnective) && ((resolved_once.children.clone().len() as i64) > 0)) - && (resolved_once.inferred.clone() == None)) + && (resolved_once.inferred.clone() == std::option::Option::None)) { if (resolved_once.clone() == n.clone()) { once @@ -10665,7 +11149,7 @@ pub fn alias_chain_type_arg_subst( { let decl = alias_chain_generic_decl(env.clone(), carrier.clone(), target.clone()); if alias_chain_type_arg_arity_mismatch(carrier.clone(), decl.clone(), type_args.clone()) { - None + std::option::Option::None } else { Some( Rc::new( @@ -10774,7 +11258,8 @@ pub fn alias_chain_target_after_args( ) { None => target.clone(), Some(subst) => { - let is_parameterized_alias = (((decl.inferred.clone() != None) + let is_parameterized_alias = (((decl.inferred.clone() + != std::option::Option::None) && ((decl.children.clone().len() as i64) == 0)) && (decl.connective.clone() == Connective::NoConnective)); if is_parameterized_alias.clone() { @@ -11008,7 +11493,7 @@ pub fn record_lit_alias_struct_expansion( Some(decl) => { let to_expand = if (((decl.connective.clone() == Connective::NoConnective) && ((decl.children.clone().len() as i64) == 0)) - && (decl.inferred.clone() != None)) + && (decl.inferred.clone() != std::option::Option::None)) { match decl.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => target.clone(), @@ -11023,7 +11508,7 @@ pub fn record_lit_alias_struct_expansion( scope.module_name.clone(), )) } - None => None, + None => std::option::Option::None, } } @@ -11051,10 +11536,10 @@ pub fn record_lit_construction_field_names( __result })) } else { - None + std::option::Option::None } } - None => None, + None => std::option::Option::None, } } } @@ -11182,7 +11667,7 @@ pub fn map_literal_expected_keyed_node( scope: Rc, ) -> Option> { match type_name.clone() { - Some(_) => None, + Some(_) => std::option::Option::None, None => match expected.clone() { Some(e) => { if crate::v1_compiler_infer_types::node_is_keyed_collection( @@ -11191,10 +11676,10 @@ pub fn map_literal_expected_keyed_node( ) { Some(e.clone()) } else { - None + std::option::Option::None } } - None => None, + None => std::option::Option::None, }, } } @@ -11216,7 +11701,7 @@ pub fn infer_map_literal( .next() { Some(v) => Some(v.clone()), - None => None, + None => std::option::Option::None, }; let fi_results = Rc::new({ let mut __result = Vec::new(); @@ -11248,7 +11733,9 @@ pub fn infer_map_literal( Rc::new(InferResult { typed: crate::v1_std_core::make_expr_node( occurrence_identity.clone(), - Rc::new(ExprData::ExprRecordLit { parent_enum: None }), + Rc::new(ExprData::ExprRecordLit { + parent_enum: std::option::Option::None, + }), Rc::new({ let mut __result = Vec::new(); for fir in fi_results.iter().cloned() { @@ -11313,13 +11800,15 @@ pub fn infer_record_lit_structural( { let instantiated_struct_fields = record_lit_instantiated_fields(type_name.clone(), expected.clone(), scope.clone()); - let expected_struct_fields = if (instantiated_struct_fields.clone() == None) { - record_lit_fields_from_expected(type_name.clone(), expected.clone(), scope.clone()) - } else { - None - }; - let expected_variant_node = if ((instantiated_struct_fields.clone() == None) - && (expected_struct_fields.clone() == None)) + let expected_struct_fields = + if (instantiated_struct_fields.clone() == std::option::Option::None) { + record_lit_fields_from_expected(type_name.clone(), expected.clone(), scope.clone()) + } else { + std::option::Option::None + }; + let expected_variant_node = if ((instantiated_struct_fields.clone() + == std::option::Option::None) + && (expected_struct_fields.clone() == std::option::Option::None)) { match type_name.clone() { Some(_) => record_lit_variant_from_expected( @@ -11327,24 +11816,24 @@ pub fn infer_record_lit_structural( expected.clone(), scope.clone(), ), - None => None, + None => std::option::Option::None, } } else { - None + std::option::Option::None }; let alias_struct_expansion = match type_name.clone() { Some(tn) => { - if ((((instantiated_struct_fields.clone() == None) - && (expected_struct_fields.clone() == None)) - && (expected_variant_node.clone() == None)) - && (expected.clone() == None)) + if ((((instantiated_struct_fields.clone() == std::option::Option::None) + && (expected_struct_fields.clone() == std::option::Option::None)) + && (expected_variant_node.clone() == std::option::Option::None)) + && (expected.clone() == std::option::Option::None)) { record_lit_alias_struct_expansion(tn.clone(), scope.clone()) } else { - None + std::option::Option::None } } - None => None, + None => std::option::Option::None, }; let struct_fields = match type_name.clone() { Some(_) => match instantiated_struct_fields.clone() { @@ -11390,7 +11879,7 @@ pub fn infer_record_lit_structural( }; let construction_field_names = match type_name.clone() { Some(tn) => record_lit_construction_field_names(tn.clone(), scope.clone()), - None => None, + None => std::option::Option::None, }; let tn_str = match type_name.clone() { Some(tn) => tn.clone(), @@ -11447,17 +11936,17 @@ pub fn infer_record_lit_structural( }, } }; - let is_zero_field_variant_tag_reference = - (((field_inits.clone().len() as i64) == 0) && (presence_variant_owner.clone() != None)); + let is_zero_field_variant_tag_reference = (((field_inits.clone().len() as i64) == 0) + && (presence_variant_owner.clone() != std::option::Option::None)); let presence_name_is_ambiguous = (crate::v1_compiler_infer_env::global_bare_is_ambiguous( scope.type_env.clone(), tn_str.clone(), ) && (v1_rt::map_get(&scope.type_env.clone().str_bindings.clone(), tn_str.clone()) - == None)); + == std::option::Option::None)); let presence_ambiguity_refusal_diags = if ((tn_str.clone() != "".to_string()) && (v1_rt::map_get(&scope.type_env.clone().str_bindings.clone(), tn_str.clone()) - == None)) + == std::option::Option::None)) { { let strict_cands = @@ -11499,7 +11988,7 @@ pub fn infer_record_lit_structural( _ => crate::v1_std_core::field_node_type_expr(sf.clone()), }; (((sf_type.return_cardinality.clone() != Cardinality::CardOptional) - && (sf.body.clone() == None)) + && (sf.body.clone() == std::option::Option::None)) && ({ let mut __found = false; for fi in field_inits.iter().cloned() { @@ -11565,15 +12054,15 @@ let field_declared_type = match Rc::new({ let mut __result = Vec::new(); for sf }; Some(ft.clone()) }, - None => None, + None => std::option::Option::None, }; let field_expected = match field_declared_type.clone() { - Some(ft) => if ((((ft.ident_span.clone() != None) || type_node_is_callable(ft.clone())) || (ft.return_cardinality.clone() == Cardinality::CardOptional)) || field_type_is_optional_coproduct(ft.clone(), scope.type_env.clone())) { + Some(ft) => if ((((ft.ident_span.clone() != std::option::Option::None) || type_node_is_callable(ft.clone())) || (ft.return_cardinality.clone() == Cardinality::CardOptional)) || field_type_is_optional_coproduct(ft.clone(), scope.type_env.clone())) { Some(ft.clone()) } else { - None + std::option::Option::None }, - None => None, + None => std::option::Option::None, }; let ar = infer_expr(crate::v1_std_core::field_init_node_value(fi.clone()), scope.clone(), field_expected.clone()); let ar_typed = ar.typed.clone(); @@ -11638,7 +12127,7 @@ Rc::new(FieldInferResult { } __result }); - if (type_name.clone() == None) { + if (type_name.clone() == std::option::Option::None) { { let child_nodes = Rc::new({ let mut __result = Vec::new(); @@ -11659,13 +12148,13 @@ Rc::new(FieldInferResult { inferred: fir.infer_result.clone().typed.clone().inferred.clone(), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, })); @@ -11676,27 +12165,29 @@ Rc::new(FieldInferResult { occurrence_identity: Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), name: "".to_string(), span: crate::v1_std_core::no_span(), - ident_span: None, + ident_span: std::option::Option::None, children: child_nodes.clone(), connective: Connective::Conj, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); let typed_field_nodes = typed_fields.clone(); let texpr = crate::v1_std_core::make_expr_node( occurrence_identity.clone(), - Rc::new(ExprData::ExprRecordLit { parent_enum: None }), + Rc::new(ExprData::ExprRecordLit { + parent_enum: std::option::Option::None, + }), typed_field_nodes.clone(), Some(Rc::new(InferredNode::Resolved { node: anon_node.clone(), @@ -11936,14 +12427,14 @@ pub fn classify_size_expr(val: Rc, ctx: Rc) -> Option Some(Rc::new(DescentSizeExpr::ParamSize { param: rname.clone(), })), - None => None, + None => std::option::Option::None, } } - _ => None, + _ => std::option::Option::None, } } } else { - None + std::option::Option::None } } ExprData::ExprBinOp { .. } => { @@ -11973,21 +12464,21 @@ pub fn classify_size_expr(val: Rc, ctx: Rc) -> Option None, + None => std::option::Option::None, } } - _ => None, + _ => std::option::Option::None, } } - _ => None, + _ => std::option::Option::None, }, - _ => None, + _ => std::option::Option::None, } } - _ => None, + _ => std::option::Option::None, } } @@ -12034,22 +12525,22 @@ Some(Rc::new(SubValueRelation::StrictSubValue { }), })) }, - None => None, + None => std::option::Option::None, } } else { - None + std::option::Option::None } } - None => None, + None => std::option::Option::None, } } else { - None + std::option::Option::None } } - _ => None, + _ => std::option::Option::None, } } - _ => None, + _ => std::option::Option::None, } } @@ -12215,9 +12706,9 @@ pub fn method_callback_element_position(semantics: Option>) .. }) => match at.clone() { Some(template) => template.callback_element_position.clone(), - None => None, + None => std::option::Option::None, }, - _ => None, + _ => std::option::Option::None, } } @@ -12255,7 +12746,7 @@ pub fn maybe_insert_output_field_relation( Some(param_map) => { classify_call_via_provenance(val.clone(), param_map.clone(), ctx.clone()) } - None => None, + None => std::option::Option::None, }; maybe_insert_composed_field_relation(acc.clone(), fname.clone(), composed.clone()) } @@ -12533,11 +13024,11 @@ pub fn resolve_collection_field( .first() .cloned(); } else { - break None; + break std::option::Option::None; } } _ => { - break None; + break std::option::Option::None; } } } @@ -12556,7 +13047,7 @@ pub fn resolve_collection_field( break Some(f.clone()); } _ => { - break None; + break std::option::Option::None; } } } @@ -12566,16 +13057,16 @@ pub fn resolve_collection_field( break Some(f.clone()); } _ => { - break None; + break std::option::Option::None; } } } _ => { - break None; + break std::option::Option::None; } }, None => { - break None; + break std::option::Option::None; } } } @@ -12600,11 +13091,11 @@ pub fn resolve_collection_field( continue; } } else { - break None; + break std::option::Option::None; } } _ => { - break None; + break std::option::Option::None; } } } @@ -12687,10 +13178,10 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option match (*binding.provenance.clone()).clone() { - SubValueRelation::SubValueUnknown => None, + SubValueRelation::SubValueUnknown => std::option::Option::None, _ => Some(binding.provenance.clone()), }, - None => None, + None => std::option::Option::None, } } ExprData::ExprFieldAccess { summary: _, .. } => { @@ -12710,7 +13201,7 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option v1_rt::map_get(&field_map, field.clone()), - None => None, + None => std::option::Option::None, }; match from_per_field.clone() { Some(rel) => Some(rel.clone()), @@ -12753,16 +13244,16 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option None, + None => std::option::Option::None, } } } else { - None + std::option::Option::None } } } } - _ => None, + _ => std::option::Option::None, } } ExprData::ExprCall { .. } => { @@ -12782,10 +13273,10 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option None, + None => std::option::Option::None, } } - DerivedCalleeSig::NoDerivableSig { reason: _, .. } => None, + DerivedCalleeSig::NoDerivableSig { reason: _, .. } => std::option::Option::None, }; match from_provenance.clone() { Some(_) => from_provenance.clone(), @@ -12854,21 +13345,21 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option None, + None => std::option::Option::None, } } } else { - None + std::option::Option::None } } - _ => None, + _ => std::option::Option::None, } } - None => None, + None => std::option::Option::None, } } } else { - None + std::option::Option::None } } } @@ -12920,18 +13411,18 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option None, + None => std::option::Option::None, } } } else { - None + std::option::Option::None } } } else { - None + std::option::Option::None } } - _ => None, + _ => std::option::Option::None, }; match type_based.clone() { Some(_) => type_based.clone(), @@ -12949,11 +13440,11 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option match crate::std_termination::positive_descent_amount_from_positive_int(k.clone()) { @@ -12963,15 +13454,15 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option None, + None => std::option::Option::None, }, - None => None, + None => std::option::Option::None, } } else { - None + std::option::Option::None } } - _ => None, + _ => std::option::Option::None, }, BinOp::Div => { let left_name = match (*left.expr_data.clone()).clone() { @@ -12985,11 +13476,11 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option, ctx: Rc) -> Option, ctx: Rc) -> Option None, + None => std::option::Option::None, }, - None => None, + None => std::option::Option::None, } } else { - None + std::option::Option::None } } - BinOp::Add => None, - _ => None, + BinOp::Add => std::option::Option::None, + _ => std::option::Option::None, } } ExprData::ExprMethodCall { @@ -13101,11 +13592,11 @@ pub fn classify_let_value(val: Rc, ctx: Rc) -> Option { @@ -13123,29 +13614,29 @@ Some(Rc::new(SubValueRelation::StrictSubValue { }), })) }, - None => None, + None => std::option::Option::None, } } else { - None + std::option::Option::None } } - _ => None, + _ => std::option::Option::None, } } else { - None + std::option::Option::None } } } else { - None + std::option::Option::None } } } } } else { - None + std::option::Option::None } } - _ => None, + _ => std::option::Option::None, }, } } @@ -13176,7 +13667,7 @@ pub fn classify_call_via_provenance( }, ); Rc::new(v1_rt::map_keys(¶m_map)).iter().cloned().fold( - None, + std::option::Option::None, |result: _, callee_pname: String| match v1_rt::map_get(¶m_map, callee_pname.clone()) { Some(callee_rel) => match v1_rt::map_get(&arg_by_name, callee_pname.clone()) { @@ -13217,7 +13708,8 @@ pub fn classify_call_arg_provenance( arg_expr.clone(), ctx.type_env.clone().source_indices.clone(), ); - if (v1_rt::map_get(&ctx.param_names.clone(), name.clone()) != None) { + if (v1_rt::map_get(&ctx.param_names.clone(), name.clone()) != std::option::Option::None) + { Some(Rc::new(SubValueRelation::PreservedValue)) } else { v1_rt::map_get(&ctx.sub_value_vars.clone(), name.clone()) @@ -13361,10 +13853,12 @@ pub fn classify_argument( param_map.clone(), ctx.clone(), ), - None => None, + None => std::option::Option::None, } } - DerivedCalleeSig::NoDerivableSig { reason: _, .. } => None, + DerivedCalleeSig::NoDerivableSig { reason: _, .. } => { + std::option::Option::None + } }; match from_provenance.clone() { Some(prov_rel) => prov_rel.clone(), @@ -13468,7 +13962,7 @@ pub fn classify_argument( left.clone(), ctx.type_env.clone().source_indices.clone(), ), - ) != None)) + ) != std::option::Option::None)) } _ => false, }; @@ -13504,7 +13998,7 @@ pub fn classify_argument( left.clone(), ctx.type_env.clone().source_indices.clone(), ), - ) != None)) + ) != std::option::Option::None)) } ExprData::ExprBinOp { op: BinOp::Sub, .. } => { let inner_left = crate::v1_std_core::binop_left(left.clone()); @@ -13522,7 +14016,7 @@ pub fn classify_argument( inner_left.clone(), ctx.type_env.clone().source_indices.clone(), ), - ) != None)) + ) != std::option::Option::None)) } _ => false, } @@ -13747,7 +14241,7 @@ pub fn build_call_evidence( if (crate::v1_std_core::arg_name_at( arg_node.clone(), ctx.type_env.clone().source_indices.clone(), - ) == None) + ) == std::option::Option::None) { __result.push(arg_node); } @@ -14097,10 +14591,10 @@ crate::v1_std_core::make_arg_node(child.occurrence_identity.clone(), crate::v1_s .cloned() } } else { - None + std::option::Option::None } } - _ => None, + _ => std::option::Option::None, } } ExprData::ExprMethodCall { @@ -14119,10 +14613,10 @@ crate::v1_std_core::make_arg_node(child.occurrence_identity.clone(), crate::v1_s resolve_collection_field(receiver.clone(), ctx.clone()) } } else { - None + std::option::Option::None } } - _ => None, + _ => std::option::Option::None, }; let scrut_has_inductive = (((scrut_type.clone() != "".to_string()) && ((crate::v1_compiler_infer_env::inductive_fields_for( @@ -14131,7 +14625,7 @@ crate::v1_std_core::make_arg_node(child.occurrence_identity.clone(), crate::v1_s ) .len() as i64) > 0)) - || (scrut_inducing_field.clone() != None)); + || (scrut_inducing_field.clone() != std::option::Option::None)); let scrut_variant_sig = match (*scrut.expr_data.clone()).clone() { ExprData::ExprCall { .. } => { let callee = crate::v1_std_core::expr_call_func_at( @@ -14150,13 +14644,15 @@ crate::v1_std_core::make_arg_node(child.occurrence_identity.clone(), crate::v1_s { Some(sig.clone()) } else { - None + std::option::Option::None } } - DerivedCalleeSig::NoDerivableSig { reason: _, .. } => None, + DerivedCalleeSig::NoDerivableSig { reason: _, .. } => { + std::option::Option::None + } } } - _ => None, + _ => std::option::Option::None, }; let annotated_scrut = annotate_descent(scrut.clone(), ctx.clone()); let annotated_arms = Rc::new({ @@ -14168,7 +14664,7 @@ crate::v1_std_core::make_arg_node(child.occurrence_identity.clone(), crate::v1_s __result.push({ let variant_arm_ctx = match scrut_variant_sig.clone() { Some(sig) => arm_ctx_from_variant_provenance(arm_node.clone(), sig.clone(), scrut.clone(), ctx.clone()), - None => None, + None => std::option::Option::None, }; let arm_ctx = match variant_arm_ctx.clone() { Some(c) => c.clone(), @@ -14559,7 +15055,7 @@ Rc::new(BlockAnnotateAcc { ctx.type_env.clone().source_indices.clone(), ); let elem_position = method_callback_element_position(ms.clone()); - if (elem_position.clone() != None) { + if (elem_position.clone() != std::option::Option::None) { { let raw_receiver = crate::v1_std_core::method_receiver(body.clone()); let receiver = match (*raw_receiver.expr_data.clone()).clone() { @@ -14620,10 +15116,10 @@ Rc::new(BlockAnnotateAcc { if (base_type.clone() != "".to_string()) { Rc::new({ let mut __result = Vec::new(); for f in crate::v1_compiler_infer_env::inductive_fields_for(ctx.type_env.clone(), base_type.clone()).iter().cloned() { if (f.field_name.clone() == fname.clone()) { __result.push(f); } } __result }).first().cloned() } else { - None + std::option::Option::None } } - _ => None, + _ => std::option::Option::None, } } ExprData::ExprVar { @@ -14638,21 +15134,21 @@ Rc::new(BlockAnnotateAcc { SubValueRelation::StrictSubValue { field: f, .. } => { match f.shape.clone() { RecursionShape::ListRecursion => Some(f.clone()), - _ => None, + _ => std::option::Option::None, } } SubValueRelation::IteratedSubValue { field: f, .. } => { match f.shape.clone() { RecursionShape::ListRecursion => Some(f.clone()), - _ => None, + _ => std::option::Option::None, } } - _ => None, + _ => std::option::Option::None, }, - None => None, + None => std::option::Option::None, } } - _ => None, + _ => std::option::Option::None, }; let method_args = crate::v1_std_core::method_arg_nodes(body.clone()); let lambda_arg = Rc::new({ @@ -14687,7 +15183,7 @@ Rc::new(BlockAnnotateAcc { .skip(elem_position.clone().unwrap() as usize) .next() } - None => None, + None => std::option::Option::None, }; let is_fold = (elem_position.clone().unwrap() > 0); let inner_ctx = match lambda_elem_info.clone() { @@ -14767,7 +15263,7 @@ Rc::new(BlockAnnotateAcc { ctx.type_env.clone().source_indices.clone(), ) { Some(n) => Some(n.clone()), - None => None, + None => std::option::Option::None, }, annotate_descent(arg_val.clone(), inner_ctx.clone()), arg_node.span.clone(), @@ -14781,7 +15277,7 @@ Rc::new(BlockAnnotateAcc { ctx.type_env.clone().source_indices.clone(), ) { Some(n) => Some(n.clone()), - None => None, + None => std::option::Option::None, }, annotate_descent(arg_val.clone(), ctx.clone()), arg_node.span.clone(), @@ -15923,9 +16419,9 @@ pub fn arm_ctx_from_variant_provenance( ); Some(extended.clone()) } - None => None, + None => std::option::Option::None, }, - _ => None, + _ => std::option::Option::None, } } @@ -16374,7 +16870,7 @@ pub fn merge_field_prov_maps( from_a.clone(), |result: Rc>>>>, fname: String| { - if (v1_rt::map_get(&result, fname.clone()) != None) { + if (v1_rt::map_get(&result, fname.clone()) != std::option::Option::None) { result.clone() } else { match v1_rt::map_get(&b, fname.clone()) { @@ -16414,7 +16910,7 @@ pub fn union_prov_maps( Rc::new(v1_rt::map_keys(&b)).iter().cloned().fold( from_a.clone(), |result: Rc>>, key: String| { - if (v1_rt::map_get(&result, key.clone()) != None) { + if (v1_rt::map_get(&result, key.clone()) != std::option::Option::None) { result.clone() } else { match v1_rt::map_get(&b, key.clone()) { @@ -16716,7 +17212,8 @@ pub fn infer_property_values( for p in props.iter().cloned() { __result.push({ let val = crate::v1_std_core::field_init_node_value(p.clone()); - let val_result = infer_expr(val.clone(), scope.clone(), None); + let val_result = + infer_expr(val.clone(), scope.clone(), std::option::Option::None); Rc::new(PropertyInferenceResult { prop: Rc::new(Node { occurrence_identity: Rc::new( @@ -16828,7 +17325,7 @@ pub fn infer_service_config_properties( match (*service_config_field_judgment(field.clone())).clone() { ServiceConfigFieldJudgment::FieldJudged => { let val = crate::v1_std_core::field_init_node_value(p.clone()); -let val_result = infer_expr(val.clone(), scope.clone(), None); +let val_result = infer_expr(val.clone(), scope.clone(), std::option::Option::None); Rc::new(PropertyInferenceResult { prop: Rc::new(Node { occurrence_identity: Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), @@ -16897,7 +17394,7 @@ pub fn infer_transport_node( ) -> Rc { match transport.clone() { None => Rc::new(InferTransportResult { - transport: None, + transport: std::option::Option::None, diagnostics: Rc::new(vec![]), }), Some(t) => { @@ -16946,7 +17443,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc let typed_properties = props_result.props.clone(); let props_diags = props_result.diagnostics.clone(); if ((item.connective.clone() != Connective::NoConnective) - && (item.transport.clone() == None)) + && (item.transport.clone() == std::option::Option::None)) { Rc::new(TypedItemResult { item: Rc::new(Node { @@ -16965,21 +17462,23 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc inferred: Some(Rc::new(InferredNode::Resolved { node: unit_type() })), return_cardinality: item.return_cardinality.clone(), uses: item.uses.clone(), - body: None, + body: std::option::Option::None, connective: item.connective.clone(), transport: typed_transport.clone(), properties: typed_properties.clone(), type_annotation: typed_anno.clone(), is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }), diagnostics: v1_rt::concat(transport_diags.clone(), props_diags.clone()), }) } else { - if ((item.body.clone() != None) && ((item.params.clone().len() as i64) > 0)) { + if ((item.body.clone() != std::option::Option::None) + && ((item.params.clone().len() as i64) > 0)) + { { let fn_scope = build_params_scope(scope.clone(), item.params.clone()); let fn_scope = item.uses.clone().iter().cloned().fold( @@ -17012,10 +17511,11 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc caller_decl_name: fn_decl_name.clone(), lambda_param_provenance: fn_scope.lambda_param_provenance.clone(), }); - let fn_return_expected = if (item.inferred.clone() != None) { + let fn_return_expected = if (item.inferred.clone() != std::option::Option::None) + { Some(crate::v1_compiler_infer_types::resolved_type(item.clone())) } else { - None + std::option::Option::None }; let body_result = infer_expr( item.body.clone().clone().unwrap(), @@ -17024,12 +17524,14 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc ); let body_typed = body_result.typed.clone(); let body_diags = body_result.diagnostics.clone(); - let inferred_ret = if (item.inferred.clone() != None) { + let inferred_ret = if (item.inferred.clone() != std::option::Option::None) { item.inferred.clone() } else { body_typed.inferred.clone() }; - let return_conformance_diags = if (item.inferred.clone() != None) { + let return_conformance_diags = if (item.inferred.clone() + != std::option::Option::None) + { v1_rt::concat( declared_type_conformance_diags( declared_return_type_node(item.clone()), @@ -17102,7 +17604,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc true, scope.type_env.clone().source_indices.clone(), ), - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }), @@ -17113,8 +17615,9 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc }) } } else { - if (((item.body.clone() != None) && ((item.params.clone().len() as i64) == 0)) - && (item.inferred.clone() != None)) + if (((item.body.clone() != std::option::Option::None) + && ((item.params.clone().len() as i64) == 0)) + && (item.inferred.clone() != std::option::Option::None)) { { let fn_decl_name = crate::v1_std_core::authored_name_at( @@ -17175,7 +17678,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc type_annotation: typed_anno.clone(), is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }), @@ -17186,41 +17689,46 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc }) } } else { - if ((item.body.clone() != None) && ((item.params.clone().len() as i64) == 0)) { + if ((item.body.clone() != std::option::Option::None) + && ((item.params.clone().len() as i64) == 0)) + { { - let data_expected = if (item.type_annotation.clone() != None) { - Some(item.type_annotation.clone().clone().unwrap()) - } else { - None - }; + let data_expected = + if (item.type_annotation.clone() != std::option::Option::None) { + Some(item.type_annotation.clone().clone().unwrap()) + } else { + std::option::Option::None + }; let val_result = infer_expr( item.body.clone().clone().unwrap(), scope.clone(), data_expected.clone(), ); let val_typed = val_result.typed.clone(); - let val_diags = if (item.type_annotation.clone() != None) { - v1_rt::concat( - val_result.diagnostics.clone(), - declared_type_conformance_diags( - item.type_annotation.clone().clone().unwrap(), - crate::v1_compiler_infer_types::resolved_type( - val_typed.clone(), + let val_diags = + if (item.type_annotation.clone() != std::option::Option::None) { + v1_rt::concat( + val_result.diagnostics.clone(), + declared_type_conformance_diags( + item.type_annotation.clone().clone().unwrap(), + crate::v1_compiler_infer_types::resolved_type( + val_typed.clone(), + ), + item.body.clone().clone().unwrap().span.clone(), + scope.clone(), ), - item.body.clone().clone().unwrap().span.clone(), - scope.clone(), - ), - ) - } else { - val_result.diagnostics.clone() - }; - let inferred_ret = if (item.type_annotation.clone() != None) { - Some(Rc::new(InferredNode::Resolved { - node: item.type_annotation.clone().clone().unwrap(), - })) - } else { - val_typed.inferred.clone() - }; + ) + } else { + val_result.diagnostics.clone() + }; + let inferred_ret = + if (item.type_annotation.clone() != std::option::Option::None) { + Some(Rc::new(InferredNode::Resolved { + node: item.type_annotation.clone().clone().unwrap(), + })) + } else { + val_typed.inferred.clone() + }; Rc::new(TypedItemResult { item: Rc::new(Node { occurrence_identity: item.occurrence_identity.clone(), @@ -17239,7 +17747,7 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc type_annotation: typed_anno.clone(), is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }), @@ -17250,7 +17758,8 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc }) } } else { - if (((item.params.clone().len() as i64) > 0) && (item.body.clone() == None)) + if (((item.params.clone().len() as i64) > 0) + && (item.body.clone() == std::option::Option::None)) { Rc::new(TypedItemResult { item: Rc::new(Node { @@ -17268,21 +17777,23 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc __result }), params: item.params.clone(), - inferred: if (item.inferred.clone() != None) { + inferred: if (item.inferred.clone() + != std::option::Option::None) + { item.inferred.clone() } else { Some(Rc::new(InferredNode::Resolved { node: unit_type() })) }, return_cardinality: item.return_cardinality.clone(), uses: item.uses.clone(), - body: None, + body: std::option::Option::None, connective: Connective::NoConnective, transport: typed_transport.clone(), properties: typed_properties.clone(), type_annotation: typed_anno.clone(), is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }), @@ -17308,21 +17819,23 @@ pub fn infer_item(item: Rc, scope: Rc) -> Rc __result }), params: item.params.clone(), - inferred: if (item.inferred.clone() != None) { + inferred: if (item.inferred.clone() + != std::option::Option::None) + { item.inferred.clone() } else { Some(Rc::new(InferredNode::Resolved { node: unit_type() })) }, return_cardinality: item.return_cardinality.clone(), uses: item.uses.clone(), - body: None, + body: std::option::Option::None, connective: item.connective.clone(), transport: typed_transport.clone(), properties: typed_properties.clone(), type_annotation: typed_anno.clone(), is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }), @@ -18373,7 +18886,7 @@ pub fn local_binding_for_item( source_indices: Rc>>, ) -> Option> { if is_namespace_alias_item(item.clone(), source_indices.clone()) { - None + std::option::Option::None } else { { let has_structure = (item.connective.clone() != Connective::NoConnective); @@ -18387,16 +18900,16 @@ pub fn local_binding_for_item( children: item.children.clone(), connective: item.connective.clone(), params: item.params.clone(), - inferred: None, + inferred: std::option::Option::None, return_cardinality: item.return_cardinality.clone(), uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: item.properties.clone(), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -18410,7 +18923,9 @@ pub fn local_binding_for_item( })) } } else { - if ((item.body.clone() != None) && (item.transport.clone() == None)) { + if ((item.body.clone() != std::option::Option::None) + && (item.transport.clone() == std::option::Option::None)) + { { let fn_node = Rc::new(Node { occurrence_identity: item.occurrence_identity.clone(), @@ -18423,13 +18938,13 @@ pub fn local_binding_for_item( inferred: item.inferred.clone(), return_cardinality: item.return_cardinality.clone(), uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: item.properties.clone(), type_annotation: item.type_annotation.clone(), is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -18443,9 +18958,9 @@ pub fn local_binding_for_item( })) } } else { - if (((item.inferred.clone() != None) + if (((item.inferred.clone() != std::option::Option::None) && ((item.params.clone().len() as i64) == 0)) - && (item.body.clone() == None)) + && (item.body.clone() == std::option::Option::None)) { { let alias_node = Rc::new(Node { @@ -18459,13 +18974,13 @@ pub fn local_binding_for_item( inferred: item.inferred.clone(), return_cardinality: item.return_cardinality.clone(), uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -18479,7 +18994,7 @@ pub fn local_binding_for_item( })) } } else { - if ((item.transport.clone() == None) + if ((item.transport.clone() == std::option::Option::None) && ((item.children.clone().len() as i64) > 0)) { { @@ -18503,8 +19018,8 @@ pub fn local_binding_for_item( } else { if (((((item.params.clone().len() as i64) > 0) && (item.connective.clone() == Connective::NoConnective)) - && (item.body.clone() == None)) - && (item.transport.clone() == None)) + && (item.body.clone() == std::option::Option::None)) + && (item.transport.clone() == std::option::Option::None)) { { let bare_node = Rc::new(Node { @@ -18518,13 +19033,13 @@ pub fn local_binding_for_item( inferred: item.inferred.clone(), return_cardinality: item.return_cardinality.clone(), uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -18540,8 +19055,8 @@ pub fn local_binding_for_item( } else { if ((((((item.properties.clone().len() as i64) > 0) && (item.connective.clone() == Connective::NoConnective)) - && (item.transport.clone() == None)) - && (item.inferred.clone() == None)) + && (item.transport.clone() == std::option::Option::None)) + && (item.inferred.clone() == std::option::Option::None)) && ((item.params.clone().len() as i64) == 0)) { Some(nominal_type_binding( @@ -18551,7 +19066,7 @@ pub fn local_binding_for_item( ), )) } else { - None + std::option::Option::None } } } @@ -18598,7 +19113,9 @@ pub fn symbol_index_insert_item( ), } }; - if ((item.transport.clone() != None) && ((item.children.clone().len() as i64) > 0)) { + if ((item.transport.clone() != std::option::Option::None) + && ((item.children.clone().len() as i64) > 0)) + { crate::v1_compiler_infer_env::symbol_index_insert_service( with_decl.clone(), crate::v1_std_core::authored_name_at(source_indices.clone(), item.clone()), @@ -18748,7 +19265,7 @@ item.children.clone().iter().cloned().fold(acc.clone(), |a2: Rc, ch let a2_qualified = crate::v1_compiler_infer_env::symbol_index_insert(a2, v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(module_path.clone(), ".".to_string()), tname.clone()), ".".to_string()), vname.clone()), item.clone()); match v1_rt::map_get(&counts, vname.clone()) { Some(1) => match v1_rt::map_get(&corpus_variant_counts, vname.clone()) { - Some(1) => if ((v1_rt::map_get(&corpus_item_counts, vname.clone()) != None) || overlay_skips_kernel_name(vname.clone())) { + Some(1) => if ((v1_rt::map_get(&corpus_item_counts, vname.clone()) != std::option::Option::None) || overlay_skips_kernel_name(vname.clone())) { crate::v1_compiler_infer_env::symbol_index_insert(a2_qualified.clone(), v1_rt::concat(v1_rt::concat(module_path.clone(), ".".to_string()), vname.clone()), item.clone()) } else { crate::v1_compiler_infer_env::symbol_index_insert_decl(a2_qualified.clone(), module_path.clone(), Rc::new(TypeBinding { @@ -18777,7 +19294,7 @@ pub fn transparent_alias_target_name( && (item.connective.clone() == Connective::NoConnective)) && ((item.children.clone().len() as i64) == 0)) && ((item.properties.clone().len() as i64) == 0)) - && (item.type_annotation.clone() == None)); + && (item.type_annotation.clone() == std::option::Option::None)); if !item_shape_admits.clone() { "".to_string() } else { @@ -18793,7 +19310,7 @@ pub fn transparent_alias_target_name( == Connective::NoConnective) && ((target.children.clone().len() as i64) == 0)) && ((target.params.clone().len() as i64) == 0)) - && (target.type_annotation.clone() == None)) + && (target.type_annotation.clone() == std::option::Option::None)) && (target.return_cardinality.clone() == Cardinality::Required)); if !target_shape_admits.clone() { "".to_string() @@ -19064,7 +19581,7 @@ pub fn exposure_view_for_node( true => Rc::new(TypeHeadExposure::StuckTypeHead { cause: "declaration identity unavailable".to_string(), }), - false => match ((n.type_annotation.clone() != None) + false => match ((n.type_annotation.clone() != std::option::Option::None) || ((n.properties.clone().len() as i64) > 0)) { true => Rc::new(TypeHeadExposure::OpaqueTypeHead { @@ -19319,9 +19836,9 @@ pub fn census_binding_is_borrowable_fn_sig( let node = binding.resolved.clone(); ((((((node.connective.clone() == Connective::NoConnective) && ((node.children.clone().len() as i64) == 0)) - && (node.body.clone() == None)) - && (node.transport.clone() == None)) - && (node.inferred.clone() != None)) + && (node.body.clone() == std::option::Option::None)) + && (node.transport.clone() == std::option::Option::None)) + && (node.inferred.clone() != std::option::Option::None)) && ((node.params.clone().len() as i64) > 0)) } } @@ -19419,7 +19936,8 @@ pub fn stamp_field_type_from_decl_params( serving_decl: Rc, source_indices: Rc>>, ) -> Rc { - if (((serving_decl.params.clone().len() as i64) == 0) || (field_type.inferred.clone() != None)) + if (((serving_decl.params.clone().len() as i64) == 0) + || (field_type.inferred.clone() != std::option::Option::None)) { field_type.clone() } else { @@ -19471,7 +19989,7 @@ pub fn stamp_type_param_occurrences( && (n.connective.clone() == Connective::NoConnective)) && ((n.params.clone().len() as i64) == 0)); if is_bare.clone() { - if (n.inferred.clone() == None) { + if (n.inferred.clone() == std::option::Option::None) { { let nm = type_node_label(n.clone(), source_indices.clone()); match v1_rt::map_get(¶m_names, nm.clone()) { @@ -19641,7 +20159,7 @@ pub fn census_upgrade_binding( source_indices.clone(), ) } else { - if (binding.resolved.clone().inferred.clone() != None) { + if (binding.resolved.clone().inferred.clone() != std::option::Option::None) { census_qualify_leaf_binding( binding.clone(), module_path.clone(), @@ -20189,16 +20707,16 @@ pub fn build_type_env( children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }), @@ -20223,16 +20741,16 @@ pub fn build_type_env( children: Rc::new(vec![]), connective: Connective::Conj, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }), @@ -20252,13 +20770,13 @@ pub fn build_type_env( })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -20270,16 +20788,16 @@ pub fn build_type_env( children: Rc::new(vec![present_value_field.clone()]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -20291,16 +20809,16 @@ pub fn build_type_env( children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -20312,16 +20830,16 @@ pub fn build_type_env( children: Rc::new(vec![present_variant.clone(), absent_variant.clone()]), connective: Connective::Disj, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -20551,7 +21069,7 @@ pub fn build_type_env( None => false, }; if ((((item.params.clone().len() as i64) > 0) && is_type_decl.clone()) - && (item.body.clone() == None)) + && (item.body.clone() == std::option::Option::None)) { { let result = item.params.clone().iter().cloned().fold( @@ -20918,16 +21436,16 @@ pub fn build_type_env_unresolved( children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }), @@ -20949,13 +21467,13 @@ pub fn build_type_env_unresolved( })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -20967,16 +21485,16 @@ pub fn build_type_env_unresolved( children: Rc::new(vec![present_value_field.clone()]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -20988,16 +21506,16 @@ pub fn build_type_env_unresolved( children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -21009,16 +21527,16 @@ pub fn build_type_env_unresolved( children: Rc::new(vec![present_variant.clone(), absent_variant.clone()]), connective: Connective::Disj, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -21106,16 +21624,16 @@ pub fn build_type_env_unresolved( children: item.children.clone(), connective: item.connective.clone(), params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: item.return_cardinality.clone(), uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -21133,9 +21651,9 @@ pub fn build_type_env_unresolved( ) } } else { - if (((item.inferred.clone() != None) + if (((item.inferred.clone() != std::option::Option::None) && ((item.params.clone().len() as i64) == 0)) - && (item.body.clone() == None)) + && (item.body.clone() == std::option::Option::None)) { { let alias_node = Rc::new(Node { @@ -21149,13 +21667,13 @@ pub fn build_type_env_unresolved( inferred: item.inferred.clone(), return_cardinality: item.return_cardinality.clone(), uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -21175,7 +21693,7 @@ pub fn build_type_env_unresolved( ) } } else { - if ((item.transport.clone() == None) + if ((item.transport.clone() == std::option::Option::None) && ((item.children.clone().len() as i64) > 0)) { { @@ -21206,8 +21724,10 @@ pub fn build_type_env_unresolved( if ((((((item.properties.clone().len() as i64) > 0) && (item.connective.clone() == Connective::NoConnective)) - && (item.transport.clone() == None)) - && (item.inferred.clone() == None)) + && (item.transport.clone() + == std::option::Option::None)) + && (item.inferred.clone() + == std::option::Option::None)) && ((item.params.clone().len() as i64) == 0)) { v1_rt::rc_map_insert( @@ -21417,7 +21937,7 @@ pub fn build_item_info( name: item_name_str.clone(), module_name: module_name.clone(), kind: kind.clone(), - service_names: if (item.body.clone() == None) { + service_names: if (item.body.clone() == std::option::Option::None) { Rc::new(vec![]) } else { crate::v1_compiler_infer_service::collect_typed_service_calls( @@ -21434,7 +21954,7 @@ pub fn build_item_info( name: item_name_str.clone(), module_name: module_name.clone(), kind: kind.clone(), - service_names: if (item.body.clone() == None) { + service_names: if (item.body.clone() == std::option::Option::None) { Rc::new(vec![]) } else { crate::v1_compiler_infer_service::collect_typed_service_calls( @@ -21444,7 +21964,7 @@ pub fn build_item_info( }, resource_names: res_names.clone(), params: item.params.clone(), - is_self_recursive: if (item.body.clone() == None) { + is_self_recursive: if (item.body.clone() == std::option::Option::None) { false } else { crate::v1_std_core::expr_has_self_call( @@ -21453,7 +21973,7 @@ pub fn build_item_info( source_indices.clone(), ) }, - has_non_tail_self_call: if (item.body.clone() == None) { + has_non_tail_self_call: if (item.body.clone() == std::option::Option::None) { false } else { crate::v1_std_core::expr_has_non_tail_self_call( @@ -21488,14 +22008,14 @@ pub fn analyze_item(item: Rc, env: Rc, module_name: String) -> Rc let ritem = resolved.item.clone(); let is_func = ((ritem.params.clone().len() as i64) > 0); let is_zero_arg_func = ((((ritem.params.clone().len() as i64) == 0) - && (ritem.inferred.clone() != None)) - && (ritem.body.clone() != None)); + && (ritem.inferred.clone() != std::option::Option::None)) + && (ritem.body.clone() != std::option::Option::None)); let func_sig = if (is_func.clone() || is_zero_arg_func.clone()) { { - let declared_rt = if (ritem.inferred.clone() != None) { + let declared_rt = if (ritem.inferred.clone() != std::option::Option::None) { Some(crate::v1_compiler_infer_types::resolved_type(ritem.clone())) } else { - None + std::option::Option::None }; Some(Rc::new(DeclaredFuncSig { name: crate::v1_std_core::authored_name_at( @@ -21513,24 +22033,25 @@ pub fn analyze_item(item: Rc, env: Rc, module_name: String) -> Rc })) } } else { - None + std::option::Option::None }; - let svc_entries = - if ((ritem.transport.clone() != None) && ((ritem.children.clone().len() as i64) > 0)) { - Rc::new({ - let mut __result = Vec::new(); - for c in ritem.children.clone().iter().cloned() { - __result.push(crate::v1_compiler_infer_service::service_op_entry( - c.clone(), - env.source_indices.clone(), - )); - } - __result - }) - } else { - Rc::new(vec![]) - }; - let svc_local = if ((ritem.transport.clone() != None) + let svc_entries = if ((ritem.transport.clone() != std::option::Option::None) + && ((ritem.children.clone().len() as i64) > 0)) + { + Rc::new({ + let mut __result = Vec::new(); + for c in ritem.children.clone().iter().cloned() { + __result.push(crate::v1_compiler_infer_service::service_op_entry( + c.clone(), + env.source_indices.clone(), + )); + } + __result + }) + } else { + Rc::new(vec![]) + }; + let svc_local = if ((ritem.transport.clone() != std::option::Option::None) && ((ritem.children.clone().len() as i64) > 0)) { { @@ -21542,7 +22063,7 @@ pub fn analyze_item(item: Rc, env: Rc, module_name: String) -> Rc Some(nominal_type_binding(root.clone())) } } else { - None + std::option::Option::None }; Rc::new(ItemContribution { resolved_item: ritem.clone(), @@ -22456,9 +22977,10 @@ pub fn typecheck_module( let data_locals = ctx.resolved_items.clone().iter().cloned().fold( ctx.locals.clone(), |acc: Rc>>, item: Rc| { - if ((((item.body.clone() != None) && ((item.params.clone().len() as i64) == 0)) - && (item.inferred.clone() == None)) - && (item.type_annotation.clone() != None)) + if ((((item.body.clone() != std::option::Option::None) + && ((item.params.clone().len() as i64) == 0)) + && (item.inferred.clone() == std::option::Option::None)) + && (item.type_annotation.clone() != std::option::Option::None)) { v1_rt::rc_map_insert( acc.clone(), @@ -22514,7 +23036,9 @@ pub fn typecheck_module( let mut __result = Vec::new(); for item in typed_items.iter().cloned() { __result.push( - if (item.is_self_recursive.clone() && (item.body.clone() != None)) { + if (item.is_self_recursive.clone() + && (item.body.clone() != std::option::Option::None)) + { Rc::new(Node { occurrence_identity: item.occurrence_identity.clone(), name: item.name.clone(), @@ -23151,7 +23675,7 @@ pub fn build_emit_graph_info(modules: Rc>>) -> Rc>>(), fn_generic_param_names: Rc::new(vec![]), fn_type_env: crate::v1_compiler_infer_env::empty_type_env(), - fn_return_type: None, + fn_return_type: std::option::Option::None, }) } } @@ -23779,16 +24303,16 @@ pub fn compiler_kernel_type_env( children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }), @@ -23813,16 +24337,16 @@ pub fn compiler_kernel_type_env( children: Rc::new(vec![]), connective: Connective::Conj, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }), @@ -23842,13 +24366,13 @@ pub fn compiler_kernel_type_env( })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -23860,16 +24384,16 @@ pub fn compiler_kernel_type_env( children: Rc::new(vec![present_value_field.clone()]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -23881,16 +24405,16 @@ pub fn compiler_kernel_type_env( children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -23902,16 +24426,16 @@ pub fn compiler_kernel_type_env( children: Rc::new(vec![present_variant.clone(), absent_variant.clone()]), connective: Connective::Disj, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); diff --git a/src/v1/stage0/src/v1_compiler_infer_access.rs b/src/v1/stage0/src/v1_compiler_infer_access.rs index aa0ea7f247a..9345282b51c 100644 --- a/src/v1/stage0/src/v1_compiler_infer_access.rs +++ b/src/v1/stage0/src/v1_compiler_infer_access.rs @@ -86,12 +86,12 @@ pub fn keyed_collection_parts( key_type: crate::v1_compiler_infer_types::resolved_type(key_child.clone()), value_type: crate::v1_compiler_infer_types::resolved_type(value_child.clone()), })), - None => None, + None => std::option::Option::None, }, - None => None, + None => std::option::Option::None, } } else { - None + std::option::Option::None } } diff --git a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs index b0ce1dda23b..17d58a7ae56 100644 --- a/src/v1/stage0/src/v1_compiler_infer_emit_info.rs +++ b/src/v1/stage0/src/v1_compiler_infer_emit_info.rs @@ -115,7 +115,7 @@ pub fn collect_type_node_import_surface_names( stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let peeled = crate::v1_compiler_infer_types::normalize_access_type_node(n.clone()); let name = crate::v1_std_core::authored_name_at(source_indices.clone(), peeled.clone()); - let is_tv = if (peeled.inferred.clone() != None) { + let is_tv = if (peeled.inferred.clone() != std::option::Option::None) { is_type_variable(peeled.inferred.clone().clone().unwrap()) } else { false @@ -215,7 +215,7 @@ pub fn empty_emit_graph_info() -> Rc { clone_impl_required_type_params: v1_rt::rc_empty_map::>>(), fn_generic_param_names: Rc::new(vec![]), fn_type_env: crate::v1_compiler_infer_env::empty_type_env(), - fn_return_type: None, + fn_return_type: std::option::Option::None, }) } @@ -316,7 +316,7 @@ pub fn emit_graph_records_type_decl( ((((item.connective.clone() == Connective::NoConnective) && ((item.children.clone().len() as i64) == 0)) && ((item.params.clone().len() as i64) == 0)) - && (item.transport.clone() == None)) + && (item.transport.clone() == std::option::Option::None)) } } } @@ -331,7 +331,8 @@ pub fn emit_graph_records_fn_decl_note() -> String { } pub fn emit_graph_records_fn_decl(item: Rc) -> bool { - ((item.body.clone() != None) && (item.type_annotation.clone() == None)) + ((item.body.clone() != std::option::Option::None) + && (item.type_annotation.clone() == std::option::Option::None)) } pub fn derive_variant_to_enum( @@ -460,7 +461,8 @@ pub fn field_value_shape_from_type_node(type_node: Rc) -> FieldValueShape } pub fn is_tuple_type(n: Rc) -> bool { - (((n.connective.clone() == Connective::Conj) && (n.ident_span.clone() == None)) + (((n.connective.clone() == Connective::Conj) + && (n.ident_span.clone() == std::option::Option::None)) && ((n.children.clone().len() as i64) == 2)) } @@ -487,7 +489,7 @@ pub fn build_struct_field_summaries( |acc: Rc>>, pair: (i64, Rc)| { let idx = pair.0.clone(); let child = pair.1.clone(); - if (child.inferred.clone() == None) { + if (child.inferred.clone() == std::option::Option::None) { acc.clone() } else { { @@ -533,9 +535,9 @@ pub fn find_first_enum_field_node( source_indices.clone(), ) { Some(field_child) => Some(field_child.clone()), - None => None, + None => std::option::Option::None, }, - None => None, + None => std::option::Option::None, } } @@ -688,7 +690,7 @@ pub fn build_field_type_map( source_indices.clone(), crate::v1_compiler_infer_types::normalize_access_type_node(ft.clone()), ); - let ft_is_type_var = if (ft.inferred.clone() != None) { + let ft_is_type_var = if (ft.inferred.clone() != std::option::Option::None) { is_type_variable(ft.inferred.clone().clone().unwrap()) } else { false @@ -729,9 +731,9 @@ pub fn build_type_summary( { if (((item.connective.clone() == Connective::NoConnective) || (item.connective.clone() == Connective::Arrow)) - || (item.transport.clone() != None)) + || (item.transport.clone() != std::option::Option::None)) { - return None; + return std::option::Option::None; } let gpn = Rc::new({ let mut __result = Vec::new(); @@ -1016,9 +1018,9 @@ pub fn add_emit_item_summary( crate::v1_std_core::authored_name_at(source_indices.clone(), alias_rhs.clone()); let is_type_alias = (((((((decl_name.clone() != "".to_string()) && (item.connective.clone() == Connective::NoConnective)) - && (item.body.clone() == None)) + && (item.body.clone() == std::option::Option::None)) && ((item.params.clone().len() as i64) == 0)) - && (item.transport.clone() == None)) + && (item.transport.clone() == std::option::Option::None)) && ((item.children.clone().len() as i64) == 0)) && (alias_rhs_name.clone() != "Unit".to_string())); let is_structural_alias = if is_type_alias.clone() { diff --git a/src/v1/stage0/src/v1_compiler_infer_env.rs b/src/v1/stage0/src/v1_compiler_infer_env.rs index 5c2b8912579..df984e0f366 100644 --- a/src/v1/stage0/src/v1_compiler_infer_env.rs +++ b/src/v1/stage0/src/v1_compiler_infer_env.rs @@ -80,7 +80,9 @@ pub fn is_unit_variant_node(variant: Rc) -> bool { } pub fn variant_lookup_structural(ty: Rc) -> Rc { - if ((ty.connective.clone() == Connective::NoConnective) && (ty.inferred.clone() != None)) { + if ((ty.connective.clone() == Connective::NoConnective) + && (ty.inferred.clone() != std::option::Option::None)) + { match ty.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => target.clone(), _ => ty, @@ -223,16 +225,16 @@ pub fn effective_visible_binding( ) -> Option> { match v1_rt::map_get(&str_bindings, name.clone()) { Some(b) => Some(b.clone()), - None => parents - .iter() - .cloned() - .fold(None, |acc: _, parent: Rc| { - if (acc.clone() != None) { + None => parents.iter().cloned().fold( + std::option::Option::None, + |acc: _, parent: Rc| { + if (acc.clone() != std::option::Option::None) { acc.clone() } else { v1_rt::map_get(&parent.str_bindings.clone(), name.clone()) } - }), + }, + ), } } @@ -1050,7 +1052,7 @@ pub fn lookup_binding_by_name(env: Rc, name: String) -> Option { if listed_import_required_bare_call_blocked(env.clone(), name.clone()) { - None + std::option::Option::None } else { Some(binding.clone()) } @@ -1090,7 +1092,7 @@ pub fn listed_import_required_bare_call_blocked(env: Rc, name: String) pub fn lookup_binding_after_global_bare(env: Rc, name: String) -> Option> { if global_bare_blocked_by_listed_import_requirement(env.clone(), name.clone()) { - None + std::option::Option::None } else { match global_bare_lookup(env.clone(), name.clone()) { Some(binding) => Some(binding.clone()), @@ -1194,7 +1196,7 @@ pub fn global_bare_nearest_ancestor_candidate( let scan = candidates.iter().cloned().fold( Rc::new(GlobalBareNearestCandidateScan { best_lcp: (0 - 1), - best: None, + best: std::option::Option::None, tie: false, }), |acc: Rc, cand: Rc| { @@ -1518,7 +1520,7 @@ pub fn qualify_borrowed_type_names( let owner_hit = if rewrite.clone() { global_bare_owner_module(env.clone(), owner_module_path.clone(), name.clone()) } else { - None + std::option::Option::None }; match owner_hit.clone() { Some(mp) => { @@ -1731,7 +1733,8 @@ pub fn global_bare_is_ambiguous(env: Rc, name: String) -> bool { } } } else { - (global_bare_nearest_ancestor(env.module_path.clone(), cands.clone()) == None) + (global_bare_nearest_ancestor(env.module_path.clone(), cands.clone()) + == std::option::Option::None) } } Some(GlobalBareLookupState::GlobalBareUniqueBinding { .. }) => false, @@ -2167,13 +2170,13 @@ pub fn env_with_type_variable_bindings(env: Rc, tp_names: Rc r.clone(), - _ => n.clone(), + _ => match lookup_type_for(env.clone(), n.clone()) { + Some(bound) => bound.clone(), + None => n.clone(), + }, }; let decl_name = crate::v1_std_core::qualified_last_segment( crate::v1_std_core::authored_name_at(source_indices.clone(), rt.clone()), ); if (decl_name.clone() == "".to_string()) { - return None; + return std::option::Option::None; } match rt.ident_span.clone() { - None => None, + None => std::option::Option::None, Some(sp) => match v1_rt::map_get( &env.symbol_index.clone().global_bare.clone(), decl_name.clone(), @@ -2263,7 +2269,7 @@ pub fn type_reference_declaration_ref( if binding_declares_span(b.clone(), sp.clone()) { Some(crate::std_decl_ref::decl_ref(mp.clone(), decl_name.clone())) } else { - None + std::option::Option::None } } Some(GlobalBareLookupState::GlobalBareAmbiguousBinding { @@ -2285,9 +2291,9 @@ pub fn type_reference_declaration_ref( c.module_path.clone(), decl_name.clone(), )), - None => None, + None => std::option::Option::None, }, - None => None, + None => std::option::Option::None, }, } } diff --git a/src/v1/stage0/src/v1_compiler_infer_items.rs b/src/v1/stage0/src/v1_compiler_infer_items.rs index 8bfa22acd74..26d487bf979 100644 --- a/src/v1/stage0/src/v1_compiler_infer_items.rs +++ b/src/v1/stage0/src/v1_compiler_infer_items.rs @@ -135,7 +135,7 @@ pub fn inferred_to_outputs( span: Rc, source_indices: Rc>>, ) -> Rc>> { - if (inferred.clone() == None) { + if (inferred.clone() == std::option::Option::None) { Rc::new(vec![]) } else { match (*inferred.clone().unwrap()).clone() { @@ -147,7 +147,7 @@ pub fn inferred_to_outputs( { let is_product = (rt.connective.clone() == Connective::Conj); if is_product.clone() { - if (rt.ident_span.clone() == None) { + if (rt.ident_span.clone() == std::option::Option::None) { Rc::new({ let mut __result = Vec::new(); for child in rt.children.clone().iter().cloned() { @@ -166,7 +166,7 @@ pub fn inferred_to_outputs( ), child_type.clone(), Cardinality::Required, - None, + std::option::Option::None, Rc::new(vec![]), span.clone(), crate::v1_std_core::node_name_span(child.clone()), @@ -181,7 +181,7 @@ pub fn inferred_to_outputs( "value".to_string(), rt.clone(), Cardinality::Required, - None, + std::option::Option::None, Rc::new(vec![]), span.clone(), crate::v1_std_core::no_span(), @@ -193,7 +193,7 @@ pub fn inferred_to_outputs( "value".to_string(), rt.clone(), Cardinality::Required, - None, + std::option::Option::None, Rc::new(vec![]), span.clone(), crate::v1_std_core::no_span(), @@ -211,7 +211,7 @@ pub fn inferred_to_outputs( "value".to_string(), rt.clone(), Cardinality::Required, - None, + std::option::Option::None, Rc::new(vec![]), span.clone(), crate::v1_std_core::no_span(), @@ -226,23 +226,29 @@ pub fn inferred_to_outputs( pub fn item_kind(item: Rc) -> ItemKind { { let kind = if ((item.connective.clone() != Connective::NoConnective) - && (item.transport.clone() == None)) + && (item.transport.clone() == std::option::Option::None)) { ItemKind::TypeItem } else { - if (item.transport.clone() != None) { + if (item.transport.clone() != std::option::Option::None) { ItemKind::ServiceItem } else { - if ((item.body.clone() != None) && ((item.uses.clone().len() as i64) > 0)) { + if ((item.body.clone() != std::option::Option::None) + && ((item.uses.clone().len() as i64) > 0)) + { ItemKind::FuncItem } else { - if ((item.body.clone() != None) && ((item.params.clone().len() as i64) > 0)) { + if ((item.body.clone() != std::option::Option::None) + && ((item.params.clone().len() as i64) > 0)) + { ItemKind::FnItem } else { - if ((item.body.clone() != None) && (item.type_annotation.clone() != None)) { + if ((item.body.clone() != std::option::Option::None) + && (item.type_annotation.clone() != std::option::Option::None)) + { ItemKind::DataItem } else { - if (item.body.clone() != None) { + if (item.body.clone() != std::option::Option::None) { ItemKind::FnItem } else { ItemKind::OtherItem diff --git a/src/v1/stage0/src/v1_compiler_infer_lookup.rs b/src/v1/stage0/src/v1_compiler_infer_lookup.rs index 714d8300bf7..03d12cdb326 100644 --- a/src/v1/stage0/src/v1_compiler_infer_lookup.rs +++ b/src/v1/stage0/src/v1_compiler_infer_lookup.rs @@ -209,7 +209,7 @@ pub fn resolved_declaration_call_target( crate::std_primitive_projection::primitive_identity_runtime_name( row.primitive.clone(), ), - projected_from: None, + projected_from: std::option::Option::None, }) } ProjectionFidelity::ModeledProjection => { @@ -254,7 +254,7 @@ pub fn builtin_call_target_or_undetermined(func_name: String) -> Rc Rc::new(CallTargetIdentity::RuntimePrimitiveCall { primitive_name: func_name.clone(), - projected_from: None, + projected_from: std::option::Option::None, }), None => Rc::new(CallTargetIdentity::CallableTargetUndetermined), } @@ -444,20 +444,20 @@ pub fn func_decl_owner_module(func_env: Rc, name: String) -> Op match v1_rt::map_get(&func_env.local.clone(), name.clone()) { Some(_) => Some(func_env.name.clone()), None => match func_env.parents.clone().iter().cloned().fold( - None, + std::option::Option::None, |found: _, p: Rc| { - if (found.clone() != None) { + if (found.clone() != std::option::Option::None) { found.clone() } else { match v1_rt::map_get(&p.local.clone(), name.clone()) { Some(_) => Some(p.name.clone()), - None => None, + None => std::option::Option::None, } } }, ) { Some(owner) => Some(owner.clone()), - None => None, + None => std::option::Option::None, }, } } @@ -662,8 +662,8 @@ pub fn func_sig_from_global_bare(type_env: Rc, name: String) -> Rc { let node = bd.node.clone(); match ((((node.params.clone().len() as i64) > 0) - || (node.inferred.clone() != None)) - || (node.type_annotation.clone() != None)) + || (node.inferred.clone() != std::option::Option::None)) + || (node.type_annotation.clone() != std::option::Option::None)) { false => Rc::new(FuncSigLookup::FuncSigUnresolved), true => { @@ -774,19 +774,19 @@ pub fn func_sig_from_global_bare(type_env: Rc, name: String) -> Rc, name: String) -> Option> { { if crate::std_algebra::algebra_method_template_name(name.clone()) { - return None; + return std::option::Option::None; } match crate::v1_compiler_infer_env::lookup_binding_by_name(type_env.clone(), name.clone()) { Some(binding) => { if (((binding.resolved.clone().params.clone().len() as i64) > 0) - || (binding.resolved.clone().inferred.clone() != None)) + || (binding.resolved.clone().inferred.clone() != std::option::Option::None)) { Some(binding.resolved.clone()) } else { - None + std::option::Option::None } } - None => None, + None => std::option::Option::None, } } } @@ -812,7 +812,7 @@ pub fn lookup_field_type_node( Some(inner_result) => Some(crate::v1_std_core::with_optional_cardinality( inner_result.clone(), )), - None => None, + None => std::option::Option::None, } } } @@ -864,7 +864,7 @@ pub fn lookup_field_type_node( )) } } - None => None, + None => std::option::Option::None, } } else { lookup_coproduct_common_field_node( @@ -883,7 +883,7 @@ pub fn lookup_field_type_node( source_indices.clone(), ) } - _ => None, + _ => std::option::Option::None, } } } @@ -918,16 +918,16 @@ pub fn lookup_coproduct_common_field_node( field_name.clone(), source_indices.clone(), ), - None => None, + None => std::option::Option::None, } } else { - None + std::option::Option::None }; match first_field.clone() { Some(field_child) => Some(crate::v1_compiler_infer_types::child_type_node( field_child.clone(), )), - None => None, + None => std::option::Option::None, } } } @@ -981,7 +981,7 @@ pub fn resolve_scrutinee_type_node_seen( seen: Rc>, ) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let n_is_type_var = if (n.inferred.clone() != None) { + let n_is_type_var = if (n.inferred.clone() != std::option::Option::None) { is_type_variable(n.inferred.clone().clone().unwrap()) } else { false @@ -992,7 +992,7 @@ pub fn resolve_scrutinee_type_node_seen( let normed = crate::v1_compiler_infer_types::normalize_access_type_node(n.clone()); if (((normed.connective.clone() == Connective::NoConnective) && ((normed.children.clone().len() as i64) > 0)) - && (normed.inferred.clone() != None)) + && (normed.inferred.clone() != std::option::Option::None)) { match normed.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { @@ -1010,7 +1010,7 @@ pub fn resolve_scrutinee_type_node_seen( { let canonical = crate::v1_compiler_infer_env::authored_name(env.clone(), normed.clone()); - if (normed.inferred.clone() != None) { + if (normed.inferred.clone() != std::option::Option::None) { { let next_seen = if (canonical.clone() == "".to_string()) { seen.clone() @@ -1023,7 +1023,7 @@ pub fn resolve_scrutinee_type_node_seen( env.clone(), target.clone(), ) == canonical.clone()) - && (target.inferred.clone() == None)) + && (target.inferred.clone() == std::option::Option::None)) && (target.connective.clone() == Connective::NoConnective)) && ((target.children.clone().len() as i64) == 0)) { @@ -1066,7 +1066,8 @@ pub fn resolve_scrutinee_type_node_seen( env.clone(), resolved.clone(), ) == canonical.clone()) - && (resolved.inferred.clone() == None)) + && (resolved.inferred.clone() + == std::option::Option::None)) && (resolved.connective.clone() == Connective::NoConnective)) && ((resolved.children.clone().len() as i64) == 0)) @@ -1115,10 +1116,10 @@ pub fn map_value_type_in_env(type_node: Rc, env: Rc) -> Option Some(value_type.clone()), - None => None, + None => std::option::Option::None, } } else { - None + std::option::Option::None } } } @@ -1135,10 +1136,10 @@ pub fn map_key_type_in_env(type_node: Rc, env: Rc) -> Option Some(key_type.clone()), - None => None, + None => std::option::Option::None, } } else { - None + std::option::Option::None } } } @@ -1155,10 +1156,10 @@ pub fn set_element_type_in_env(type_node: Rc, env: Rc) -> Option< { match set_type.children.clone().first().cloned() { Some(elem_type) => Some(elem_type.clone()), - None => None, + None => std::option::Option::None, } } else { - None + std::option::Option::None } } } @@ -1186,14 +1187,14 @@ pub fn field_summary_for_type( access_style: inner_summary.access_style.clone(), value_shape: FieldValueShape::OptionalValue, })), - None => None, + None => std::option::Option::None, } } } else { { let no_structure = (resolved.connective.clone() == Connective::NoConnective); if no_structure.clone() { - None + std::option::Option::None } else { { let is_product = (resolved.connective.clone() == Connective::Conj); @@ -1245,7 +1246,7 @@ pub fn product_field_result_type(field: Rc) -> Option> { Some(rt.clone()) } } - _ => None, + _ => std::option::Option::None, } } @@ -1265,10 +1266,10 @@ pub fn map_lookup_result_type( Some(crate::v1_std_core::with_optional_cardinality(raw.clone())) } } - None => None, + None => std::option::Option::None, } } else { - None + std::option::Option::None } } @@ -1293,27 +1294,27 @@ pub fn lookup_field_in_product( Some(field) => match if (method_name.clone() == "lookup".to_string()) { map_lookup_result_type(product.clone(), field.clone(), source_indices.clone()) } else { - None + std::option::Option::None } { Some(lookup_rt) => Some(Rc::new(MethodFieldResult { field_node: field.clone(), result_type: lookup_rt.clone(), - size_effect: None, - cost_shape: None, - algebra_template: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + algebra_template: std::option::Option::None, })), None => match product_field_result_type(field.clone()) { Some(rt) => Some(Rc::new(MethodFieldResult { field_node: field.clone(), result_type: rt.clone(), - size_effect: None, - cost_shape: None, - algebra_template: None, + size_effect: std::option::Option::None, + cost_shape: std::option::Option::None, + algebra_template: std::option::Option::None, })), - None => None, + None => std::option::Option::None, }, }, - None => None, + None => std::option::Option::None, } } } @@ -1382,7 +1383,7 @@ pub fn lookup_structural_method( .first() .cloned() } - None => None, + None => std::option::Option::None, }; let resolution = match template_match.clone() { Some(t) => Some(Rc::new(MethodFieldResult { @@ -1400,14 +1401,14 @@ pub fn lookup_structural_method( }) } None => Rc::new(StructuralMethodLookup { - resolution: None, + resolution: std::option::Option::None, kernel_diagnostics: enriched.diagnostics.clone(), }), } } } else { Rc::new(StructuralMethodLookup { - resolution: None, + resolution: std::option::Option::None, kernel_diagnostics: enriched.diagnostics.clone(), }) } @@ -1563,8 +1564,8 @@ pub fn resolve_known_method_node( diagnostics: tier0.kernel_diagnostics.clone(), }), None => Rc::new(KnownMethodResolution { - semantics: None, - result_type: None, + semantics: std::option::Option::None, + result_type: std::option::Option::None, diagnostics: tier0.kernel_diagnostics.clone(), }), }, diff --git a/src/v1/stage0/src/v1_compiler_infer_method.rs b/src/v1/stage0/src/v1_compiler_infer_method.rs index 7b08875726b..c38badb62d9 100644 --- a/src/v1/stage0/src/v1_compiler_infer_method.rs +++ b/src/v1/stage0/src/v1_compiler_infer_method.rs @@ -48,20 +48,20 @@ pub fn type_variable_node(id: String) -> Rc { occurrence_identity: Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), name: "".to_string(), span: crate::v1_std_core::no_span(), - ident_span: None, + ident_span: std::option::Option::None, children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), inferred: Some(Rc::new(InferredNode::TypeVariable { id: id.clone() })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }) diff --git a/src/v1/stage0/src/v1_compiler_infer_patterns.rs b/src/v1/stage0/src/v1_compiler_infer_patterns.rs index 8c34867e9c9..797904160d9 100644 --- a/src/v1/stage0/src/v1_compiler_infer_patterns.rs +++ b/src/v1/stage0/src/v1_compiler_infer_patterns.rs @@ -93,7 +93,7 @@ pub fn expand_scrut_from_decl( ) -> Rc { { let decl_is_disj = (decl.connective.clone() == Connective::Disj); - let has_inferred_alias = (((decl.inferred.clone() != None) + let has_inferred_alias = (((decl.inferred.clone() != std::option::Option::None) && (decl.connective.clone() == Connective::NoConnective)) && ((decl.children.clone().len() as i64) == 0)); if decl_is_disj.clone() { @@ -181,7 +181,8 @@ pub fn expand_scrut_from_type_name(scrut_node: Rc, env: Rc) -> Rc } else { { let def_is_disj = (decl.connective.clone() == Connective::Disj); - let has_inferred_body = ((decl.inferred.clone() != None) + let has_inferred_body = ((decl.inferred.clone() + != std::option::Option::None) && (decl.connective.clone() == Connective::NoConnective)); if def_is_disj.clone() { decl.clone() @@ -311,13 +312,13 @@ pub fn synthesize_optional_present_variant(scrut: Rc) -> Rc { })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -329,16 +330,16 @@ pub fn synthesize_optional_present_variant(scrut: Rc) -> Rc { children: Rc::new(vec![value_field.clone()]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -365,13 +366,13 @@ pub fn synthesize_witness_holds_variant(scrut: Rc) -> Rc { })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -383,16 +384,16 @@ pub fn synthesize_witness_holds_variant(scrut: Rc) -> Rc { children: Rc::new(vec![value_field.clone()]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }) @@ -409,16 +410,16 @@ pub fn synthesize_witness_violates_variant(scrut: Rc) -> Rc { children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -435,13 +436,13 @@ pub fn synthesize_witness_violates_variant(scrut: Rc) -> Rc { })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -453,16 +454,16 @@ pub fn synthesize_witness_violates_variant(scrut: Rc) -> Rc { children: Rc::new(vec![diagnostic_field.clone()]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }) @@ -488,7 +489,7 @@ pub fn pattern_subject_preserving_outer_optional( pub fn pattern_subject_from_node(n: Rc) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let is_error = if (n.inferred.clone() != None) { + let is_error = if (n.inferred.clone() != std::option::Option::None) { crate::v1_std_core::is_compiler_error(n.inferred.clone().clone().unwrap()) } else { false @@ -498,7 +499,7 @@ pub fn pattern_subject_from_node(n: Rc) -> Rc { } else { if (((n.connective.clone() == Connective::NoConnective) && ((n.children.clone().len() as i64) > 0)) - && (n.inferred.clone() != None)) + && (n.inferred.clone() != std::option::Option::None)) { match n.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { diff --git a/src/v1/stage0/src/v1_compiler_infer_resolve.rs b/src/v1/stage0/src/v1_compiler_infer_resolve.rs index d684198f677..aa3ad0fbf54 100644 --- a/src/v1/stage0/src/v1_compiler_infer_resolve.rs +++ b/src/v1/stage0/src/v1_compiler_infer_resolve.rs @@ -88,13 +88,13 @@ pub fn lookup_unit_variant_phantom_type( .cloned() { Some(single) => Some(single.variant.clone()), - None => None, + None => std::option::Option::None, } } else { - None + std::option::Option::None } } - None => None, + None => std::option::Option::None, } } @@ -192,7 +192,7 @@ pub fn peel_nominal_alias_identity(n: Rc, env: Rc, module_name: S Some(resolved) => { let structural = if (((resolved.connective.clone() == Connective::NoConnective) && ((resolved.children.clone().len() as i64) == 0)) - && (resolved.inferred.clone() != None)) + && (resolved.inferred.clone() != std::option::Option::None)) { match resolved.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => resolve_node_bounded( @@ -245,7 +245,7 @@ pub fn peel_nominal_alias_identity(n: Rc, env: Rc, module_name: S } else { if (((resolved.connective.clone() == Connective::NoConnective) && ((resolved.children.clone().len() as i64) == 0)) - && (resolved.inferred.clone() != None)) + && (resolved.inferred.clone() != std::option::Option::None)) { match resolved.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: target, .. }) => { @@ -438,7 +438,7 @@ pub fn is_user_generic_use_site(n: Rc, env: Rc) -> bool { if crate::std_types::is_container_type(n.name.clone()) { false } else { - if (decl.inferred.clone() != None) { + if (decl.inferred.clone() != std::option::Option::None) { true } else { true @@ -480,18 +480,18 @@ pub fn substitute_type_slots_scoped( Some(InferredNode::TypeVariable { id: tv_id, .. }) => { v1_rt::map_get(&slot_bindings, tv_id.clone()) } - _ => None, + _ => std::option::Option::None, } } else { - None + std::option::Option::None }; - if (tv_slot.clone() != None) { + if (tv_slot.clone() != std::option::Option::None) { return tv_slot.clone().unwrap(); } let is_slot = (((((n.children.clone().len() as i64) == 0) && (n.connective.clone() == Connective::NoConnective)) - && (n.body.clone() == None)) - && (n.inferred.clone() == None)); + && (n.body.clone() == std::option::Option::None)) + && (n.inferred.clone() == std::option::Option::None)); if is_slot.clone() { match v1_rt::map_get( &slot_bindings, @@ -619,7 +619,7 @@ pub fn classify_alias(target: Rc) -> AliasKind { AliasKind::AliasParameterized } else { if ((((target.children.clone().len() as i64) == 0) && nc.clone()) - && (target.ident_span.clone() != None)) + && (target.ident_span.clone() != std::option::Option::None)) { AliasKind::AliasLeaf } else { @@ -659,9 +659,9 @@ pub fn resolve_alias_target( pub fn is_parametric_type_alias_decl(item: Rc) -> bool { ((((((item.params.clone().len() as i64) > 0) && (item.connective.clone() == Connective::NoConnective)) - && (item.body.clone() == None)) - && (item.transport.clone() == None)) - && (item.inferred.clone() != None)) + && (item.body.clone() == std::option::Option::None)) + && (item.transport.clone() == std::option::Option::None)) + && (item.inferred.clone() != std::option::Option::None)) } pub fn resolve_nominal_alias_rhs( @@ -719,7 +719,7 @@ pub fn resolve_nominal_alias_rhs( type_annotation: n.type_annotation.clone(), is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), }), diagnostics: v1_rt::concat(arg_diags.clone(), validation.diagnostics.clone()), @@ -897,7 +897,7 @@ pub fn resolve_node_bounded( { let is_product = (n.connective.clone() == Connective::Conj); if is_product.clone() { - if (n.type_annotation.clone() != None) { + if (n.type_annotation.clone() != std::option::Option::None) { match n.children.clone().first().cloned() { Some(base) => { let base_result = resolve_node_bounded( @@ -927,7 +927,7 @@ pub fn resolve_node_bounded( type_annotation: n.type_annotation.clone(), is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }), @@ -944,65 +944,45 @@ pub fn resolve_node_bounded( let child_results = Rc::new({ let mut __result = Vec::new(); for child in n.children.clone().iter().cloned() { - __result.push(if (child.inferred.clone() == None) { - Rc::new(NodeResolveResult { - resolved: child.clone(), - diagnostics: Rc::new(vec![]), - }) - } else { - { - let child_rt = - crate::v1_compiler_infer_types::resolved_type( - child.clone(), - ); - let rt_result = resolve_node_bounded( - child_rt.clone(), - env.clone(), - module_name.clone(), - (depth.clone() + 1), - masked.clone(), - ); - let rt_resolved = rt_result.resolved.clone(); - let rt_diags = rt_result.diagnostics.clone(); - Rc::new(NodeResolveResult { - resolved: Rc::new(Node { - occurrence_identity: child - .occurrence_identity - .clone(), - name: child.name.clone(), - span: child.span.clone(), - ident_span: child.ident_span.clone(), - children: child.children.clone(), - connective: child.connective.clone(), - params: child.params.clone(), - inferred: Some(Rc::new( - InferredNode::Resolved { - node: rt_resolved.clone(), - }, - )), - return_cardinality: child - .return_cardinality - .clone(), - uses: child.uses.clone(), - body: child.body.clone(), - transport: child.transport.clone(), - properties: v1_rt::concat( - child.properties.clone(), - rt_resolved.properties.clone(), - ), - type_annotation: child - .type_annotation - .clone(), - is_self_recursive: false, - has_non_tail_self_call: false, - match_pattern: None, - expr_data: Rc::new(ExprData::NoExprData), - ident: None, - }), - diagnostics: rt_diags.clone(), - }) - } - }); + __result.push(if (child.inferred.clone() == std::option::Option::None) { + Rc::new(NodeResolveResult { + resolved: child.clone(), + diagnostics: Rc::new(vec![]), +}) + } else { + { + let child_rt = crate::v1_compiler_infer_types::resolved_type(child.clone()); +let rt_result = resolve_node_bounded(child_rt.clone(), env.clone(), module_name.clone(), (depth.clone() + 1), masked.clone()); +let rt_resolved = rt_result.resolved.clone(); +let rt_diags = rt_result.diagnostics.clone(); +Rc::new(NodeResolveResult { + resolved: Rc::new(Node { + occurrence_identity: child.occurrence_identity.clone(), + name: child.name.clone(), + span: child.span.clone(), + ident_span: child.ident_span.clone(), + children: child.children.clone(), + connective: child.connective.clone(), + params: child.params.clone(), + inferred: Some(Rc::new(InferredNode::Resolved { + node: rt_resolved.clone(), +})), + return_cardinality: child.return_cardinality.clone(), + uses: child.uses.clone(), + body: child.body.clone(), + transport: child.transport.clone(), + properties: v1_rt::concat(child.properties.clone(), rt_resolved.properties.clone()), + type_annotation: child.type_annotation.clone(), + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: std::option::Option::None, + expr_data: Rc::new(ExprData::NoExprData), + ident: None, +}), + diagnostics: rt_diags.clone(), +}) +} + }); } __result }); @@ -1038,7 +1018,7 @@ pub fn resolve_node_bounded( type_annotation: n.type_annotation.clone(), is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }), @@ -1076,7 +1056,7 @@ pub fn resolve_node_bounded( let mut __result = Vec::new(); for variant_child in n.children.clone().iter().cloned() { __result.push({ - let field_results = Rc::new({ let mut __result = Vec::new(); for field_child in variant_child.children.clone().iter().cloned() { __result.push(if (field_child.inferred.clone() == None) { + let field_results = Rc::new({ let mut __result = Vec::new(); for field_child in variant_child.children.clone().iter().cloned() { __result.push(if (field_child.inferred.clone() == std::option::Option::None) { Rc::new(NodeResolveResult { resolved: field_child.clone(), diagnostics: Rc::new(vec![]), @@ -1115,7 +1095,7 @@ Rc::new(NodeResolveResult { type_annotation: field_child.type_annotation.clone(), is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }), @@ -1143,7 +1123,7 @@ Rc::new(NodeResolveResult { type_annotation: variant_child.type_annotation.clone(), is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }), @@ -1186,7 +1166,7 @@ Rc::new(NodeResolveResult { type_annotation: n.type_annotation.clone(), is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }), @@ -1307,7 +1287,8 @@ Rc::new(NodeResolveResult { } }, ); - let is_parameterized_alias = (((decl.inferred.clone() != None) + let is_parameterized_alias = (((decl.inferred.clone() + != std::option::Option::None) && ((decl.children.clone().len() as i64) == 0)) && (decl.connective.clone() == Connective::NoConnective)); if is_parameterized_alias.clone() { @@ -1515,7 +1496,9 @@ Rc::new(NodeResolveResult { ); let val_resolved = val_result.resolved.clone(); let val_diags = val_result.diagnostics.clone(); - let key_param_name = if (key_child_node.inferred.clone() != None) { + let key_param_name = if (key_child_node.inferred.clone() + != std::option::Option::None) + { crate::v1_compiler_infer_env::authored_name( env.clone(), key_child_node.clone(), @@ -1532,7 +1515,9 @@ Rc::new(NodeResolveResult { ), } }; - let val_param_name = if (val_child_node.inferred.clone() != None) { + let val_param_name = if (val_child_node.inferred.clone() + != std::option::Option::None) + { crate::v1_compiler_infer_env::authored_name( env.clone(), val_child_node.clone(), @@ -1562,13 +1547,13 @@ Rc::new(NodeResolveResult { })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -1585,13 +1570,13 @@ Rc::new(NodeResolveResult { })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -1616,7 +1601,7 @@ Rc::new(NodeResolveResult { type_annotation: n.type_annotation.clone(), is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }), @@ -1648,14 +1633,15 @@ Rc::new(NodeResolveResult { ); let el_resolved = el_result.resolved.clone(); let el_diags = el_result.diagnostics.clone(); - let el_param_name = - if (child_node.inferred.clone() != None) { - crate::v1_compiler_infer_env::authored_name( - env.clone(), - child_node.clone(), - ) - } else { - match crate::std_types::container_param_name( + let el_param_name = if (child_node.inferred.clone() + != std::option::Option::None) + { + crate::v1_compiler_infer_env::authored_name( + env.clone(), + child_node.clone(), + ) + } else { + match crate::std_types::container_param_name( type_name.clone(), 0, ) { @@ -1667,7 +1653,7 @@ Rc::new(NodeResolveResult { ) } } - }; + }; let resolved_child = Rc::new(Node { occurrence_identity: child_node .occurrence_identity @@ -1683,13 +1669,13 @@ Rc::new(NodeResolveResult { })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -1715,7 +1701,7 @@ Rc::new(NodeResolveResult { type_annotation: n.type_annotation.clone(), is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }), @@ -1780,7 +1766,8 @@ Rc::new(NodeResolveResult { && ((resolved.children.clone().len() as i64) == 0)) - && (resolved.inferred.clone() != None)) + && (resolved.inferred.clone() + != std::option::Option::None)) { match resolved .inferred @@ -1848,7 +1835,8 @@ Rc::new(NodeResolveResult { } } None => { - let n_is_error = if (n.inferred.clone() != None) + let n_is_error = if (n.inferred.clone() + != std::option::Option::None) { crate::v1_std_core::is_compiler_error( n.inferred.clone().clone().unwrap(), @@ -1856,14 +1844,15 @@ Rc::new(NodeResolveResult { } else { false }; - let n_is_type_var = - if (n.inferred.clone() != None) { - is_type_variable( - n.inferred.clone().clone().unwrap(), - ) - } else { - false - }; + let n_is_type_var = if (n.inferred.clone() + != std::option::Option::None) + { + is_type_variable( + n.inferred.clone().clone().unwrap(), + ) + } else { + false + }; if (((is_width_nat_type_literal(n.clone()) || crate::std_types::is_kernel_type(crate::v1_compiler_infer_env::authored_name(env.clone(), n.clone()))) || n_is_type_var.clone()) || n_is_error.clone()) { Rc::new(NodeResolveResult { resolved: n.clone(), @@ -1934,7 +1923,7 @@ pub fn resolve_optional_node( env: Rc, module_name: String, ) -> Rc { - if (n.clone() == None) { + if (n.clone() == std::option::Option::None) { Rc::new(NodeResolveResult { resolved: unit_type(), diagnostics: Rc::new(vec![]), @@ -1975,13 +1964,13 @@ pub fn resolve_optional_node( inferred: Some(Rc::new(InferredNode::TypeVariable { id: tv.clone() })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }), @@ -2014,7 +2003,7 @@ pub fn resolve_field( env.clone(), module_name.clone(), )), - None => None, + None => std::option::Option::None, }; let default_diags = match default_resolved.clone() { Some(result) => result.diagnostics.clone(), @@ -2028,7 +2017,7 @@ pub fn resolve_field( crate::v1_std_core::field_node_cardinality(field.clone()), match default_resolved.clone() { Some(result) => Some(result.expr.clone()), - None => None, + None => std::option::Option::None, }, Rc::new({ let mut __result = Vec::new(); @@ -2105,7 +2094,7 @@ pub fn resolve_param( env.clone(), module_name.clone(), )), - None => None, + None => std::option::Option::None, }; let default_diags = match default_resolved.clone() { Some(result) => result.diagnostics.clone(), @@ -2113,7 +2102,7 @@ pub fn resolve_param( }; let default_expr = match default_resolved.clone() { Some(result) => Some(result.expr.clone()), - None => None, + None => std::option::Option::None, }; Rc::new(ParamResolveResult { param: crate::v1_std_core::make_resolved_param_node( @@ -2224,7 +2213,7 @@ pub fn resolve_match_arm( env.clone(), module_name.clone(), )), - None => None, + None => std::option::Option::None, }; let guard_diags = match guard_result.clone() { Some(result) => result.diagnostics.clone(), @@ -2243,7 +2232,7 @@ pub fn resolve_match_arm( crate::v1_std_core::arm_pattern(arm.clone()), match guard_result.clone() { Some(result) => Some(result.expr.clone()), - None => None, + None => std::option::Option::None, }, body_expr.clone(), arm.span.clone(), @@ -2460,8 +2449,8 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: crate::v1_std_core::make_arg_node( arg_node.occurrence_identity.clone(), - if (arg_node.ident_span.clone() == None) { - None + if (arg_node.ident_span.clone() == std::option::Option::None) { + std::option::Option::None } else { Some(crate::v1_compiler_infer_env::authored_name( env.clone(), @@ -2559,8 +2548,10 @@ pub fn resolve_expr_types( Rc::new(ExprResolveResult { expr: crate::v1_std_core::make_arg_node( child.occurrence_identity.clone(), - if (child.ident_span.clone() == None) { - None + if (child.ident_span.clone() + == std::option::Option::None) + { + std::option::Option::None } else { Some(crate::v1_std_core::authored_name_at( env.source_indices.clone(), @@ -2713,7 +2704,7 @@ pub fn resolve_expr_types( Some(p) => p.clone(), None => Rc::new(MatchPattern::Wildcard), }, - None, + std::option::Option::None, body_r.expr.clone(), child.span.clone(), ), @@ -2774,7 +2765,7 @@ pub fn resolve_expr_types( env.clone(), module_name.clone(), )), - None => None, + None => std::option::Option::None, }; let resolved_children = match er.clone() { Some(r) => Rc::new(vec![cr.expr.clone(), tr.expr.clone(), r.expr.clone()]), @@ -2812,13 +2803,14 @@ pub fn resolve_expr_types( env.clone(), module_name.clone(), )), - None => None, + None => std::option::Option::None, }; let resolved_children = match br.clone() { Some(r) => Rc::new(vec![vr.expr.clone(), r.expr.clone()]), None => Rc::new(vec![vr.expr.clone()]), }; - let anno_resolved = if (texpr.type_annotation.clone() == None) { + let anno_resolved = if (texpr.type_annotation.clone() == std::option::Option::None) + { Rc::new(NodeResolveResult { resolved: unit_type(), diagnostics: Rc::new(vec![]), @@ -2839,8 +2831,9 @@ pub fn resolve_expr_types( }) } }; - let resolved_anno = if (texpr.type_annotation.clone() == None) { - None + let resolved_anno = if (texpr.type_annotation.clone() == std::option::Option::None) + { + std::option::Option::None } else { if crate::v1_compiler_infer_types::is_type_expr_annotation( texpr.type_annotation.clone().clone().unwrap(), @@ -2870,13 +2863,13 @@ pub fn resolve_expr_types( inferred: texpr.inferred.clone(), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), type_annotation: resolved_anno.clone(), is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::ExprLet), ident: None, }); @@ -3420,7 +3413,7 @@ pub fn resolve_item_types( ) -> Rc { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { let tp_names = if ((item.connective.clone() != Connective::NoConnective) - && (item.transport.clone() == None)) + && (item.transport.clone() == std::option::Option::None)) { Rc::new({ let mut __result = Vec::new(); @@ -3484,8 +3477,8 @@ pub fn resolve_item_types( }; let ret_resolved = ret_result.resolved.clone(); let ret_diags = ret_result.diagnostics.clone(); - let resolved_ret = if (item.inferred.clone() == None) { - None + let resolved_ret = if (item.inferred.clone() == std::option::Option::None) { + std::option::Option::None } else { Some(Rc::new(InferredNode::Resolved { node: ret_resolved.clone(), @@ -3516,7 +3509,7 @@ pub fn resolve_item_types( } __result }); - let body_resolved = if (item.body.clone() == None) { + let body_resolved = if (item.body.clone() == std::option::Option::None) { Rc::new(ExprResolveResult { expr: item.clone(), diagnostics: Rc::new(vec![]), @@ -3528,17 +3521,17 @@ pub fn resolve_item_types( module_name.clone(), ) }; - let resolved_body = if (item.body.clone() == None) { - None + let resolved_body = if (item.body.clone() == std::option::Option::None) { + std::option::Option::None } else { Some(body_resolved.expr.clone()) }; - let body_diags = if (item.body.clone() == None) { + let body_diags = if (item.body.clone() == std::option::Option::None) { Rc::new(vec![]) } else { body_resolved.diagnostics.clone() }; - let anno_resolved = if (item.type_annotation.clone() == None) { + let anno_resolved = if (item.type_annotation.clone() == std::option::Option::None) { Rc::new(NodeResolveResult { resolved: unit_type(), diagnostics: Rc::new(vec![]), @@ -3550,13 +3543,13 @@ pub fn resolve_item_types( module_name.clone(), ) }; - let resolved_anno = if (item.type_annotation.clone() == None) { - None + let resolved_anno = if (item.type_annotation.clone() == std::option::Option::None) { + std::option::Option::None } else { Some(anno_resolved.resolved.clone()) }; let anno_diags = anno_resolved.diagnostics.clone(); - let transport_resolved = if (item.transport.clone() == None) { + let transport_resolved = if (item.transport.clone() == std::option::Option::None) { Rc::new(TransportResolveResult { transport: crate::v1_std_core::local_transport_node( Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), @@ -3571,8 +3564,8 @@ pub fn resolve_item_types( module_name.clone(), ) }; - let resolved_transport = if (item.transport.clone() == None) { - None + let resolved_transport = if (item.transport.clone() == std::option::Option::None) { + std::option::Option::None } else { Some(transport_resolved.transport.clone()) }; @@ -3603,7 +3596,7 @@ pub fn resolve_item_types( __result }); let child_results = if ((item.connective.clone() == Connective::Conj) - && (item.transport.clone() == None)) + && (item.transport.clone() == std::option::Option::None)) { Rc::new({ let mut __result = Vec::new(); @@ -3641,7 +3634,7 @@ pub fn resolve_item_types( type_annotation: child.type_annotation.clone(), is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }), @@ -3652,7 +3645,9 @@ pub fn resolve_item_types( __result }) } else { - if ((item.connective.clone() == Connective::Disj) && (item.transport.clone() == None)) { + if ((item.connective.clone() == Connective::Disj) + && (item.transport.clone() == std::option::Option::None)) + { Rc::new({ let mut __result = Vec::new(); for variant in item.children.clone().iter().cloned() { @@ -3701,7 +3696,7 @@ pub fn resolve_item_types( type_annotation: field.type_annotation.clone(), is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }), @@ -3743,7 +3738,7 @@ pub fn resolve_item_types( type_annotation: variant.type_annotation.clone(), is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }), @@ -3799,7 +3794,7 @@ pub fn resolve_item_types( type_annotation: resolved_anno.clone(), is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }), diff --git a/src/v1/stage0/src/v1_compiler_infer_service.rs b/src/v1/stage0/src/v1_compiler_infer_service.rs index 2c36f23c889..fd3f7579098 100644 --- a/src/v1/stage0/src/v1_compiler_infer_service.rs +++ b/src/v1/stage0/src/v1_compiler_infer_service.rs @@ -91,10 +91,10 @@ pub fn extract_typed_service_name( f.clone(), )) } - _ => None, + _ => std::option::Option::None, } } - _ => None, + _ => std::option::Option::None, } } @@ -233,7 +233,7 @@ pub fn item_callees_for(m: Rc, item: Rc) -> Rc { m.type_env.clone().source_indices.clone(), item.clone(), ); - let has_no_body = (item.body.clone() == None); + let has_no_body = (item.body.clone() == std::option::Option::None); if has_no_body.clone() { Rc::new(ItemCallees { item_name: item_name.clone(), @@ -386,11 +386,11 @@ pub fn check_service_field_access_node( Some(_) => Some(crate::v1_compiler_infer_types::nominal_type_ref( path.clone(), )), - None => None, + None => std::option::Option::None, } } } else { - None + std::option::Option::None } } @@ -432,7 +432,7 @@ pub fn check_service_method_call_node( ), name: "".to_string(), span: crate::v1_std_core::no_span(), - ident_span: None, + ident_span: std::option::Option::None, children: Rc::new({ let mut __result = Vec::new(); for f in op.outputs.clone().iter().cloned() { @@ -453,13 +453,13 @@ pub fn check_service_method_call_node( })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, })); @@ -468,16 +468,16 @@ pub fn check_service_method_call_node( }), connective: Connective::Conj, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }), @@ -485,13 +485,13 @@ pub fn check_service_method_call_node( })) } } - None => None, + None => std::option::Option::None, } } - None => None, + None => std::option::Option::None, } } else { - None + std::option::Option::None } } diff --git a/src/v1/stage0/src/v1_compiler_infer_sigs.rs b/src/v1/stage0/src/v1_compiler_infer_sigs.rs index 3a6aca9869c..537f74abe18 100644 --- a/src/v1/stage0/src/v1_compiler_infer_sigs.rs +++ b/src/v1/stage0/src/v1_compiler_infer_sigs.rs @@ -311,22 +311,22 @@ pub fn lookup_resolved_sig_with_telemetry( { let scan = env.parents.clone().iter().cloned().fold( Rc::new(ParentSigScan { - sig: None, + sig: std::option::Option::None, match_count: 0, - first_parent: None, + first_parent: std::option::Option::None, }), |acc: Rc, p: Rc| match v1_rt::map_get( &p.local.clone(), name.clone(), ) { Some(sig) => Rc::new(ParentSigScan { - sig: if (acc.sig.clone() != None) { + sig: if (acc.sig.clone() != std::option::Option::None) { acc.sig.clone() } else { Some(sig.clone()) }, match_count: (acc.match_count.clone() + 1), - first_parent: if (acc.first_parent.clone() != None) { + first_parent: if (acc.first_parent.clone() != std::option::Option::None) { acc.first_parent.clone() } else { Some(p.name.clone()) @@ -335,7 +335,7 @@ pub fn lookup_resolved_sig_with_telemetry( None => acc.clone(), }, ); - if ((scan.match_count.clone() >= 2) && (scan.sig.clone() != None)) { + if ((scan.match_count.clone() >= 2) && (scan.sig.clone() != std::option::Option::None)) { match scan.first_parent.clone() { Some(chosen_parent) => v1_rt::resolution_silent_pick_record_fn_parent_first_hit( env.name.clone(), @@ -352,9 +352,9 @@ pub fn lookup_resolved_sig_with_telemetry( sig: sig.clone(), owner_module_path: owner.clone(), })), - None => None, + None => std::option::Option::None, }, - None => None, + None => std::option::Option::None, } } } @@ -386,7 +386,7 @@ pub fn lookup_resolved_sig(env: Rc, name: String) -> Rc None, + None => std::option::Option::None, }, } }, @@ -421,7 +421,9 @@ pub fn collect_func_call_edges( let mut __result = Vec::new(); for item in items.iter().cloned() { __result.extend( - (*if (((item.params.clone().len() as i64) > 0) && (item.body.clone() != None)) { + (*if (((item.params.clone().len() as i64) > 0) + && (item.body.clone() != std::option::Option::None)) + { collect_calls_in_expr( crate::v1_std_core::authored_name_at(source_indices.clone(), item.clone()), item.body.clone().clone().unwrap(), @@ -566,7 +568,7 @@ pub fn merge_remaining_declared( .fold( resolved.clone(), |acc: Rc>>, dsig: Rc| { - if (dsig.inferred.clone() != None) { + if (dsig.inferred.clone() != std::option::Option::None) { v1_rt::rc_map_insert( acc.clone(), dsig.name.clone(), @@ -600,7 +602,7 @@ pub fn topo_resolve_loop( resolved.clone(), |acc: Rc>>, dsig: Rc| { - if (dsig.inferred.clone() != None) { + if (dsig.inferred.clone() != std::option::Option::None) { v1_rt::rc_map_insert( acc.clone(), dsig.name.clone(), @@ -660,7 +662,8 @@ pub fn topo_resolve_loop( { let mut __all = true; for c in local_callees.iter().cloned() { - if !(v1_rt::map_get(&resolved, c.clone()) != None) { + if !(v1_rt::map_get(&resolved, c.clone()) != std::option::Option::None) + { __all = false; break; } @@ -685,7 +688,7 @@ pub fn topo_resolve_loop( fn_name.clone(), ) { Some(dsig) => { - if (dsig.inferred.clone() != None) { + if (dsig.inferred.clone() != std::option::Option::None) { Rc::new(SigsAccum { signatures: v1_rt::rc_map_insert( acc.signatures.clone(), @@ -721,7 +724,7 @@ pub fn topo_resolve_loop( cycle_accum.signatures.clone(), |acc: Rc>>, dsig: Rc| { - if (dsig.inferred.clone() != None) { + if (dsig.inferred.clone() != std::option::Option::None) { v1_rt::rc_map_insert( acc.clone(), dsig.name.clone(), @@ -755,7 +758,7 @@ pub fn topo_resolve_loop( fn_name.clone(), ) { Some(dsig) => { - if (dsig.inferred.clone() != None) { + if (dsig.inferred.clone() != std::option::Option::None) { Rc::new(SigsAccum { signatures: v1_rt::rc_map_insert( acc.signatures.clone(), @@ -830,7 +833,9 @@ pub fn resolve_func_sigs( for item in Rc::new({ let mut __result = Vec::new(); for item in items.iter().cloned() { - if (((item.params.clone().len() as i64) > 0) && (item.body.clone() != None)) { + if (((item.params.clone().len() as i64) > 0) + && (item.body.clone() != std::option::Option::None)) + { __result.push(item); } } diff --git a/src/v1/stage0/src/v1_compiler_infer_types.rs b/src/v1/stage0/src/v1_compiler_infer_types.rs index b805935a2f9..599c0927314 100644 --- a/src/v1/stage0/src/v1_compiler_infer_types.rs +++ b/src/v1/stage0/src/v1_compiler_infer_types.rs @@ -73,20 +73,20 @@ pub fn type_variable_node(id: String) -> Rc { occurrence_identity: Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), name: "".to_string(), span: crate::v1_std_core::no_span(), - ident_span: None, + ident_span: std::option::Option::None, children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), inferred: Some(Rc::new(InferredNode::TypeVariable { id: id.clone() })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }) @@ -100,7 +100,7 @@ pub fn resolved_type(n: Rc) -> Rc { } pub fn child_type_node(ch: Rc) -> Rc { - if (ch.inferred.clone() != None) { + if (ch.inferred.clone() != std::option::Option::None) { resolved_type(ch.clone()) } else { ch.clone() @@ -181,18 +181,20 @@ pub fn container_alias_canonical_spelling(algebra: String) -> Option { Rc::new(v1_rt::sorted_map_keys(&container_template_alias_rows())) .iter() .cloned() - .fold(None, |acc: _, k: String| match acc.clone() { - Some(_) => acc.clone(), - None => match v1_rt::map_get(&container_template_alias_rows(), k.clone()) { - Some(v) => { - if (v.clone() == algebra.clone()) { - Some(k.clone()) - } else { - None + .fold(std::option::Option::None, |acc: _, k: String| { + match acc.clone() { + Some(_) => acc.clone(), + None => match v1_rt::map_get(&container_template_alias_rows(), k.clone()) { + Some(v) => { + if (v.clone() == algebra.clone()) { + Some(k.clone()) + } else { + std::option::Option::None + } } - } - None => None, - }, + None => std::option::Option::None, + }, + } }) } @@ -432,13 +434,13 @@ pub fn bare_map_node() -> Option> { })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }), @@ -455,35 +457,35 @@ pub fn bare_map_node() -> Option> { })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }), ]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, })), - None => None, + None => std::option::Option::None, }, - None => None, + None => std::option::Option::None, } } @@ -507,32 +509,32 @@ pub fn bare_set_node() -> Option> { })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, })]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, })), - None => None, + None => std::option::Option::None, } } @@ -562,7 +564,7 @@ pub fn missing_kernel_container_profile_type(kind_name: String) -> Rc { occurrence_identity: Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), name: "".to_string(), span: crate::v1_std_core::no_span(), - ident_span: None, + ident_span: std::option::Option::None, children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), @@ -572,13 +574,13 @@ pub fn missing_kernel_container_profile_type(kind_name: String) -> Rc { })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::ExprError { kind: ExprErrorKind::InternalExprError, message: msg.clone(), @@ -617,13 +619,13 @@ pub fn make_kernel_record_field(field_name: String, field_type: Rc) -> Rc< })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }) @@ -638,16 +640,16 @@ pub fn make_kernel_record_type(type_name: String, fields: Rc>>) -> children: fields.clone(), connective: Connective::Conj, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }) @@ -674,28 +676,28 @@ pub fn make_container_type(kind_name: String, element: Rc) -> Rc, value: Rc) -> Rc { inferred: Some(Rc::new(InferredNode::Resolved { node: key.clone() })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }), @@ -758,29 +760,29 @@ pub fn make_map_type(key: Rc, value: Rc) -> Rc { })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }), ]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }), @@ -814,13 +816,13 @@ pub fn make_callable_type(func_params: Rc>>, ret: Rc) -> Rc, second: Rc) -> Rc { occurrence_identity: Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), name: "".to_string(), span: crate::v1_std_core::no_span(), - ident_span: None, + ident_span: std::option::Option::None, children: Rc::new(vec![ Rc::new(Node { occurrence_identity: Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), @@ -846,13 +848,13 @@ pub fn make_tuple_type(first: Rc, second: Rc) -> Rc { })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }), @@ -869,29 +871,29 @@ pub fn make_tuple_type(first: Rc, second: Rc) -> Rc { })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }), ]), connective: Connective::Conj, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }) @@ -911,13 +913,13 @@ pub fn algebra_value_field(name: String, type_node: Rc) -> Rc { })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }) @@ -936,7 +938,7 @@ pub fn algebra_method_field( Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), "_".to_string(), t.clone(), - None, + std::option::Option::None, crate::v1_std_core::no_span(), crate::v1_std_core::no_span(), )); @@ -957,13 +959,13 @@ pub fn algebra_method_field( })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }) @@ -1177,7 +1179,7 @@ pub fn instantiate_algebra_type( Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), "_".to_string(), pn.clone(), - None, + std::option::Option::None, crate::v1_std_core::no_span(), crate::v1_std_core::no_span(), )); @@ -1305,7 +1307,7 @@ pub fn unify_template( stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { match (*template.clone()).clone() { AlgebraTypeTemplate::AlgebraTypeVariable { id: var_id, .. } => { - if (v1_rt::map_get(&subst, var_id.clone()) != None) { + if (v1_rt::map_get(&subst, var_id.clone()) != std::option::Option::None) { subst.clone() } else { v1_rt::rc_map_insert(subst.clone(), var_id.clone(), concrete.clone()) @@ -1314,7 +1316,9 @@ pub fn unify_template( AlgebraTypeTemplate::ReceiverSelf => { let s1 = match concrete.children.clone().first().cloned() { Some(k) => { - if (v1_rt::map_get(&subst, "__key__".to_string()) != None) { + if (v1_rt::map_get(&subst, "__key__".to_string()) + != std::option::Option::None) + { subst.clone() } else { v1_rt::rc_map_insert( @@ -1335,7 +1339,9 @@ pub fn unify_template( .next() { Some(v) => { - if (v1_rt::map_get(&s1, "__value__".to_string()) != None) { + if (v1_rt::map_get(&s1, "__value__".to_string()) + != std::option::Option::None) + { s1.clone() } else { v1_rt::rc_map_insert( @@ -1349,21 +1355,22 @@ pub fn unify_template( } } AlgebraTypeTemplate::ReceiverKey => { - if (v1_rt::map_get(&subst, "__key__".to_string()) != None) { + if (v1_rt::map_get(&subst, "__key__".to_string()) != std::option::Option::None) { subst.clone() } else { v1_rt::rc_map_insert(subst.clone(), "__key__".to_string(), concrete.clone()) } } AlgebraTypeTemplate::ReceiverValue => { - if (v1_rt::map_get(&subst, "__value__".to_string()) != None) { + if (v1_rt::map_get(&subst, "__value__".to_string()) != std::option::Option::None) { subst.clone() } else { v1_rt::rc_map_insert(subst.clone(), "__value__".to_string(), concrete.clone()) } } AlgebraTypeTemplate::ReceiverElement => { - if (v1_rt::map_get(&subst, "__element__".to_string()) != None) { + if (v1_rt::map_get(&subst, "__element__".to_string()) != std::option::Option::None) + { subst.clone() } else { v1_rt::rc_map_insert(subst.clone(), "__element__".to_string(), concrete.clone()) @@ -1593,10 +1600,10 @@ pub fn apply_type_substitution( for ch in receiver.children.clone().iter().cloned() { if !({ let inner = child_type_node(ch.clone()); - if (inner.inferred.clone() != None) { + if (inner.inferred.clone() != std::option::Option::None) { is_type_variable(inner.inferred.clone().clone().unwrap()) } else { - ((inner.ident_span.clone() == None) + ((inner.ident_span.clone() == std::option::Option::None) || !crate::std_types::is_kernel_type( crate::v1_std_core::authored_name_at( source_indices.clone(), @@ -1883,7 +1890,7 @@ pub fn apply_type_substitution( Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), "_".to_string(), pn.clone(), - None, + std::option::Option::None, crate::v1_std_core::no_span(), crate::v1_std_core::no_span(), )); @@ -1993,12 +2000,12 @@ pub fn callable_return_type(n: Rc) -> Rc { } pub fn global_bare_callable_binding(binding: Rc) -> bool { - ((((((binding.resolved.clone().transport.clone() == None) + ((((((binding.resolved.clone().transport.clone() == std::option::Option::None) && (binding.resolved.clone().expr_data.clone() == Rc::new(ExprData::NoExprData))) && (binding.resolved.clone().connective.clone() == Connective::NoConnective)) - && (binding.resolved.clone().inferred.clone() != None)) + && (binding.resolved.clone().inferred.clone() != std::option::Option::None)) && ((binding.resolved.clone().properties.clone().len() as i64) == 0)) - && (binding.resolved.clone().type_annotation.clone() == None)) + && (binding.resolved.clone().type_annotation.clone() == std::option::Option::None)) } pub fn value_binding_expr_type_node(resolved: Rc) -> Rc { @@ -2011,10 +2018,12 @@ pub fn value_binding_expr_type_node(resolved: Rc) -> Rc { pub fn normalize_access_type_node(mut n: Rc) -> Rc { loop { let has_structure = (n.connective.clone() != Connective::NoConnective); - let unwrapped = if ((n.type_annotation.clone() != None) && has_structure.clone()) { + let unwrapped = if ((n.type_annotation.clone() != std::option::Option::None) + && has_structure.clone()) + { n.children.clone().first().cloned() } else { - None + std::option::Option::None }; match unwrapped.clone() { Some(base) => { @@ -2076,7 +2085,7 @@ pub fn node_type_shape( Some(InferredNode::Resolved { node: rt, .. }) => { (((((rt.connective.clone() == Connective::NoConnective) && ((rt.children.clone().len() as i64) == 0)) - && (rt.ident_span.clone() != None)) + && (rt.ident_span.clone() != std::option::Option::None)) && (crate::v1_std_core::authored_name_at( source_indices.clone(), rt.clone(), @@ -2107,7 +2116,7 @@ pub fn node_type_shape( let is_product = (n.connective.clone() == Connective::Conj); let is_coproduct = (n.connective.clone() == Connective::Disj); if is_product.clone() { - if (n.ident_span.clone() == None) { + if (n.ident_span.clone() == std::option::Option::None) { "Product()".to_string() } else { v1_rt::concat( @@ -2117,7 +2126,7 @@ pub fn node_type_shape( } } else { if is_coproduct.clone() { - if (n.ident_span.clone() == None) { + if (n.ident_span.clone() == std::option::Option::None) { "Coproduct()".to_string() } else { v1_rt::concat( @@ -2217,22 +2226,22 @@ pub fn node_type_compatible( mut source_indices: Rc>>, ) -> bool { loop { - let left_err = if (left.inferred.clone() != None) { + let left_err = if (left.inferred.clone() != std::option::Option::None) { crate::v1_std_core::is_compiler_error(left.inferred.clone().clone().unwrap()) } else { false }; - let right_err = if (right.inferred.clone() != None) { + let right_err = if (right.inferred.clone() != std::option::Option::None) { crate::v1_std_core::is_compiler_error(right.inferred.clone().clone().unwrap()) } else { false }; - let left_tv = if (left.inferred.clone() != None) { + let left_tv = if (left.inferred.clone() != std::option::Option::None) { is_type_variable(left.inferred.clone().clone().unwrap()) } else { false }; - let right_tv = if (right.inferred.clone() != None) { + let right_tv = if (right.inferred.clone() != std::option::Option::None) { is_type_variable(right.inferred.clone().clone().unwrap()) } else { false @@ -2471,22 +2480,22 @@ pub fn node_type_equals( source_indices: Rc>>, ) -> bool { { - let left_err = if (left.inferred.clone() != None) { + let left_err = if (left.inferred.clone() != std::option::Option::None) { crate::v1_std_core::is_compiler_error(left.inferred.clone().clone().unwrap()) } else { false }; - let right_err = if (right.inferred.clone() != None) { + let right_err = if (right.inferred.clone() != std::option::Option::None) { crate::v1_std_core::is_compiler_error(right.inferred.clone().clone().unwrap()) } else { false }; - let left_tv = if (left.inferred.clone() != None) { + let left_tv = if (left.inferred.clone() != std::option::Option::None) { is_type_variable(left.inferred.clone().clone().unwrap()) } else { false }; - let right_tv = if (right.inferred.clone() != None) { + let right_tv = if (right.inferred.clone() != std::option::Option::None) { is_type_variable(right.inferred.clone().clone().unwrap()) } else { false @@ -2761,7 +2770,8 @@ pub fn node_type_equals_core( _ => false, }, None => { - (right.inferred.clone() == None) + (right.inferred.clone() + == std::option::Option::None) } _ => false, } @@ -2787,7 +2797,7 @@ pub fn node_type_deps( source_indices: Rc>>, ) -> Rc> { stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { - let n_is_type_var = if (n.inferred.clone() != None) { + let n_is_type_var = if (n.inferred.clone() != std::option::Option::None) { is_type_variable(n.inferred.clone().clone().unwrap()) } else { false @@ -2795,14 +2805,14 @@ pub fn node_type_deps( if n_is_type_var.clone() { return Rc::new(vec![]); } - let __is_named_ref = if (n.inferred.clone() == None) { + let __is_named_ref = if (n.inferred.clone() == std::option::Option::None) { false } else { match n.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { (((((rt.connective.clone() == Connective::NoConnective) && ((rt.children.clone().len() as i64) == 0)) - && (rt.ident_span.clone() != None)) + && (rt.ident_span.clone() != std::option::Option::None)) && (crate::v1_std_core::authored_name_at( source_indices.clone(), rt.clone(), @@ -2840,7 +2850,7 @@ pub fn node_type_deps( node_type_deps(rt.clone(), source_indices.clone()) } _ => { - if (child.inferred.clone() == None) { + if (child.inferred.clone() == std::option::Option::None) { node_type_deps(child.clone(), source_indices.clone()) } else { Rc::new(vec![]) @@ -2854,7 +2864,7 @@ pub fn node_type_deps( __result }) } else { - if (n.inferred.clone() != None) { + if (n.inferred.clone() != std::option::Option::None) { match n.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: rt, .. }) => { node_type_deps(rt.clone(), source_indices.clone()) @@ -2875,7 +2885,7 @@ pub fn node_type_deps( } __result }); - if ((n.ident_span.clone() != None) + if ((n.ident_span.clone() != std::option::Option::None) && (crate::std_types::is_kernel_type(n_name.clone()) == false)) { v1_rt::concat(Rc::new(vec![n_name.clone()]), child_deps.clone()) @@ -2886,7 +2896,7 @@ pub fn node_type_deps( } else { if ((crate::std_types::is_kernel_type(n_name.clone()) || (n_name.clone() == "None".to_string())) - || (n.ident_span.clone() == None)) + || (n.ident_span.clone() == std::option::Option::None)) { Rc::new(vec![]) } else { @@ -2926,7 +2936,7 @@ pub fn method_receiver_element_node( .next() { Some(ch) => Some(child_type_node(ch.clone())), - None => None, + None => std::option::Option::None, } } else { if ((normed.connective.clone() == Connective::NoConnective) @@ -2934,10 +2944,10 @@ pub fn method_receiver_element_node( { match normed.children.clone().first().cloned() { Some(ch) => Some(child_type_node(ch.clone())), - None => None, + None => std::option::Option::None, } } else { - None + std::option::Option::None } }; match maybe_element.clone() { @@ -3016,7 +3026,7 @@ pub fn first_matching_algebra_field( loop { match candidates.clone().first().cloned() { None => { - break None; + break std::option::Option::None; } Some(kind) => { match crate::v1_std_core::find_child_named( @@ -3061,39 +3071,39 @@ pub fn infer_binop_type_node( match op.clone() { BinOp::Eq => Rc::new(BinOpInferred { result_type: bool_type(), - algebra_field: None, + algebra_field: std::option::Option::None, }), BinOp::Ne => Rc::new(BinOpInferred { result_type: bool_type(), - algebra_field: None, + algebra_field: std::option::Option::None, }), BinOp::Lt => Rc::new(BinOpInferred { result_type: bool_type(), - algebra_field: None, + algebra_field: std::option::Option::None, }), BinOp::Gt => Rc::new(BinOpInferred { result_type: bool_type(), - algebra_field: None, + algebra_field: std::option::Option::None, }), BinOp::Le => Rc::new(BinOpInferred { result_type: bool_type(), - algebra_field: None, + algebra_field: std::option::Option::None, }), BinOp::Ge => Rc::new(BinOpInferred { result_type: bool_type(), - algebra_field: None, + algebra_field: std::option::Option::None, }), BinOp::And => Rc::new(BinOpInferred { result_type: bool_type(), - algebra_field: None, + algebra_field: std::option::Option::None, }), BinOp::Or => Rc::new(BinOpInferred { result_type: bool_type(), - algebra_field: None, + algebra_field: std::option::Option::None, }), BinOp::NullCoalesce => Rc::new(BinOpInferred { result_type: extract_optional_inner_node(left_type.clone()), - algebra_field: None, + algebra_field: std::option::Option::None, }), _ => { let candidates = binop_algebra_fields(op.clone()); @@ -3128,18 +3138,18 @@ pub fn infer_binop_type_node( } _ => Rc::new(BinOpInferred { result_type: left_type.clone(), - algebra_field: None, + algebra_field: std::option::Option::None, }), }, None => Rc::new(BinOpInferred { result_type: left_type.clone(), - algebra_field: None, + algebra_field: std::option::Option::None, }), } } else { Rc::new(BinOpInferred { result_type: left_type.clone(), - algebra_field: None, + algebra_field: std::option::Option::None, }) } } @@ -3157,10 +3167,10 @@ pub fn for_each_element_type_node( let extracted = if is_single_child.clone() { match normed.children.clone().first().cloned() { Some(ch) => Some(child_type_node(ch.clone())), - None => None, + None => std::option::Option::None, } } else { - None + std::option::Option::None }; match extracted.clone() { Some(el) => el.clone(), diff --git a/src/v1/stage0/src/v1_compiler_languages.rs b/src/v1/stage0/src/v1_compiler_languages.rs index edbbddb68b0..c4697d83d3a 100644 --- a/src/v1/stage0/src/v1_compiler_languages.rs +++ b/src/v1/stage0/src/v1_compiler_languages.rs @@ -504,7 +504,7 @@ pub fn rust_spec() -> Rc { }), scaffold: Rc::new(ProjectScaffold { manifest_file: Some("Cargo.toml".to_string()), - module_init_file: None, + module_init_file: std::option::Option::None, source_file_extension: rust_source_extension(), source_dir: Some(rust_source_dir()), }), @@ -515,8 +515,8 @@ pub fn rust_spec() -> Rc { enum_derives_copy: Some(rust_enum_derives_copy()), tag_attribute: Some(rust_serde_tag()), rename_attribute_template: Some(rust_serde_rename_template()), - derive_attribute: None, - default_value: None, + derive_attribute: std::option::Option::None, + default_value: std::option::Option::None, }), test_conventions: Rc::new(TestConventions { file_prefix: "".to_string(), @@ -693,15 +693,15 @@ pub fn python_spec() -> Rc { manifest_file: Some("requirements.txt".to_string()), module_init_file: Some(python_module_init()), source_file_extension: python_source_extension(), - source_dir: None, + source_dir: std::option::Option::None, }), serialization: Rc::new(SerializationSpec { - struct_derives: None, - struct_derives_copy: None, - enum_derives: None, - enum_derives_copy: None, - tag_attribute: None, - rename_attribute_template: None, + struct_derives: std::option::Option::None, + struct_derives_copy: std::option::Option::None, + enum_derives: std::option::Option::None, + enum_derives_copy: std::option::Option::None, + tag_attribute: std::option::Option::None, + rename_attribute_template: std::option::Option::None, derive_attribute: Some(python_derive_attribute()), default_value: Some(python_default_value()), }), @@ -711,7 +711,7 @@ pub fn python_spec() -> Rc { file_dir: Some("tests/".to_string()), function_prefix: "test_".to_string(), name_style: TestNameStyle::SnakeCaseTestNames, - async_decorator: None, + async_decorator: std::option::Option::None, }), visibility: Rc::new(VisibilitySpec::KeywordVisibility { prefix: "".to_string(), @@ -839,8 +839,8 @@ pub fn python_spec() -> Rc { }), ]), }), - callable_type_template: None, - callable_value_wrap_template: None, + callable_type_template: std::option::Option::None, + callable_value_wrap_template: std::option::Option::None, naming_case: NamingCase::SnakeCase, async_call_prefix: "await ".to_string(), bridge_method_prefix: "".to_string(), @@ -880,27 +880,27 @@ pub fn go_spec() -> Rc { }), scaffold: Rc::new(ProjectScaffold { manifest_file: Some("go.mod".to_string()), - module_init_file: None, + module_init_file: std::option::Option::None, source_file_extension: ".go".to_string(), - source_dir: None, + source_dir: std::option::Option::None, }), serialization: Rc::new(SerializationSpec { - struct_derives: None, - struct_derives_copy: None, - enum_derives: None, - enum_derives_copy: None, - tag_attribute: None, - rename_attribute_template: None, - derive_attribute: None, - default_value: None, + struct_derives: std::option::Option::None, + struct_derives_copy: std::option::Option::None, + enum_derives: std::option::Option::None, + enum_derives_copy: std::option::Option::None, + tag_attribute: std::option::Option::None, + rename_attribute_template: std::option::Option::None, + derive_attribute: std::option::Option::None, + default_value: std::option::Option::None, }), test_conventions: Rc::new(TestConventions { file_prefix: "".to_string(), file_suffix: "_test".to_string(), - file_dir: None, + file_dir: std::option::Option::None, function_prefix: "Test".to_string(), name_style: TestNameStyle::PascalCaseTestNames, - async_decorator: None, + async_decorator: std::option::Option::None, }), visibility: Rc::new(VisibilitySpec::CaseVisibility { export_case: NamingCase::PascalCase, @@ -1016,8 +1016,8 @@ pub fn go_spec() -> Rc { to: "%%".to_string(), })]), }), - callable_type_template: None, - callable_value_wrap_template: None, + callable_type_template: std::option::Option::None, + callable_value_wrap_template: std::option::Option::None, naming_case: NamingCase::CamelCase, async_call_prefix: "".to_string(), bridge_method_prefix: "v2rt.".to_string(), @@ -1052,20 +1052,20 @@ pub fn dag_spec() -> Rc { strategy: Rc::new(ReservedWordStrategy::NoEscape), }), scaffold: Rc::new(ProjectScaffold { - manifest_file: None, - module_init_file: None, + manifest_file: std::option::Option::None, + module_init_file: std::option::Option::None, source_file_extension: dag_source_extension(), - source_dir: None, + source_dir: std::option::Option::None, }), serialization: Rc::new(SerializationSpec { - struct_derives: None, - struct_derives_copy: None, - enum_derives: None, - enum_derives_copy: None, - tag_attribute: None, - rename_attribute_template: None, - derive_attribute: None, - default_value: None, + struct_derives: std::option::Option::None, + struct_derives_copy: std::option::Option::None, + enum_derives: std::option::Option::None, + enum_derives_copy: std::option::Option::None, + tag_attribute: std::option::Option::None, + rename_attribute_template: std::option::Option::None, + derive_attribute: std::option::Option::None, + default_value: std::option::Option::None, }), test_conventions: Rc::new(TestConventions { file_prefix: "test_".to_string(), @@ -1073,7 +1073,7 @@ pub fn dag_spec() -> Rc { file_dir: Some("tests/".to_string()), function_prefix: "test_".to_string(), name_style: TestNameStyle::SnakeCaseTestNames, - async_decorator: None, + async_decorator: std::option::Option::None, }), visibility: Rc::new(VisibilitySpec::KeywordVisibility { prefix: "".to_string(), @@ -1198,8 +1198,8 @@ pub fn dag_spec() -> Rc { }), ]), }), - callable_type_template: None, - callable_value_wrap_template: None, + callable_type_template: std::option::Option::None, + callable_value_wrap_template: std::option::Option::None, naming_case: NamingCase::AsAuthored, async_call_prefix: "".to_string(), bridge_method_prefix: "".to_string(), @@ -1294,14 +1294,14 @@ pub fn binop_symbol( }) .first() .cloned(), - None => None, + None => std::option::Option::None, }; let result = match specific.clone() { Some(_) => specific.clone(), None => Rc::new({ let mut __result = Vec::new(); for spec in op_matching.iter().cloned() { - if (spec.algebra_field.clone() == None) { + if (spec.algebra_field.clone() == std::option::Option::None) { __result.push(spec); } } @@ -1312,7 +1312,7 @@ pub fn binop_symbol( }; match result.clone() { Some(spec) => Some(spec.symbol.clone()), - None => None, + None => std::option::Option::None, } } } diff --git a/src/v1/stage0/src/v1_compiler_ownership.rs b/src/v1/stage0/src/v1_compiler_ownership.rs index 40115b72501..d340561b89b 100644 --- a/src/v1/stage0/src/v1_compiler_ownership.rs +++ b/src/v1/stage0/src/v1_compiler_ownership.rs @@ -171,11 +171,11 @@ pub fn record_use( Some(usage) => usage.clone(), None => Rc::new(BindingUsage { name: name.clone(), - binding_kind: None, + binding_kind: std::option::Option::None, consumers: Rc::new(vec![]), }), }; - let effective_kind = if (existing.binding_kind.clone() != None) { + let effective_kind = if (existing.binding_kind.clone() != std::option::Option::None) { existing.binding_kind.clone() } else { binding_kind.clone() @@ -620,7 +620,7 @@ pub fn walk_expr( usage.name.clone(), EdgeKind::Read, "lambda-capture".to_string(), - None, + std::option::Option::None, 0, ) }, @@ -650,7 +650,7 @@ pub fn walk_expr( usage.name.clone(), EdgeKind::Read, "foreach-capture".to_string(), - None, + std::option::Option::None, 0, ) }, @@ -1332,7 +1332,7 @@ pub fn analyze_ownership( p_name.clone(), Rc::new(BindingUsage { name: p_name.clone(), - binding_kind: None, + binding_kind: std::option::Option::None, consumers: Rc::new(vec![]), }), ), diff --git a/src/v1/stage0/src/v1_compiler_parse.rs b/src/v1/stage0/src/v1_compiler_parse.rs index 630a43d1dd8..63bba4fbcfd 100644 --- a/src/v1/stage0/src/v1_compiler_parse.rs +++ b/src/v1/stage0/src/v1_compiler_parse.rs @@ -555,7 +555,7 @@ pub fn parsed_expr_result( expr: build(minted.identity.clone()), tokens: tokens.clone(), ctx: minted.ctx.clone(), - err: None, + err: std::option::Option::None, }) } } @@ -579,7 +579,7 @@ pub fn parsed_sole_constructor_properties( value: Rc::new(LiteralValue::LitBool { value: true }), }), Rc::new(vec![]), - None, + std::option::Option::None, span.clone(), ), span.clone(), @@ -614,7 +614,7 @@ pub fn mint_parsed_bool_property( value: Rc::new(LiteralValue::LitBool { value: true }), }), Rc::new(vec![]), - None, + std::option::Option::None, span.clone(), ), span.clone(), @@ -645,7 +645,7 @@ pub fn mint_parsed_optional_int_property( value: Rc::new(LiteralValue::LitInt { value: n.clone() }), }), Rc::new(vec![]), - None, + std::option::Option::None, span.clone(), ), span.clone(), @@ -720,7 +720,7 @@ pub fn parsed_predicate_result( predicate: build(value_mint.identity.clone(), predicate_mint.identity.clone()), tokens: tokens.clone(), ctx: predicate_mint.ctx.clone(), - err: None, + err: std::option::Option::None, }) } } @@ -1216,7 +1216,7 @@ pub fn parse_string_literal_value(tokens: Rc) -> Rc Rc::new(StringLitResult { value: t.text.clone(), tokens: token_stream_advance(tokens.clone(), 1), - err: None, + err: std::option::Option::None, }), _ => Rc::new(StringLitResult { value: "".to_string(), @@ -1250,7 +1250,7 @@ pub fn parse_int_literal_value(tokens: Rc) -> Rc { Some(n) => Rc::new(IntLitResult { value: n.clone(), tokens: token_stream_advance(tokens.clone(), 1), - err: None, + err: std::option::Option::None, }), None => Rc::new(IntLitResult { value: 0, @@ -1804,10 +1804,10 @@ pub fn tok_keyword_to_name(tok: Option>) -> Option { if is_name_keyword(t.clone()) { Some(t.text.clone()) } else { - None + std::option::Option::None } } - None => None, + None => std::option::Option::None, } } @@ -1937,7 +1937,7 @@ pub fn expect(tokens: Rc, expected: Rc) -> Rc) -> Rc { let tok = token_stream_first(tokens.clone()); let sh = match tok.clone() { Some(t) => Some(t.shape.clone()), - None => None, + None => std::option::Option::None, }; match sh.clone() { Some(TokenShape::ShIdent) => { @@ -1978,7 +1978,7 @@ pub fn expect_ident(tokens: Rc) -> Rc { name: n.clone(), span: span.clone(), tokens: token_stream_advance(tokens.clone(), 1), - err: None, + err: std::option::Option::None, }) } _ => { @@ -2005,7 +2005,7 @@ pub fn expect_name(tokens: Rc) -> Rc { let tok = token_stream_first(tokens.clone()); let sh = match tok.clone() { Some(t) => Some(t.shape.clone()), - None => None, + None => std::option::Option::None, }; match sh.clone() { Some(TokenShape::ShIdent) => { @@ -2015,7 +2015,7 @@ pub fn expect_name(tokens: Rc) -> Rc { name: n.clone(), span: span.clone(), tokens: token_stream_advance(tokens.clone(), 1), - err: None, + err: std::option::Option::None, }) } _ => { @@ -2027,7 +2027,7 @@ pub fn expect_name(tokens: Rc) -> Rc { name: n.clone(), span: span.clone(), tokens: token_stream_advance(tokens.clone(), 1), - err: None, + err: std::option::Option::None, }) } None => { @@ -2103,7 +2103,7 @@ pub fn find_operator_bp(ops: Rc>>, symbol: String) -> Optio }) } } else { - None + std::option::Option::None } } } @@ -2129,7 +2129,7 @@ pub fn find_operator_binop(ops: Rc>>, symbol: String) -> Op .binop .clone() } else { - None + std::option::Option::None } } } @@ -2236,11 +2236,11 @@ pub fn parser_result_base_var( base.clone(), source_indices.clone(), )), - _ => None, + _ => std::option::Option::None, }, - None => None, + None => std::option::Option::None, }, - _ => None, + _ => std::option::Option::None, } } @@ -2260,30 +2260,34 @@ pub fn parser_helper_state_arg_expr( ) .iter() .cloned() - .fold(None, |acc: _, pair: (i64, Rc)| { - if (acc.clone() != None) { - acc.clone() - } else { - { - let idx = pair.0.clone(); - let arg_node = pair.1.clone(); - let matches_state = - match crate::v1_std_core::arg_name_at(arg_node.clone(), source_indices.clone()) - { + .fold( + std::option::Option::None, + |acc: _, pair: (i64, Rc)| { + if (acc.clone() != std::option::Option::None) { + acc.clone() + } else { + { + let idx = pair.0.clone(); + let arg_node = pair.1.clone(); + let matches_state = match crate::v1_std_core::arg_name_at( + arg_node.clone(), + source_indices.clone(), + ) { Some(name) => { ((name.clone() == "state".to_string()) || (name.clone() == "tokens".to_string())) } None => (idx.clone() == 0), }; - if matches_state.clone() { - Some(crate::v1_std_core::arg_value(arg_node.clone())) - } else { - None + if matches_state.clone() { + Some(crate::v1_std_core::arg_value(arg_node.clone())) + } else { + std::option::Option::None + } } } - } - }) + }, + ) } pub fn parser_progress_flag_var( @@ -2299,10 +2303,10 @@ pub fn parser_progress_flag_var( { parser_result_base_var(expr.clone(), source_indices.clone()) } else { - None + std::option::Option::None } } - _ => None, + _ => std::option::Option::None, } } @@ -2316,7 +2320,7 @@ pub fn parser_helper_identity(callee: String) -> Option { if (callee.clone() == "with".to_string()) { Some(ParserHelperIdentity::ParserHelperWith) } else { - None + std::option::Option::None } } } @@ -2339,12 +2343,12 @@ pub fn parser_passthrough_state_expr( Some(ParserHelperIdentity::ParserHelperWith) => { match expr.children.clone().first().cloned() { Some(base_arg) => Some(crate::v1_std_core::arg_value(base_arg.clone())), - None => None, + None => std::option::Option::None, } } - None => None, + None => std::option::Option::None, }, - _ => None, + _ => std::option::Option::None, } } @@ -2386,23 +2390,23 @@ pub fn leaf_type_node( name: name.clone(), span: span.clone(), ident_span: if (name.clone() == "".to_string()) { - None + std::option::Option::None } else { Some(span.clone()) }, children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }) @@ -2417,20 +2421,20 @@ pub fn literal_width_nat_type_node( occurrence_identity: occurrence_identity.clone(), name: "".to_string(), span: span.clone(), - ident_span: None, + ident_span: std::option::Option::None, children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::ExprLiteral { value: Rc::new(LiteralValue::LitInt { value: value.clone(), @@ -2446,7 +2450,7 @@ pub fn parse_type_angle_arg(tokens: Rc, ctx: Rc) -> R let tok = token_stream_first(tokens.clone()); let sh = match tok.clone() { Some(t) => Some(t.shape.clone()), - None => None, + None => std::option::Option::None, }; let span = token_span(tok.clone()); match sh.clone() { @@ -2474,7 +2478,7 @@ pub fn parse_type_angle_arg(tokens: Rc, ctx: Rc) -> R ), tokens: r.tokens.clone(), ctx: minted.ctx.clone(), - err: None, + err: std::option::Option::None, }) } } @@ -2544,7 +2548,7 @@ pub fn node_inferred_to_outputs( "value".to_string(), rt.clone(), Cardinality::Required, - None, + std::option::Option::None, Rc::new(vec![]), rt.span.clone(), crate::v1_std_core::no_span(), @@ -2595,7 +2599,7 @@ pub fn parse_dotted_ident_rest( name: acc.clone(), span: span.clone(), tokens: __eu.clone(), - err: None, + err: std::option::Option::None, }); } } @@ -2803,7 +2807,7 @@ pub fn stamp_parsed_node_list( Rc::new(ParsedNodeListStampResult { nodes: Rc::new(vec![]), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }), |acc: Rc, node: Rc| { if has_err(acc.err.clone()) { @@ -2844,9 +2848,9 @@ pub fn stamp_parsed_optional_node( }) } None => Rc::new(ParsedOptionalNodeStampResult { - node: None, + node: std::option::Option::None, ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }), } } @@ -2906,17 +2910,17 @@ pub fn stamp_parsed_pattern( value: value.clone(), })), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }), Some(MatchPattern::Wildcard) => Rc::new(ParsedPatternStampResult { pattern: Some(Rc::new(MatchPattern::Wildcard)), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }), None => Rc::new(ParsedPatternStampResult { - pattern: None, + pattern: std::option::Option::None, ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }), } } @@ -2943,9 +2947,9 @@ pub fn stamp_parsed_inferred( }) } _ => Rc::new(ParsedOptionalNodeStampResult { - node: None, + node: std::option::Option::None, ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }), } } @@ -3091,7 +3095,7 @@ pub fn stamp_parsed_node_list_with_head_role( None => Rc::new(ParsedNodeListStampResult { nodes: Rc::new(vec![]), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }), } } @@ -3159,7 +3163,7 @@ pub fn stamp_parsed_node( { let occurrence = match (*node.occurrence_identity.clone()).clone() { NodeOccurrenceIdentity::OccurrenceMinted { id: id, .. } => Some(id.clone()), - NodeOccurrenceIdentity::OccurrenceSynthetic => None, + NodeOccurrenceIdentity::OccurrenceSynthetic => std::option::Option::None, NodeOccurrenceIdentity::OccurrenceProjected { .. } => { return Rc::new(ParsedNodeStampResult { node: node.clone(), @@ -3352,7 +3356,7 @@ pub fn parse_with_table_at( ); Rc::new(ParseWithTableResult { result: Rc::new(ParseResult { - module: None, + module: std::option::Option::None, error: r.err.clone(), }), intern_table: crate::v1_std_core::intern_table_with_authored_token_ordinals( @@ -3384,7 +3388,7 @@ pub fn parse_with_table_at( Rc::new(ParseWithTableResult { result: Rc::new(ParseResult { module: if has_err(stamped.err.clone()) { - None + std::option::Option::None } else { Some(stamped.node.clone()) }, @@ -3460,10 +3464,10 @@ pub fn parse_with_table_ready_module_path_note() -> String { pub fn parse_with_table_ready_module_path(parsed: Rc) -> Option { match parsed.result.clone().error.clone() { - Some(_) => None, + Some(_) => std::option::Option::None, None => match parsed.result.clone().module.clone() { Some(module_node) => Some(module_node.name.clone()), - None => None, + None => std::option::Option::None, }, } } @@ -3571,16 +3575,16 @@ pub fn parse_module(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { @@ -3783,7 +3787,7 @@ pub fn parse_import(tokens: Rc, ctx: Rc) -> Rc>>, keyword: String) -> Option None, + 0 => std::option::Option::None, _ => Some(matches.clone().first().cloned().clone().unwrap()), } } @@ -3882,17 +3886,17 @@ pub fn parse_item(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { @@ -4585,13 +4589,13 @@ pub fn parse_type_after_kw( })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -4599,7 +4603,7 @@ pub fn parse_type_after_kw( item: item.clone(), tokens: __eu.clone(), ctx: item_mint.ctx.clone(), - err: None, + err: std::option::Option::None, }) } } @@ -4624,17 +4628,17 @@ pub fn parse_type_body_from_prefix( ident_span: Some(name_span.clone()), children: Rc::new(vec![]), params: type_params.clone(), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, + body: std::option::Option::None, connective: Connective::NoConnective, - transport: None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -4687,16 +4691,16 @@ pub fn parse_type_body_from_prefix( children: type_children.clone(), connective: Connective::Conj, params: type_params.clone(), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: sole.properties.clone(), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -4704,7 +4708,7 @@ pub fn parse_type_body_from_prefix( item: item.clone(), tokens: skip_newlines(r2.tokens.clone()), ctx: minted.ctx.clone(), - err: None, + err: std::option::Option::None, }) } EatResult::EatUnchanged { tokens: __eu, .. } => { @@ -4741,13 +4745,13 @@ pub fn parse_type_body_from_prefix( })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -4755,7 +4759,7 @@ pub fn parse_type_body_from_prefix( item: item.clone(), tokens: __eu.clone(), ctx: item_mint.ctx.clone(), - err: None, + err: std::option::Option::None, }) } } @@ -4765,8 +4769,9 @@ pub fn parse_type_body_from_prefix( } pub fn alias_rhs_is_anonymous_record(te: Rc) -> bool { - (((te.connective.clone() == Connective::Conj) && (te.ident_span.clone() == None)) - && (te.type_annotation.clone() == None)) + (((te.connective.clone() == Connective::Conj) + && (te.ident_span.clone() == std::option::Option::None)) + && (te.type_annotation.clone() == std::option::Option::None)) } pub fn type_item_from_alias_rhs( @@ -4787,16 +4792,16 @@ pub fn type_item_from_alias_rhs( children: te.children.clone(), connective: Connective::Conj, params: type_params.clone(), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: sole_constructor_properties.clone(), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }) @@ -4812,13 +4817,13 @@ pub fn type_item_from_alias_rhs( inferred: Some(Rc::new(InferredNode::Resolved { node: te.clone() })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: sole_constructor_properties.clone(), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }) @@ -4842,17 +4847,17 @@ pub fn parse_type_body_after_eq( ident_span: Some(name_span.clone()), children: Rc::new(vec![]), params: type_params.clone(), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, + body: std::option::Option::None, connective: Connective::NoConnective, - transport: None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -4914,16 +4919,16 @@ pub fn parse_type_body_after_eq( children: type_children.clone(), connective: Connective::Disj, params: type_params.clone(), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -4931,7 +4936,7 @@ pub fn parse_type_body_after_eq( item: item.clone(), tokens: skip_newlines(rest.tokens.clone()), ctx: minted.ctx.clone(), - err: None, + err: std::option::Option::None, }) } EatResult::EatUnchanged { tokens: _, .. } => { @@ -5002,16 +5007,16 @@ pub fn parse_type_body_after_eq( children: type_children.clone(), connective: Connective::Disj, params: type_params.clone(), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -5019,7 +5024,7 @@ pub fn parse_type_body_after_eq( item: item.clone(), tokens: skip_newlines(rest.tokens.clone()), ctx: minted.ctx.clone(), - err: None, + err: std::option::Option::None, }) } } else { @@ -5071,7 +5076,7 @@ pub fn parse_type_body_after_eq( item: item.clone(), tokens: skip_newlines(wr.tokens.clone()), ctx: minted.ctx.clone(), - err: None, + err: std::option::Option::None, }) } } @@ -5120,7 +5125,7 @@ pub fn parse_type_body_after_eq( item: item.clone(), tokens: skip_newlines(wr.tokens.clone()), ctx: minted.ctx.clone(), - err: None, + err: std::option::Option::None, }) } } @@ -5153,20 +5158,20 @@ pub fn try_where_clause( occurrence_identity: predicate_mint.identity.clone(), name: "".to_string(), span: start_span.clone(), - ident_span: None, + ident_span: std::option::Option::None, children: r.predicates.clone(), connective: Connective::Conj, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -5174,20 +5179,20 @@ pub fn try_where_clause( occurrence_identity: refined_mint.identity.clone(), name: "".to_string(), span: start_span.clone(), - ident_span: None, + ident_span: std::option::Option::None, children: Rc::new(vec![base_te.clone()]), connective: Connective::Conj, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), type_annotation: Some(predicate_node.clone()), is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -5195,14 +5200,14 @@ pub fn try_where_clause( type_expr: refined.clone(), tokens: r.tokens.clone(), ctx: refined_mint.ctx.clone(), - err: None, + err: std::option::Option::None, }) } AdvanceResult::AdvanceEof => Rc::new(TypeResult { type_expr: base_te.clone(), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }), } } else { @@ -5210,7 +5215,7 @@ pub fn try_where_clause( type_expr: base_te.clone(), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }) } } @@ -5247,7 +5252,7 @@ pub fn parse_predicates_acc( predicates: acc.clone(), tokens: r.tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }); } } @@ -5266,7 +5271,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> value: Rc::new(LiteralValue::LitBool { value: false }), }), Rc::new(vec![]), - None, + std::option::Option::None, zero_span.clone(), ), zero_span.clone(), @@ -5321,7 +5326,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> }), }), Rc::new(vec![]), - None, + std::option::Option::None, zero_span.clone(), ), zero_span.clone(), @@ -5364,7 +5369,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> }), }), Rc::new(vec![]), - None, + std::option::Option::None, zero_span.clone(), ), zero_span.clone(), @@ -5407,7 +5412,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> }), }), Rc::new(vec![]), - None, + std::option::Option::None, zero_span.clone(), ), zero_span.clone(), @@ -5450,7 +5455,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> }), }), Rc::new(vec![]), - None, + std::option::Option::None, zero_span.clone(), ), zero_span.clone(), @@ -5493,7 +5498,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> }), }), Rc::new(vec![]), - None, + std::option::Option::None, zero_span.clone(), ), zero_span.clone(), @@ -5542,12 +5547,14 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> "range".to_string(), crate::v1_std_core::make_expr_node( value_identity.clone(), - Rc::new(ExprData::ExprRecordLit { parent_enum: None }), + Rc::new(ExprData::ExprRecordLit { + parent_enum: std::option::Option::None, + }), v1_rt::concat( min.properties.clone(), max.properties.clone(), ), - None, + std::option::Option::None, zero_span.clone(), ), zero_span.clone(), @@ -5587,7 +5594,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> value: Rc::new(LiteralValue::LitBool { value: true }), }), Rc::new(vec![]), - None, + std::option::Option::None, zero_span.clone(), ), zero_span.clone(), @@ -5608,7 +5615,7 @@ pub fn parse_single_predicate(tokens: Rc, ctx: Rc) -> value: Rc::new(LiteralValue::LitBool { value: true }), }), Rc::new(vec![]), - None, + std::option::Option::None, zero_span.clone(), ), zero_span.clone(), @@ -5626,8 +5633,8 @@ pub fn parse_named_int_args(tokens: Rc, ctx: Rc) -> R let r = parse_single_named_int(tokens.clone(), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(RangeArgsResult { - min_val: None, - max_val: None, + min_val: std::option::Option::None, + max_val: std::option::Option::None, tokens: r.tokens.clone(), ctx: r.ctx.clone(), err: r.err.clone(), @@ -5638,8 +5645,8 @@ pub fn parse_named_int_args(tokens: Rc, ctx: Rc) -> R let r2 = parse_single_named_int(skip_newlines(__ec.clone()), r.ctx.clone()); if has_err(r2.err.clone()) { return Rc::new(RangeArgsResult { - min_val: None, - max_val: None, + min_val: std::option::Option::None, + max_val: std::option::Option::None, tokens: r2.tokens.clone(), ctx: r2.ctx.clone(), err: r2.err.clone(), @@ -5651,7 +5658,7 @@ pub fn parse_named_int_args(tokens: Rc, ctx: Rc) -> R if (r2.arg_name.clone() == "min".to_string()) { Some(r2.arg_value.clone()) } else { - None + std::option::Option::None } }; let max_val = if (r.arg_name.clone() == "max".to_string()) { @@ -5660,7 +5667,7 @@ pub fn parse_named_int_args(tokens: Rc, ctx: Rc) -> R if (r2.arg_name.clone() == "max".to_string()) { Some(r2.arg_value.clone()) } else { - None + std::option::Option::None } }; Rc::new(RangeArgsResult { @@ -5668,26 +5675,26 @@ pub fn parse_named_int_args(tokens: Rc, ctx: Rc) -> R max_val: max_val.clone(), tokens: r2.tokens.clone(), ctx: r2.ctx.clone(), - err: None, + err: std::option::Option::None, }) } EatResult::EatUnchanged { tokens: __eu, .. } => { let min_val = if (r.arg_name.clone() == "min".to_string()) { Some(r.arg_value.clone()) } else { - None + std::option::Option::None }; let max_val = if (r.arg_name.clone() == "max".to_string()) { Some(r.arg_value.clone()) } else { - None + std::option::Option::None }; Rc::new(RangeArgsResult { min_val: min_val.clone(), max_val: max_val.clone(), tokens: r.tokens.clone(), ctx: r.ctx.clone(), - err: None, + err: std::option::Option::None, }) } } @@ -5735,7 +5742,7 @@ pub fn parse_single_named_int( arg_value: r3.value.clone(), tokens: r3.tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }) } } @@ -5764,12 +5771,12 @@ pub fn parse_positional_variant_type_fields( }), EatResult::EatUnchanged { tokens: __eu, .. } => { let minted = mint_parsed_node_identity(r.ctx.clone()); -let field = crate::v1_std_core::make_field_node(minted.identity.clone(), "0".to_string(), r.type_expr.clone(), Cardinality::Required, None, Rc::new(vec![]), r.type_expr.clone().span.clone(), crate::v1_std_core::kernel_span("0".to_string())); +let field = crate::v1_std_core::make_field_node(minted.identity.clone(), "0".to_string(), r.type_expr.clone(), Cardinality::Required, std::option::Option::None, Rc::new(vec![]), r.type_expr.clone().span.clone(), crate::v1_std_core::kernel_span("0".to_string())); Rc::new(FieldsResult { fields: Rc::new(vec![field.clone()]), tokens: r.tokens.clone(), ctx: minted.ctx.clone(), - err: None, + err: std::option::Option::None, }) }, } @@ -5829,7 +5836,7 @@ pub fn parse_variant_fields( variant: v.clone(), tokens: r2.tokens.clone(), ctx: minted.ctx.clone(), - err: None, + err: std::option::Option::None, }) } EatResult::EatUnchanged { tokens: __eu, .. } => { @@ -5877,7 +5884,7 @@ pub fn parse_variant_fields( variant: v.clone(), tokens: r2.tokens.clone(), ctx: minted.ctx.clone(), - err: None, + err: std::option::Option::None, }) } EatResult::EatUnchanged { tokens: __eu2, .. } => { @@ -5893,7 +5900,7 @@ pub fn parse_variant_fields( variant: v.clone(), tokens: tokens.clone(), ctx: minted.ctx.clone(), - err: None, + err: std::option::Option::None, }) } } @@ -5954,7 +5961,7 @@ pub fn parse_more_variants_acc( variants: acc.clone(), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }); } } @@ -5967,7 +5974,7 @@ pub fn parse_type_expr(tokens: Rc, ctx: Rc) -> Rc Some(t.shape.clone()), - None => None, + None => std::option::Option::None, }; let span = token_span(tok.clone()); match sh.clone() { @@ -6007,7 +6014,7 @@ pub fn parse_type_expr(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { @@ -6125,7 +6132,7 @@ pub fn parse_callable_type_expr( params: Rc::new(vec![]), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }) } else { parse_callable_param_types(tokens.clone(), ctx.clone(), Rc::new(vec![])) @@ -6180,13 +6187,13 @@ pub fn parse_callable_type_expr( })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -6219,7 +6226,7 @@ pub fn parse_callable_param_types( minted.identity.clone(), "".to_string(), r.type_expr.clone(), - None, + std::option::Option::None, r.type_expr.clone().span.clone(), r.type_expr.clone().span.clone(), ); @@ -6232,7 +6239,7 @@ pub fn parse_callable_param_types( params: acc.clone(), tokens: tokens.clone(), ctx: minted.ctx.clone(), - err: None, + err: std::option::Option::None, }); } else { { @@ -6247,7 +6254,7 @@ pub fn parse_callable_param_types( params: acc.clone(), tokens: r.tokens.clone(), ctx: minted.ctx.clone(), - err: None, + err: std::option::Option::None, }); } } @@ -6304,16 +6311,16 @@ pub fn finish_type_expr_from_name( children: type_args.args.clone(), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -6392,7 +6399,7 @@ pub fn collect_type_param_names( param_mint.identity.clone(), r.name.clone(), type_expr.clone(), - None, + std::option::Option::None, span.clone(), span.clone(), ); @@ -6465,7 +6472,7 @@ pub fn collect_type_args( args: args.clone(), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }); } } @@ -6505,14 +6512,14 @@ pub fn maybe_optional( type_expr: ote.clone(), tokens: __ec.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }) } EatResult::EatUnchanged { tokens: __eu, .. } => Rc::new(TypeResult { type_expr: te.clone(), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }), } } @@ -6534,7 +6541,7 @@ pub fn parse_field_list_acc( fields: acc.clone(), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }); } else { if (tok_is_ident(tok.clone()) || tok_is_keyword_name(tok.clone())) { @@ -6565,7 +6572,7 @@ pub fn parse_field_list_acc( fields: acc.clone(), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }); } } @@ -6584,7 +6591,7 @@ pub fn parse_field(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { @@ -6676,7 +6683,7 @@ pub fn parse_field(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc Some(t.shape.clone()), - None => None, + None => std::option::Option::None, }; match sh.clone() { Some(TokenShape::ShIdent) => { @@ -6709,7 +6716,7 @@ pub fn parse_optional_from_key( let tok2 = token_stream_first(token_stream_advance(tokens.clone(), 1)); let sh2 = match tok2.clone() { Some(t) => Some(t.shape.clone()), - None => None, + None => std::option::Option::None, }; match sh2.clone() { Some(TokenShape::ShLitStr) => { @@ -6724,7 +6731,7 @@ pub fn parse_optional_from_key( value: Rc::new(LiteralValue::LitStr { value: key.clone() }), }), Rc::new(vec![]), - None, + std::option::Option::None, token_span(tok2.clone()), token_span(tok2.clone()), ); @@ -6739,14 +6746,14 @@ pub fn parse_optional_from_key( properties: Rc::new(vec![property.clone()]), tokens: token_stream_advance(tokens.clone(), 2), ctx: property_mint.ctx.clone(), - err: None, + err: std::option::Option::None, }) } _ => Rc::new(FromKeyResult { properties: Rc::new(vec![]), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }), } } @@ -6755,7 +6762,7 @@ pub fn parse_optional_from_key( properties: Rc::new(vec![]), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }) } } @@ -6763,7 +6770,7 @@ pub fn parse_optional_from_key( properties: Rc::new(vec![]), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }), } } @@ -6776,20 +6783,20 @@ pub fn parse_fn_def(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { @@ -7654,7 +7661,7 @@ pub fn parse_uses_entry(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) - let r = parse_type_expr(__ec.clone(), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(OptRetResult { - inferred: None, + inferred: std::option::Option::None, tokens: r.tokens.clone(), ctx: r.ctx.clone(), err: r.err.clone(), @@ -7766,14 +7773,14 @@ pub fn parse_optional_inferred(tokens: Rc, ctx: Rc) - })), tokens: r.tokens.clone(), ctx: r.ctx.clone(), - err: None, + err: std::option::Option::None, }) } EatResult::EatUnchanged { tokens: __eu, .. } => Rc::new(OptRetResult { - inferred: None, + inferred: std::option::Option::None, tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }), } } @@ -7785,20 +7792,20 @@ pub fn parse_service_def(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc< parse_service_entries( tokens.clone(), ctx.clone(), - None, + std::option::Option::None, crate::v1_std_core::local_transport_node( Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), token_span(token_stream_first(tokens.clone())), @@ -8004,12 +8011,12 @@ pub fn parse_service_entries( operations: operations.clone(), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }); } else { let sh = match tok.clone() { Some(t) => Some(t.shape.clone()), - None => None, + None => std::option::Option::None, }; let span = token_span(tok.clone()); match sh.clone() { @@ -8167,7 +8174,15 @@ pub fn parse_service_config_block( tokens: Rc, ctx: Rc, ) -> Rc { - parse_config_fields(tokens.clone(), ctx.clone(), None, None, None, None, None) + parse_config_fields( + tokens.clone(), + ctx.clone(), + std::option::Option::None, + std::option::Option::None, + std::option::Option::None, + std::option::Option::None, + std::option::Option::None, + ) } pub fn parse_config_fields( @@ -8195,7 +8210,7 @@ pub fn parse_config_fields( }), }), Rc::new(vec![]), - None, + std::option::Option::None, crate::v1_std_core::no_span(), ), }, @@ -8208,7 +8223,7 @@ pub fn parse_config_fields( config: cfg.clone(), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }); } else { let dummy_cfg = Rc::new(ServiceConfig { @@ -8220,13 +8235,13 @@ pub fn parse_config_fields( }), }), Rc::new(vec![]), - None, + std::option::Option::None, crate::v1_std_core::no_span(), ), - auth: None, - auth_input: None, - auth_source: None, - rate_limit: None, + auth: std::option::Option::None, + auth_input: std::option::Option::None, + auth_source: std::option::Option::None, + rate_limit: std::option::Option::None, }); let r = expect_ident(tokens.clone()); if has_err(r.err.clone()) { @@ -8319,7 +8334,7 @@ pub fn parse_transport_binding( }; let sh = match tok.clone() { Some(t) => Some(t.shape.clone()), - None => None, + None => std::option::Option::None, }; match sh.clone() { Some(TokenShape::ShIdent) => { @@ -8363,7 +8378,7 @@ pub fn parse_transport_binding( transport: r2.transport.clone(), tokens: r3.tokens.clone(), ctx: r2.ctx.clone(), - err: None, + err: std::option::Option::None, }) } } else { @@ -8409,7 +8424,7 @@ pub fn parse_transport_binding( transport: r2.transport.clone(), tokens: r3.tokens.clone(), ctx: r2.ctx.clone(), - err: None, + err: std::option::Option::None, }) } } else { @@ -8455,7 +8470,7 @@ pub fn parse_transport_binding( transport: r2.transport.clone(), tokens: r3.tokens.clone(), ctx: r2.ctx.clone(), - err: None, + err: std::option::Option::None, }) } } else { @@ -8463,7 +8478,7 @@ pub fn parse_transport_binding( transport: dummy.clone(), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }) } } @@ -8473,7 +8488,7 @@ pub fn parse_transport_binding( transport: dummy.clone(), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }), } } @@ -8486,12 +8501,12 @@ pub fn parse_rest_binding_body( parse_rest_fields( tokens.clone(), ctx.clone(), - None, - None, - None, - None, - None, - None, + std::option::Option::None, + std::option::Option::None, + std::option::Option::None, + std::option::Option::None, + std::option::Option::None, + std::option::Option::None, Rc::new(vec![]), ) } @@ -8527,7 +8542,7 @@ pub fn parse_rest_fields( }), }), Rc::new(vec![]), - None, + std::option::Option::None, crate::v1_std_core::no_span(), ), }; @@ -8547,7 +8562,7 @@ pub fn parse_rest_fields( ), tokens: tokens.clone(), ctx: minted.ctx.clone(), - err: None, + err: std::option::Option::None, }); } else { let r = expect_ident(tokens.clone()); @@ -8689,7 +8704,12 @@ pub fn parse_shell_binding_body( tokens: Rc, ctx: Rc, ) -> Rc { - parse_shell_fields(tokens.clone(), ctx.clone(), Rc::new(vec![]), None) + parse_shell_fields( + tokens.clone(), + ctx.clone(), + Rc::new(vec![]), + std::option::Option::None, + ) } pub fn parse_shell_fields( @@ -8719,7 +8739,7 @@ pub fn parse_shell_fields( ), tokens: tokens.clone(), ctx: minted.ctx.clone(), - err: None, + err: std::option::Option::None, }); } else { let r = expect_ident(tokens.clone()); @@ -8834,7 +8854,12 @@ pub fn parse_file_binding_body( tokens: Rc, ctx: Rc, ) -> Rc { - parse_file_fields(tokens.clone(), ctx.clone(), None, None) + parse_file_fields( + tokens.clone(), + ctx.clone(), + std::option::Option::None, + std::option::Option::None, + ) } pub fn parse_file_fields( @@ -8865,7 +8890,7 @@ pub fn parse_file_fields( ), tokens: tokens.clone(), ctx: minted.ctx.clone(), - err: None, + err: std::option::Option::None, }); } None => { @@ -8956,14 +8981,14 @@ pub fn parse_operation_def(tokens: Rc, ctx: Rc) -> Rc let dummy_op = make_operation_node( Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), "".to_string(), - None, + std::option::Option::None, Rc::new(vec![]), Rc::new(vec![]), Rc::new(vec![]), Rc::new(vec![]), Rc::new(vec![]), Rc::new(vec![]), - None, + std::option::Option::None, start_span.clone(), ctx.source_indices.clone(), ); @@ -9024,14 +9049,14 @@ pub fn parse_operation_v2_inline( let dummy_op = make_operation_node( Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), "".to_string(), - None, + std::option::Option::None, Rc::new(vec![]), Rc::new(vec![]), Rc::new(vec![]), Rc::new(vec![]), Rc::new(vec![]), Rc::new(vec![]), - None, + std::option::Option::None, start_span.clone(), ctx.source_indices.clone(), ); @@ -9123,7 +9148,7 @@ pub fn parse_operation_v2_inline( mock_r.mocks.clone(), Rc::new(vec![]), mod_props.clone(), - None, + std::option::Option::None, start_span.clone(), ctx.source_indices.clone(), ); @@ -9131,7 +9156,7 @@ pub fn parse_operation_v2_inline( operation: op.clone(), tokens: tokens.clone(), ctx: minted.ctx.clone(), - err: None, + err: std::option::Option::None, }) } } @@ -9147,14 +9172,14 @@ pub fn parse_operation_v1_body( let dummy_op = make_operation_node( Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), "".to_string(), - None, + std::option::Option::None, Rc::new(vec![]), Rc::new(vec![]), Rc::new(vec![]), Rc::new(vec![]), Rc::new(vec![]), Rc::new(vec![]), - None, + std::option::Option::None, start_span.clone(), ctx.source_indices.clone(), ); @@ -9174,7 +9199,7 @@ pub fn parse_operation_v1_body( Rc::new(vec![]), Rc::new(vec![]), Rc::new(vec![]), - None, + std::option::Option::None, Rc::new(vec![]), Rc::new(vec![]), Rc::new(vec![]), @@ -9218,7 +9243,7 @@ pub fn parse_operation_v1_body( operation: op.clone(), tokens: skip_newlines(r3.tokens.clone()), ctx: minted.ctx.clone(), - err: None, + err: std::option::Option::None, }) } } @@ -9248,14 +9273,14 @@ pub fn parse_op_body_entries( mock_props: mock_props.clone(), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }); if (tok_is_rbrace(tok.clone()) || tok_is_eof(tok.clone())) { break mk_result; } else { let sh = match tok.clone() { Some(t) => Some(t.shape.clone()), - None => None, + None => std::option::Option::None, }; match sh.clone() { Some(TokenShape::ShKeyword) => { @@ -9830,7 +9855,7 @@ pub fn node_to_name_str( None => v1_rt::concat(opt_prefix.clone(), effective_name.clone()), } } else { - if (effective_n.type_annotation.clone() != None) { + if (effective_n.type_annotation.clone() != std::option::Option::None) { match effective_n.children.clone().first().cloned() { Some(ch) => v1_rt::concat( opt_prefix.clone(), @@ -9848,7 +9873,7 @@ pub fn node_to_name_str( None => v1_rt::concat(opt_prefix.clone(), effective_name.clone()), } } else { - if (effective_n.ident_span.clone() == None) { + if (effective_n.ident_span.clone() == std::option::Option::None) { { let is_conj = (effective_n.connective.clone() == Connective::Conj); let is_disj = (effective_n.connective.clone() == Connective::Disj); @@ -9889,7 +9914,7 @@ pub fn parse_exit_entries_acc( entries: acc.clone(), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }); } else { let r = parse_status_pattern(tokens.clone(), ctx.clone()); @@ -9923,7 +9948,7 @@ pub fn parse_exit_entries_acc( let desc_tok = token_stream_first(r3.tokens.clone()); let desc_sh = match desc_tok.clone() { Some(t) => Some(t.shape.clone()), - None => None, + None => std::option::Option::None, }; let desc_tokens = match desc_sh.clone() { Some(TokenShape::ShLitStr) => token_stream_advance(r3.tokens.clone(), 1), @@ -9939,9 +9964,11 @@ pub fn parse_exit_entries_acc( crate::v1_std_core::make_named_expr_node( r3.type_expr.clone().occurrence_identity.clone(), type_name.clone(), - Rc::new(ExprData::ExprVar { binding_kind: None }), + Rc::new(ExprData::ExprVar { + binding_kind: std::option::Option::None, + }), Rc::new(vec![]), - None, + std::option::Option::None, r3.type_expr.clone().span.clone(), r3.type_expr.clone().span.clone(), ), @@ -10027,7 +10054,7 @@ pub fn parse_operation_modifiers_acc( properties: acc.clone(), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }); } } @@ -10040,7 +10067,7 @@ pub fn parse_status_pattern(tokens: Rc, ctx: Rc) -> R let tok = token_stream_first(tokens.clone()); let sh = match tok.clone() { Some(t) => Some(t.shape.clone()), - None => None, + None => std::option::Option::None, }; let span = token_span(tok.clone()); match sh.clone() { @@ -10065,7 +10092,7 @@ pub fn parse_status_pattern(tokens: Rc, ctx: Rc) -> R ), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }) } }; @@ -10086,7 +10113,7 @@ pub fn parse_status_pattern(tokens: Rc, ctx: Rc) -> R }), }), Rc::new(vec![]), - None, + std::option::Option::None, span.clone(), ) }, @@ -10104,7 +10131,7 @@ pub fn parse_status_pattern(tokens: Rc, ctx: Rc) -> R }), }), Rc::new(vec![]), - None, + std::option::Option::None, span.clone(), ) }, @@ -10121,7 +10148,7 @@ pub fn parse_status_pattern(tokens: Rc, ctx: Rc) -> R value: Rc::new(LiteralValue::LitInt { value: n.clone() }), }), Rc::new(vec![]), - None, + std::option::Option::None, span.clone(), ) }, @@ -10140,7 +10167,7 @@ pub fn parse_status_pattern(tokens: Rc, ctx: Rc) -> R value: Rc::new(LiteralValue::LitStr { value: id.clone() }), }), Rc::new(vec![]), - None, + std::option::Option::None, span.clone(), ) }, @@ -10158,7 +10185,7 @@ pub fn parse_status_pattern(tokens: Rc, ctx: Rc) -> R }), }), Rc::new(vec![]), - None, + std::option::Option::None, span.clone(), ) }, @@ -10218,7 +10245,7 @@ pub fn parse_optional_response_block( responses: r2.entries.clone(), tokens: r3.tokens.clone(), ctx: r2.ctx.clone(), - err: None, + err: std::option::Option::None, }) } } else { @@ -10226,7 +10253,7 @@ pub fn parse_optional_response_block( responses: Rc::new(vec![]), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }) } } @@ -10253,7 +10280,7 @@ pub fn parse_response_entries_acc( entries: acc.clone(), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }); } else { let r = parse_status_pattern(tokens.clone(), ctx.clone()); @@ -10294,9 +10321,11 @@ pub fn parse_response_entries_acc( crate::v1_std_core::make_named_expr_node( r3.type_expr.clone().occurrence_identity.clone(), type_name.clone(), - Rc::new(ExprData::ExprVar { binding_kind: None }), + Rc::new(ExprData::ExprVar { + binding_kind: std::option::Option::None, + }), Rc::new(vec![]), - None, + std::option::Option::None, r3.type_expr.clone().span.clone(), r3.type_expr.clone().span.clone(), ), @@ -10370,7 +10399,7 @@ pub fn parse_optional_mock_response_block( mocks: r2.entries.clone(), tokens: r3.tokens.clone(), ctx: r2.ctx.clone(), - err: None, + err: std::option::Option::None, }) } } else { @@ -10378,7 +10407,7 @@ pub fn parse_optional_mock_response_block( mocks: Rc::new(vec![]), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }) } } @@ -10405,7 +10434,7 @@ pub fn parse_mock_response_entries_acc( entries: acc.clone(), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }); } else { let r = parse_status_pattern(tokens.clone(), ctx.clone()); @@ -10440,7 +10469,7 @@ pub fn parse_mock_response_entries_acc( let desc_tok = token_stream_first(r3.tokens.clone()); let desc_sh = match desc_tok.clone() { Some(t) => Some(t.shape.clone()), - None => None, + None => std::option::Option::None, }; let desc_tokens = match desc_sh.clone() { Some(TokenShape::ShLitStr) => token_stream_advance(r3.tokens.clone(), 1), @@ -10479,20 +10508,20 @@ pub fn parse_resource_def(tokens: Rc, ctx: Rc) -> Rc< occurrence_identity: Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), name: "".to_string(), span: start_span.clone(), - ident_span: None, + ident_span: std::option::Option::None, children: Rc::new(vec![]), params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, + body: std::option::Option::None, connective: Connective::NoConnective, - transport: None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -10524,20 +10553,20 @@ pub fn parse_resource_after_kw( occurrence_identity: Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), name: "".to_string(), span: start_span.clone(), - ident_span: None, + ident_span: std::option::Option::None, children: Rc::new(vec![]), params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, + body: std::option::Option::None, connective: Connective::NoConnective, - transport: None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -10559,17 +10588,17 @@ pub fn parse_resource_after_kw( ident_span: Some(name_span.clone()), children: Rc::new(vec![]), params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, + body: std::option::Option::None, connective: Connective::NoConnective, - transport: None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -10616,17 +10645,17 @@ pub fn parse_resource_after_kw( ident_span: Some(name_span.clone()), children: r.capabilities.clone(), params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, + body: std::option::Option::None, connective: Connective::NoConnective, - transport: None, + transport: std::option::Option::None, properties: r.properties.clone(), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -10634,7 +10663,7 @@ pub fn parse_resource_after_kw( item: item.clone(), tokens: skip_newlines(r2.tokens.clone()), ctx: minted.ctx.clone(), - err: None, + err: std::option::Option::None, }) } } @@ -10655,12 +10684,12 @@ pub fn parse_resource_entries( capabilities: capabilities.clone(), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }); } else { let sh = match tok.clone() { Some(t) => Some(t.shape.clone()), - None => None, + None => std::option::Option::None, }; match sh.clone() { Some(TokenShape::ShKeyword) => { @@ -10853,13 +10882,13 @@ pub fn skip_until_rbrace(tokens: Rc) -> Rc { if (tok_is_rbrace(tok.clone()) || tok_is_eof(tok.clone())) { Rc::new(UnitResult { tokens: tokens.clone(), - err: None, + err: std::option::Option::None, }) } else { { let sh = match tok.clone() { Some(t) => Some(t.shape.clone()), - None => None, + None => std::option::Option::None, }; match sh.clone() { Some(TokenShape::ShLBrace) => { @@ -10886,7 +10915,7 @@ pub fn parse_capability(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { @@ -11681,7 +11710,7 @@ pub fn parse_param(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> expr: census_heads_body_stand_in(), tokens: skipped.tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }) } } @@ -11861,7 +11890,7 @@ pub fn parse_block(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc Some(t.shape.clone()), - None => None, + None => std::option::Option::None, }; match sh.clone() { Some(TokenShape::ShKeyword) => { @@ -12050,17 +12079,17 @@ pub fn parse_constrained_assignment( ident_span: Some(name_span.clone()), children: Rc::new(vec![r3.expr.clone()]), params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, + body: std::option::Option::None, connective: Connective::NoConnective, - transport: None, + transport: std::option::Option::None, properties: cr.constraints.clone(), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::ExprLet), ident: None, }) @@ -12141,13 +12170,13 @@ pub fn parse_node_decl(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> ident_span: Some(name_span.clone()), children: Rc::new(vec![r3.expr.clone()]), params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, + body: std::option::Option::None, connective: Connective::NoConnective, - transport: None, + transport: std::option::Option::None, properties: cr.constraints.clone(), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::ExprLet), ident: None, }) @@ -12250,7 +12279,7 @@ pub fn parse_expr_loop( expr: lhs.clone(), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }); } else { let loop_span = token_span(token_stream_first(tokens.clone())); @@ -12283,7 +12312,7 @@ pub fn parse_expr_loop( expr: lhs.clone(), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }); } else { match (*advance(tokens.clone())).clone() { @@ -12308,10 +12337,10 @@ pub fn parse_expr_loop( minted.identity.clone(), r.name.clone(), Rc::new(ExprData::ExprFieldAccess { - summary: None, + summary: std::option::Option::None, }), Rc::new(vec![lhs.clone()]), - None, + std::option::Option::None, loop_span.clone(), r.span.clone(), ); @@ -12378,13 +12407,14 @@ pub fn parse_expr_loop( minted.identity.clone(), Rc::new(ExprData::ExprBinOp { op: binop.clone(), - algebra_field: None, + algebra_field: + std::option::Option::None, }), Rc::new(vec![ lhs.clone(), r.expr.clone(), ]), - None, + std::option::Option::None, loop_span.clone(), ); { @@ -12421,7 +12451,7 @@ pub fn parse_expr_loop( expr: lhs.clone(), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }); } } @@ -12432,7 +12462,7 @@ pub fn parse_expr_loop( expr: lhs.clone(), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }); } } @@ -12445,7 +12475,7 @@ pub fn parse_expr_loop( pub fn infix_bp(tokens: Rc) -> Option { match token_stream_first(tokens.clone()) { Some(t) => find_operator_bp(dag_syntax_spec().operators.clone(), t.text.clone()), - None => None, + None => std::option::Option::None, } } @@ -12481,18 +12511,22 @@ pub fn parse_pipe_callee_rest( None => crate::v1_std_core::make_named_expr_node( minted.identity.clone(), name.clone(), - Rc::new(ExprData::ExprVar { binding_kind: None }), + Rc::new(ExprData::ExprVar { + binding_kind: std::option::Option::None, + }), Rc::new(vec![]), - None, + std::option::Option::None, name_span.clone(), name_span.clone(), ), Some(base) => crate::v1_std_core::make_named_expr_node( minted.identity.clone(), name.clone(), - Rc::new(ExprData::ExprFieldAccess { summary: None }), + Rc::new(ExprData::ExprFieldAccess { + summary: std::option::Option::None, + }), Rc::new(vec![base.clone()]), - None, + std::option::Option::None, name_span.clone(), name_span.clone(), ), @@ -12517,7 +12551,7 @@ pub fn parse_pipe_callee_rest( method_span: name_span.clone(), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }); } } @@ -12543,7 +12577,7 @@ pub fn parse_pipe_rhs( let dotted = parse_pipe_callee_rest( r.tokens.clone(), ctx.clone(), - None, + std::option::Option::None, r.name.clone(), r.span.clone(), ); @@ -12559,12 +12593,12 @@ pub fn parse_pipe_rhs( dotted.clone() } else { Rc::new(PipeCalleeResult { - spine: None, + spine: std::option::Option::None, method: r.name.clone(), method_span: r.span.clone(), tokens: r.tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }) }; let method = callee.method.clone(); @@ -12580,7 +12614,7 @@ pub fn parse_pipe_rhs( qualifier.clone(), crate::v1_std_core::make_arg_node( wrapper_mint.identity.clone(), - None, + std::option::Option::None, receiver.clone(), receiver.span.clone(), receiver.span.clone(), @@ -12607,7 +12641,7 @@ pub fn parse_pipe_rhs( identity.clone(), method.clone(), Rc::new(ExprData::ExprMethodCall { - method_semantics: None, + method_semantics: std::option::Option::None, }), v1_rt::concat( leading_result.nodes.clone(), @@ -12628,7 +12662,7 @@ pub fn parse_pipe_rhs( __result }), ), - None, + std::option::Option::None, span.clone(), callee.method_span.clone(), ) @@ -12640,10 +12674,10 @@ pub fn parse_pipe_rhs( identity.clone(), method.clone(), Rc::new(ExprData::ExprMethodCall { - method_semantics: None, + method_semantics: std::option::Option::None, }), leading_result.nodes.clone(), - None, + std::option::Option::None, span.clone(), callee.method_span.clone(), ) @@ -12657,7 +12691,7 @@ pub fn parse_prefix(tokens: Rc, ctx: Rc) -> Rc Some(t.shape.clone()), - None => None, + None => std::option::Option::None, }; let span = token_span(tok.clone()); match sh.clone() { @@ -12678,7 +12712,7 @@ pub fn parse_prefix(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc Some(t.shape.clone()), - None => None, + None => std::option::Option::None, }; match next_shape.clone() { Some(TokenShape::ShIdent) => { @@ -12738,7 +12772,7 @@ pub fn parse_caret_expr(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { @@ -12827,7 +12863,7 @@ pub fn parse_primary(tokens: Rc, ctx: Rc) -> Rc Some(t.shape.clone()), - None => None, + None => std::option::Option::None, }; let span = token_span(tok.clone()); match sh.clone() { @@ -12844,7 +12880,7 @@ pub fn parse_primary(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc Some(t.shape.clone()), - None => None, + None => std::option::Option::None, }; let span = token_span(tok.clone()); match sh.clone() { @@ -13168,7 +13206,7 @@ pub fn try_postfix( changed: false, tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }) } else { { @@ -13195,7 +13233,7 @@ pub fn try_postfix( changed: true, tokens: r.tokens.clone(), ctx: minted.ctx.clone(), - err: None, + err: std::option::Option::None, }) } } @@ -13208,7 +13246,7 @@ pub fn try_postfix( changed: false, tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }) } else { { @@ -13231,13 +13269,13 @@ pub fn try_postfix( minted.identity.clone(), Rc::new(ExprData::ExprCast), Rc::new(vec![lhs.clone(), r.type_expr.clone()]), - None, + std::option::Option::None, span.clone(), ), changed: true, tokens: r.tokens.clone(), ctx: minted.ctx.clone(), - err: None, + err: std::option::Option::None, }) } } @@ -13247,7 +13285,7 @@ pub fn try_postfix( changed: false, tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }) } } @@ -13258,7 +13296,7 @@ pub fn try_postfix( changed: false, tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }) } else { if is_constraint_bracket(tokens.clone()) { @@ -13267,7 +13305,7 @@ pub fn try_postfix( changed: false, tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }) } else { { @@ -13291,7 +13329,7 @@ pub fn try_postfix( changed: true, tokens: r.tokens.clone(), ctx: r.ctx.clone(), - err: None, + err: std::option::Option::None, }) } } @@ -13311,7 +13349,7 @@ pub fn try_postfix( changed: false, tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }) } else { if is_uppercase_start(n.clone()) { @@ -13336,7 +13374,7 @@ pub fn try_postfix( changed: true, tokens: r.tokens.clone(), ctx: r.ctx.clone(), - err: None, + err: std::option::Option::None, }) } } else { @@ -13345,7 +13383,7 @@ pub fn try_postfix( changed: false, tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }) } } @@ -13361,7 +13399,7 @@ pub fn try_postfix( changed: false, tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }) } else { if is_uppercase_start(last_seg.clone()) { @@ -13391,7 +13429,7 @@ pub fn try_postfix( changed: true, tokens: r.tokens.clone(), ctx: r.ctx.clone(), - err: None, + err: std::option::Option::None, }) } None => Rc::new(PostfixResult { @@ -13399,7 +13437,7 @@ pub fn try_postfix( changed: false, tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }), } } else { @@ -13408,7 +13446,7 @@ pub fn try_postfix( changed: false, tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }) } } @@ -13418,7 +13456,7 @@ pub fn try_postfix( changed: false, tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }), }, _ => Rc::new(PostfixResult { @@ -13426,7 +13464,7 @@ pub fn try_postfix( changed: false, tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }), } } @@ -13476,14 +13514,14 @@ pub fn parse_constraint_annotations( constraints: r.constraints.clone(), tokens: r2.tokens.clone(), ctx: r.ctx.clone(), - err: None, + err: std::option::Option::None, }) } EatResult::EatUnchanged { tokens: __eu, .. } => Rc::new(ConstraintsResult { constraints: Rc::new(vec![]), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }), } } @@ -13509,7 +13547,7 @@ pub fn parse_constraint_list( constraints: acc.clone(), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }); } let kw_name = tok.clone().unwrap().text.clone(); @@ -13544,7 +13582,7 @@ pub fn parse_constraint_list( constraints: acc.clone(), tokens: r.tokens.clone(), ctx: minted.ctx.clone(), - err: None, + err: std::option::Option::None, }); } } @@ -13562,7 +13600,7 @@ pub fn try_constraint_annotations( constraints: Rc::new(vec![]), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }) } } @@ -13581,11 +13619,11 @@ pub fn make_call_expr( occurrence_identity.clone(), crate::v1_std_core::expr_var_name_at(lhs.clone(), source_indices.clone()), Rc::new(ExprData::ExprCall { - call_semantics: None, - descent_evidence: None, + call_semantics: std::option::Option::None, + descent_evidence: std::option::Option::None, }), args.clone(), - None, + std::option::Option::None, lhs.span.clone(), crate::v1_std_core::node_name_span(lhs.clone()), ), @@ -13593,13 +13631,13 @@ pub fn make_call_expr( occurrence_identity.clone(), crate::v1_std_core::field_access_field_at(lhs.clone(), source_indices.clone()), Rc::new(ExprData::ExprMethodCall { - method_semantics: None, + method_semantics: std::option::Option::None, }), v1_rt::concat( Rc::new(vec![lhs.children.clone().first().cloned().clone().unwrap()]), args.clone(), ), - None, + std::option::Option::None, lhs.span.clone(), crate::v1_std_core::node_name_span(lhs.clone()), ), @@ -13607,11 +13645,11 @@ pub fn make_call_expr( occurrence_identity.clone(), "".to_string(), Rc::new(ExprData::ExprCall { - call_semantics: None, - descent_evidence: None, + call_semantics: std::option::Option::None, + descent_evidence: std::option::Option::None, }), args.clone(), - None, + std::option::Option::None, lhs.span.clone(), crate::v1_std_core::no_span(), ), @@ -13674,7 +13712,7 @@ pub fn parse_index_or_slice( identity.clone(), Rc::new(ExprData::ExprSlice), Rc::new(vec![base.clone(), first_expr.clone(), end_expr.clone()]), - None, + std::option::Option::None, span.clone(), ) }) @@ -13695,7 +13733,7 @@ pub fn parse_index_or_slice( identity.clone(), Rc::new(ExprData::ExprIndex), Rc::new(vec![base.clone(), first_expr.clone()]), - None, + std::option::Option::None, span.clone(), ) }) @@ -13721,7 +13759,7 @@ pub fn parse_call_args(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> R expr: r.stmts.clone().first().cloned().clone().unwrap(), tokens: r.tokens.clone(), ctx: r.ctx.clone(), - err: None, + err: std::option::Option::None, }) } else { parsed_expr_result(r.tokens.clone(), r.ctx.clone(), |identity| { @@ -14451,7 +14492,7 @@ pub fn parse_match_arm_body(tokens: Rc, ctx: Rc) -> R identity.clone(), Rc::new(ExprData::ExprBlock), r.stmts.clone(), - None, + std::option::Option::None, span.clone(), ) }) @@ -14477,7 +14518,7 @@ pub fn parse_match_arm_stmts( stmts: acc.clone(), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }); } else { if looks_like_arm_start(tokens.clone()) { @@ -14485,7 +14526,7 @@ pub fn parse_match_arm_stmts( stmts: acc.clone(), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }); } else { let r = parse_stmt(tokens.clone(), ctx.clone()); @@ -14577,7 +14618,7 @@ pub fn looks_like_arm_start(tokens: Rc) -> bool { let tok = token_stream_first(tokens.clone()); let sh = match tok.clone() { Some(t) => Some(t.shape.clone()), - None => None, + None => std::option::Option::None, }; match sh.clone() { Some(TokenShape::ShIdent) => { @@ -14684,7 +14725,7 @@ pub fn parse_optional_guard(tokens: Rc, ctx: Rc) -> R let r = parse_expr(token_stream_advance(tokens.clone(), 1), ctx.clone()); if has_err(r.err.clone()) { return Rc::new(GuardResult { - guard: None, + guard: std::option::Option::None, tokens: r.tokens.clone(), ctx: r.ctx.clone(), err: r.err.clone(), @@ -14694,15 +14735,15 @@ pub fn parse_optional_guard(tokens: Rc, ctx: Rc) -> R guard: Some(r.expr.clone()), tokens: r.tokens.clone(), ctx: r.ctx.clone(), - err: None, + err: std::option::Option::None, }) } } else { Rc::new(GuardResult { - guard: None, + guard: std::option::Option::None, tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }) } } @@ -14712,7 +14753,7 @@ pub fn parse_pattern(tokens: Rc, ctx: Rc) -> Rc Some(t.shape.clone()), - None => None, + None => std::option::Option::None, }; let span = token_span(tok.clone()); match sh.clone() { @@ -14732,7 +14773,7 @@ pub fn parse_pattern(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc Rc::new(PatternResult { pattern: Rc::new(MatchPattern::Wildcard), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }), } } @@ -14805,7 +14846,7 @@ pub fn parse_pattern(tokens: Rc, ctx: Rc) -> Rc { @@ -14816,14 +14857,14 @@ pub fn parse_pattern(tokens: Rc, ctx: Rc) -> Rc Rc::new(PatternResult { pattern: Rc::new(MatchPattern::Wildcard), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }), } } @@ -14865,12 +14906,12 @@ pub fn parse_variant_pattern( Rc::new(PatternResult { pattern: Rc::new(MatchPattern::VariantPattern { name: name.clone(), - parent_enum: None, + parent_enum: std::option::Option::None, field_bindings: r.field_bindings.clone(), }), tokens: r2.tokens.clone(), ctx: r.ctx.clone(), - err: None, + err: std::option::Option::None, }) } } else { @@ -14905,24 +14946,24 @@ pub fn parse_variant_pattern( Rc::new(PatternResult { pattern: Rc::new(MatchPattern::VariantPattern { name: name.clone(), - parent_enum: None, + parent_enum: std::option::Option::None, field_bindings: Rc::new(vec![fb.clone()]), }), tokens: r2.tokens.clone(), ctx: minted.ctx.clone(), - err: None, + err: std::option::Option::None, }) } } else { Rc::new(PatternResult { pattern: Rc::new(MatchPattern::VariantPattern { name: name.clone(), - parent_enum: None, + parent_enum: std::option::Option::None, field_bindings: Rc::new(vec![]), }), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }) } } @@ -14950,7 +14991,7 @@ pub fn parse_variant_bindings_brace_acc( field_bindings: acc.clone(), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }); } else { let bind_span = token_span(token_stream_first(tokens.clone())); @@ -15111,7 +15152,7 @@ pub fn parse_if(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc { @@ -15289,7 +15330,7 @@ pub fn parse_let(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc< identity.clone(), Rc::new(ExprData::ExprListLit), r.exprs.clone(), - None, + std::option::Option::None, span.clone(), ) }) @@ -15774,7 +15819,7 @@ pub fn parse_expr_list_until_acc( exprs: acc.clone(), tokens: tokens.clone(), ctx: ctx.clone(), - err: None, + err: std::option::Option::None, }); } else { let r = parse_expr(tokens.clone(), ctx.clone()); @@ -15823,9 +15868,11 @@ pub fn parse_paren_expr(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc let span = token_span(tok.clone()); let sh = match tok.clone() { Some(t) => Some(t.shape.clone()), - None => None, + None => std::option::Option::None, }; match sh.clone() { Some(TokenShape::ShStrBegin) => { @@ -16222,7 +16269,7 @@ pub fn parse_interp_parts( let interp_tok = token_stream_first(tokens.clone()); let interp_sh = match interp_tok.clone() { Some(t) => Some(t.shape.clone()), - None => None, + None => std::option::Option::None, }; match interp_sh.clone() { Some(TokenShape::ShStrMid) => { @@ -16269,7 +16316,7 @@ pub fn parse_interp_parts( identity.clone(), Rc::new(ExprData::ExprStringInterp), children.nodes.clone(), - None, + std::option::Option::None, span.clone(), ) }, @@ -16302,12 +16349,15 @@ pub fn parse_interp_parts( } __result }), - None, + std::option::Option::None, span.clone(), ), tokens: tokens.clone(), ctx: ctx.clone(), - err: Some(parse_error(interp_body_error_message(None), span.clone())), + err: Some(parse_error( + interp_body_error_message(std::option::Option::None), + span.clone(), + )), }); } } @@ -16327,9 +16377,11 @@ pub fn parse_brace_expr(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc Some(t.shape.clone()), - None => None, + None => std::option::Option::None, }; match sh.clone() { Some(TokenShape::ShKeyword) => { @@ -16372,7 +16424,7 @@ pub fn parse_brace_expr(tokens: Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc, ctx: Rc) -> Rc Option { if ((cp.clone() >= 65) && (cp.clone() <= 70)) { Some((cp.clone() - 55)) } else { - None + std::option::Option::None } } } @@ -1223,9 +1223,9 @@ pub fn hex_escape_char(hi: i64, lo: i64) -> Option { match hex_digit_value(hi.clone()) { Some(h) => match hex_digit_value(lo.clone()) { Some(l) => Some(((h.clone() * 16) + l.clone())), - None => None, + None => std::option::Option::None, }, - None => None, + None => std::option::Option::None, } } @@ -1243,7 +1243,7 @@ pub fn unicode_escape_at( ) -> Option { loop { if (pos.clone() >= (source.clone().len() as i64)) { - break None; + break std::option::Option::None; } else { let ch = code_point_at(source.clone(), pos.clone()); if (ch.clone() == 125) { @@ -1255,11 +1255,11 @@ pub fn unicode_escape_at( next_pos: (pos.clone() + 1), }); } else { - break None; + break std::option::Option::None; } } else { if (digit_count.clone() >= 6) { - break None; + break std::option::Option::None; } else { match hex_digit_value(ch.clone()) { Some(digit) => { @@ -1272,7 +1272,7 @@ pub fn unicode_escape_at( continue; } None => { - break None; + break std::option::Option::None; } } } @@ -1358,7 +1358,7 @@ pub fn process_escapes_loop( if (next.clone() == 125) { Some(125) } else { - None + std::option::Option::None } } } diff --git a/src/v1/stage0/src/v1_compiler_trace.rs b/src/v1/stage0/src/v1_compiler_trace.rs index 2069be866eb..66230b53f23 100644 --- a/src/v1/stage0/src/v1_compiler_trace.rs +++ b/src/v1/stage0/src/v1_compiler_trace.rs @@ -273,7 +273,7 @@ pub fn capture_repro( Rc::new(ReproCase { func_name: func_name.clone(), inputs: inputs.clone(), - expected_output: None, + expected_output: std::option::Option::None, trace: Some(trace.clone()), }) } diff --git a/src/v1/stage0/src/v1_compiler_trait_derive_emit.rs b/src/v1/stage0/src/v1_compiler_trait_derive_emit.rs index 781fe50ba50..37c4eb959c3 100644 --- a/src/v1/stage0/src/v1_compiler_trait_derive_emit.rs +++ b/src/v1/stage0/src/v1_compiler_trait_derive_emit.rs @@ -3204,7 +3204,7 @@ pub fn v1_type_expr_head_is_known( type_decl_items: Rc>>, ) -> bool { (crate::std_types::is_container_type(name.clone()) - || (v1_rt::map_get(&type_decl_items, name.clone()) != None)) + || (v1_rt::map_get(&type_decl_items, name.clone()) != std::option::Option::None)) } pub fn v1_item_generic_param_name_set( @@ -4059,31 +4059,31 @@ pub fn v1_item_wf_propagated_clone_bounded_param_names( item: Rc, generic_param_names: Rc>, bounds: Rc>>>, + type_decl_items: Rc>>, source_indices: Rc>>, ) -> Rc> { - { - let field_type_exprs = v1_item_field_type_exprs(item.clone(), source_indices.clone()); - Rc::new({ - let mut __result = Vec::new(); - for g in v1_item_clone_bounded_param_names( - item_name.clone(), - generic_param_names.clone(), + Rc::new({ + let mut __result = Vec::new(); + for g in v1_item_clone_bounded_param_names( + item_name.clone(), + generic_param_names.clone(), + bounds.clone(), + ) + .iter() + .cloned() + { + if v1_item_param_wf_needs_clone( + g.clone(), + item.clone(), bounds.clone(), - ) - .iter() - .cloned() - { - if !v1_item_type_param_needs_clone_bound_struct( - g.clone(), - field_type_exprs.clone(), - source_indices.clone(), - ) { - __result.push(g); - } + type_decl_items.clone(), + source_indices.clone(), + ) { + __result.push(g); } - __result - }) - } + } + __result + }) } pub fn v1_emit_type_params_with_clone_bounds( diff --git a/src/v1/stage0/src/v1_gunbc_occurrence_binding_parser_walk.rs b/src/v1/stage0/src/v1_gunbc_occurrence_binding_parser_walk.rs index 8c1b11e70da..ed4782f1e07 100644 --- a/src/v1/stage0/src/v1_gunbc_occurrence_binding_parser_walk.rs +++ b/src/v1/stage0/src/v1_gunbc_occurrence_binding_parser_walk.rs @@ -167,7 +167,7 @@ pub fn reference_named( .cloned() { Some(reference) => Some(reference.clone()), - None => None, + None => std::option::Option::None, } } @@ -223,7 +223,7 @@ pub fn index_entry_for_occurrence( .iter() .cloned() .fold( - None, + std::option::Option::None, |found: _, entry: Rc| match found.clone() { Some(_) => found.clone(), None => match (entry.projection.clone().occurrence.clone().value.clone() @@ -248,7 +248,7 @@ pub fn occurrence_id_for_authored_name( .iter() .cloned() .fold( - None, + std::option::Option::None, |found: _, entry: Rc| match found.clone() { Some(_) => found.clone(), None => match (entry.projection.clone().authored_name.clone() == name.clone()) { @@ -258,6 +258,6 @@ pub fn occurrence_id_for_authored_name( }, ) { Some(occurrence) => Some(occurrence.clone()), - None => None, + None => std::option::Option::None, } } diff --git a/src/v1/stage0/src/v1_std_core.rs b/src/v1/stage0/src/v1_std_core.rs index bcadba6cb09..17948509024 100644 --- a/src/v1/stage0/src/v1_std_core.rs +++ b/src/v1/stage0/src/v1_std_core.rs @@ -192,8 +192,8 @@ pub enum InferredNode { pub fn inferred_to_node(inferred: Rc) -> Option> { match (*inferred.clone()).clone() { InferredNode::Resolved { node: n, .. } => Some(n.clone()), - InferredNode::CompilerError { .. } => None, - InferredNode::TypeVariable { id: _, .. } => None, + InferredNode::CompilerError { .. } => std::option::Option::None, + InferredNode::TypeVariable { id: _, .. } => std::option::Option::None, } } @@ -206,7 +206,7 @@ pub fn is_compiler_error(inferred: Rc) -> bool { } pub fn has_inferred(n: Rc) -> bool { - (n.inferred.clone() != None) + (n.inferred.clone() != std::option::Option::None) } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -910,7 +910,7 @@ pub fn diagnostic_frontier_occurrence_key( method: m.clone(), receiver_shape: t.clone(), })), - _ => None, + _ => std::option::Option::None, } } @@ -1051,7 +1051,7 @@ pub struct Node { pub fn default_ident_span(name: String, span: Rc) -> Option> { if (name.clone() == "".to_string()) { - None + std::option::Option::None } else { Some(span.clone()) } @@ -1079,20 +1079,20 @@ pub fn make_expr_node( occurrence_identity: occurrence_identity.clone(), name: "".to_string(), span: span.clone(), - ident_span: None, + ident_span: std::option::Option::None, children: children.clone(), connective: Connective::NoConnective, params: Rc::new(vec![]), inferred: inferred.clone(), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: expr_data.clone(), ident: None, }) @@ -1118,13 +1118,13 @@ pub fn make_named_expr_node( inferred: inferred.clone(), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: expr_data.clone(), ident: None, }) @@ -1140,7 +1140,7 @@ pub fn make_pattern_binder_declaration_node( name.clone(), Rc::new(ExprData::NoExprData), Rc::new(vec![]), - None, + std::option::Option::None, span.clone(), span.clone(), ) @@ -1156,7 +1156,7 @@ pub fn make_expr_error_node( occurrence_identity: occurrence_identity.clone(), name: "".to_string(), span: span.clone(), - ident_span: None, + ident_span: std::option::Option::None, children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), @@ -1166,13 +1166,13 @@ pub fn make_expr_error_node( })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::ExprError { kind: kind.clone(), message: message.clone(), @@ -1201,16 +1201,16 @@ pub fn make_arg_node( children: Rc::new(vec![value.clone()]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }) @@ -1233,17 +1233,17 @@ pub fn make_arm_node( occurrence_identity: occurrence_identity.clone(), name: "".to_string(), span: span.clone(), - ident_span: None, + ident_span: std::option::Option::None, children: children.clone(), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, match_pattern: Some(pattern.clone()), @@ -1268,16 +1268,16 @@ pub fn make_resource_use_node( children: Rc::new(vec![resource.clone()]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }) @@ -1317,16 +1317,16 @@ pub fn make_field_init_node( children: Rc::new(vec![value.clone()]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }) @@ -1347,13 +1347,13 @@ pub fn make_field_binding_node( children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, match_pattern: Some(binding.clone()), @@ -1385,20 +1385,20 @@ pub fn make_text_part_node( occurrence_identity: occurrence_identity.clone(), name: "".to_string(), span: span.clone(), - ident_span: None, + ident_span: std::option::Option::None, children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::ExprLiteral { value: Rc::new(LiteralValue::LitStr { value: text.clone(), @@ -1417,20 +1417,20 @@ pub fn make_interp_part_node( occurrence_identity: occurrence_identity.clone(), name: "".to_string(), span: span.clone(), - ident_span: None, + ident_span: std::option::Option::None, children: Rc::new(vec![expr.clone()]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }) @@ -1457,16 +1457,16 @@ pub fn make_param_node( children: children.clone(), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }) @@ -1500,13 +1500,13 @@ pub fn make_resolved_param_node( })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: properties.clone(), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }) @@ -1577,7 +1577,7 @@ pub fn find_child_named( .cloned() { Some(ch) => Some(ch.clone()), - None => None, + None => std::option::Option::None, } } @@ -1614,7 +1614,7 @@ pub fn param_node_default_value(n: Rc) -> Option> { if ((n.children.clone().len() as i64) > 1) { n.children.clone().iter().cloned().skip(1 as usize).next() } else { - None + std::option::Option::None } } @@ -1645,16 +1645,16 @@ pub fn make_field_node( children: children.clone(), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: cardinality.clone(), uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: v1_rt::concat(from_key_properties.clone(), type_expr.properties.clone()), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }) @@ -1688,7 +1688,7 @@ pub fn field_node_default_value(n: Rc) -> Option> { if ((n.children.clone().len() as i64) > 1) { n.children.clone().iter().cloned().skip(1 as usize).next() } else { - None + std::option::Option::None } } @@ -1702,7 +1702,7 @@ pub fn field_node_from_key( source_indices.clone(), ) { Some(p) => Some(authored_name_at(source_indices.clone(), p.clone())), - None => None, + None => std::option::Option::None, } } @@ -1725,16 +1725,16 @@ pub fn make_variant_node( children: fields.clone(), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }) @@ -1968,7 +1968,7 @@ pub fn arg_name_at( { let name = authored_name_at(source_indices.clone(), n.clone()); if (name.clone() == "".to_string()) { - None + std::option::Option::None } else { Some(name.clone()) } @@ -1998,7 +1998,7 @@ pub fn arm_guard(n: Rc) -> Option> { if ((n.children.clone().len() as i64) == 2) { n.children.clone().first().cloned() } else { - None + std::option::Option::None } } @@ -2067,7 +2067,7 @@ pub fn call_named_arg_string_optional( .cloned() { Some(arg) => expr_literal_string_optional(arg_value(arg.clone())), - None => None, + None => std::option::Option::None, } } @@ -2083,7 +2083,7 @@ pub fn decl_ref_coords_from_call_expr( source_indices: Rc>>, ) -> Option> { if (expr_call_func_at(expr.clone(), source_indices.clone()) != "decl_ref".to_string()) { - None + std::option::Option::None } else { match call_named_arg_string_optional( expr.clone(), @@ -2099,9 +2099,9 @@ pub fn decl_ref_coords_from_call_expr( module_path: mp.clone(), decl_name: dn.clone(), })), - None => None, + None => std::option::Option::None, }, - None => None, + None => std::option::Option::None, } } } @@ -2263,7 +2263,7 @@ pub fn field_access_field_at( pub fn expr_field_access_summary(texpr: Rc) -> Option> { match (*texpr.expr_data.clone()).clone() { ExprData::ExprFieldAccess { summary: s, .. } => s.clone(), - _ => None, + _ => std::option::Option::None, } } @@ -2297,10 +2297,10 @@ pub fn field_access_spine( field_access_field_at(texpr.clone(), source_indices.clone()), ), })), - None => None, + None => std::option::Option::None, } } - _ => None, + _ => std::option::Option::None, } }) } @@ -2318,7 +2318,7 @@ pub fn expr_call_descent_evidence(texpr: Rc) -> Option de.clone(), - _ => None, + _ => std::option::Option::None, } } @@ -2351,7 +2351,7 @@ pub fn expr_method_call_semantics(texpr: Rc) -> Option method_semantics: ms, .. } => ms.clone(), - _ => None, + _ => std::option::Option::None, } } @@ -2462,7 +2462,7 @@ pub fn record_lit_type_name_at( { let name = authored_name_at(source_indices.clone(), texpr.clone()); if (name.clone() == "".to_string()) { - None + std::option::Option::None } else { Some(name.clone()) } @@ -2615,20 +2615,20 @@ pub fn make_transport_node( occurrence_identity: occurrence_identity.clone(), name: "".to_string(), span: span.clone(), - ident_span: None, + ident_span: std::option::Option::None, children: children.clone(), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), body: body.clone(), - transport: None, + transport: std::option::Option::None, properties: properties.clone(), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }) @@ -2642,7 +2642,7 @@ pub fn local_transport_node( occurrence_identity.clone(), Rc::new(vec![]), Rc::new(vec![]), - None, + std::option::Option::None, span.clone(), ) } @@ -2744,7 +2744,7 @@ pub fn rest_transport_node( occurrence_identity.clone(), props.clone(), Rc::new(vec![]), - None, + std::option::Option::None, span.clone(), ) } @@ -2762,20 +2762,20 @@ pub fn shell_transport_node( occurrence_identity: Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), name: "".to_string(), span: span.clone(), - ident_span: None, + ident_span: std::option::Option::None, children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }); @@ -2795,20 +2795,20 @@ pub fn shell_transport_node( occurrence_identity: occurrence_identity.clone(), name: "".to_string(), span: span.clone(), - ident_span: None, + ident_span: std::option::Option::None, children: argv.clone(), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), body: Some(shell_marker.clone()), - transport: None, + transport: std::option::Option::None, properties: all_props.clone(), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }) @@ -2846,7 +2846,7 @@ pub fn file_transport_node( occurrence_identity.clone(), props.clone(), Rc::new(vec![]), - None, + std::option::Option::None, span.clone(), ) } @@ -2870,7 +2870,7 @@ pub fn find_property( .cloned() { Some(fi) => Some(field_init_node_value(fi.clone())), - None => None, + None => std::option::Option::None, } } @@ -2881,7 +2881,7 @@ pub fn find_property_string( ) -> Option { match find_property(props.clone(), prop_name.clone(), source_indices.clone()) { Some(n) => expr_literal_string_optional(n.clone()), - None => None, + None => std::option::Option::None, } } @@ -2890,20 +2890,20 @@ pub fn expr_literal_int_optional(expr: Rc) -> Option { match (*expr.expr_data.clone()).clone() { ExprData::ExprLiteral { value: lit, .. } => match (*lit.clone()).clone() { LiteralValue::LitInt { value: v, .. } => Some(v.clone()), - _ => None, + _ => std::option::Option::None, }, ExprData::ExprElaboratedLiteral { value: lit, .. } => match (*lit.clone()).clone() { LiteralValue::LitInt { value: v, .. } => Some(v.clone()), - _ => None, + _ => std::option::Option::None, }, ExprData::ExprUnaryOp { op: UnaryOpKind::Neg, .. } => match expr_literal_int_optional(unaryop_operand(expr.clone())) { Some(v) => Some((0 - v.clone())), - None => None, + None => std::option::Option::None, }, - _ => None, + _ => std::option::Option::None, } }) } @@ -2912,9 +2912,9 @@ pub fn expr_literal_string_optional(expr: Rc) -> Option { match (*expr.expr_data.clone()).clone() { ExprData::ExprLiteral { value: lit, .. } => match (*lit.clone()).clone() { LiteralValue::LitStr { value: v, .. } => Some(v.clone()), - _ => None, + _ => std::option::Option::None, }, - _ => None, + _ => std::option::Option::None, } } @@ -2922,9 +2922,9 @@ pub fn expr_literal_symbol_optional(expr: Rc) -> Option { match (*expr.expr_data.clone()).clone() { ExprData::ExprLiteral { value: lit, .. } => match (*lit.clone()).clone() { LiteralValue::LitSymbol { value: v, .. } => Some(v.clone()), - _ => None, + _ => std::option::Option::None, }, - _ => None, + _ => std::option::Option::None, } } @@ -2960,7 +2960,7 @@ pub fn expr_is_any_literal(mut expr: Rc) -> bool { pub fn record_lit_expr_optional(expr: Rc) -> Option> { match (*expr.expr_data.clone()).clone() { ExprData::ExprRecordLit { parent_enum: _, .. } => Some(expr.clone()), - _ => None, + _ => std::option::Option::None, } } @@ -2983,9 +2983,9 @@ pub fn record_lit_named_field_value_optional( .cloned() { Some(fi) => Some(field_init_node_value(fi.clone())), - None => None, + None => std::option::Option::None, }, - None => None, + None => std::option::Option::None, } } @@ -3019,23 +3019,23 @@ pub fn is_rest_transport( t: Rc, source_indices: Rc>>, ) -> bool { - (transport_base_url(t.clone(), source_indices.clone()) != None) + (transport_base_url(t.clone(), source_indices.clone()) != std::option::Option::None) } pub fn is_shell_transport(t: Rc) -> bool { - (t.body.clone() != None) + (t.body.clone() != std::option::Option::None) } pub fn is_file_transport( t: Rc, source_indices: Rc>>, ) -> bool { - (transport_base_path(t.clone(), source_indices.clone()) != None) + (transport_base_path(t.clone(), source_indices.clone()) != std::option::Option::None) } pub fn is_bare_transport(t: Rc) -> bool { ((((t.properties.clone().len() as i64) == 0) && ((t.children.clone().len() as i64) == 0)) - && (t.body.clone() == None)) + && (t.body.clone() == std::option::Option::None)) } pub fn classify_transport( @@ -3054,7 +3054,7 @@ pub fn classify_transport( if is_bare_transport(t.clone()) { Some(TransportKind::LocalTransport) } else { - None + std::option::Option::None } } } @@ -3086,7 +3086,7 @@ pub fn field_init_operation_modifier( if (fi_name.clone() == "hermetic".to_string()) { Some(OperationModifier::Hermetic) } else { - None + std::option::Option::None } } } @@ -3817,16 +3817,16 @@ pub fn module_node( children: items.clone(), connective: Connective::NoConnective, params: imports.clone(), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }) @@ -3846,25 +3846,25 @@ pub fn import_node( occurrence_identity: Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), name: "".to_string(), span: span.clone(), - ident_span: None, + ident_span: std::option::Option::None, children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, })) } else { - None + std::option::Option::None }; Rc::new(Node { occurrence_identity: occurrence_identity.clone(), @@ -3874,16 +3874,16 @@ pub fn import_node( children: specific_names.clone(), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), body: wildcard_marker.clone(), - transport: None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }) @@ -3891,7 +3891,7 @@ pub fn import_node( } pub fn import_is_all(n: Rc) -> bool { - (n.body.clone() != None) + (n.body.clone() != std::option::Option::None) } pub fn import_specific_names_at( @@ -3928,16 +3928,16 @@ pub fn leaf_node_with_span( children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }) @@ -3965,16 +3965,16 @@ pub fn unit_type() -> Rc { children: Rc::new(vec![]), connective: Connective::Conj, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }) @@ -3994,16 +3994,16 @@ pub fn bool_type() -> Rc { children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }) @@ -4023,16 +4023,16 @@ pub fn string_type() -> Rc { children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }) @@ -4052,16 +4052,16 @@ pub fn hash_type() -> Rc { children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }) @@ -4081,16 +4081,16 @@ pub fn int_type() -> Rc { children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }) @@ -4110,16 +4110,16 @@ pub fn float_type() -> Rc { children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }) @@ -4139,16 +4139,16 @@ pub fn none_type() -> Rc { children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), - inferred: None, + inferred: std::option::Option::None, return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::NoExprData), ident: None, }) @@ -4173,7 +4173,7 @@ pub fn error_type() -> Rc { occurrence_identity: Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), name: "".to_string(), span: no_span(), - ident_span: None, + ident_span: std::option::Option::None, children: Rc::new(vec![]), connective: Connective::NoConnective, params: Rc::new(vec![]), @@ -4183,13 +4183,13 @@ pub fn error_type() -> Rc { })), return_cardinality: Cardinality::Required, uses: Rc::new(vec![]), - body: None, - transport: None, + body: std::option::Option::None, + transport: std::option::Option::None, properties: Rc::new(vec![]), - type_annotation: None, + type_annotation: std::option::Option::None, is_self_recursive: false, has_non_tail_self_call: false, - match_pattern: None, + match_pattern: std::option::Option::None, expr_data: Rc::new(ExprData::ExprError { kind: ExprErrorKind::SemanticExprError, message: "unresolved type".to_string(), @@ -4412,7 +4412,7 @@ pub fn intern_str(table: Rc, id: i64) -> String { pub fn intern_find(table: Rc, s: String) -> Option { match v1_rt::map_get(&table.index.clone(), s.clone()) { Some(id) => Some(id.clone()), - None => None, + None => std::option::Option::None, } } @@ -4582,7 +4582,7 @@ pub fn known_container_leaf(name: String) -> Option { let leaf = qualified_last_segment(name.clone()); match crate::std_types::container_expected_arity(leaf.clone()) { Some(_) => Some(leaf.clone()), - None => None, + None => std::option::Option::None, } } } diff --git a/src/v1/stage0/src/v1_tests_claim_checkpoint_identity_keying_witness_test.rs b/src/v1/stage0/src/v1_tests_claim_checkpoint_identity_keying_witness_test.rs index 8f4501050cf..5b69074931f 100644 --- a/src/v1/stage0/src/v1_tests_claim_checkpoint_identity_keying_witness_test.rs +++ b/src/v1/stage0/src/v1_tests_claim_checkpoint_identity_keying_witness_test.rs @@ -45,14 +45,14 @@ pub fn same_spelling_different_declaration_does_not_realize_natively() -> bool { (crate::v1_compiler_emit_rust::rust_scalar_checkpoint_reference_base( "Nat".to_string(), "src/v2/std/nat.dag".to_string(), - ) == None) + ) == std::option::Option::None) } pub fn unknown_declaration_identity_refuses_rather_than_guessing() -> bool { (crate::v1_compiler_emit_rust::rust_scalar_checkpoint_reference_base( "Nat".to_string(), "".to_string(), - ) == None) + ) == std::option::Option::None) } pub fn residue_table_present_int_bypasses_identity() -> bool { @@ -68,28 +68,28 @@ pub fn table_present_hash_refuses_under_structural_declaration() -> bool { (crate::v1_compiler_emit_rust::rust_scalar_checkpoint_reference_base( "Hash".to_string(), "src/v2/std/node.dag".to_string(), - ) == None) + ) == std::option::Option::None) } pub fn table_present_string_refuses_under_structural_declaration_text() -> bool { (crate::v1_compiler_emit_rust::rust_scalar_checkpoint_reference_base( "String".to_string(), "src/v2/std/text.dag".to_string(), - ) == None) + ) == std::option::Option::None) } pub fn table_present_string_refuses_under_structural_declaration_string_type() -> bool { (crate::v1_compiler_emit_rust::rust_scalar_checkpoint_reference_base( "String".to_string(), "dag/std/string_type.dag".to_string(), - ) == None) + ) == std::option::Option::None) } pub fn table_present_bool_refuses_under_structural_declaration_logic() -> bool { (crate::v1_compiler_emit_rust::rust_scalar_checkpoint_reference_base( "Bool".to_string(), "src/v2/std/logic.dag".to_string(), - ) == None) + ) == std::option::Option::None) } pub fn table_present_bool_renders_natively_for_the_corpus_prelude() -> bool { @@ -116,7 +116,7 @@ pub fn literal_suffix_refuses_under_structural_declaration_text() -> bool { RenderTarget::Rust, "String".to_string(), "src/v2/std/text.dag".to_string(), - ) == None) + ) == std::option::Option::None) } pub fn literal_suffix_refuses_under_structural_declaration_string_type() -> bool { @@ -124,7 +124,7 @@ pub fn literal_suffix_refuses_under_structural_declaration_string_type() -> bool RenderTarget::Rust, "String".to_string(), "dag/std/string_type.dag".to_string(), - ) == None) + ) == std::option::Option::None) } pub fn literal_suffix_production_call_site_never_threads_declaration_identity() -> bool { diff --git a/src/v1/stage0/src/v1_tests_claim_transport_roster_closure_witness_test.rs b/src/v1/stage0/src/v1_tests_claim_transport_roster_closure_witness_test.rs index 4abe687c6e6..98bbd969602 100644 --- a/src/v1/stage0/src/v1_tests_claim_transport_roster_closure_witness_test.rs +++ b/src/v1/stage0/src/v1_tests_claim_transport_roster_closure_witness_test.rs @@ -39,7 +39,7 @@ pub fn str_expr(s: String) -> Rc { value: Rc::new(LiteralValue::LitStr { value: s.clone() }), }), Rc::new(vec![]), - None, + std::option::Option::None, crate::v1_std_core::no_span(), ) } @@ -63,11 +63,11 @@ pub fn rest_transport_classifies_as_rest() -> bool { str_expr("https://example.invalid".to_string()), Rc::new(vec![]), Rc::new(vec![]), - None, - None, - None, - None, - None, + std::option::Option::None, + std::option::Option::None, + std::option::Option::None, + std::option::Option::None, + std::option::Option::None, crate::v1_std_core::no_span(), )) == "rest".to_string()) } @@ -77,7 +77,7 @@ pub fn shell_transport_classifies_as_shell() -> bool { Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), Rc::new(vec![str_expr("ls".to_string())]), Rc::new(vec![]), - None, + std::option::Option::None, crate::v1_std_core::no_span(), )) == "shell".to_string()) } @@ -86,7 +86,7 @@ pub fn file_transport_classifies_as_file() -> bool { (kind_name(crate::v1_std_core::file_transport_node( Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), str_expr("/tmp/x".to_string()), - None, + std::option::Option::None, crate::v1_std_core::no_span(), )) == "file".to_string()) } @@ -109,7 +109,7 @@ pub fn keyless_transport() -> Rc { crate::v1_std_core::no_span(), )]), Rc::new(vec![]), - None, + std::option::Option::None, crate::v1_std_core::no_span(), ) } @@ -155,7 +155,7 @@ pub fn rest_wins_over_a_file_key_on_the_same_transport() -> bool { ), ]), Rc::new(vec![]), - None, + std::option::Option::None, crate::v1_std_core::no_span(), )) == "rest".to_string()) } From c7b8056abf1d0cf3adf15fb366188c2b8f23d314 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 12:27:27 +0000 Subject: [PATCH 58/75] XL-0N: type_reference_declaration_ref falls back to the module-visible name binding when the reference carries no ident-keyed binding (the emitter's scope env) -- the found declaration is still span-matched against the global roster, so a by-name hit only confirms an exact declaration; measured: Peano literal rows passed while the operator rows still lost Nat's identity Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_013koFunEtpLQCnvUiz85k7Y --- src/v1/04_env.dag | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/v1/04_env.dag b/src/v1/04_env.dag index c2d8af4adc8..90f0084d9ab 100644 --- a/src/v1/04_env.dag +++ b/src/v1/04_env.dag @@ -1244,14 +1244,23 @@ fn binding_declares_span(binding: TypeBinding, sp: SourceSpan) -> Bool { // (lookup_type_for) carries the declaration's own ident_span, which is the span the global roster is // matched on. Without this arm every recursive destination answered Absent here and fell to the // identity-unavailable arms downstream (measured: the Peano literal and ordering rows passed for -// v2.std.logic Bool and failed for v2.std.nat Nat on the same compiler). +// v2.std.logic Bool and failed for v2.std.nat Nat on the same compiler). The ident-keyed lookup +// serves inference; the emitter's scope env answers a reference by the module-visible NAME +// (lookup_type_by_name), which is that module's own import binding -- and either way the +// declaration found here is then matched by SPAN against the global roster, so a by-name hit can +// only ever confirm an exact declaration, never pick among homonyms (measured: the Peano literal +// rows passed and the Peano operator rows failed on the same compiler after the ident arm alone). fn type_reference_declaration_ref(n: Node, source_indices: Map, env: TypeEnv) -> DeclarationRef? { let rt = match n.inferred { Present { value: Resolved { node: r } } => r _ => match lookup_type_for(env: env, node: n) { Present { value: bound } => bound - Absent => n + Absent => + match lookup_type_by_name(env: env, name: authored_name_at(source_indices: source_indices, node: n)) { + Present { value: bound } => bound + Absent => n + } } } let decl_name = qualified_last_segment(name: authored_name_at(source_indices: source_indices, node: rt)) From 370f5face7ade3b45bd79ebbbbade95bfaa235ed Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 15:28:33 +0000 Subject: [PATCH 59/75] XL-0N: regen mirrors at e10a8a1 (main cba8580 merged, fixed point round 2); expand a nested record literal's resolved type before naming its ctor (Nat::Nat -> Nat::Succ) Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_013koFunEtpLQCnvUiz85k7Y --- src/v1/05_emit_rust.dag | 3 +- src/v1/stage0/src/v1_compiler_coercion.rs | 16 + src/v1/stage0/src/v1_compiler_compile.rs | 7 + src/v1/stage0/src/v1_compiler_complexity.rs | 16 +- src/v1/stage0/src/v1_compiler_emit.rs | 16 +- src/v1/stage0/src/v1_compiler_emit_rust.rs | 525 ++++++++++++------ src/v1/stage0/src/v1_compiler_infer.rs | 315 ++++++++++- src/v1/stage0/src/v1_compiler_infer_env.rs | 85 ++- .../stage0/src/v1_compiler_infer_resolve.rs | 11 +- src/v1/stage0/src/v1_compiler_ownership.rs | 7 +- src/v1/stage0/src/v1_std_core.rs | 13 + 11 files changed, 819 insertions(+), 195 deletions(-) diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index f39d5fc410c..65bafef2188 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -11629,7 +11629,8 @@ fn emit_field_value_with_context(field_value: Node, struct_node: Node, outer_typ } else { pe } Absent => pe } - let raw = emit_typed_record_lit(type_name: tn, fields: inner_fields, parent_enum: corrected_parent, resolved_type: resolved_type(n: field_value), registry: registry, scope: scope, depth: depth, shared_types: shared_types, emit_info: emit_info) + let nested_rt = expand_type_for_field_access(n: resolved_type(n: field_value), env: scope.type_env, module_name: scope.module_name).resolved + let raw = emit_typed_record_lit(type_name: tn, fields: inner_fields, parent_enum: corrected_parent, resolved_type: nested_rt, registry: registry, scope: scope, depth: depth, shared_types: shared_types, emit_info: emit_info) let rc_name = match corrected_parent { Present { value: en } => en Absent => variant_name diff --git a/src/v1/stage0/src/v1_compiler_coercion.rs b/src/v1/stage0/src/v1_compiler_coercion.rs index 42e2fbd0656..a4cf840e7b5 100644 --- a/src/v1/stage0/src/v1_compiler_coercion.rs +++ b/src/v1/stage0/src/v1_compiler_coercion.rs @@ -372,6 +372,22 @@ pub fn rust_exact_realization_decision( } } +pub fn declaration_realizes_natively_on_rust( + declaration: Rc, + decl_file: String, +) -> bool { + match (*rust_exact_realization_decision(Some(declaration.clone()))).clone() { + TypeRealizationDecision::Realized { checkpoint: _, .. } => true, + _ => { + (lookup_checkpoint( + RenderTarget::Rust, + declaration.decl_name.clone(), + decl_file.clone(), + ) != std::option::Option::None) + } + } +} + pub fn rust_checkpoint_row_keeps_bare_row(dag_name: String) -> bool { if (dag_name.clone() == "".to_string()) { false diff --git a/src/v1/stage0/src/v1_compiler_compile.rs b/src/v1/stage0/src/v1_compiler_compile.rs index f365510487e..40f151eefc0 100644 --- a/src/v1/stage0/src/v1_compiler_compile.rs +++ b/src/v1/stage0/src/v1_compiler_compile.rs @@ -1397,6 +1397,13 @@ pub fn serialize_expr_data( ), "}".to_string(), ), + ExprData::ExprElaboratedLiteral { value, .. } => v1_rt::concat( + v1_rt::concat( + "{\"kind\": \"ExprElaboratedLiteral\", \"value\": ".to_string(), + serialize_literal(value.clone()), + ), + "}".to_string(), + ), ExprData::ExprError { kind, message, .. } => v1_rt::concat( v1_rt::concat( v1_rt::concat( diff --git a/src/v1/stage0/src/v1_compiler_complexity.rs b/src/v1/stage0/src/v1_compiler_complexity.rs index d5740fb0359..abb4f925579 100644 --- a/src/v1/stage0/src/v1_compiler_complexity.rs +++ b/src/v1/stage0/src/v1_compiler_complexity.rs @@ -74,9 +74,9 @@ pub use crate::v1_compiler_parse::{ParserCallIdentity, ParserResultWitness}; use crate::v1_rt; use crate::v1_rt::{VecCompat, VecJoin}; use crate::v1_std_core::ExprData::{ - ExprBinOp, ExprBlock, ExprCall, ExprError, ExprFieldAccess, ExprForEach, ExprIf, ExprLambda, - ExprLet, ExprLiteral, ExprMatch, ExprMethodCall, ExprRecordLit, ExprReturn, ExprUnaryOp, - ExprVar, + ExprBinOp, ExprBlock, ExprCall, ExprElaboratedLiteral, ExprError, ExprFieldAccess, ExprForEach, + ExprIf, ExprLambda, ExprLet, ExprLiteral, ExprMatch, ExprMethodCall, ExprRecordLit, ExprReturn, + ExprUnaryOp, ExprVar, }; use crate::v1_std_core::MatchPattern::{Bind, VariantPattern}; use crate::v1_std_core::MethodSemantics::{ @@ -9143,6 +9143,16 @@ pub fn cost_of_expr( }), table: table.clone(), }), + ExprData::ExprElaboratedLiteral { .. } => Rc::new(SummaryResult { + summary: Rc::new(ComplexitySummary { + work: Rc::new(CostExpr::CostConst { value: 1 }), + span: Rc::new(CostExpr::CostConst { value: 1 }), + output_size: v1_rt::rc_empty_map::>(), + certainty: Certainty::Proven, + peak_space: None, + }), + table: table.clone(), + }), ExprData::ExprError { .. } => Rc::new(SummaryResult { summary: Rc::new(ComplexitySummary { work: Rc::new(CostExpr::CostConst { value: 0 }), diff --git a/src/v1/stage0/src/v1_compiler_emit.rs b/src/v1/stage0/src/v1_compiler_emit.rs index 6ee38dffc00..7da56f5fecd 100644 --- a/src/v1/stage0/src/v1_compiler_emit.rs +++ b/src/v1/stage0/src/v1_compiler_emit.rs @@ -94,9 +94,10 @@ use crate::v1_std_core::Cardinality::CardOptional; use crate::v1_std_core::CompilerDiagnostic::TransportEmissionNotModeled; use crate::v1_std_core::Connective::{Arrow, Conj, Disj, NoConnective}; use crate::v1_std_core::ExprData::{ - ExprBinOp, ExprBlock, ExprCall, ExprCast, ExprError, ExprFieldAccess, ExprForEach, ExprIf, - ExprIndex, ExprLambda, ExprLet, ExprListLit, ExprLiteral, ExprMatch, ExprMethodCall, - ExprRecordLit, ExprReturn, ExprSlice, ExprStringInterp, ExprUnaryOp, ExprVar, NoExprData, + ExprBinOp, ExprBlock, ExprCall, ExprCast, ExprElaboratedLiteral, ExprError, ExprFieldAccess, + ExprForEach, ExprIf, ExprIndex, ExprLambda, ExprLet, ExprListLit, ExprLiteral, ExprMatch, + ExprMethodCall, ExprRecordLit, ExprReturn, ExprSlice, ExprStringInterp, ExprUnaryOp, ExprVar, + NoExprData, }; use crate::v1_std_core::FieldAccessStyle::{TupleFirst, TupleSecond}; use crate::v1_std_core::InferredNode::{CompilerError, Resolved, TypeVariable}; @@ -2817,6 +2818,7 @@ pub enum ExprCategory { pub fn classify_expr(texpr: Rc) -> ExprCategory { match (*texpr.expr_data.clone()).clone() { ExprData::ExprLiteral { value: _, .. } => ExprCategory::ExprCatLeaf, + ExprData::ExprElaboratedLiteral { .. } => ExprCategory::ExprCatLeaf, ExprData::ExprError { .. } => ExprCategory::ExprCatLeaf, ExprData::ExprVar { binding_kind: _, .. @@ -5401,6 +5403,14 @@ pub fn emit_shared_expr( ExprData::ExprLiteral { value: v, .. } => { wrap_result(emit_literal(v.clone(), target.clone())) } + ExprData::ExprElaboratedLiteral { .. } => match texpr.children.clone().first().cloned() { + Some(image) => recurse(image.clone()), + None => wrap_result(emit_error_expr( + "elaborated literal carries no image (v1.compiler.infer unfold_literal_image)" + .to_string(), + target.clone(), + )), + }, ExprData::ExprError { message, .. } => { wrap_result(emit_error_expr(message.clone(), target.clone())) } diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index 5ff2e8ddec8..96efe947dca 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -35,6 +35,7 @@ pub use crate::gunbc_stage0_emitted_population_manifest::{ emitted_population_manifest_basename, emitted_population_manifest_line_prefix, emitted_population_manifest_line_separator, }; +pub use crate::gunbc_structural_realization_bindings::structural_ordering_rows; pub use crate::std_algebra::trim; pub use crate::std_coercion::TypeCheckpoint; pub use crate::std_content_hash::Fnv1a64Structural; @@ -46,6 +47,19 @@ pub use crate::std_measure::millisecond_count; pub use crate::std_nat::Nat; pub use crate::std_occurrence_identity::NodeOccurrenceIdentity; use crate::std_occurrence_identity::NodeOccurrenceIdentity::OccurrenceSynthetic; +use crate::std_operator_realization::OperandRealization::{ + HostNumericOperand, OperandIdentityUnavailable, StructuralOperand, +}; +use crate::std_operator_realization::OperatorRealization::{ + HostOperator, OperatorRealizationRefused, StructuralComparison, StructuralEquality, +}; +use crate::std_operator_realization::OrderingTest::{OrderingIs, OrderingIsNot}; +pub use crate::std_operator_realization::{ + operator_realization_for, operator_realization_refusal_message, +}; +pub use crate::std_operator_realization::{ + OperandRealization, OperatorRealization, OrderingTest, StructuralOrderingBinding, +}; pub use crate::std_primitive_projection::{ primitive_identity_runtime_name, primitive_projection_row_for_declaration, }; @@ -72,8 +86,9 @@ pub use crate::v1_compiler_closure_stub_v2_std_integer_rust::closure_stub_v2_std pub use crate::v1_compiler_closure_stub_v2_std_text_rust::closure_stub_v2_std_text_source; pub use crate::v1_compiler_coercion::decl_identity_file; pub use crate::v1_compiler_coercion::{ - coerce_primitive_type, is_copy, lookup_checkpoint, rust_lookup_exact_binding, - rust_seed_host_numeric_alias, target_callable, type_reference_decl_file, + coerce_primitive_type, declaration_realizes_natively_on_rust, is_copy, lookup_checkpoint, + rust_lookup_exact_binding, rust_seed_host_numeric_alias, target_callable, + type_reference_decl_file, }; pub use crate::v1_compiler_compiler_tests_rust::compiler_tests_source; use crate::v1_compiler_emit::BoundOperation::{ @@ -133,7 +148,8 @@ use crate::v1_compiler_infer_env::GlobalBareLookupState::{ GlobalBareAmbiguousBinding, GlobalBareUniqueBinding, }; pub use crate::v1_compiler_infer_env::{ - authored_name, empty_symbol_index, lookup_type_by_name, lookup_type_for, + authored_name, binding_declares_span, empty_symbol_index, lookup_type_by_name, lookup_type_for, + type_reference_declaration_ref, }; pub use crate::v1_compiler_infer_env::{GlobalBareLookupState, TypeBinding, TypeEnv}; pub use crate::v1_compiler_infer_items::item_kind; @@ -1066,76 +1082,6 @@ pub fn rust_render_checkpoint_scalar_bare( } } -pub fn binding_declares_span(binding: Rc, sp: Rc) -> bool { - match binding.resolved.clone().ident_span.clone() { - Some(s) => ((s.file.clone() == sp.file.clone()) && (s.start.clone() == sp.start.clone())), - None => false, - } -} - -pub fn type_reference_declaration_ref( - n: Rc, - source_indices: Rc>>, - env: Rc, -) -> Option> { - { - let rt = match n.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: r, .. }) => r.clone(), - _ => n.clone(), - }; - let decl_name = crate::v1_std_core::qualified_last_segment( - crate::v1_std_core::authored_name_at(source_indices.clone(), rt.clone()), - ); - if (decl_name.clone() == "".to_string()) { - return std::option::Option::None; - } - match rt.ident_span.clone() { - None => std::option::Option::None, - Some(sp) => match v1_rt::map_get( - &env.symbol_index.clone().global_bare.clone(), - decl_name.clone(), - ) - .as_deref() - .cloned() - { - Some(GlobalBareLookupState::GlobalBareUniqueBinding { - module_path: mp, - binding: b, - .. - }) => { - if binding_declares_span(b.clone(), sp.clone()) { - Some(crate::std_decl_ref::decl_ref(mp.clone(), decl_name.clone())) - } else { - std::option::Option::None - } - } - Some(GlobalBareLookupState::GlobalBareAmbiguousBinding { - candidates: cands, - .. - }) => match Rc::new({ - let mut __result = Vec::new(); - for c in cands.iter().cloned() { - if binding_declares_span(c.binding.clone(), sp.clone()) { - __result.push(c); - } - } - __result - }) - .first() - .cloned() - { - Some(c) => Some(crate::std_decl_ref::decl_ref( - c.module_path.clone(), - decl_name.clone(), - )), - None => std::option::Option::None, - }, - None => std::option::Option::None, - }, - } - } -} - pub fn rust_exact_binding_spelling( source: Option>, grounding: bool, @@ -1181,7 +1127,11 @@ pub fn rust_exact_reference_spelling( env: Rc, ) -> Option { rust_exact_binding_spelling( - type_reference_declaration_ref(n.clone(), source_indices.clone(), env.clone()), + crate::v1_compiler_infer_env::type_reference_declaration_ref( + n.clone(), + source_indices.clone(), + env.clone(), + ), false, ) } @@ -29428,133 +29378,370 @@ pub fn emit_typed_bin_op( RenderTarget::Rust, ) } else { - { - let op_str = crate::v1_compiler_emit::emit_bin_op_symbol( + match (*binop_operator_realization(op.clone(), left.clone(), scope.clone())).clone() { + OperatorRealization::OperatorRealizationRefused { cause: c, .. } => { + emit_rust_compile_error_expr( + crate::std_operator_realization::operator_realization_refusal_message( + c.clone(), + ), + ) + } + OperatorRealization::StructuralComparison { + binding: b, + test: t, + .. + } => emit_rust_structural_comparison( + l_str.clone(), + r_str.clone(), + b.clone(), + t.clone(), + ), + OperatorRealization::StructuralEquality { declaration: _, .. } => { + emit_rust_host_bin_op( + op.clone(), + algebra_field.clone(), + left.clone(), + right.clone(), + l_str.clone(), + r_str.clone(), + scope.clone(), + ) + } + OperatorRealization::HostOperator => emit_rust_host_bin_op( op.clone(), - RenderTarget::Rust, algebra_field.clone(), - ); - if is_string_comparison( - op.clone(), left.clone(), right.clone(), - scope.type_env.clone().source_indices.clone(), + l_str.clone(), + r_str.clone(), + scope.clone(), + ), + } + } + } +} + +pub fn rust_operand_realization( + operand: Rc, + scope: Rc, +) -> Rc { + rust_operand_realization_of_type( + crate::v1_compiler_infer_types::resolved_type(operand.clone()), + scope.clone(), + 8, + ) +} + +pub fn rust_operand_realization_of_type( + mut rt: Rc, + mut scope: Rc, + mut fuel: i64, +) -> Rc { + loop { + match crate::v1_compiler_infer_env::type_reference_declaration_ref( + rt.clone(), + scope.type_env.clone().source_indices.clone(), + scope.type_env.clone(), + ) { + None => { + break Rc::new(OperandRealization::OperandIdentityUnavailable); + } + Some(d) => { + if crate::v1_compiler_coercion::declaration_realizes_natively_on_rust( + d.clone(), + crate::v1_compiler_coercion::type_reference_decl_file(rt.clone()), ) { + break Rc::new(OperandRealization::HostNumericOperand); + } else { + let decl = match rt.inferred.clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: r, .. }) => r.clone(), + _ => rt.clone(), + }; + if ((fuel.clone() > 0) + && crate::v1_compiler_infer::is_where_refinement_type(rt.clone())) { - let l_optional = is_optional_typed_expr(left.clone()); - let r_optional = is_optional_typed_expr(right.clone()); - if (l_optional.clone() || r_optional.clone()) { + match rt.children.clone().first().cloned() { + Some(base) => { + let base_resolved = + match crate::v1_compiler_infer_env::lookup_type_for( + scope.type_env.clone(), + base.clone(), + ) { + Some(r) => r.clone(), + None => base.clone(), + }; + { + let __tco_0 = base_resolved.clone(); + let __tco_1 = (fuel - 1); + rt = __tco_0; + fuel = __tco_1; + continue; + } + } + None => { + break Rc::new(OperandRealization::StructuralOperand { + declaration: d.clone(), + }); + } + } + } else { + if ((fuel.clone() > 0) + && crate::v1_compiler_emit_core_support::is_type_alias_item( + decl.clone(), + scope.type_env.clone().source_indices.clone(), + )) + { { - let l_cmp = if l_optional.clone() { - v1_rt::concat(l_str.clone(), ".as_deref()".to_string()) - } else { - v1_rt::concat( - v1_rt::concat( - "Some(".to_string(), - emit_rust_dag_string_to_host_via_seam(l_str.clone()), - ), - ").as_deref()".to_string(), - ) - }; - let r_cmp = if r_optional.clone() { - v1_rt::concat(r_str.clone(), ".as_deref()".to_string()) - } else { - v1_rt::concat( - v1_rt::concat( - "Some(".to_string(), - emit_rust_dag_string_to_host_via_seam(r_str.clone()), - ), - ").as_deref()".to_string(), - ) - }; + let __tco_0 = + crate::v1_compiler_infer_types::resolved_type(decl.clone()); + let __tco_1 = (fuel - 1); + rt = __tco_0; + fuel = __tco_1; + continue; + } + } else { + break Rc::new(OperandRealization::StructuralOperand { + declaration: d.clone(), + }); + } + } + } + } + } + } +} + +pub fn binop_operator_realization( + op: BinOp, + left: Rc, + scope: Rc, +) -> Rc { + crate::std_operator_realization::operator_realization_for( + op.clone(), + rust_operand_realization(left.clone(), scope.clone()), + structural_ordering_rows(), + ) +} + +pub fn rust_declaration_path(module_path: String, decl_name: String) -> String { + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + "crate::".to_string(), + crate::v1_compiler_emit_core_support::module_to_filename(module_path.clone()), + ), + "::".to_string(), + ), + crate::v1_compiler_emit::emit_ident(decl_name.clone(), RenderTarget::Rust), + ) +} + +pub fn emit_rust_structural_comparison( + l_str: String, + r_str: String, + binding: Rc, + test: Rc, +) -> String { + { + let call = v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + rust_declaration_path( + binding.compare.clone().module_path.clone(), + binding.compare.clone().decl_name.clone(), + ), + "(".to_string(), + ), + l_str.clone(), + ), + ", ".to_string(), + ), + r_str.clone(), + ), + ")".to_string(), + ); + let ordering = v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + "crate::".to_string(), + crate::v1_compiler_emit_core_support::module_to_filename( + binding.ordering.clone().module_path.clone(), + ), + ), + "::".to_string(), + ), + binding.ordering.clone().decl_name.clone(), + ); + match (*test.clone()).clone() { + OrderingTest::OrderingIs { variant: v, .. } => v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat("(".to_string(), call.clone()), + " == ".to_string(), + ), + ordering.clone(), + ), + "::".to_string(), + ), + v.clone(), + ), + ")".to_string(), + ), + OrderingTest::OrderingIsNot { variant: v, .. } => v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat("(".to_string(), call.clone()), + " != ".to_string(), + ), + ordering.clone(), + ), + "::".to_string(), + ), + v.clone(), + ), + ")".to_string(), + ), + } + } +} + +pub fn emit_rust_host_bin_op( + op: BinOp, + algebra_field: Option, + left: Rc, + right: Rc, + l_str: String, + r_str: String, + scope: Rc, +) -> String { + { + let op_str = crate::v1_compiler_emit::emit_bin_op_symbol( + op.clone(), + RenderTarget::Rust, + algebra_field.clone(), + ); + if is_string_comparison( + op.clone(), + left.clone(), + right.clone(), + scope.type_env.clone().source_indices.clone(), + ) { + { + let l_optional = is_optional_typed_expr(left.clone()); + let r_optional = is_optional_typed_expr(right.clone()); + if (l_optional.clone() || r_optional.clone()) { + { + let l_cmp = if l_optional.clone() { + v1_rt::concat(l_str.clone(), ".as_deref()".to_string()) + } else { + v1_rt::concat( + v1_rt::concat( + "Some(".to_string(), + emit_rust_dag_string_to_host_via_seam(l_str.clone()), + ), + ").as_deref()".to_string(), + ) + }; + let r_cmp = if r_optional.clone() { + v1_rt::concat(r_str.clone(), ".as_deref()".to_string()) + } else { + v1_rt::concat( + v1_rt::concat( + "Some(".to_string(), + emit_rust_dag_string_to_host_via_seam(r_str.clone()), + ), + ").as_deref()".to_string(), + ) + }; + v1_rt::concat( + v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat("(".to_string(), l_cmp.clone()), - " ".to_string(), - ), - op_str.clone(), - ), + v1_rt::concat("(".to_string(), l_cmp.clone()), " ".to_string(), ), - r_cmp.clone(), + op_str.clone(), ), - ")".to_string(), - ) - } - } else { + " ".to_string(), + ), + r_cmp.clone(), + ), + ")".to_string(), + ) + } + } else { + v1_rt::concat( + v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - "(".to_string(), - emit_rust_dag_string_to_host_via_seam( - l_str.clone(), - ), - ), - " ".to_string(), - ), - op_str.clone(), + "(".to_string(), + emit_rust_dag_string_to_host_via_seam(l_str.clone()), ), " ".to_string(), ), - emit_rust_dag_string_to_host_via_seam(r_str.clone()), + op_str.clone(), ), - ")".to_string(), - ) - } - } - } else { - { - let both_string = (is_string_typed_expr( - left.clone(), - scope.type_env.clone().source_indices.clone(), - ) && is_string_typed_expr( - right.clone(), - scope.type_env.clone().source_indices.clone(), - )); - let is_str_concat = - ((op_str.clone() == "+".to_string()) && both_string.clone()); - if is_str_concat.clone() { + " ".to_string(), + ), + emit_rust_dag_string_to_host_via_seam(r_str.clone()), + ), + ")".to_string(), + ) + } + } + } else { + { + let both_string = (is_string_typed_expr( + left.clone(), + scope.type_env.clone().source_indices.clone(), + ) && is_string_typed_expr( + right.clone(), + scope.type_env.clone().source_indices.clone(), + )); + let is_str_concat = ((op_str.clone() == "+".to_string()) && both_string.clone()); + if is_str_concat.clone() { + v1_rt::concat( + v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat("(".to_string(), l_str.clone()), - " ".to_string(), - ), - op_str.clone(), - ), - " &".to_string(), + v1_rt::concat("(".to_string(), l_str.clone()), + " ".to_string(), ), - r_str.clone(), + op_str.clone(), ), - ")".to_string(), - ) - } else { + " &".to_string(), + ), + r_str.clone(), + ), + ")".to_string(), + ) + } else { + v1_rt::concat( + v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat("(".to_string(), l_str.clone()), - " ".to_string(), - ), - op_str.clone(), - ), + v1_rt::concat("(".to_string(), l_str.clone()), " ".to_string(), ), - r_str.clone(), + op_str.clone(), ), - ")".to_string(), - ) - } - } + " ".to_string(), + ), + r_str.clone(), + ), + ")".to_string(), + ) } } } diff --git a/src/v1/stage0/src/v1_compiler_infer.rs b/src/v1/stage0/src/v1_compiler_infer.rs index 113b673af70..277e165f623 100644 --- a/src/v1/stage0/src/v1_compiler_infer.rs +++ b/src/v1/stage0/src/v1_compiler_infer.rs @@ -7,10 +7,12 @@ use self::DescentSizeExpr::*; use self::InhabitanceRefusalReason::*; use self::InhabitanceUndecidableReason::*; use self::InhabitanceVerdict::*; +use self::LiteralBoundary::*; use self::ServiceConfigFieldJudgment::*; pub use crate::extdeps_container_oci_digest::{ oci_other_digest_algorithm, oci_other_digest_encoded, }; +pub use crate::gunbc_structural_realization_bindings::literal_homomorphism_rows; pub use crate::std_algebra::AlgebraFieldTemplate; use crate::std_algebra::CollectionSizeEffect::ShrinkEffect; pub use crate::std_algebra::{CollectionSizeEffect, FreeMonoid}; @@ -23,6 +25,7 @@ pub use crate::std_content_hash::{ content_hash_validate_lower_hex_length, }; pub use crate::std_content_hash::{ContentHash, Fnv1a64Structural}; +pub use crate::std_decl_ref::DeclarationRef; pub use crate::std_dissolution::DissolutionCondition; use crate::std_dissolution::DissolutionCondition::*; pub use crate::std_dissolution::{dissolution_description, unbound_dissolution}; @@ -41,14 +44,24 @@ pub use crate::std_induction::{InductiveField, RecursionShape, SubValueRelation} use crate::std_interface_summary::ExportKind::{ExportData, ExportFn, ExportService, ExportType}; pub use crate::std_interface_summary::{interface_summary_rollup, signature_contract}; pub use crate::std_interface_summary::{ExportEntry, ExportKind, InterfaceSummary}; +use crate::std_literal_elaboration::LiteralElaborationOutcome::{ + DirectLiteral, LiteralElaborationRefused, ViaHomomorphism, +}; +use crate::std_literal_elaboration::LiteralUnfolding::{BooleanUnfold, PeanoUnfold}; +pub use crate::std_literal_elaboration::{ + elaborate_literal_at, literal_elaboration_refusal_message, literal_source_kind_of, +}; +pub use crate::std_literal_elaboration::{ + LiteralElaboration, LiteralElaborationOutcome, LiteralHomomorphism, LiteralUnfolding, +}; pub use crate::std_node::{compiler_inductive_fields, compiler_recursive_types}; pub use crate::std_occurrence_identity::NodeOccurrenceIdentity; use crate::std_occurrence_identity::NodeOccurrenceIdentity::OccurrenceSynthetic; pub use crate::std_occurrence_identity::OccurrenceId; use crate::std_syntax::BinOp::Add; use crate::std_syntax::BinOp::{And, Div, Eq, Ge, Gt, Le, Lt, Mod, Mul, Ne, NullCoalesce, Or, Sub}; -use crate::std_syntax::LiteralValue::LitStr; -use crate::std_syntax::LiteralValue::{LitBool, LitFloat, LitInt, LitNull}; +use crate::std_syntax::LiteralValue::{LitBool, LitInt, LitStr}; +use crate::std_syntax::LiteralValue::{LitFloat, LitNull}; pub use crate::std_syntax::{BinOp, LiteralValue}; pub use crate::std_termination::PositiveDescentAmount; use crate::std_termination::PositiveDescentAmount::OneStep; @@ -86,7 +99,8 @@ pub use crate::v1_compiler_infer_env::{ node_with_inferred, put_inductive_field, put_inductive_field_cross, qualified_all_but_last, qualify_borrowed_inferred, qualify_borrowed_type_names, qualify_decl_reference_positions, str_bindings_from_bindings, symbol_index_insert, symbol_index_insert_decl, - symbol_index_insert_service, symbol_index_lookup, unit_variant_index_shadow_insert, + symbol_index_insert_service, symbol_index_lookup, type_reference_declaration_ref, + unit_variant_index_shadow_insert, }; pub use crate::v1_compiler_infer_env::{ GlobalBareCandidate, GlobalBareLookupState, GuardedTypeEnvCacheMerge, ServiceCensusEntry, @@ -206,9 +220,10 @@ use crate::v1_std_core::CompilerDiagnostic::{ }; use crate::v1_std_core::Connective::{Arrow, Conj, Disj, NoConnective}; use crate::v1_std_core::ExprData::{ - ExprBinOp, ExprBlock, ExprCall, ExprCast, ExprError, ExprFieldAccess, ExprForEach, ExprIf, - ExprIndex, ExprLambda, ExprLet, ExprListLit, ExprLiteral, ExprMatch, ExprMethodCall, - ExprRecordLit, ExprReturn, ExprSlice, ExprStringInterp, ExprUnaryOp, ExprVar, NoExprData, + ExprBinOp, ExprBlock, ExprCall, ExprCast, ExprElaboratedLiteral, ExprError, ExprFieldAccess, + ExprForEach, ExprIf, ExprIndex, ExprLambda, ExprLet, ExprListLit, ExprLiteral, ExprMatch, + ExprMethodCall, ExprRecordLit, ExprReturn, ExprSlice, ExprStringInterp, ExprUnaryOp, ExprVar, + NoExprData, }; use crate::v1_std_core::ExprErrorKind::{ CensusHeadsBodyStripped, InternalExprError, ParseRecoveryError, SemanticExprError, @@ -7771,6 +7786,247 @@ pub fn qualified_value_projection( } } +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[serde(tag = "_variant")] +pub enum LiteralBoundary { + LiteralBoundaryPlain, + LiteralBoundaryElaborated { + elaboration: Rc, + destination_type: Rc, + }, + LiteralBoundaryRefused { + message: String, + }, +} + +pub fn literal_boundary_elaboration( + lit: Rc, + expected: Option>, + scope: Rc, +) -> Rc { + match expected.clone() { + None => Rc::new(LiteralBoundary::LiteralBoundaryPlain), + Some(exp) => { + if (exp.return_cardinality.clone() == Cardinality::CardOptional) { + Rc::new(LiteralBoundary::LiteralBoundaryPlain) + } else { + match crate::v1_compiler_infer_env::type_reference_declaration_ref( + exp.clone(), + scope.type_env.clone().source_indices.clone(), + scope.type_env.clone(), + ) { + None => Rc::new(LiteralBoundary::LiteralBoundaryPlain), + Some(destination) => { + let kind = + crate::std_literal_elaboration::literal_source_kind_of(lit.clone()); + let natively = crate::v1_compiler_coercion::decl_file_realizes_natively( + crate::v1_compiler_coercion::type_reference_decl_file(exp.clone()), + ); + match (*crate::std_literal_elaboration::elaborate_literal_at(literal_homomorphism_rows(), kind.clone(), destination.clone(), natively.clone())).clone() { + LiteralElaborationOutcome::DirectLiteral => Rc::new(LiteralBoundary::LiteralBoundaryPlain), + LiteralElaborationOutcome::ViaHomomorphism { homomorphism: h, .. } => Rc::new(LiteralBoundary::LiteralBoundaryElaborated { + elaboration: Rc::new(LiteralElaboration { + source_kind: kind.clone(), + destination: destination.clone(), + homomorphism: h.clone(), +}), + destination_type: exp.clone(), +}), + LiteralElaborationOutcome::LiteralElaborationRefused { cause: c, .. } => Rc::new(LiteralBoundary::LiteralBoundaryRefused { + message: crate::std_literal_elaboration::literal_elaboration_refusal_message(c.clone()), +}), +} + } + } + } + } + } +} + +pub fn elaborated_span(name: String) -> Rc { + Rc::new(SourceSpan { + file: "".to_string(), + start: 0, + end: v1_rt::string_length(&name), + }) +} + +pub fn elaborated_expr_node( + name: String, + expr_data: Rc, + children: Rc>>, + destination_type: Rc, + span: Rc, +) -> Rc { + Rc::new(Node { + occurrence_identity: Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), + name: name.clone(), + span: span.clone(), + ident_span: Some(elaborated_span(name.clone())), + children: children.clone(), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: Some(Rc::new(InferredNode::Resolved { + node: destination_type.clone(), + })), + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: std::option::Option::None, + transport: std::option::Option::None, + properties: Rc::new(vec![]), + type_annotation: std::option::Option::None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: std::option::Option::None, + expr_data: expr_data.clone(), + ident: None, + }) +} + +pub fn unfold_peano_image( + n: i64, + zero: String, + succ: String, + prev_field: String, + parent: String, + destination_type: Rc, + span: Rc, +) -> Rc { + stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { + if (n.clone() <= 0) { + elaborated_expr_node( + zero.clone(), + Rc::new(ExprData::ExprVar { + binding_kind: Some(Rc::new(VarBindingKind::VariantValueBinding { + parent_enum: parent.clone(), + })), + }), + Rc::new(vec![]), + destination_type.clone(), + span.clone(), + ) + } else { + { + let prev = unfold_peano_image( + (n.clone() - 1), + zero.clone(), + succ.clone(), + prev_field.clone(), + parent.clone(), + destination_type.clone(), + span.clone(), + ); + let field = crate::v1_std_core::make_field_init_node( + Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), + prev_field.clone(), + prev.clone(), + span.clone(), + elaborated_span(prev_field.clone()), + ); + elaborated_expr_node( + succ.clone(), + Rc::new(ExprData::ExprRecordLit { + parent_enum: Some(parent.clone()), + }), + Rc::new(vec![field.clone()]), + destination_type.clone(), + span.clone(), + ) + } + } + }) +} + +pub fn unfold_literal_image( + lit: Rc, + elaboration: Rc, + destination_type: Rc, + span: Rc, +) -> Rc { + match (*elaboration.homomorphism.clone().producer.clone()).clone() { + LiteralUnfolding::PeanoUnfold { zero, succ, prev_field, .. } => match (*lit.clone()).clone() { + LiteralValue::LitInt { value: n, .. } => unfold_peano_image(n.clone(), zero.decl_name.clone(), succ.decl_name.clone(), prev_field.clone(), elaboration.destination.clone().decl_name.clone(), destination_type.clone(), span.clone()), + _ => crate::v1_std_core::make_expr_error_node(Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), ExprErrorKind::InternalExprError, "literal elaboration: a Peano unfolding row was selected for a non-integer literal (gunbc.structural_realization_bindings keys the row on KernelIntLiteral, so this row is malformed)".to_string(), span.clone()), +}, + LiteralUnfolding::BooleanUnfold { true_variant: t, false_variant: f, .. } => match (*lit.clone()).clone() { + LiteralValue::LitBool { value: b, .. } => elaborated_expr_node(if b.clone() { + t.decl_name.clone() + } else { + f.decl_name.clone() + }, Rc::new(ExprData::ExprVar { + binding_kind: Some(Rc::new(VarBindingKind::VariantValueBinding { + parent_enum: elaboration.destination.clone().decl_name.clone(), +})), +}), Rc::new(vec![]), destination_type.clone(), span.clone()), + _ => crate::v1_std_core::make_expr_error_node(Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), ExprErrorKind::InternalExprError, "literal elaboration: a Boolean unfolding row was selected for a non-boolean literal (gunbc.structural_realization_bindings keys the row on KernelBoolLiteral, so this row is malformed)".to_string(), span.clone()), +}, +} +} + +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct BinopOperands { + pub left: Rc, + pub right: Rc, +} + +pub fn infer_operand_literal( + lit_expr: Rc, + other: Rc, + scope: Rc, +) -> Rc { + { + let other_type = match other.inferred.clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: rt, .. }) => Some(rt.clone()), + _ => std::option::Option::None, + }; + infer_expr_body(lit_expr.clone(), scope.clone(), other_type.clone()) + } +} + +pub fn infer_binop_operands( + left_expr: Rc, + right_expr: Rc, + scope: Rc, +) -> Rc { + { + let left_is_literal = expr_is_any_literal(left_expr.clone()); + let right_is_literal = expr_is_any_literal(right_expr.clone()); + if (right_is_literal.clone() && !left_is_literal.clone()) { + { + let l = infer_expr(left_expr.clone(), scope.clone(), std::option::Option::None); + Rc::new(BinopOperands { + left: l.clone(), + right: infer_operand_literal( + right_expr.clone(), + l.typed.clone(), + scope.clone(), + ), + }) + } + } else { + if (left_is_literal.clone() && !right_is_literal.clone()) { + { + let r = + infer_expr(right_expr.clone(), scope.clone(), std::option::Option::None); + Rc::new(BinopOperands { + left: infer_operand_literal( + left_expr.clone(), + r.typed.clone(), + scope.clone(), + ), + right: r.clone(), + }) + } + } else { + Rc::new(BinopOperands { + left: infer_expr(left_expr.clone(), scope.clone(), std::option::Option::None), + right: infer_expr(right_expr.clone(), scope.clone(), std::option::Option::None), + }) + } + } + } +} + pub fn infer_expr_body( texpr: Rc, scope: Rc, @@ -7779,7 +8035,7 @@ pub fn infer_expr_body( match (*texpr.expr_data.clone()).clone() { ExprData::ExprLiteral { value: lit, .. } => { let span = texpr.span.clone(); - ok_infer(crate::v1_std_core::make_expr_node( + let plain = crate::v1_std_core::make_expr_node( texpr.occurrence_identity.clone(), Rc::new(ExprData::ExprLiteral { value: lit.clone() }), Rc::new(vec![]), @@ -7787,8 +8043,43 @@ pub fn infer_expr_body( node: crate::v1_compiler_infer_types::infer_literal_node(lit.clone()), })), span.clone(), - )) + ); + match (*literal_boundary_elaboration(lit.clone(), expected.clone(), scope.clone())) + .clone() + { + LiteralBoundary::LiteralBoundaryPlain => ok_infer(plain.clone()), + LiteralBoundary::LiteralBoundaryElaborated { + elaboration: e, + destination_type: dt, + .. + } => ok_infer(crate::v1_std_core::make_expr_node( + texpr.occurrence_identity.clone(), + Rc::new(ExprData::ExprElaboratedLiteral { + value: lit.clone(), + elaboration: e.clone(), + }), + Rc::new(vec![unfold_literal_image( + lit.clone(), + e.clone(), + dt.clone(), + span.clone(), + )]), + Some(Rc::new(InferredNode::Resolved { node: dt.clone() })), + span.clone(), + )), + LiteralBoundary::LiteralBoundaryRefused { message: m, .. } => { + Rc::new(InferResult { + typed: plain.clone(), + diagnostics: Rc::new(vec![inference_error( + m.clone(), + span.clone(), + scope.module_name.clone(), + )]), + }) + } + } } + ExprData::ExprElaboratedLiteral { .. } => ok_infer(texpr.clone()), ExprData::ExprError { kind, message, .. } => { let span = texpr.span.clone(); let diagnostics = match kind.clone() { @@ -9782,12 +10073,12 @@ crate::v1_compiler_infer_types::resolve_type_variables_from_template(t.clone(), let span = texpr.span.clone(); let left_expr = crate::v1_std_core::binop_left(texpr.clone()); let right_expr = crate::v1_std_core::binop_right(texpr.clone()); - let left_result = - infer_expr(left_expr.clone(), scope.clone(), std::option::Option::None); + let operands = + infer_binop_operands(left_expr.clone(), right_expr.clone(), scope.clone()); + let left_result = operands.left.clone(); let left_typed = left_result.typed.clone(); let left_diags = left_result.diagnostics.clone(); - let right_result = - infer_expr(right_expr.clone(), scope.clone(), std::option::Option::None); + let right_result = operands.right.clone(); let right_typed = right_result.typed.clone(); let right_diags = right_result.diagnostics.clone(); let binop_info = crate::v1_compiler_infer_types::infer_binop_type_node( diff --git a/src/v1/stage0/src/v1_compiler_infer_env.rs b/src/v1/stage0/src/v1_compiler_infer_env.rs index 7c03cde716e..171cb22eabd 100644 --- a/src/v1/stage0/src/v1_compiler_infer_env.rs +++ b/src/v1/stage0/src/v1_compiler_infer_env.rs @@ -3,6 +3,8 @@ use self::GlobalBareLookupState::*; pub use crate::std_algebra::FreeMonoid; +pub use crate::std_decl_ref::decl_ref; +pub use crate::std_decl_ref::DeclarationRef; use crate::std_induction::RecursionShape::{ DirectRecursion, ListRecursion, MapValueRecursion, OptionalRecursion, SetRecursion, }; @@ -27,11 +29,11 @@ use crate::v1_std_core::Cardinality::*; use crate::v1_std_core::CompilerDiagnostic::{AmbiguousReference, UnresolvedType}; use crate::v1_std_core::Connective::*; use crate::v1_std_core::ExprData::*; -use crate::v1_std_core::InferredNode::*; +use crate::v1_std_core::InferredNode::Resolved; pub use crate::v1_std_core::{ authored_name_at, empty_intern_table, find_child_named, intern, intern_find, intern_str, kernel_span, merge_intern_tables, module_path_segments, param_node_name_at, - param_node_type_expr, source_text_at, + param_node_type_expr, qualified_last_segment, source_text_at, }; pub use crate::v1_std_core::{ Cardinality, CompilerDiagnostic, Connective, ExprData, InferredNode, InternTable, NewlineIndex, @@ -2223,3 +2225,82 @@ pub fn env_with_type_variable_bindings(env: Rc, tp_names: Rc, sp: Rc) -> bool { + match binding.resolved.clone().ident_span.clone() { + Some(s) => ((s.file.clone() == sp.file.clone()) && (s.start.clone() == sp.start.clone())), + None => false, + } +} + +pub fn type_reference_declaration_ref( + n: Rc, + source_indices: Rc>>, + env: Rc, +) -> Option> { + { + let rt = match n.inferred.clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: r, .. }) => r.clone(), + _ => match lookup_type_for(env.clone(), n.clone()) { + Some(bound) => bound.clone(), + None => match lookup_type_by_name( + env.clone(), + crate::v1_std_core::authored_name_at(source_indices.clone(), n.clone()), + ) { + Some(bound) => bound.clone(), + None => n.clone(), + }, + }, + }; + let decl_name = crate::v1_std_core::qualified_last_segment( + crate::v1_std_core::authored_name_at(source_indices.clone(), rt.clone()), + ); + if (decl_name.clone() == "".to_string()) { + return std::option::Option::None; + } + match rt.ident_span.clone() { + None => std::option::Option::None, + Some(sp) => match v1_rt::map_get( + &env.symbol_index.clone().global_bare.clone(), + decl_name.clone(), + ) + .as_deref() + .cloned() + { + Some(GlobalBareLookupState::GlobalBareUniqueBinding { + module_path: mp, + binding: b, + .. + }) => { + if binding_declares_span(b.clone(), sp.clone()) { + Some(crate::std_decl_ref::decl_ref(mp.clone(), decl_name.clone())) + } else { + std::option::Option::None + } + } + Some(GlobalBareLookupState::GlobalBareAmbiguousBinding { + candidates: cands, + .. + }) => match Rc::new({ + let mut __result = Vec::new(); + for c in cands.iter().cloned() { + if binding_declares_span(c.binding.clone(), sp.clone()) { + __result.push(c); + } + } + __result + }) + .first() + .cloned() + { + Some(c) => Some(crate::std_decl_ref::decl_ref( + c.module_path.clone(), + decl_name.clone(), + )), + None => std::option::Option::None, + }, + None => std::option::Option::None, + }, + } + } +} diff --git a/src/v1/stage0/src/v1_compiler_infer_resolve.rs b/src/v1/stage0/src/v1_compiler_infer_resolve.rs index 2bc3204227c..aa3ad0fbf54 100644 --- a/src/v1/stage0/src/v1_compiler_infer_resolve.rs +++ b/src/v1/stage0/src/v1_compiler_infer_resolve.rs @@ -29,9 +29,10 @@ use crate::v1_std_core::CompilerDiagnostic::{ }; use crate::v1_std_core::Connective::{Arrow, Conj, Disj, NoConnective}; use crate::v1_std_core::ExprData::{ - ExprBinOp, ExprBlock, ExprCall, ExprCast, ExprError, ExprFieldAccess, ExprForEach, ExprIf, - ExprIndex, ExprLambda, ExprLet, ExprListLit, ExprLiteral, ExprMatch, ExprMethodCall, - ExprRecordLit, ExprReturn, ExprSlice, ExprStringInterp, ExprUnaryOp, ExprVar, NoExprData, + ExprBinOp, ExprBlock, ExprCall, ExprCast, ExprElaboratedLiteral, ExprError, ExprFieldAccess, + ExprForEach, ExprIf, ExprIndex, ExprLambda, ExprLet, ExprListLit, ExprLiteral, ExprMatch, + ExprMethodCall, ExprRecordLit, ExprReturn, ExprSlice, ExprStringInterp, ExprUnaryOp, ExprVar, + NoExprData, }; use crate::v1_std_core::ExprErrorKind::SemanticExprError; use crate::v1_std_core::InferredNode::{CompilerError, Resolved, TypeVariable}; @@ -2390,6 +2391,10 @@ pub fn resolve_expr_types( expr: texpr.clone(), diagnostics: Rc::new(vec![]), }), + ExprData::ExprElaboratedLiteral { .. } => Rc::new(ExprResolveResult { + expr: texpr.clone(), + diagnostics: Rc::new(vec![]), + }), ExprData::ExprError { kind, message, .. } => Rc::new(ExprResolveResult { expr: crate::v1_std_core::make_expr_error_node( Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), diff --git a/src/v1/stage0/src/v1_compiler_ownership.rs b/src/v1/stage0/src/v1_compiler_ownership.rs index 4a82b79ba34..d340561b89b 100644 --- a/src/v1/stage0/src/v1_compiler_ownership.rs +++ b/src/v1/stage0/src/v1_compiler_ownership.rs @@ -8,8 +8,9 @@ use crate::v1_rt; use crate::v1_rt::{VecCompat, VecJoin}; use crate::v1_std_core::Cardinality::Required; use crate::v1_std_core::ExprData::{ - ExprBlock, ExprCall, ExprError, ExprFieldAccess, ExprForEach, ExprIf, ExprLambda, ExprLet, - ExprLiteral, ExprMatch, ExprMethodCall, ExprRecordLit, ExprReturn, ExprVar, NoExprData, + ExprBlock, ExprCall, ExprElaboratedLiteral, ExprError, ExprFieldAccess, ExprForEach, ExprIf, + ExprLambda, ExprLet, ExprLiteral, ExprMatch, ExprMethodCall, ExprRecordLit, ExprReturn, + ExprVar, NoExprData, }; use crate::v1_std_core::InferredNode::Resolved; use crate::v1_std_core::VarBindingKind::{FunctionValueBinding, LocalValueBinding}; @@ -309,6 +310,7 @@ pub fn walk_expr( } } ExprData::ExprLiteral { value: _, .. } => accum.clone(), + ExprData::ExprElaboratedLiteral { .. } => accum.clone(), ExprData::ExprFieldAccess { .. } => { let base_node = crate::v1_std_core::field_access_base(texpr.clone()); match (*base_node.expr_data.clone()).clone() { @@ -854,6 +856,7 @@ pub fn collect_callable_refs( _ => v1_rt::rc_empty_set::(), }, ExprData::ExprLiteral { value: _, .. } => v1_rt::rc_empty_set::(), + ExprData::ExprElaboratedLiteral { .. } => v1_rt::rc_empty_set::(), ExprData::ExprFieldAccess { .. } => collect_callable_refs( crate::v1_std_core::field_access_base(texpr.clone()), si.clone(), diff --git a/src/v1/stage0/src/v1_std_core.rs b/src/v1/stage0/src/v1_std_core.rs index 2120bf2120b..17948509024 100644 --- a/src/v1/stage0/src/v1_std_core.rs +++ b/src/v1/stage0/src/v1_std_core.rs @@ -29,6 +29,7 @@ use crate::std_algebra::CostShape::*; pub use crate::std_algebra::{AlgebraFieldTemplate, CollectionSizeEffect, CostShape}; pub use crate::std_induction::SubValueRelation; use crate::std_induction::SubValueRelation::*; +pub use crate::std_literal_elaboration::LiteralElaboration; use crate::std_occurrence_identity::NodeOccurrenceIdentity::OccurrenceSynthetic; pub use crate::std_occurrence_identity::OccurrenceId; use crate::std_occurrence_identity::OccurrenceTransportRefusal::{ @@ -301,6 +302,10 @@ pub enum ExprData { ExprLiteral { value: Rc, }, + ExprElaboratedLiteral { + value: Rc, + elaboration: Rc, + }, ExprError { kind: ExprErrorKind, message: String, @@ -2887,6 +2892,10 @@ pub fn expr_literal_int_optional(expr: Rc) -> Option { LiteralValue::LitInt { value: v, .. } => Some(v.clone()), _ => std::option::Option::None, }, + ExprData::ExprElaboratedLiteral { value: lit, .. } => match (*lit.clone()).clone() { + LiteralValue::LitInt { value: v, .. } => Some(v.clone()), + _ => std::option::Option::None, + }, ExprData::ExprUnaryOp { op: UnaryOpKind::Neg, .. @@ -2930,6 +2939,9 @@ pub fn expr_is_any_literal(mut expr: Rc) -> bool { break true; } }, + ExprData::ExprElaboratedLiteral { .. } => { + break true; + } ExprData::ExprUnaryOp { op: UnaryOpKind::Neg, .. @@ -3397,6 +3409,7 @@ pub fn expr_has_non_tail_self_call( binding_kind: _, .. } => false, ExprData::ExprLiteral { value: _, .. } => false, + ExprData::ExprElaboratedLiteral { .. } => false, ExprData::ExprFieldAccess { summary: _, .. } => { let mut __found = false; for child in texpr.children.clone().iter().cloned() { From 4a5f9e5ca64b82b8a7e48e9a817b3ee743c087e5 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 15:54:28 +0000 Subject: [PATCH 60/75] XL-0N: regen mirror for the nested record-literal expansion (fixed point round 2 on 370f5fa) Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_013koFunEtpLQCnvUiz85k7Y --- src/v1/stage0/src/v1_compiler_emit_rust.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index 96efe947dca..e3641369ec7 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -28142,11 +28142,18 @@ pub fn emit_field_value_with_context( } None => pe.clone(), }; + let nested_rt = crate::v1_compiler_infer::expand_type_for_field_access( + crate::v1_compiler_infer_types::resolved_type(field_value.clone()), + scope.type_env.clone(), + scope.module_name.clone(), + ) + .resolved + .clone(); let raw = emit_typed_record_lit( tn.clone(), inner_fields.clone(), corrected_parent.clone(), - crate::v1_compiler_infer_types::resolved_type(field_value.clone()), + nested_rt.clone(), registry.clone(), scope.clone(), depth.clone(), From 991d232fd754eeb792ba6ffc45085e92d32f9457 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 15:55:27 +0000 Subject: [PATCH 61/75] XL-0N: regenerate the stage0 crate partition artifact (main_wet on 370f5fa): std_literal_elaboration, std_operator_realization, gunbc_structural_realization_bindings enter their partition crates Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_013koFunEtpLQCnvUiz85k7Y --- dag/gunbc/stage0/stage0_crate_partition_generated.dag | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dag/gunbc/stage0/stage0_crate_partition_generated.dag b/dag/gunbc/stage0/stage0_crate_partition_generated.dag index 2e41077f14e..c5a1191a37b 100644 --- a/dag/gunbc/stage0/stage0_crate_partition_generated.dag +++ b/dag/gunbc/stage0/stage0_crate_partition_generated.dag @@ -71,6 +71,8 @@ data generated_partition_crate_rows: List = [ "std_occurrence_identity", "std_source_annotation", "std_target_representation", + "std_literal_elaboration", + "std_operator_realization", "v1_std_core" ], reexport_packages: [ @@ -147,6 +149,7 @@ data generated_partition_crate_rows: List = [ kind: GeneratedLayeredCoreCrate, modules: [ "gunbc_rust_source_type_bindings", + "gunbc_structural_realization_bindings", "v1_compiler_coercion", "v1_compiler_infer_emit_info", "v1_compiler_infer_env", From f7b0e1f346c4059ee49353223a50d597ee1db90e Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 16:36:04 +0000 Subject: [PATCH 62/75] XL-0N: partition crates rendered from the regenerated artifact (regen17 fixed point on 991d232); an operand whose declaration cannot be read is a typed refusal carrying its shape, host-by-construction operands named (kernel-minted, generic parameter, container); literal rows spelled in the emitter's record-literal layout Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_013koFunEtpLQCnvUiz85k7Y --- dag/std/operator_realization.dag | 36 +++++++++++++++++-- ...eral_operator_realization_witness_test.dag | 9 +++-- src/v1/05_emit_rust.dag | 23 ++++++++++-- src/v1/coercion.dag | 7 ++++ .../gunbc_stage0_crate_partition_generated.rs | 4 +-- src/v1/stage0_std_core/src/lib.rs | 6 ++++ src/v1/stage0_v1_infer/src/lib.rs | 3 ++ .../peano_nat_structural_realization_test.dag | 19 ++++++++-- 8 files changed, 95 insertions(+), 12 deletions(-) diff --git a/dag/std/operator_realization.dag b/dag/std/operator_realization.dag index d1004549f57..9d8990e3378 100644 --- a/dag/std/operator_realization.dag +++ b/dag/std/operator_realization.dag @@ -32,8 +32,31 @@ import std.syntax { BinOp, Add, Sub, Mul, Div, Mod, Eq, Ne, Lt, Gt, Le, Ge, And, type OperandRealization = HostNumericOperand + | HostRealizedOperand { reason: HostRealizationReason } | StructuralOperand { declaration: DeclarationRef } - | OperandIdentityUnavailable + | OperandIdentityUnavailable { facts: OperandShapeFacts } + +// AN OPERAND THAT REALIZES AS A HOST VALUE BY CONSTRUCTION, without a declaration to ask: the type +// the parser mints for a kernel literal or a builtin's result (a `` file, not a +// declaration in the corpus), a generic type parameter (the host bound carries the operator), and a +// host container (Vec/HashMap realize the container and its comparisons). Each is a decidable arm, +// named so that "no identity" never stands in for "host by construction". +type HostRealizationReason + = KernelMintedType + | GenericTypeParameter + | HostContainer + +// WHAT THE CALLER SAW when it could not read the operand's declaration -- carried on the refusal so +// a miss returns the shape, not a token rustc refuses later under E0369 (DESIGN section 5: a failure +// arm refuses, never widens; the seed's host-token fallback here was the absorbing arm that hid this +// lane's own defect behind an ordinary-looking `<`). +type OperandShapeFacts { + authored_name: String + connective: String + child_count: Int + resolved: Bool + decl_file: String +} // A structural declaration's declared ordering: the comparison to call and the Ordering declaration // whose variants its result is tested against. Keyed on the carrier's exact DeclarationRef. @@ -134,6 +157,7 @@ fn binop_label(op: BinOp) -> String { type OperatorRealizationRefusal = NoStructuralOperationDeclared { declaration: DeclarationRef, operator: String } | StructuralOrderingDuplicated { declaration: DeclarationRef, row_count: Int } + | OperandIdentityUnavailableAt { operator: String, facts: OperandShapeFacts } type OperatorRealization = HostOperator @@ -155,6 +179,12 @@ fn operator_realization_refusal_message(cause: OperatorRealizationRefusal) -> St d.module_path as String, ".", d.decl_name as String, " has more than one declared comparison (gunbc.structural_realization_bindings authoring defect)" ) + OperandIdentityUnavailableAt { operator: o, facts: f } => + concat( + "operator realization: host operator `", o, "` on an operand whose declaration could not be read", + " (authored `", f.authored_name, "`, connective ", f.connective, ", children ", to_string(value: f.child_count), + ", resolved ", if f.resolved { "yes" } else { "no" }, ", decl_file `", f.decl_file, "`)" + ) } } @@ -171,7 +201,9 @@ fn operator_realization_for( ) -> OperatorRealization { match operand { HostNumericOperand => HostOperator - OperandIdentityUnavailable => HostOperator + HostRealizedOperand { reason: _ } => HostOperator + OperandIdentityUnavailable { facts: f } => + OperatorRealizationRefused { cause: OperandIdentityUnavailableAt { operator: binop_label(op: op), facts: f } } StructuralOperand { declaration: d } => match op { Eq => StructuralEquality { declaration: d } diff --git a/dag/test/claim/self_host_peano_literal_operator_realization_witness_test.dag b/dag/test/claim/self_host_peano_literal_operator_realization_witness_test.dag index 2237bae82e4..3341724f584 100644 --- a/dag/test/claim/self_host_peano_literal_operator_realization_witness_test.dag +++ b/dag/test/claim/self_host_peano_literal_operator_realization_witness_test.dag @@ -10,6 +10,9 @@ data live_tree_disposition: LiveTreeDisposition = SubstrateInputsOnly // operations on nontrivial Succ values and the generic decisions by row and identity -- is // v2.test.claim.self_host.peano_nat_structural_realization_test. // +// The required images are spelled in the emitter's record-literal layout (emit_typed_record_lit: +// one field per line, four-space indent, the closing brace at column zero), read off the same +// probes compiled with the lane's fixed-point binary; a single-line spelling never matches. // The forbidden tokens are the emitter's rendering BEFORE this lane, read off the same probes // compiled with the pre-lane binary (recorded here so a reader can see what each row turns red on): // arg boundary crate::v2_std_nat::nat_add(n.clone(), 2) -> E0308 Rc vs integer @@ -26,7 +29,7 @@ test fn w_literal_at_peano_argument_boundary_emits_its_image() -> Bool { compile_dag_rust_emit_check( "module test.claim.peano_arg_probe\nimport std.types { Bool }\nimport v2.std.nat { Nat, nat_add }\nfn probe(n: Nat) -> Nat { nat_add(a: n, b: 2) }\n", "src/test_claim_peano_arg_probe.rs", - ["Nat::Succ { prev: Rc::new(Nat::Succ { prev: Rc::new(Nat::Zero) }) }"], + ["Nat::Succ {\n prev: Rc::new(Nat::Succ {\n prev: Rc::new(Nat::Zero),\n})"], [", 2)"] ) } @@ -36,7 +39,7 @@ test fn w_literal_at_peano_return_boundary_emits_its_image() -> Bool { compile_dag_rust_emit_check( "module test.claim.peano_return_probe\nimport v2.std.nat { Nat }\nfn probe() -> Nat { 2 }\n", "src/test_claim_peano_return_probe.rs", - ["Nat::Succ { prev: Rc::new(Nat::Succ { prev: Rc::new(Nat::Zero) }) }"], + ["Nat::Succ {\n prev: Rc::new(Nat::Succ {\n prev: Rc::new(Nat::Zero),\n})"], ["{\n 2\n}"] ) } @@ -47,7 +50,7 @@ test fn w_literal_operand_of_peano_equality_emits_its_image() -> Bool { compile_dag_rust_emit_check( "module test.claim.peano_literal_eq_probe\nimport std.types { Bool }\nimport v2.std.nat { Nat }\nfn probe(a: Nat) -> Bool { a == 3 }\n", "src/test_claim_peano_literal_eq_probe.rs", - ["== Rc::new(Nat::Succ { prev: Rc::new(Nat::Succ { prev: Rc::new(Nat::Succ { prev: Rc::new(Nat::Zero) }) }) }))"], + ["== Rc::new(Nat::Succ {\n prev: Rc::new(Nat::Succ {\n prev: Rc::new(Nat::Succ {\n prev: Rc::new(Nat::Zero),\n})"], ["== 3)"] ) } diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index 65bafef2188..7d202a7c604 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -96,8 +96,9 @@ import v1.compiler.closure_stub_v2_std_text_rust { closure_stub_v2_std_text_sour import v1.compiler.coercion { coerce_primitive_type, is_copy, lookup_checkpoint, type_reference_decl_file, rust_seed_host_numeric_alias, target_callable, rust_lookup_exact_binding, - declaration_realizes_natively_on_rust + declaration_realizes_natively_on_rust, is_kernel_minted_file } +import v1.compiler.dag_collect_support { connective_name } import v1.compiler.trait_derive_emit { v1_emit_enum_derives, v1_emit_struct_from_capability_table, v1_emit_enum_supplemental_impls, @@ -124,6 +125,7 @@ import v1.compiler.infer_env { TypeEnv, TypeBinding, authored_name, lookup_type_ import std.operator_realization { OperatorRealization, HostOperator, StructuralEquality, StructuralComparison, OperatorRealizationRefused, OperandRealization, HostNumericOperand, StructuralOperand, OperandIdentityUnavailable, + HostRealizedOperand, KernelMintedType, GenericTypeParameter, HostContainer, OperandShapeFacts, StructuralOrderingBinding, OrderingTest, OrderingIs, OrderingIsNot, operator_realization_for, operator_realization_refusal_message } @@ -12045,8 +12047,24 @@ fn rust_operand_realization(operand: Node, scope: InferScope) -> OperandRealizat // (render_rust_alias_rhs_type hops is_where_refinement_type to the first child), so the operand // decision hops the same way, resolving the base through the env as where_refinement_chain does. fn rust_operand_realization_of_type(rt: Node, scope: InferScope, fuel: Int) -> OperandRealization { + let decl_file = type_reference_decl_file(n: rt) + let authored = authored_name_at(source_indices: scope.type_env.source_indices, node: rt) + let rt_is_type_var = match rt.inferred { Present { value: i } => is_type_variable(inferred: i) Absent => false } + if is_kernel_minted_file(file: decl_file) { + HostRealizedOperand { reason: KernelMintedType } + } else if rt_is_type_var { + HostRealizedOperand { reason: GenericTypeParameter } + } else if is_container_type(name: qualified_last_segment(name: authored)) { + HostRealizedOperand { reason: HostContainer } + } else { match type_reference_declaration_ref(n: rt, source_indices: scope.type_env.source_indices, env: scope.type_env) { - Absent => OperandIdentityUnavailable + Absent => OperandIdentityUnavailable { facts: OperandShapeFacts { + authored_name: authored, + connective: connective_name(value: rt.connective), + child_count: rt.children |> count, + resolved: rt.inferred != none, + decl_file: decl_file + } } Present { value: d } => if declaration_realizes_natively_on_rust(declaration: d, decl_file: type_reference_decl_file(n: rt)) { HostNumericOperand @@ -12072,6 +12090,7 @@ fn rust_operand_realization_of_type(rt: Node, scope: InferScope, fuel: Int) -> O } } } + } } diff --git a/src/v1/coercion.dag b/src/v1/coercion.dag index 30559ff39ba..8c2b8a00a4a 100644 --- a/src/v1/coercion.dag +++ b/src/v1/coercion.dag @@ -147,6 +147,13 @@ fn numeric_realization_declaring_modules() -> List { ["dag/std/nat.dag", "dag/std/integer.dag", "` pseudo-file, never a declaration in the corpus. One predicate for the three +// places that read it, so the spelling lives here and not in each consumer. +fn is_kernel_minted_file(file: String) -> Bool { + contains(file, " Bool { if decl_file == "" { false diff --git a/src/v1/stage0/src/gunbc_stage0_crate_partition_generated.rs b/src/v1/stage0/src/gunbc_stage0_crate_partition_generated.rs index 20afea08f33..4dd672c7c2e 100644 --- a/src/v1/stage0/src/gunbc_stage0_crate_partition_generated.rs +++ b/src/v1/stage0/src/gunbc_stage0_crate_partition_generated.rs @@ -54,7 +54,7 @@ pub fn generated_partition_crate_rows() -> Rc package_name: "v1-stage0-std-core".to_string(), crate_dir: "src/v1/stage0_std_core".to_string(), kind: GeneratedPartitionCrateKind::GeneratedLayeredCoreCrate, - modules: Rc::new(vec!["std_content_hash".to_string(), "std_coercion".to_string(), "extdeps_currency_currency".to_string(), "std_decl_ref".to_string(), "std_keyed_row".to_string(), "std_keyed_roster".to_string(), "std_roster_frontier".to_string(), "std_dissolution".to_string(), "std_disposition".to_string(), "std_error_primitives".to_string(), "std_emit_model".to_string(), "std_magnitude".to_string(), "std_measure".to_string(), "std_types".to_string(), "std_unicode_types".to_string(), "std_algebra".to_string(), "std_nat".to_string(), "std_node".to_string(), "std_syntax".to_string(), "std_computation".to_string(), "std_termination".to_string(), "std_checked_arithmetic".to_string(), "std_induction".to_string(), "std_graph".to_string(), "extdeps_uri".to_string(), "extdeps_external_authority".to_string(), "std_process_termination".to_string(), "extdeps_container_oci_digest".to_string(), "extdeps_units_dimensionless".to_string(), "extdeps_units_iec_80000_13".to_string(), "extdeps_units_iso8601".to_string(), "extdeps_units_iso_80000_3".to_string(), "std_occurrence_identity".to_string(), "std_source_annotation".to_string(), "std_target_representation".to_string(), "v1_std_core".to_string()]), + modules: Rc::new(vec!["std_content_hash".to_string(), "std_coercion".to_string(), "extdeps_currency_currency".to_string(), "std_decl_ref".to_string(), "std_keyed_row".to_string(), "std_keyed_roster".to_string(), "std_roster_frontier".to_string(), "std_dissolution".to_string(), "std_disposition".to_string(), "std_error_primitives".to_string(), "std_emit_model".to_string(), "std_magnitude".to_string(), "std_measure".to_string(), "std_types".to_string(), "std_unicode_types".to_string(), "std_algebra".to_string(), "std_nat".to_string(), "std_node".to_string(), "std_syntax".to_string(), "std_computation".to_string(), "std_termination".to_string(), "std_checked_arithmetic".to_string(), "std_induction".to_string(), "std_graph".to_string(), "extdeps_uri".to_string(), "extdeps_external_authority".to_string(), "std_process_termination".to_string(), "extdeps_container_oci_digest".to_string(), "extdeps_units_dimensionless".to_string(), "extdeps_units_iec_80000_13".to_string(), "extdeps_units_iso8601".to_string(), "extdeps_units_iso_80000_3".to_string(), "std_occurrence_identity".to_string(), "std_source_annotation".to_string(), "std_target_representation".to_string(), "std_literal_elaboration".to_string(), "std_operator_realization".to_string(), "v1_std_core".to_string()]), reexport_packages: Rc::new(vec!["v1-stage0-runtime".to_string()]), carries_non_empty_wrappers: false, }), Rc::new(GeneratedPartitionCrateRow { @@ -82,7 +82,7 @@ pub fn generated_partition_crate_rows() -> Rc package_name: "v1-stage0-v1-infer".to_string(), crate_dir: "src/v1/stage0_v1_infer".to_string(), kind: GeneratedPartitionCrateKind::GeneratedLayeredCoreCrate, - modules: Rc::new(vec!["gunbc_rust_source_type_bindings".to_string(), "v1_compiler_coercion".to_string(), "v1_compiler_infer_emit_info".to_string(), "v1_compiler_infer_env".to_string(), "v1_compiler_infer_items".to_string(), "v1_compiler_infer_occurrence_binding".to_string(), "v1_compiler_infer_service".to_string(), "v1_compiler_infer_sigs".to_string(), "v1_compiler_infer_types".to_string(), "v1_compiler_type_head_exposure".to_string()]), + modules: Rc::new(vec!["gunbc_rust_source_type_bindings".to_string(), "gunbc_structural_realization_bindings".to_string(), "v1_compiler_coercion".to_string(), "v1_compiler_infer_emit_info".to_string(), "v1_compiler_infer_env".to_string(), "v1_compiler_infer_items".to_string(), "v1_compiler_infer_occurrence_binding".to_string(), "v1_compiler_infer_service".to_string(), "v1_compiler_infer_sigs".to_string(), "v1_compiler_infer_types".to_string(), "v1_compiler_type_head_exposure".to_string()]), reexport_packages: Rc::new(vec!["v1-stage0-runtime".to_string(), "v1-stage0-std-core".to_string(), "v1-stage0-std-surface".to_string(), "v1-stage0-extdeps-languages".to_string(), "v1-stage0-v1-artifact".to_string()]), carries_non_empty_wrappers: false, }), Rc::new(GeneratedPartitionCrateRow { diff --git a/src/v1/stage0_std_core/src/lib.rs b/src/v1/stage0_std_core/src/lib.rs index 7f6dcc8b681..51000bae6fb 100644 --- a/src/v1/stage0_std_core/src/lib.rs +++ b/src/v1/stage0_std_core/src/lib.rs @@ -126,5 +126,11 @@ pub mod std_source_annotation; #[path = "../../stage0/src/std_target_representation.rs"] pub mod std_target_representation; #[rustfmt::skip] +#[path = "../../stage0/src/std_literal_elaboration.rs"] +pub mod std_literal_elaboration; +#[rustfmt::skip] +#[path = "../../stage0/src/std_operator_realization.rs"] +pub mod std_operator_realization; +#[rustfmt::skip] #[path = "../../stage0/src/v1_std_core.rs"] pub mod v1_std_core; diff --git a/src/v1/stage0_v1_infer/src/lib.rs b/src/v1/stage0_v1_infer/src/lib.rs index 319fe110028..1ea34b7d98c 100644 --- a/src/v1/stage0_v1_infer/src/lib.rs +++ b/src/v1/stage0_v1_infer/src/lib.rs @@ -28,6 +28,9 @@ pub use v1_stage0_v1_artifact::*; #[path = "../../stage0/src/gunbc_rust_source_type_bindings.rs"] pub mod gunbc_rust_source_type_bindings; #[rustfmt::skip] +#[path = "../../stage0/src/gunbc_structural_realization_bindings.rs"] +pub mod gunbc_structural_realization_bindings; +#[rustfmt::skip] #[path = "../../stage0/src/v1_compiler_coercion.rs"] pub mod v1_compiler_coercion; #[rustfmt::skip] diff --git a/src/v2/test/claim/self_host/peano_nat_structural_realization_test.dag b/src/v2/test/claim/self_host/peano_nat_structural_realization_test.dag index 4ea098f9c85..5552eb7636c 100644 --- a/src/v2/test/claim/self_host/peano_nat_structural_realization_test.dag +++ b/src/v2/test/claim/self_host/peano_nat_structural_realization_test.dag @@ -11,7 +11,8 @@ import std.literal_elaboration { literal_homomorphism_for, elaborate_literal_at } import std.operator_realization { - HostNumericOperand, StructuralOperand, OperandIdentityUnavailable, + HostNumericOperand, StructuralOperand, OperandIdentityUnavailable, HostRealizedOperand, KernelMintedType, + OperandShapeFacts, OperandIdentityUnavailableAt, HostOperator, StructuralEquality, StructuralComparison, OperatorRealizationRefused, NoStructuralOperationDeclared, OrderingIs, OrderingIsNot, operator_realization_for @@ -256,11 +257,23 @@ test fn host_numeric_operand_keeps_the_host_operator() -> Bool { HostOperator => true _ => false } - let unknown_holds = match operator_realization_for(op: Ge, operand: OperandIdentityUnavailable, ordering_rows: structural_ordering_rows) { + let by_construction_holds = match operator_realization_for(op: Ge, operand: HostRealizedOperand { reason: KernelMintedType }, ordering_rows: structural_ordering_rows) { HostOperator => true _ => false } - native_holds && unknown_holds + native_holds && by_construction_holds +} + +// AN OPERAND WHOSE DECLARATION COULD NOT BE READ REFUSES, carrying what the caller saw. The seed's +// host-token fallback here was an absorbing arm (DESIGN section 5): it rendered `a < b` on a Peano +// operand as the host `<` with no signature, and the lane's own emitted-path rows went red on a +// token rustc refuses later. This row pins that the unknown arm is a refusal, not a widen. +test fn operand_without_a_readable_declaration_refuses() -> Bool { + let facts = OperandShapeFacts { authored_name: "Nat", connective: "NoConnective", child_count: 0, resolved: false, decl_file: "probe.dag" } + match operator_realization_for(op: Lt, operand: OperandIdentityUnavailable { facts: facts }, ordering_rows: structural_ordering_rows) { + OperatorRealizationRefused { cause: OperandIdentityUnavailableAt { operator: o, facts: f } } => o == "<" && f.authored_name == "Nat" + _ => false + } } test fn logical_connective_on_a_structural_operand_stays_host() -> Bool { From 022d265a323f7e06178692734dde51914817fe91 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 17:02:38 +0000 Subject: [PATCH 63/75] XL-0N: an operand without a readable declaration decides by operator class -- equality and connectives are the host token by construction, ordering and arithmetic refuse with the shape facts (regen18 census: 50 sites, all equality) Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_013koFunEtpLQCnvUiz85k7Y --- dag/std/operator_realization.dag | 28 ++++++++++++++++++- .../peano_nat_structural_realization_test.dag | 18 +++++++++++- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/dag/std/operator_realization.dag b/dag/std/operator_realization.dag index 9d8990e3378..756b3ab36b1 100644 --- a/dag/std/operator_realization.dag +++ b/dag/std/operator_realization.dag @@ -46,6 +46,17 @@ type HostRealizationReason | GenericTypeParameter | HostContainer +// AN OPERAND WITHOUT A READABLE DECLARATION decides BY OPERATOR CLASS, never by guessing a +// declaration. Equality and the connectives do not depend on the declaration at all: every +// structural declaration realizes equality structurally and every host value realizes it natively, +// and on the target these are one token (the emitted enum derives PartialEq), so `==`/`!=`/`&&`/ +// `||`/`??` on such an operand are the host token by construction -- the same bytes a known +// declaration would produce. Ordering and arithmetic DO depend on the declaration (a declared +// comparison, or a refusal), so on an unreadable declaration they refuse, carrying the facts below. +// Measured on the v1 closure (XL-0N regen18, 50 sites / 139 refusals): every unreadable-declaration +// operand in the seed is under `==` or `!=` -- field-access and method-return type nodes inference +// synthesizes without a span -- and none is under an ordering or arithmetic operator. +// // WHAT THE CALLER SAW when it could not read the operand's declaration -- carried on the refusal so // a miss returns the shape, not a token rustc refuses later under E0369 (DESIGN section 5: a failure // arm refuses, never widens; the seed's host-token fallback here was the absorbing arm that hid this @@ -203,7 +214,22 @@ fn operator_realization_for( HostNumericOperand => HostOperator HostRealizedOperand { reason: _ } => HostOperator OperandIdentityUnavailable { facts: f } => - OperatorRealizationRefused { cause: OperandIdentityUnavailableAt { operator: binop_label(op: op), facts: f } } + match op { + Eq => HostOperator + Ne => HostOperator + And => HostOperator + Or => HostOperator + NullCoalesce => HostOperator + Lt => OperatorRealizationRefused { cause: OperandIdentityUnavailableAt { operator: binop_label(op: op), facts: f } } + Gt => OperatorRealizationRefused { cause: OperandIdentityUnavailableAt { operator: binop_label(op: op), facts: f } } + Le => OperatorRealizationRefused { cause: OperandIdentityUnavailableAt { operator: binop_label(op: op), facts: f } } + Ge => OperatorRealizationRefused { cause: OperandIdentityUnavailableAt { operator: binop_label(op: op), facts: f } } + Add => OperatorRealizationRefused { cause: OperandIdentityUnavailableAt { operator: binop_label(op: op), facts: f } } + Sub => OperatorRealizationRefused { cause: OperandIdentityUnavailableAt { operator: binop_label(op: op), facts: f } } + Mul => OperatorRealizationRefused { cause: OperandIdentityUnavailableAt { operator: binop_label(op: op), facts: f } } + Div => OperatorRealizationRefused { cause: OperandIdentityUnavailableAt { operator: binop_label(op: op), facts: f } } + Mod => OperatorRealizationRefused { cause: OperandIdentityUnavailableAt { operator: binop_label(op: op), facts: f } } + } StructuralOperand { declaration: d } => match op { Eq => StructuralEquality { declaration: d } diff --git a/src/v2/test/claim/self_host/peano_nat_structural_realization_test.dag b/src/v2/test/claim/self_host/peano_nat_structural_realization_test.dag index 5552eb7636c..13830b3542e 100644 --- a/src/v2/test/claim/self_host/peano_nat_structural_realization_test.dag +++ b/src/v2/test/claim/self_host/peano_nat_structural_realization_test.dag @@ -270,10 +270,26 @@ test fn host_numeric_operand_keeps_the_host_operator() -> Bool { // token rustc refuses later. This row pins that the unknown arm is a refusal, not a widen. test fn operand_without_a_readable_declaration_refuses() -> Bool { let facts = OperandShapeFacts { authored_name: "Nat", connective: "NoConnective", child_count: 0, resolved: false, decl_file: "probe.dag" } - match operator_realization_for(op: Lt, operand: OperandIdentityUnavailable { facts: facts }, ordering_rows: structural_ordering_rows) { + let ordering_refuses = match operator_realization_for(op: Lt, operand: OperandIdentityUnavailable { facts: facts }, ordering_rows: structural_ordering_rows) { OperatorRealizationRefused { cause: OperandIdentityUnavailableAt { operator: o, facts: f } } => o == "<" && f.authored_name == "Nat" _ => false } + let arithmetic_refuses = match operator_realization_for(op: Div, operand: OperandIdentityUnavailable { facts: facts }, ordering_rows: structural_ordering_rows) { + OperatorRealizationRefused { cause: OperandIdentityUnavailableAt { operator: o, facts: _ } } => o == "/" + _ => false + } + ordering_refuses && arithmetic_refuses +} + +// EQUALITY ON THE SAME OPERAND IS THE HOST TOKEN BY CONSTRUCTION: structural and host equality are +// one token on the target, so the decision does not need the declaration. This is a decided arm, +// not the widen above -- ordering on the same operand refuses (the row before this one). +test fn equality_without_a_readable_declaration_is_host_by_construction() -> Bool { + let facts = OperandShapeFacts { authored_name: "", connective: "NoConnective", child_count: 0, resolved: true, decl_file: "" } + match operator_realization_for(op: Eq, operand: OperandIdentityUnavailable { facts: facts }, ordering_rows: structural_ordering_rows) { + HostOperator => true + _ => false + } } test fn logical_connective_on_a_structural_operand_stays_host() -> Bool { From 279ab70ef467c6506c01bf8aec6f93a34d0faea0 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 17:45:52 +0000 Subject: [PATCH 64/75] XL-0N: the binary operator's operand declaration is read once at inference and carried on the typed tree (ExprBinOp.operand: OperandDeclaration); emission consumes it -- the emitter-scope by-name read answered the pool-precedence homonym (std.nat.Nat for a v2.std.nat import) and is removed; regen19 mirrors Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_013koFunEtpLQCnvUiz85k7Y --- dag/std/operator_realization.dag | 12 ++ src/v1/00_core.dag | 3 +- src/v1/02_parse.dag | 4 +- src/v1/04_env.dag | 35 ++-- src/v1/04_infer.dag | 26 ++- src/v1/04_resolve.dag | 4 +- src/v1/05_emit_rust.dag | 25 ++- src/v1/stage0/src/std_operator_realization.rs | 126 ++++++++++--- src/v1/stage0/src/v1_compiler_coercion.rs | 4 + src/v1/stage0/src/v1_compiler_emit_rust.rs | 177 +++++++++++------- 10 files changed, 297 insertions(+), 119 deletions(-) diff --git a/dag/std/operator_realization.dag b/dag/std/operator_realization.dag index 756b3ab36b1..22fbc080d27 100644 --- a/dag/std/operator_realization.dag +++ b/dag/std/operator_realization.dag @@ -30,6 +30,18 @@ import std.syntax { BinOp, Add, Sub, Mul, Div, Mod, Eq, Ne, Lt, Gt, Le, Ge, And, // operation exists to expose. So the source spells structural arithmetic as calls, and this // decision refuses the infix form on structural operands. +// THE OPERAND'S DECLARATION AS READ AT INFERENCE, carried on the typed tree (the ExprBinOp node) +// so emission consumes it and never re-reads identity with a weaker env. Inference reads a +// parameter's type reference in the function's own scope, where the reference's ident binding is +// live; the emitter's scope is the module env, where that binding is gone and a by-name read can +// only answer the module-visible homonym (measured: `a < b` with a: v2.std.nat.Nat emitted the host +// `<` because the emitter read std.nat.Nat, which realizes natively). decl_file is the declaration's +// own file -- the key v1.compiler.coercion's native-realization decision is made on. +type OperandDeclaration { + declaration: DeclarationRef + decl_file: String +} + type OperandRealization = HostNumericOperand | HostRealizedOperand { reason: HostRealizationReason } diff --git a/src/v1/00_core.dag b/src/v1/00_core.dag index e4fb438ae52..51758f396cd 100644 --- a/src/v1/00_core.dag +++ b/src/v1/00_core.dag @@ -9,6 +9,7 @@ import std.syntax { } import std.algebra { CollectionSizeEffect, CostShape, AlgebraFieldTemplate } import std.literal_elaboration { LiteralElaboration } +import std.operator_realization { OperandDeclaration } import std.induction { SubValueRelation } import std.occurrence_identity { NodeOccurrenceIdentity, @@ -177,7 +178,7 @@ type ExprData | ExprLet | ExprRecordLit { parent_enum: String? } | ExprListLit - | ExprBinOp { op: BinOp, algebra_field: AlgebraFieldKind? } + | ExprBinOp { op: BinOp, algebra_field: AlgebraFieldKind?, operand: OperandDeclaration? } | ExprUnaryOp { op: UnaryOpKind } | ExprLambda | ExprStringInterp diff --git a/src/v1/02_parse.dag b/src/v1/02_parse.dag index 7ce9a37c2a2..a23b72a5661 100644 --- a/src/v1/02_parse.dag +++ b/src/v1/02_parse.dag @@ -4613,7 +4613,7 @@ fn parse_expr_loop(tokens: TokenStream, ctx: ParseContext, lhs: Node, min_bp: In match binop_opt { Present { value: binop } => { let minted = mint_parsed_node_identity(ctx: r.ctx) - let new_lhs = make_expr_node(occurrence_identity: minted.identity, expr_data: ExprBinOp { op: binop, algebra_field: none }, children: [lhs, r.expr], inferred: none, span: loop_span) + let new_lhs = make_expr_node(occurrence_identity: minted.identity, expr_data: ExprBinOp { op: binop, algebra_field: none, operand: none }, children: [lhs, r.expr], inferred: none, span: loop_span) parse_expr_loop(tokens: r.tokens, ctx: minted.ctx, lhs: new_lhs, min_bp: min_bp) } Absent => ExprResult { expr: lhs, tokens: r.tokens, ctx: r.ctx, err: Present { value: parse_error(msg: concat("unknown binary operator: ", op_tok.text), span: loop_span) } } @@ -5270,7 +5270,7 @@ fn parse_expr_loop_no_brace(tokens: TokenStream, ctx: ParseContext, lhs: Node, m match binop_opt { Present { value: binop } => { let minted = mint_parsed_node_identity(ctx: r.ctx) - let new_lhs = make_expr_node(occurrence_identity: minted.identity, expr_data: ExprBinOp { op: binop, algebra_field: none }, children: [lhs, r.expr], inferred: none, span: loop_span) + let new_lhs = make_expr_node(occurrence_identity: minted.identity, expr_data: ExprBinOp { op: binop, algebra_field: none, operand: none }, children: [lhs, r.expr], inferred: none, span: loop_span) parse_expr_loop_no_brace(tokens: r.tokens, ctx: minted.ctx, lhs: new_lhs, min_bp: min_bp) } Absent => ExprResult { expr: lhs, tokens: r.tokens, ctx: r.ctx, err: Present { value: parse_error(msg: concat("unknown binary operator: ", op_tok.text), span: loop_span) } } diff --git a/src/v1/04_env.dag b/src/v1/04_env.dag index 90f0084d9ab..d1aed9dd3ef 100644 --- a/src/v1/04_env.dag +++ b/src/v1/04_env.dag @@ -7,6 +7,7 @@ import v1.compiler.type_head_exposure { TypeHeadExposure } import std.types { SourceSpan, is_kernel_type } import std.decl_ref { decl_ref, DeclarationRef } +import std.operator_realization { OperandDeclaration } import std.induction { InductiveField, RecursionShape, DirectRecursion, ListRecursion, OptionalRecursion, SetRecursion, MapValueRecursion, SubValueRelation, SubValueUnknown, PreservedValue } import std.algebra { FreeMonoid, Empty, Cons } @@ -1244,23 +1245,20 @@ fn binding_declares_span(binding: TypeBinding, sp: SourceSpan) -> Bool { // (lookup_type_for) carries the declaration's own ident_span, which is the span the global roster is // matched on. Without this arm every recursive destination answered Absent here and fell to the // identity-unavailable arms downstream (measured: the Peano literal and ordering rows passed for -// v2.std.logic Bool and failed for v2.std.nat Nat on the same compiler). The ident-keyed lookup -// serves inference; the emitter's scope env answers a reference by the module-visible NAME -// (lookup_type_by_name), which is that module's own import binding -- and either way the -// declaration found here is then matched by SPAN against the global roster, so a by-name hit can -// only ever confirm an exact declaration, never pick among homonyms (measured: the Peano literal -// rows passed and the Peano operator rows failed on the same compiler after the ident arm alone). -fn type_reference_declaration_ref(n: Node, source_indices: Map, env: TypeEnv) -> DeclarationRef? { +// v2.std.logic Bool and failed for v2.std.nat Nat on the same compiler). The ident-keyed lookup is +// scoped: a parameter's type reference is bound in its function's scope, so this read is correct +// at inference and NOT at emission, where only the module env survives. A by-name arm was tried +// here for the emitter and refuted: the module-visible name is answered by pool precedence, so it +// returned std.nat.Nat for a module that imported v2.std.nat.Nat, and the span match then confirmed +// that homonym exactly. The reading is therefore done once, at inference, and carried on the typed +// tree (std.operator_realization OperandDeclaration on ExprBinOp) for emission to consume. +fn type_reference_declaration(n: Node, source_indices: Map, env: TypeEnv) -> OperandDeclaration? { let rt = match n.inferred { Present { value: Resolved { node: r } } => r _ => match lookup_type_for(env: env, node: n) { Present { value: bound } => bound - Absent => - match lookup_type_by_name(env: env, name: authored_name_at(source_indices: source_indices, node: n)) { - Present { value: bound } => bound - Absent => n - } + Absent => n } } let decl_name = qualified_last_segment(name: authored_name_at(source_indices: source_indices, node: rt)) @@ -1270,13 +1268,22 @@ fn type_reference_declaration_ref(n: Node, source_indices: Map match map_get(env.symbol_index.global_bare, decl_name) { Present { value: GlobalBareUniqueBinding { module_path: mp, binding: b } } => - if binding_declares_span(binding: b, sp: sp) { Present { value: decl_ref(module_path: mp, decl_name: decl_name) } } else { none } + if binding_declares_span(binding: b, sp: sp) { + Present { value: OperandDeclaration { declaration: decl_ref(module_path: mp, decl_name: decl_name), decl_file: sp.file } } + } else { none } Present { value: GlobalBareAmbiguousBinding { candidates: cands } } => match cands |> filter(c => binding_declares_span(binding: c.binding, sp: sp)) |> first { - Present { value: c } => Present { value: decl_ref(module_path: c.module_path, decl_name: decl_name) } + Present { value: c } => Present { value: OperandDeclaration { declaration: decl_ref(module_path: c.module_path, decl_name: decl_name), decl_file: sp.file } } Absent => none } Absent => none } } } + +fn type_reference_declaration_ref(n: Node, source_indices: Map, env: TypeEnv) -> DeclarationRef? { + match type_reference_declaration(n: n, source_indices: source_indices, env: env) { + Present { value: od } => Present { value: od.declaration } + Absent => none + } +} diff --git a/src/v1/04_infer.dag b/src/v1/04_infer.dag index 138c546b144..f56084d494c 100644 --- a/src/v1/04_infer.dag +++ b/src/v1/04_infer.dag @@ -10,6 +10,7 @@ import std.content_hash { import extdeps.container.oci.digest { oci_other_digest_algorithm, oci_other_digest_encoded } import std.syntax { Add, BinOp, LitStr, LitInt, LitBool, LiteralValue } import std.decl_ref { DeclarationRef } +import std.operator_realization { OperandDeclaration } import std.literal_elaboration { LiteralElaboration, LiteralHomomorphism, LiteralUnfolding, PeanoUnfold, BooleanUnfold, LiteralElaborationOutcome, DirectLiteral, ViaHomomorphism, LiteralElaborationRefused, @@ -123,7 +124,7 @@ import v1.compiler.infer_env { qualify_borrowed_type_names, qualify_borrowed_inferred, qualified_all_but_last, env_with_type_variable_bindings, GlobalBareCandidate, node_with_inferred, node_with_children, ServiceCensusEntry, qualify_decl_reference_positions, - lookup_binding_by_name, binding_declares_name, type_reference_declaration_ref, + lookup_binding_by_name, binding_declares_name, type_reference_declaration_ref, type_reference_declaration, listed_import_required_bare_call_blocked, effective_visible_binding, unit_variant_index_shadow_insert, build_unit_variant_index, UnitVariantContribution @@ -4851,6 +4852,27 @@ type BinopOperands { right: InferResult } +// THE LEFT OPERAND'S DECLARATION, read here where the reference's scoped binding is live, after +// hopping a where-refinement to its base (`type Char = Int where ...` realizes as Int): the fact +// std.operator_realization decides on, stamped on the ExprBinOp node for emission. Absent when the +// operand's type node names no declaration (an inference-synthesized node), which emission answers +// by operator class. +fn operand_declaration_of_type(rt: Node, scope: InferScope, fuel: Int) -> OperandDeclaration? { + if fuel > 0 && is_where_refinement_type(ty: rt) { + match rt.children |> first { + Present { value: base } => + let base_resolved = match lookup_type_for(env: scope.type_env, node: base) { + Present { value: r } => r + Absent => base + } + operand_declaration_of_type(rt: base_resolved, scope: scope, fuel: fuel - 1) + Absent => type_reference_declaration(n: rt, source_indices: scope.type_env.source_indices, env: scope.type_env) + } + } else { + type_reference_declaration(n: rt, source_indices: scope.type_env.source_indices, env: scope.type_env) + } +} + fn infer_operand_literal(lit_expr: Node, other: Node, scope: InferScope) -> InferResult { let other_type = match other.inferred { Present { value: Resolved { node: rt } } => Present { value: rt } @@ -5996,7 +6018,7 @@ fn infer_expr_body(texpr: Node, scope: InferScope, expected: Node?) -> InferResu let right_typed = right_result.typed let right_diags = right_result.diagnostics let binop_info = infer_binop_type_node(op: op, left_type: resolved_type(n: left_typed), source_indices: scope.type_env.source_indices) - let bo_texpr = make_expr_node(occurrence_identity: texpr.occurrence_identity, expr_data: ExprBinOp { op: op, algebra_field: binop_info.algebra_field }, children: [left_typed, right_typed], inferred: Present { value: Resolved { node: binop_info.result_type } }, span: span) + let bo_texpr = make_expr_node(occurrence_identity: texpr.occurrence_identity, expr_data: ExprBinOp { op: op, algebra_field: binop_info.algebra_field, operand: operand_declaration_of_type(rt: resolved_type(n: left_typed), scope: scope, fuel: 8) }, children: [left_typed, right_typed], inferred: Present { value: Resolved { node: binop_info.result_type } }, span: span) InferResult { typed: bo_texpr, diagnostics: concat(left_diags, right_diags) diff --git a/src/v1/04_resolve.dag b/src/v1/04_resolve.dag index 7bd0faaa823..676c10dc0b0 100644 --- a/src/v1/04_resolve.dag +++ b/src/v1/04_resolve.dag @@ -963,11 +963,11 @@ fn resolve_expr_types(texpr: Node, env: TypeEnv, module_name: String) -> ExprRes let resolved_children = el_results |> map(r => r.expr) let all_diags = flat_map(el_results, r => r.diagnostics) ExprResolveResult { expr: make_expr_node(occurrence_identity: texpr.occurrence_identity, expr_data: ExprListLit, children: resolved_children, inferred: texpr.inferred, span: texpr.span), diagnostics: all_diags } - ExprBinOp { op: op, algebra_field: af } => + ExprBinOp { op: op, algebra_field: af, operand: od } => let ch = texpr.children let lr = match ch |> first { Present { value: l } => resolve_expr_types(texpr: l, env: env, module_name: module_name) Absent => ExprResolveResult { expr: texpr, diagnostics: [] } } let rr = match ch |> skip(1) |> first { Present { value: r } => resolve_expr_types(texpr: r, env: env, module_name: module_name) Absent => ExprResolveResult { expr: texpr, diagnostics: [] } } - ExprResolveResult { expr: make_expr_node(occurrence_identity: texpr.occurrence_identity, expr_data: ExprBinOp { op: op, algebra_field: af }, children: [lr.expr, rr.expr], inferred: texpr.inferred, span: texpr.span), diagnostics: concat(lr.diagnostics, rr.diagnostics) } + ExprResolveResult { expr: make_expr_node(occurrence_identity: texpr.occurrence_identity, expr_data: ExprBinOp { op: op, algebra_field: af, operand: od }, children: [lr.expr, rr.expr], inferred: texpr.inferred, span: texpr.span), diagnostics: concat(lr.diagnostics, rr.diagnostics) } ExprUnaryOp { op: op } => let r = match texpr.children |> first { Present { value: o } => resolve_expr_types(texpr: o, env: env, module_name: module_name) Absent => ExprResolveResult { expr: texpr, diagnostics: [] } } ExprResolveResult { expr: make_expr_node(occurrence_identity: texpr.occurrence_identity, expr_data: ExprUnaryOp { op: op }, children: [r.expr], inferred: texpr.inferred, span: texpr.span), diagnostics: r.diagnostics } diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index 7d202a7c604..f053d2af882 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -125,7 +125,7 @@ import v1.compiler.infer_env { TypeEnv, TypeBinding, authored_name, lookup_type_ import std.operator_realization { OperatorRealization, HostOperator, StructuralEquality, StructuralComparison, OperatorRealizationRefused, OperandRealization, HostNumericOperand, StructuralOperand, OperandIdentityUnavailable, - HostRealizedOperand, KernelMintedType, GenericTypeParameter, HostContainer, OperandShapeFacts, + HostRealizedOperand, KernelMintedType, GenericTypeParameter, HostContainer, OperandShapeFacts, OperandDeclaration, StructuralOrderingBinding, OrderingTest, OrderingIs, OrderingIsNot, operator_realization_for, operator_realization_refusal_message } @@ -9607,8 +9607,8 @@ fn emit_rust_expr_slice(expr: Node, registry: Map, scope: Infe fn emit_rust_expr_bin_op(expr: Node, registry: Map, scope: InferScope, depth: Int, shared_types: Set, emit_info: EmitGraphInfo) -> String { match expr.expr_data { - ExprBinOp { op: op, algebra_field: algebra } => - emit_typed_bin_op(op: op, algebra_field: algebra, left: binop_left(texpr: expr), right: binop_right(texpr: expr), registry: registry, scope: scope, depth: depth, shared_types: shared_types, emit_info: emit_info) + ExprBinOp { op: op, algebra_field: algebra, operand: od } => + emit_typed_bin_op(op: op, algebra_field: algebra, operand: od, left: binop_left(texpr: expr), right: binop_right(texpr: expr), registry: registry, scope: scope, depth: depth, shared_types: shared_types, emit_info: emit_info) _ => emit_error_expr(message: "emit_rust_expr_bin_op expected ExprBinOp", target: Rust) } } @@ -12001,13 +12001,13 @@ fn rust_zero_value(type_name: String) -> String? { else { none } } -fn emit_typed_bin_op(op: BinOp, algebra_field: AlgebraFieldKind?, left: Node, right: Node, registry: Map, scope: InferScope, depth: Int, shared_types: Set, emit_info: EmitGraphInfo) -> String { +fn emit_typed_bin_op(op: BinOp, algebra_field: AlgebraFieldKind?, operand: OperandDeclaration?, left: Node, right: Node, registry: Map, scope: InferScope, depth: Int, shared_types: Set, emit_info: EmitGraphInfo) -> String { let l_str = emit_typed_expr(texpr: left, registry: registry, scope: scope, depth: depth, shared_types: shared_types, emit_info: emit_info, fuel: 1024) let r_str = emit_typed_expr(texpr: right, registry: registry, scope: scope, depth: depth, shared_types: shared_types, emit_info: emit_info, fuel: 1024) if is_null_coalesce(op: op) { emit_null_coalesce(l_str: l_str, r_str: r_str, target: Rust) } else { - match binop_operator_realization(op: op, left: left, scope: scope) { + match binop_operator_realization(op: op, operand: operand, left: left, scope: scope) { OperatorRealizationRefused { cause: c } => emit_rust_compile_error_expr(message: operator_realization_refusal_message(cause: c)) StructuralComparison { declaration: _, binding: b, test: t } => @@ -12094,8 +12094,19 @@ fn rust_operand_realization_of_type(rt: Node, scope: InferScope, fuel: Int) -> O } -fn binop_operator_realization(op: BinOp, left: Node, scope: InferScope) -> OperatorRealization { - operator_realization_for(op: op, operand: rust_operand_realization(operand: left, scope: scope), ordering_rows: structural_ordering_rows) +// The operand's declaration is the one inference stamped on the node (std.operator_realization +// OperandDeclaration); the rt-shape read below is the residue for a node that carries none. +fn binop_operator_realization(op: BinOp, operand: OperandDeclaration?, left: Node, scope: InferScope) -> OperatorRealization { + let realization = match operand { + Present { value: od } => + if declaration_realizes_natively_on_rust(declaration: od.declaration, decl_file: od.decl_file) { + HostNumericOperand + } else { + StructuralOperand { declaration: od.declaration } + } + Absent => rust_operand_realization(operand: left, scope: scope) + } + operator_realization_for(op: op, operand: realization, ordering_rows: structural_ordering_rows) } fn rust_declaration_path(module_path: String, decl_name: String) -> String { diff --git a/src/v1/stage0/src/std_operator_realization.rs b/src/v1/stage0/src/std_operator_realization.rs index 11611aab1b4..4f5fb5365c9 100644 --- a/src/v1/stage0/src/std_operator_realization.rs +++ b/src/v1/stage0/src/std_operator_realization.rs @@ -1,6 +1,7 @@ // Generated by v1 compiler -- do not edit. // Source module: std.operator_realization +use self::HostRealizationReason::*; use self::OperandRealization::*; use self::OperatorRealization::*; use self::OperatorRealizationRefusal::*; @@ -25,21 +26,28 @@ use std::rc::Rc; #[serde(tag = "_variant")] pub enum OperandRealization { HostNumericOperand, + HostRealizedOperand { reason: HostRealizationReason }, StructuralOperand { declaration: Rc }, - OperandIdentityUnavailable, + OperandIdentityUnavailable { facts: Rc }, } -impl OperandRealization { - pub fn declaration(&self) -> Rc { - match self { - OperandRealization::HostNumericOperand => panic!("no declaration on unit variant"), - OperandRealization::StructuralOperand { - declaration: __val, .. - } => __val.clone(), - OperandRealization::OperandIdentityUnavailable => { - panic!("no declaration on unit variant") - } - } - } + +#[derive( + Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize, +)] +#[serde(tag = "_variant")] +pub enum HostRealizationReason { + KernelMintedType, + GenericTypeParameter, + HostContainer, +} + +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct OperandShapeFacts { + pub authored_name: String, + pub connective: String, + pub child_count: i64, + pub resolved: bool, + pub decl_file: String, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -186,19 +194,10 @@ pub enum OperatorRealizationRefusal { declaration: Rc, row_count: i64, }, -} -impl OperatorRealizationRefusal { - pub fn declaration(&self) -> Rc { - match self { - OperatorRealizationRefusal::NoStructuralOperationDeclared { - declaration: __val, - .. - } => __val.clone(), - OperatorRealizationRefusal::StructuralOrderingDuplicated { - declaration: __val, .. - } => __val.clone(), - } - } + OperandIdentityUnavailableAt { + operator: String, + facts: Rc, + }, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -222,6 +221,11 @@ pub fn operator_realization_refusal_message(cause: Rc v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("operator realization: host operator `".to_string(), o.clone()), "` on structural operand ".to_string()), d.module_path.clone()), ".".to_string()), d.decl_name.clone()), " -- the declaration has no host realization and declares no operation for this operator; spell the operation as a call to the declared structural operation".to_string()), OperatorRealizationRefusal::StructuralOrderingDuplicated { declaration: d, row_count: n, .. } => v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("operator realization: structural ordering for ".to_string(), d.module_path.clone()), ".".to_string()), d.decl_name.clone()), " has more than one declared comparison (gunbc.structural_realization_bindings authoring defect)".to_string()), + OperatorRealizationRefusal::OperandIdentityUnavailableAt { operator: o, facts: f, .. } => v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("operator realization: host operator `".to_string(), o.clone()), "` on an operand whose declaration could not be read".to_string()), " (authored `".to_string()), f.authored_name.clone()), "`, connective ".to_string()), f.connective.clone()), ", children ".to_string()), (f.child_count.clone()).to_string()), ", resolved ".to_string()), if f.resolved.clone() { + "yes".to_string() + } else { + "no".to_string() + }), ", decl_file `".to_string()), f.decl_file.clone()), "`)".to_string()), } } @@ -232,9 +236,70 @@ pub fn operator_realization_for( ) -> Rc { match (*operand.clone()).clone() { OperandRealization::HostNumericOperand => Rc::new(OperatorRealization::HostOperator), - OperandRealization::OperandIdentityUnavailable => { + OperandRealization::HostRealizedOperand { reason: _, .. } => { Rc::new(OperatorRealization::HostOperator) } + OperandRealization::OperandIdentityUnavailable { facts: f, .. } => match op.clone() { + BinOp::Eq => Rc::new(OperatorRealization::HostOperator), + BinOp::Ne => Rc::new(OperatorRealization::HostOperator), + BinOp::And => Rc::new(OperatorRealization::HostOperator), + BinOp::Or => Rc::new(OperatorRealization::HostOperator), + BinOp::NullCoalesce => Rc::new(OperatorRealization::HostOperator), + BinOp::Lt => Rc::new(OperatorRealization::OperatorRealizationRefused { + cause: Rc::new(OperatorRealizationRefusal::OperandIdentityUnavailableAt { + operator: binop_label(op.clone()), + facts: f.clone(), + }), + }), + BinOp::Gt => Rc::new(OperatorRealization::OperatorRealizationRefused { + cause: Rc::new(OperatorRealizationRefusal::OperandIdentityUnavailableAt { + operator: binop_label(op.clone()), + facts: f.clone(), + }), + }), + BinOp::Le => Rc::new(OperatorRealization::OperatorRealizationRefused { + cause: Rc::new(OperatorRealizationRefusal::OperandIdentityUnavailableAt { + operator: binop_label(op.clone()), + facts: f.clone(), + }), + }), + BinOp::Ge => Rc::new(OperatorRealization::OperatorRealizationRefused { + cause: Rc::new(OperatorRealizationRefusal::OperandIdentityUnavailableAt { + operator: binop_label(op.clone()), + facts: f.clone(), + }), + }), + BinOp::Add => Rc::new(OperatorRealization::OperatorRealizationRefused { + cause: Rc::new(OperatorRealizationRefusal::OperandIdentityUnavailableAt { + operator: binop_label(op.clone()), + facts: f.clone(), + }), + }), + BinOp::Sub => Rc::new(OperatorRealization::OperatorRealizationRefused { + cause: Rc::new(OperatorRealizationRefusal::OperandIdentityUnavailableAt { + operator: binop_label(op.clone()), + facts: f.clone(), + }), + }), + BinOp::Mul => Rc::new(OperatorRealization::OperatorRealizationRefused { + cause: Rc::new(OperatorRealizationRefusal::OperandIdentityUnavailableAt { + operator: binop_label(op.clone()), + facts: f.clone(), + }), + }), + BinOp::Div => Rc::new(OperatorRealization::OperatorRealizationRefused { + cause: Rc::new(OperatorRealizationRefusal::OperandIdentityUnavailableAt { + operator: binop_label(op.clone()), + facts: f.clone(), + }), + }), + BinOp::Mod => Rc::new(OperatorRealization::OperatorRealizationRefused { + cause: Rc::new(OperatorRealizationRefusal::OperandIdentityUnavailableAt { + operator: binop_label(op.clone()), + facts: f.clone(), + }), + }), + }, OperandRealization::StructuralOperand { declaration: d, .. } => match op.clone() { BinOp::Eq => Rc::new(OperatorRealization::StructuralEquality { declaration: d.clone(), @@ -309,3 +374,10 @@ pub fn structural_ordering_realization( } } } + +#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +pub struct KernelMintedType; +#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +pub struct GenericTypeParameter; +#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +pub struct HostContainer; diff --git a/src/v1/stage0/src/v1_compiler_coercion.rs b/src/v1/stage0/src/v1_compiler_coercion.rs index a4cf840e7b5..2812011e38b 100644 --- a/src/v1/stage0/src/v1_compiler_coercion.rs +++ b/src/v1/stage0/src/v1_compiler_coercion.rs @@ -225,6 +225,10 @@ pub fn numeric_realization_declaring_modules() -> Rc> { ]) } +pub fn is_kernel_minted_file(file: String) -> bool { + v1_rt::contains(file.clone(), " bool { if (decl_file.clone() == "".to_string()) { false diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index e3641369ec7..044b86fe868 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -47,8 +47,11 @@ pub use crate::std_measure::millisecond_count; pub use crate::std_nat::Nat; pub use crate::std_occurrence_identity::NodeOccurrenceIdentity; use crate::std_occurrence_identity::NodeOccurrenceIdentity::OccurrenceSynthetic; +use crate::std_operator_realization::HostRealizationReason::{ + GenericTypeParameter, HostContainer, KernelMintedType, +}; use crate::std_operator_realization::OperandRealization::{ - HostNumericOperand, OperandIdentityUnavailable, StructuralOperand, + HostNumericOperand, HostRealizedOperand, OperandIdentityUnavailable, StructuralOperand, }; use crate::std_operator_realization::OperatorRealization::{ HostOperator, OperatorRealizationRefused, StructuralComparison, StructuralEquality, @@ -58,7 +61,8 @@ pub use crate::std_operator_realization::{ operator_realization_for, operator_realization_refusal_message, }; pub use crate::std_operator_realization::{ - OperandRealization, OperatorRealization, OrderingTest, StructuralOrderingBinding, + HostRealizationReason, OperandRealization, OperandShapeFacts, OperatorRealization, + OrderingTest, StructuralOrderingBinding, }; pub use crate::std_primitive_projection::{ primitive_identity_runtime_name, primitive_projection_row_for_declaration, @@ -86,11 +90,12 @@ pub use crate::v1_compiler_closure_stub_v2_std_integer_rust::closure_stub_v2_std pub use crate::v1_compiler_closure_stub_v2_std_text_rust::closure_stub_v2_std_text_source; pub use crate::v1_compiler_coercion::decl_identity_file; pub use crate::v1_compiler_coercion::{ - coerce_primitive_type, declaration_realizes_natively_on_rust, is_copy, lookup_checkpoint, - rust_lookup_exact_binding, rust_seed_host_numeric_alias, target_callable, + coerce_primitive_type, declaration_realizes_natively_on_rust, is_copy, is_kernel_minted_file, + lookup_checkpoint, rust_lookup_exact_binding, rust_seed_host_numeric_alias, target_callable, type_reference_decl_file, }; pub use crate::v1_compiler_compiler_tests_rust::compiler_tests_source; +pub use crate::v1_compiler_dag_collect_support::connective_name; use crate::v1_compiler_emit::BoundOperation::{ BindingRefused, FileBound, LocalBound, RestBound, ShellBound, }; @@ -29445,71 +29450,115 @@ pub fn rust_operand_realization_of_type( mut fuel: i64, ) -> Rc { loop { - match crate::v1_compiler_infer_env::type_reference_declaration_ref( - rt.clone(), + let decl_file = crate::v1_compiler_coercion::type_reference_decl_file(rt.clone()); + let authored = crate::v1_std_core::authored_name_at( scope.type_env.clone().source_indices.clone(), - scope.type_env.clone(), - ) { - None => { - break Rc::new(OperandRealization::OperandIdentityUnavailable); - } - Some(d) => { - if crate::v1_compiler_coercion::declaration_realizes_natively_on_rust( - d.clone(), - crate::v1_compiler_coercion::type_reference_decl_file(rt.clone()), - ) { - break Rc::new(OperandRealization::HostNumericOperand); + rt.clone(), + ); + let rt_is_type_var = match rt.inferred.clone() { + Some(i) => is_type_variable(i.clone()), + None => false, + }; + if crate::v1_compiler_coercion::is_kernel_minted_file(decl_file.clone()) { + break Rc::new(OperandRealization::HostRealizedOperand { + reason: HostRealizationReason::KernelMintedType, + }); + } else { + if rt_is_type_var.clone() { + break Rc::new(OperandRealization::HostRealizedOperand { + reason: HostRealizationReason::GenericTypeParameter, + }); + } else { + if crate::std_types::is_container_type(crate::v1_std_core::qualified_last_segment( + authored.clone(), + )) { + break Rc::new(OperandRealization::HostRealizedOperand { + reason: HostRealizationReason::HostContainer, + }); } else { - let decl = match rt.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: r, .. }) => r.clone(), - _ => rt.clone(), - }; - if ((fuel.clone() > 0) - && crate::v1_compiler_infer::is_where_refinement_type(rt.clone())) - { - match rt.children.clone().first().cloned() { - Some(base) => { - let base_resolved = - match crate::v1_compiler_infer_env::lookup_type_for( - scope.type_env.clone(), - base.clone(), - ) { - Some(r) => r.clone(), - None => base.clone(), - }; + match crate::v1_compiler_infer_env::type_reference_declaration_ref( + rt.clone(), + scope.type_env.clone().source_indices.clone(), + scope.type_env.clone(), + ) { + None => { + break Rc::new(OperandRealization::OperandIdentityUnavailable { + facts: Rc::new(OperandShapeFacts { + authored_name: authored.clone(), + connective: + crate::v1_compiler_dag_collect_support::connective_name( + rt.connective.clone(), + ), + child_count: (rt.children.clone().len() as i64), + resolved: (rt.inferred.clone() != std::option::Option::None), + decl_file: decl_file.clone(), + }), + }); + } + Some(d) => { + if crate::v1_compiler_coercion::declaration_realizes_natively_on_rust( + d.clone(), + crate::v1_compiler_coercion::type_reference_decl_file(rt.clone()), + ) { + break Rc::new(OperandRealization::HostNumericOperand); + } else { + let decl = match rt.inferred.clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: r, .. }) => r.clone(), + _ => rt.clone(), + }; + if ((fuel.clone() > 0) + && crate::v1_compiler_infer::is_where_refinement_type( + rt.clone(), + )) { - let __tco_0 = base_resolved.clone(); - let __tco_1 = (fuel - 1); - rt = __tco_0; - fuel = __tco_1; - continue; + match rt.children.clone().first().cloned() { + Some(base) => { + let base_resolved = + match crate::v1_compiler_infer_env::lookup_type_for( + scope.type_env.clone(), + base.clone(), + ) { + Some(r) => r.clone(), + None => base.clone(), + }; + { + let __tco_0 = base_resolved.clone(); + let __tco_1 = (fuel - 1); + rt = __tco_0; + fuel = __tco_1; + continue; + } + } + None => { + break Rc::new(OperandRealization::StructuralOperand { + declaration: d.clone(), + }); + } + } + } else { + if ((fuel.clone() > 0) + && crate::v1_compiler_emit_core_support::is_type_alias_item( + decl.clone(), + scope.type_env.clone().source_indices.clone(), + )) + { + { + let __tco_0 = + crate::v1_compiler_infer_types::resolved_type( + decl.clone(), + ); + let __tco_1 = (fuel - 1); + rt = __tco_0; + fuel = __tco_1; + continue; + } + } else { + break Rc::new(OperandRealization::StructuralOperand { + declaration: d.clone(), + }); + } } } - None => { - break Rc::new(OperandRealization::StructuralOperand { - declaration: d.clone(), - }); - } - } - } else { - if ((fuel.clone() > 0) - && crate::v1_compiler_emit_core_support::is_type_alias_item( - decl.clone(), - scope.type_env.clone().source_indices.clone(), - )) - { - { - let __tco_0 = - crate::v1_compiler_infer_types::resolved_type(decl.clone()); - let __tco_1 = (fuel - 1); - rt = __tco_0; - fuel = __tco_1; - continue; - } - } else { - break Rc::new(OperandRealization::StructuralOperand { - declaration: d.clone(), - }); } } } From f829c75cc392967f384b981b92c96b7241114ac2 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 18:14:39 +0000 Subject: [PATCH 65/75] XL-0N: regen mirrors for the typed-tree operand declaration (fixed point round 2 on 279ab70; 12/12 emitted-path, 26/26 interpreter rows) Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_013koFunEtpLQCnvUiz85k7Y --- src/v1/stage0/src/std_operator_realization.rs | 6 +++ src/v1/stage0/src/v1_compiler_emit_rust.rs | 44 +++++++++++++--- src/v1/stage0/src/v1_compiler_infer.rs | 52 ++++++++++++++++++- src/v1/stage0/src/v1_compiler_infer_env.rs | 43 ++++++++++----- .../stage0/src/v1_compiler_infer_resolve.rs | 2 + src/v1/stage0/src/v1_compiler_parse.rs | 4 ++ src/v1/stage0/src/v1_std_core.rs | 2 + 7 files changed, 129 insertions(+), 24 deletions(-) diff --git a/src/v1/stage0/src/std_operator_realization.rs b/src/v1/stage0/src/std_operator_realization.rs index 4f5fb5365c9..414fa6ca5ec 100644 --- a/src/v1/stage0/src/std_operator_realization.rs +++ b/src/v1/stage0/src/std_operator_realization.rs @@ -22,6 +22,12 @@ use crate::NonEmptyVec; use im::{vector as vec, HashMap, OrdSet as BTreeSet, Vector as Vec}; use std::rc::Rc; +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct OperandDeclaration { + pub declaration: Rc, + pub decl_file: String, +} + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(tag = "_variant")] pub enum OperandRealization { diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index 044b86fe868..37f06a85798 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -61,8 +61,8 @@ pub use crate::std_operator_realization::{ operator_realization_for, operator_realization_refusal_message, }; pub use crate::std_operator_realization::{ - HostRealizationReason, OperandRealization, OperandShapeFacts, OperatorRealization, - OrderingTest, StructuralOrderingBinding, + HostRealizationReason, OperandDeclaration, OperandRealization, OperandShapeFacts, + OperatorRealization, OrderingTest, StructuralOrderingBinding, }; pub use crate::std_primitive_projection::{ primitive_identity_runtime_name, primitive_projection_row_for_declaration, @@ -22023,10 +22023,12 @@ pub fn emit_rust_expr_bin_op( ExprData::ExprBinOp { op, algebra_field: algebra, + operand: od, .. } => emit_typed_bin_op( op.clone(), algebra.clone(), + od.clone(), crate::v1_std_core::binop_left(expr.clone()), crate::v1_std_core::binop_right(expr.clone()), registry.clone(), @@ -29356,6 +29358,7 @@ pub fn rust_zero_value(type_name: String) -> Option { pub fn emit_typed_bin_op( op: BinOp, algebra_field: Option, + operand: Option>, left: Rc, right: Rc, registry: Rc>>, @@ -29390,7 +29393,14 @@ pub fn emit_typed_bin_op( RenderTarget::Rust, ) } else { - match (*binop_operator_realization(op.clone(), left.clone(), scope.clone())).clone() { + match (*binop_operator_realization( + op.clone(), + operand.clone(), + left.clone(), + scope.clone(), + )) + .clone() + { OperatorRealization::OperatorRealizationRefused { cause: c, .. } => { emit_rust_compile_error_expr( crate::std_operator_realization::operator_realization_refusal_message( @@ -29569,14 +29579,32 @@ pub fn rust_operand_realization_of_type( pub fn binop_operator_realization( op: BinOp, + operand: Option>, left: Rc, scope: Rc, ) -> Rc { - crate::std_operator_realization::operator_realization_for( - op.clone(), - rust_operand_realization(left.clone(), scope.clone()), - structural_ordering_rows(), - ) + { + let realization = match operand.clone() { + Some(od) => { + if crate::v1_compiler_coercion::declaration_realizes_natively_on_rust( + od.declaration.clone(), + od.decl_file.clone(), + ) { + Rc::new(OperandRealization::HostNumericOperand) + } else { + Rc::new(OperandRealization::StructuralOperand { + declaration: od.declaration.clone(), + }) + } + } + None => rust_operand_realization(left.clone(), scope.clone()), + }; + crate::std_operator_realization::operator_realization_for( + op.clone(), + realization.clone(), + structural_ordering_rows(), + ) + } } pub fn rust_declaration_path(module_path: String, decl_name: String) -> String { diff --git a/src/v1/stage0/src/v1_compiler_infer.rs b/src/v1/stage0/src/v1_compiler_infer.rs index 277e165f623..8d8e9c0251e 100644 --- a/src/v1/stage0/src/v1_compiler_infer.rs +++ b/src/v1/stage0/src/v1_compiler_infer.rs @@ -58,6 +58,7 @@ pub use crate::std_node::{compiler_inductive_fields, compiler_recursive_types}; pub use crate::std_occurrence_identity::NodeOccurrenceIdentity; use crate::std_occurrence_identity::NodeOccurrenceIdentity::OccurrenceSynthetic; pub use crate::std_occurrence_identity::OccurrenceId; +pub use crate::std_operator_realization::OperandDeclaration; use crate::std_syntax::BinOp::Add; use crate::std_syntax::BinOp::{And, Div, Eq, Ge, Gt, Le, Lt, Mod, Mul, Ne, NullCoalesce, Or, Sub}; use crate::std_syntax::LiteralValue::{LitBool, LitInt, LitStr}; @@ -99,8 +100,8 @@ pub use crate::v1_compiler_infer_env::{ node_with_inferred, put_inductive_field, put_inductive_field_cross, qualified_all_but_last, qualify_borrowed_inferred, qualify_borrowed_type_names, qualify_decl_reference_positions, str_bindings_from_bindings, symbol_index_insert, symbol_index_insert_decl, - symbol_index_insert_service, symbol_index_lookup, type_reference_declaration_ref, - unit_variant_index_shadow_insert, + symbol_index_insert_service, symbol_index_lookup, type_reference_declaration, + type_reference_declaration_ref, unit_variant_index_shadow_insert, }; pub use crate::v1_compiler_infer_env::{ GlobalBareCandidate, GlobalBareLookupState, GuardedTypeEnvCacheMerge, ServiceCensusEntry, @@ -7969,6 +7970,48 @@ pub struct BinopOperands { pub right: Rc, } +pub fn operand_declaration_of_type( + mut rt: Rc, + mut scope: Rc, + mut fuel: i64, +) -> Option> { + loop { + if ((fuel.clone() > 0) && is_where_refinement_type(rt.clone())) { + match rt.children.clone().first().cloned() { + Some(base) => { + let base_resolved = match crate::v1_compiler_infer_env::lookup_type_for( + scope.type_env.clone(), + base.clone(), + ) { + Some(r) => r.clone(), + None => base.clone(), + }; + { + let __tco_0 = base_resolved.clone(); + let __tco_1 = (fuel - 1); + rt = __tco_0; + fuel = __tco_1; + continue; + } + } + None => { + break crate::v1_compiler_infer_env::type_reference_declaration( + rt.clone(), + scope.type_env.clone().source_indices.clone(), + scope.type_env.clone(), + ); + } + } + } else { + break crate::v1_compiler_infer_env::type_reference_declaration( + rt.clone(), + scope.type_env.clone().source_indices.clone(), + scope.type_env.clone(), + ); + } + } +} + pub fn infer_operand_literal( lit_expr: Rc, other: Rc, @@ -10091,6 +10134,11 @@ crate::v1_compiler_infer_types::resolve_type_variables_from_template(t.clone(), Rc::new(ExprData::ExprBinOp { op: op.clone(), algebra_field: binop_info.algebra_field.clone(), + operand: operand_declaration_of_type( + crate::v1_compiler_infer_types::resolved_type(left_typed.clone()), + scope.clone(), + 8, + ), }), Rc::new(vec![left_typed.clone(), right_typed.clone()]), Some(Rc::new(InferredNode::Resolved { diff --git a/src/v1/stage0/src/v1_compiler_infer_env.rs b/src/v1/stage0/src/v1_compiler_infer_env.rs index 171cb22eabd..768deb115de 100644 --- a/src/v1/stage0/src/v1_compiler_infer_env.rs +++ b/src/v1/stage0/src/v1_compiler_infer_env.rs @@ -12,6 +12,7 @@ use crate::std_induction::SubValueRelation::{PreservedValue, SubValueUnknown}; pub use crate::std_induction::{InductiveField, RecursionShape, SubValueRelation}; pub use crate::std_occurrence_identity::NodeOccurrenceIdentity; use crate::std_occurrence_identity::NodeOccurrenceIdentity::OccurrenceSynthetic; +pub use crate::std_operator_realization::OperandDeclaration; pub use crate::std_types::is_kernel_type; pub use crate::std_types::SourceSpan; pub use crate::v1_compiler_infer_occurrence_binding::ModulePathBindingProjection; @@ -2233,23 +2234,17 @@ pub fn binding_declares_span(binding: Rc, sp: Rc) -> bo } } -pub fn type_reference_declaration_ref( +pub fn type_reference_declaration( n: Rc, source_indices: Rc>>, env: Rc, -) -> Option> { +) -> Option> { { let rt = match n.inferred.clone().as_deref().cloned() { Some(InferredNode::Resolved { node: r, .. }) => r.clone(), _ => match lookup_type_for(env.clone(), n.clone()) { Some(bound) => bound.clone(), - None => match lookup_type_by_name( - env.clone(), - crate::v1_std_core::authored_name_at(source_indices.clone(), n.clone()), - ) { - Some(bound) => bound.clone(), - None => n.clone(), - }, + None => n.clone(), }, }; let decl_name = crate::v1_std_core::qualified_last_segment( @@ -2273,7 +2268,13 @@ pub fn type_reference_declaration_ref( .. }) => { if binding_declares_span(b.clone(), sp.clone()) { - Some(crate::std_decl_ref::decl_ref(mp.clone(), decl_name.clone())) + Some(Rc::new(OperandDeclaration { + declaration: crate::std_decl_ref::decl_ref( + mp.clone(), + decl_name.clone(), + ), + decl_file: sp.file.clone(), + })) } else { std::option::Option::None } @@ -2293,10 +2294,13 @@ pub fn type_reference_declaration_ref( .first() .cloned() { - Some(c) => Some(crate::std_decl_ref::decl_ref( - c.module_path.clone(), - decl_name.clone(), - )), + Some(c) => Some(Rc::new(OperandDeclaration { + declaration: crate::std_decl_ref::decl_ref( + c.module_path.clone(), + decl_name.clone(), + ), + decl_file: sp.file.clone(), + })), None => std::option::Option::None, }, None => std::option::Option::None, @@ -2304,3 +2308,14 @@ pub fn type_reference_declaration_ref( } } } + +pub fn type_reference_declaration_ref( + n: Rc, + source_indices: Rc>>, + env: Rc, +) -> Option> { + match type_reference_declaration(n.clone(), source_indices.clone(), env.clone()) { + Some(od) => Some(od.declaration.clone()), + None => std::option::Option::None, + } +} diff --git a/src/v1/stage0/src/v1_compiler_infer_resolve.rs b/src/v1/stage0/src/v1_compiler_infer_resolve.rs index aa3ad0fbf54..574d414936f 100644 --- a/src/v1/stage0/src/v1_compiler_infer_resolve.rs +++ b/src/v1/stage0/src/v1_compiler_infer_resolve.rs @@ -2989,6 +2989,7 @@ pub fn resolve_expr_types( ExprData::ExprBinOp { op, algebra_field: af, + operand: od, .. } => { let ch = texpr.children.clone(); @@ -3012,6 +3013,7 @@ pub fn resolve_expr_types( Rc::new(ExprData::ExprBinOp { op: op.clone(), algebra_field: af.clone(), + operand: od.clone(), }), Rc::new(vec![lr.expr.clone(), rr.expr.clone()]), texpr.inferred.clone(), diff --git a/src/v1/stage0/src/v1_compiler_parse.rs b/src/v1/stage0/src/v1_compiler_parse.rs index 63bba4fbcfd..a29eacd12eb 100644 --- a/src/v1/stage0/src/v1_compiler_parse.rs +++ b/src/v1/stage0/src/v1_compiler_parse.rs @@ -12409,6 +12409,8 @@ pub fn parse_expr_loop( op: binop.clone(), algebra_field: std::option::Option::None, + operand: + std::option::Option::None, }), Rc::new(vec![ lhs.clone(), @@ -14279,6 +14281,8 @@ pub fn parse_expr_loop_no_brace( op: binop.clone(), algebra_field: std::option::Option::None, + operand: + std::option::Option::None, }), Rc::new(vec![ lhs.clone(), diff --git a/src/v1/stage0/src/v1_std_core.rs b/src/v1/stage0/src/v1_std_core.rs index 17948509024..8870c0fbb3c 100644 --- a/src/v1/stage0/src/v1_std_core.rs +++ b/src/v1/stage0/src/v1_std_core.rs @@ -45,6 +45,7 @@ pub use crate::std_occurrence_identity::{ AuthoredTokenOrdinalSpace, NodeOccurrenceIdentity, OccurrenceIdAllocator, OccurrenceTransportRefusal, }; +pub use crate::std_operator_realization::OperandDeclaration; pub use crate::std_source_annotation::AnnotationAttachmentRefusal; use crate::std_source_annotation::AnnotationAttachmentRefusal::*; pub use crate::std_source_annotation::{ @@ -333,6 +334,7 @@ pub enum ExprData { ExprBinOp { op: BinOp, algebra_field: Option, + operand: Option>, }, ExprUnaryOp { op: UnaryOpKind, From 0a69d26440ad97421ac8c9f9a41c028c34c9eb5a Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 19:01:18 +0000 Subject: [PATCH 66/75] XL-0N: regen mirrors on the main-merged head (bootstrapped from f829c75; fixed point round 2 on c3c2324; 12/12 emitted-path, 26/26 interpreter rows) Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_013koFunEtpLQCnvUiz85k7Y --- src/v1/stage0/src/v1_compiler_compile.rs | 7 + src/v1/stage0/src/v1_compiler_emit_rust.rs | 609 +++++++++++++----- src/v1/stage0/src/v1_compiler_infer.rs | 363 ++++++++++- src/v1/stage0/src/v1_compiler_infer_env.rs | 100 ++- .../stage0/src/v1_compiler_infer_resolve.rs | 13 +- src/v1/stage0/src/v1_compiler_parse.rs | 4 + src/v1/stage0/src/v1_std_core.rs | 15 + 7 files changed, 925 insertions(+), 186 deletions(-) diff --git a/src/v1/stage0/src/v1_compiler_compile.rs b/src/v1/stage0/src/v1_compiler_compile.rs index fbd42a92cc7..b5167a0ad8a 100644 --- a/src/v1/stage0/src/v1_compiler_compile.rs +++ b/src/v1/stage0/src/v1_compiler_compile.rs @@ -1379,6 +1379,13 @@ pub fn serialize_expr_data( ), "}".to_string(), ), + ExprData::ExprElaboratedLiteral { value, .. } => v1_rt::concat( + v1_rt::concat( + "{\"kind\": \"ExprElaboratedLiteral\", \"value\": ".to_string(), + serialize_literal(value.clone()), + ), + "}".to_string(), + ), ExprData::ExprError { kind, message, .. } => v1_rt::concat( v1_rt::concat( v1_rt::concat( diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index 5d9bcadd1e3..4edb0f6c727 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -35,6 +35,7 @@ pub use crate::gunbc_stage0_emitted_population_manifest::{ emitted_population_manifest_basename, emitted_population_manifest_line_prefix, emitted_population_manifest_line_separator, }; +pub use crate::gunbc_structural_realization_bindings::structural_ordering_rows; pub use crate::std_algebra::trim; pub use crate::std_coercion::TypeCheckpoint; pub use crate::std_content_hash::Fnv1a64Structural; @@ -46,6 +47,23 @@ pub use crate::std_measure::millisecond_count; pub use crate::std_nat::Nat; pub use crate::std_occurrence_identity::NodeOccurrenceIdentity; use crate::std_occurrence_identity::NodeOccurrenceIdentity::OccurrenceSynthetic; +use crate::std_operator_realization::HostRealizationReason::{ + GenericTypeParameter, HostContainer, KernelMintedType, +}; +use crate::std_operator_realization::OperandRealization::{ + HostNumericOperand, HostRealizedOperand, OperandIdentityUnavailable, StructuralOperand, +}; +use crate::std_operator_realization::OperatorRealization::{ + HostOperator, OperatorRealizationRefused, StructuralComparison, StructuralEquality, +}; +use crate::std_operator_realization::OrderingTest::{OrderingIs, OrderingIsNot}; +pub use crate::std_operator_realization::{ + operator_realization_for, operator_realization_refusal_message, +}; +pub use crate::std_operator_realization::{ + HostRealizationReason, OperandDeclaration, OperandRealization, OperandShapeFacts, + OperatorRealization, OrderingTest, StructuralOrderingBinding, +}; pub use crate::std_primitive_projection::{ primitive_identity_runtime_name, primitive_projection_row_for_declaration, }; @@ -72,10 +90,12 @@ pub use crate::v1_compiler_closure_stub_v2_std_integer_rust::closure_stub_v2_std pub use crate::v1_compiler_closure_stub_v2_std_text_rust::closure_stub_v2_std_text_source; pub use crate::v1_compiler_coercion::decl_identity_file; pub use crate::v1_compiler_coercion::{ - coerce_primitive_type, is_copy, lookup_checkpoint, rust_lookup_exact_binding, - rust_seed_host_numeric_alias, target_callable, type_reference_decl_file, + coerce_primitive_type, declaration_realizes_natively_on_rust, is_copy, is_kernel_minted_file, + lookup_checkpoint, rust_lookup_exact_binding, rust_seed_host_numeric_alias, target_callable, + type_reference_decl_file, }; pub use crate::v1_compiler_compiler_tests_rust::compiler_tests_source; +pub use crate::v1_compiler_dag_collect_support::connective_name; use crate::v1_compiler_emit::BoundOperation::{ BindingRefused, FileBound, LocalBound, RestBound, ShellBound, }; @@ -133,7 +153,8 @@ use crate::v1_compiler_infer_env::GlobalBareLookupState::{ GlobalBareAmbiguousBinding, GlobalBareUniqueBinding, }; pub use crate::v1_compiler_infer_env::{ - authored_name, empty_symbol_index, lookup_type_by_name, lookup_type_for, + authored_name, binding_declares_span, empty_symbol_index, lookup_type_by_name, lookup_type_for, + type_reference_declaration_ref, }; pub use crate::v1_compiler_infer_env::{GlobalBareLookupState, TypeBinding, TypeEnv}; pub use crate::v1_compiler_infer_items::item_kind; @@ -1048,76 +1069,6 @@ pub fn rust_render_checkpoint_scalar_bare( } } -pub fn binding_declares_span(binding: Rc, sp: Rc) -> bool { - match binding.resolved.clone().ident_span.clone() { - Some(s) => ((s.file.clone() == sp.file.clone()) && (s.start.clone() == sp.start.clone())), - None => false, - } -} - -pub fn type_reference_declaration_ref( - n: Rc, - source_indices: Rc>>, - env: Rc, -) -> Option> { - { - let rt = match n.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: r, .. }) => r.clone(), - _ => n.clone(), - }; - let decl_name = crate::v1_std_core::qualified_last_segment( - crate::v1_std_core::authored_name_at(source_indices.clone(), rt.clone()), - ); - if (decl_name.clone() == "".to_string()) { - return std::option::Option::None; - } - match rt.ident_span.clone() { - None => std::option::Option::None, - Some(sp) => match v1_rt::map_get( - &env.symbol_index.clone().global_bare.clone(), - decl_name.clone(), - ) - .as_deref() - .cloned() - { - Some(GlobalBareLookupState::GlobalBareUniqueBinding { - module_path: mp, - binding: b, - .. - }) => { - if binding_declares_span(b.clone(), sp.clone()) { - Some(crate::std_decl_ref::decl_ref(mp.clone(), decl_name.clone())) - } else { - std::option::Option::None - } - } - Some(GlobalBareLookupState::GlobalBareAmbiguousBinding { - candidates: cands, - .. - }) => match Rc::new({ - let mut __result = Vec::new(); - for c in cands.iter().cloned() { - if binding_declares_span(c.binding.clone(), sp.clone()) { - __result.push(c); - } - } - __result - }) - .first() - .cloned() - { - Some(c) => Some(crate::std_decl_ref::decl_ref( - c.module_path.clone(), - decl_name.clone(), - )), - None => std::option::Option::None, - }, - None => std::option::Option::None, - }, - } - } -} - pub fn rust_exact_binding_spelling( source: Option>, grounding: bool, @@ -1163,7 +1114,11 @@ pub fn rust_exact_reference_spelling( env: Rc, ) -> Option { rust_exact_binding_spelling( - type_reference_declaration_ref(n.clone(), source_indices.clone(), env.clone()), + crate::v1_compiler_infer_env::type_reference_declaration_ref( + n.clone(), + source_indices.clone(), + env.clone(), + ), false, ) } @@ -21906,10 +21861,12 @@ pub fn emit_rust_expr_bin_op( ExprData::ExprBinOp { op, algebra_field: algebra, + operand: od, .. } => emit_typed_bin_op( op.clone(), algebra.clone(), + od.clone(), crate::v1_std_core::binop_left(expr.clone()), crate::v1_std_core::binop_right(expr.clone()), registry.clone(), @@ -28021,11 +27978,18 @@ pub fn emit_field_value_with_context( } None => pe.clone(), }; + let nested_rt = crate::v1_compiler_infer::expand_type_for_field_access( + crate::v1_compiler_infer_types::resolved_type(field_value.clone()), + scope.type_env.clone(), + scope.module_name.clone(), + ) + .resolved + .clone(); let raw = emit_typed_record_lit( tn.clone(), inner_fields.clone(), corrected_parent.clone(), - crate::v1_compiler_infer_types::resolved_type(field_value.clone()), + nested_rt.clone(), registry.clone(), scope.clone(), depth.clone(), @@ -29223,6 +29187,7 @@ pub fn rust_zero_value(type_name: String) -> Option { pub fn emit_typed_bin_op( op: BinOp, algebra_field: Option, + operand: Option>, left: Rc, right: Rc, registry: Rc>>, @@ -29257,133 +29222,439 @@ pub fn emit_typed_bin_op( RenderTarget::Rust, ) } else { + match (*binop_operator_realization( + op.clone(), + operand.clone(), + left.clone(), + scope.clone(), + )) + .clone() { - let op_str = crate::v1_compiler_emit::emit_bin_op_symbol( + OperatorRealization::OperatorRealizationRefused { cause: c, .. } => { + emit_rust_compile_error_expr( + crate::std_operator_realization::operator_realization_refusal_message( + c.clone(), + ), + ) + } + OperatorRealization::StructuralComparison { + binding: b, + test: t, + .. + } => emit_rust_structural_comparison( + l_str.clone(), + r_str.clone(), + b.clone(), + t.clone(), + ), + OperatorRealization::StructuralEquality { declaration: _, .. } => { + emit_rust_host_bin_op( + op.clone(), + algebra_field.clone(), + left.clone(), + right.clone(), + l_str.clone(), + r_str.clone(), + scope.clone(), + ) + } + OperatorRealization::HostOperator => emit_rust_host_bin_op( op.clone(), - RenderTarget::Rust, algebra_field.clone(), - ); - if is_string_comparison( - op.clone(), left.clone(), right.clone(), - scope.type_env.clone().source_indices.clone(), - ) { - { - let l_optional = is_optional_typed_expr(left.clone()); - let r_optional = is_optional_typed_expr(right.clone()); - if (l_optional.clone() || r_optional.clone()) { - { - let l_cmp = if l_optional.clone() { - v1_rt::concat(l_str.clone(), ".as_deref()".to_string()) - } else { - v1_rt::concat( - v1_rt::concat( - "Some(".to_string(), - emit_rust_dag_string_to_host_via_seam(l_str.clone()), + l_str.clone(), + r_str.clone(), + scope.clone(), + ), + } + } + } +} + +pub fn rust_operand_realization( + operand: Rc, + scope: Rc, +) -> Rc { + rust_operand_realization_of_type( + crate::v1_compiler_infer_types::resolved_type(operand.clone()), + scope.clone(), + 8, + ) +} + +pub fn rust_operand_realization_of_type( + mut rt: Rc, + mut scope: Rc, + mut fuel: i64, +) -> Rc { + loop { + let decl_file = crate::v1_compiler_coercion::type_reference_decl_file(rt.clone()); + let authored = crate::v1_std_core::authored_name_at( + scope.type_env.clone().source_indices.clone(), + rt.clone(), + ); + let rt_is_type_var = match rt.inferred.clone() { + Some(i) => is_type_variable(i.clone()), + None => false, + }; + if crate::v1_compiler_coercion::is_kernel_minted_file(decl_file.clone()) { + break Rc::new(OperandRealization::HostRealizedOperand { + reason: HostRealizationReason::KernelMintedType, + }); + } else { + if rt_is_type_var.clone() { + break Rc::new(OperandRealization::HostRealizedOperand { + reason: HostRealizationReason::GenericTypeParameter, + }); + } else { + if crate::std_types::is_container_type(crate::v1_std_core::qualified_last_segment( + authored.clone(), + )) { + break Rc::new(OperandRealization::HostRealizedOperand { + reason: HostRealizationReason::HostContainer, + }); + } else { + match crate::v1_compiler_infer_env::type_reference_declaration_ref( + rt.clone(), + scope.type_env.clone().source_indices.clone(), + scope.type_env.clone(), + ) { + None => { + break Rc::new(OperandRealization::OperandIdentityUnavailable { + facts: Rc::new(OperandShapeFacts { + authored_name: authored.clone(), + connective: + crate::v1_compiler_dag_collect_support::connective_name( + rt.connective.clone(), ), - ").as_deref()".to_string(), - ) + child_count: (rt.children.clone().len() as i64), + resolved: (rt.inferred.clone() != std::option::Option::None), + decl_file: decl_file.clone(), + }), + }); + } + Some(d) => { + if crate::v1_compiler_coercion::declaration_realizes_natively_on_rust( + d.clone(), + crate::v1_compiler_coercion::type_reference_decl_file(rt.clone()), + ) { + break Rc::new(OperandRealization::HostNumericOperand); + } else { + let decl = match rt.inferred.clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: r, .. }) => r.clone(), + _ => rt.clone(), }; - let r_cmp = if r_optional.clone() { - v1_rt::concat(r_str.clone(), ".as_deref()".to_string()) + if ((fuel.clone() > 0) + && crate::v1_compiler_infer::is_where_refinement_type( + rt.clone(), + )) + { + match rt.children.clone().first().cloned() { + Some(base) => { + let base_resolved = + match crate::v1_compiler_infer_env::lookup_type_for( + scope.type_env.clone(), + base.clone(), + ) { + Some(r) => r.clone(), + None => base.clone(), + }; + { + let __tco_0 = base_resolved.clone(); + let __tco_1 = (fuel - 1); + rt = __tco_0; + fuel = __tco_1; + continue; + } + } + None => { + break Rc::new(OperandRealization::StructuralOperand { + declaration: d.clone(), + }); + } + } } else { - v1_rt::concat( - v1_rt::concat( - "Some(".to_string(), - emit_rust_dag_string_to_host_via_seam(r_str.clone()), - ), - ").as_deref()".to_string(), - ) - }; + if ((fuel.clone() > 0) + && crate::v1_compiler_emit_core_support::is_type_alias_item( + decl.clone(), + scope.type_env.clone().source_indices.clone(), + )) + { + { + let __tco_0 = + crate::v1_compiler_infer_types::resolved_type( + decl.clone(), + ); + let __tco_1 = (fuel - 1); + rt = __tco_0; + fuel = __tco_1; + continue; + } + } else { + break Rc::new(OperandRealization::StructuralOperand { + declaration: d.clone(), + }); + } + } + } + } + } + } + } + } + } +} + +pub fn binop_operator_realization( + op: BinOp, + operand: Option>, + left: Rc, + scope: Rc, +) -> Rc { + { + let realization = match operand.clone() { + Some(od) => { + if crate::v1_compiler_coercion::declaration_realizes_natively_on_rust( + od.declaration.clone(), + od.decl_file.clone(), + ) { + Rc::new(OperandRealization::HostNumericOperand) + } else { + Rc::new(OperandRealization::StructuralOperand { + declaration: od.declaration.clone(), + }) + } + } + None => rust_operand_realization(left.clone(), scope.clone()), + }; + crate::std_operator_realization::operator_realization_for( + op.clone(), + realization.clone(), + structural_ordering_rows(), + ) + } +} + +pub fn rust_declaration_path(module_path: String, decl_name: String) -> String { + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + "crate::".to_string(), + crate::v1_compiler_emit_core_support::module_to_filename(module_path.clone()), + ), + "::".to_string(), + ), + crate::v1_compiler_emit::emit_ident(decl_name.clone(), RenderTarget::Rust), + ) +} + +pub fn emit_rust_structural_comparison( + l_str: String, + r_str: String, + binding: Rc, + test: Rc, +) -> String { + { + let call = v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + rust_declaration_path( + binding.compare.clone().module_path.clone(), + binding.compare.clone().decl_name.clone(), + ), + "(".to_string(), + ), + l_str.clone(), + ), + ", ".to_string(), + ), + r_str.clone(), + ), + ")".to_string(), + ); + let ordering = v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + "crate::".to_string(), + crate::v1_compiler_emit_core_support::module_to_filename( + binding.ordering.clone().module_path.clone(), + ), + ), + "::".to_string(), + ), + binding.ordering.clone().decl_name.clone(), + ); + match (*test.clone()).clone() { + OrderingTest::OrderingIs { variant: v, .. } => v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat("(".to_string(), call.clone()), + " == ".to_string(), + ), + ordering.clone(), + ), + "::".to_string(), + ), + v.clone(), + ), + ")".to_string(), + ), + OrderingTest::OrderingIsNot { variant: v, .. } => v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat("(".to_string(), call.clone()), + " != ".to_string(), + ), + ordering.clone(), + ), + "::".to_string(), + ), + v.clone(), + ), + ")".to_string(), + ), + } + } +} + +pub fn emit_rust_host_bin_op( + op: BinOp, + algebra_field: Option, + left: Rc, + right: Rc, + l_str: String, + r_str: String, + scope: Rc, +) -> String { + { + let op_str = crate::v1_compiler_emit::emit_bin_op_symbol( + op.clone(), + RenderTarget::Rust, + algebra_field.clone(), + ); + if is_string_comparison( + op.clone(), + left.clone(), + right.clone(), + scope.type_env.clone().source_indices.clone(), + ) { + { + let l_optional = is_optional_typed_expr(left.clone()); + let r_optional = is_optional_typed_expr(right.clone()); + if (l_optional.clone() || r_optional.clone()) { + { + let l_cmp = if l_optional.clone() { + v1_rt::concat(l_str.clone(), ".as_deref()".to_string()) + } else { + v1_rt::concat( + v1_rt::concat( + "Some(".to_string(), + emit_rust_dag_string_to_host_via_seam(l_str.clone()), + ), + ").as_deref()".to_string(), + ) + }; + let r_cmp = if r_optional.clone() { + v1_rt::concat(r_str.clone(), ".as_deref()".to_string()) + } else { + v1_rt::concat( + v1_rt::concat( + "Some(".to_string(), + emit_rust_dag_string_to_host_via_seam(r_str.clone()), + ), + ").as_deref()".to_string(), + ) + }; + v1_rt::concat( + v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat("(".to_string(), l_cmp.clone()), - " ".to_string(), - ), - op_str.clone(), - ), + v1_rt::concat("(".to_string(), l_cmp.clone()), " ".to_string(), ), - r_cmp.clone(), + op_str.clone(), ), - ")".to_string(), - ) - } - } else { + " ".to_string(), + ), + r_cmp.clone(), + ), + ")".to_string(), + ) + } + } else { + v1_rt::concat( + v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - "(".to_string(), - emit_rust_dag_string_to_host_via_seam( - l_str.clone(), - ), - ), - " ".to_string(), - ), - op_str.clone(), + "(".to_string(), + emit_rust_dag_string_to_host_via_seam(l_str.clone()), ), " ".to_string(), ), - emit_rust_dag_string_to_host_via_seam(r_str.clone()), + op_str.clone(), ), - ")".to_string(), - ) - } - } - } else { - { - let both_string = (is_string_typed_expr( - left.clone(), - scope.type_env.clone().source_indices.clone(), - ) && is_string_typed_expr( - right.clone(), - scope.type_env.clone().source_indices.clone(), - )); - let is_str_concat = - ((op_str.clone() == "+".to_string()) && both_string.clone()); - if is_str_concat.clone() { + " ".to_string(), + ), + emit_rust_dag_string_to_host_via_seam(r_str.clone()), + ), + ")".to_string(), + ) + } + } + } else { + { + let both_string = (is_string_typed_expr( + left.clone(), + scope.type_env.clone().source_indices.clone(), + ) && is_string_typed_expr( + right.clone(), + scope.type_env.clone().source_indices.clone(), + )); + let is_str_concat = ((op_str.clone() == "+".to_string()) && both_string.clone()); + if is_str_concat.clone() { + v1_rt::concat( + v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat("(".to_string(), l_str.clone()), - " ".to_string(), - ), - op_str.clone(), - ), - " &".to_string(), + v1_rt::concat("(".to_string(), l_str.clone()), + " ".to_string(), ), - r_str.clone(), + op_str.clone(), ), - ")".to_string(), - ) - } else { + " &".to_string(), + ), + r_str.clone(), + ), + ")".to_string(), + ) + } else { + v1_rt::concat( + v1_rt::concat( v1_rt::concat( v1_rt::concat( v1_rt::concat( - v1_rt::concat( - v1_rt::concat( - v1_rt::concat("(".to_string(), l_str.clone()), - " ".to_string(), - ), - op_str.clone(), - ), + v1_rt::concat("(".to_string(), l_str.clone()), " ".to_string(), ), - r_str.clone(), + op_str.clone(), ), - ")".to_string(), - ) - } - } + " ".to_string(), + ), + r_str.clone(), + ), + ")".to_string(), + ) } } } diff --git a/src/v1/stage0/src/v1_compiler_infer.rs b/src/v1/stage0/src/v1_compiler_infer.rs index 8eae32c8000..9e245cf80e5 100644 --- a/src/v1/stage0/src/v1_compiler_infer.rs +++ b/src/v1/stage0/src/v1_compiler_infer.rs @@ -7,10 +7,12 @@ use self::DescentSizeExpr::*; use self::InhabitanceRefusalReason::*; use self::InhabitanceUndecidableReason::*; use self::InhabitanceVerdict::*; +use self::LiteralBoundary::*; use self::ServiceConfigFieldJudgment::*; pub use crate::extdeps_container_oci_digest::{ oci_other_digest_algorithm, oci_other_digest_encoded, }; +pub use crate::gunbc_structural_realization_bindings::literal_homomorphism_rows; pub use crate::std_algebra::AlgebraFieldTemplate; use crate::std_algebra::CollectionSizeEffect::ShrinkEffect; pub use crate::std_algebra::{CollectionSizeEffect, FreeMonoid}; @@ -23,6 +25,7 @@ pub use crate::std_content_hash::{ content_hash_validate_lower_hex_length, }; pub use crate::std_content_hash::{ContentHash, Fnv1a64Structural}; +pub use crate::std_decl_ref::DeclarationRef; pub use crate::std_dissolution::DissolutionCondition; use crate::std_dissolution::DissolutionCondition::*; pub use crate::std_dissolution::{dissolution_description, unbound_dissolution}; @@ -41,14 +44,25 @@ pub use crate::std_induction::{InductiveField, RecursionShape, SubValueRelation} use crate::std_interface_summary::ExportKind::{ExportData, ExportFn, ExportService, ExportType}; pub use crate::std_interface_summary::{interface_summary_rollup, signature_contract}; pub use crate::std_interface_summary::{ExportEntry, ExportKind, InterfaceSummary}; +use crate::std_literal_elaboration::LiteralElaborationOutcome::{ + DirectLiteral, LiteralElaborationRefused, ViaHomomorphism, +}; +use crate::std_literal_elaboration::LiteralUnfolding::{BooleanUnfold, PeanoUnfold}; +pub use crate::std_literal_elaboration::{ + elaborate_literal_at, literal_elaboration_refusal_message, literal_source_kind_of, +}; +pub use crate::std_literal_elaboration::{ + LiteralElaboration, LiteralElaborationOutcome, LiteralHomomorphism, LiteralUnfolding, +}; pub use crate::std_node::{compiler_inductive_fields, compiler_recursive_types}; pub use crate::std_occurrence_identity::NodeOccurrenceIdentity; use crate::std_occurrence_identity::NodeOccurrenceIdentity::OccurrenceSynthetic; pub use crate::std_occurrence_identity::OccurrenceId; +pub use crate::std_operator_realization::OperandDeclaration; use crate::std_syntax::BinOp::Add; use crate::std_syntax::BinOp::{And, Div, Eq, Ge, Gt, Le, Lt, Mod, Mul, Ne, NullCoalesce, Or, Sub}; -use crate::std_syntax::LiteralValue::LitStr; -use crate::std_syntax::LiteralValue::{LitBool, LitFloat, LitInt, LitNull}; +use crate::std_syntax::LiteralValue::{LitBool, LitInt, LitStr}; +use crate::std_syntax::LiteralValue::{LitFloat, LitNull}; pub use crate::std_syntax::{BinOp, LiteralValue}; pub use crate::std_termination::PositiveDescentAmount; use crate::std_termination::PositiveDescentAmount::OneStep; @@ -86,7 +100,8 @@ pub use crate::v1_compiler_infer_env::{ node_with_inferred, put_inductive_field, put_inductive_field_cross, qualified_all_but_last, qualify_borrowed_inferred, qualify_borrowed_type_names, qualify_decl_reference_positions, str_bindings_from_bindings, symbol_index_insert, symbol_index_insert_decl, - symbol_index_insert_service, symbol_index_lookup, unit_variant_index_shadow_insert, + symbol_index_insert_service, symbol_index_lookup, type_reference_declaration, + type_reference_declaration_ref, unit_variant_index_shadow_insert, }; pub use crate::v1_compiler_infer_env::{ GlobalBareCandidate, GlobalBareLookupState, GuardedTypeEnvCacheMerge, ServiceCensusEntry, @@ -206,9 +221,10 @@ use crate::v1_std_core::CompilerDiagnostic::{ }; use crate::v1_std_core::Connective::{Arrow, Conj, Disj, NoConnective}; use crate::v1_std_core::ExprData::{ - ExprBinOp, ExprBlock, ExprCall, ExprCast, ExprError, ExprFieldAccess, ExprForEach, ExprIf, - ExprIndex, ExprLambda, ExprLet, ExprListLit, ExprLiteral, ExprMatch, ExprMethodCall, - ExprRecordLit, ExprReturn, ExprSlice, ExprStringInterp, ExprUnaryOp, ExprVar, NoExprData, + ExprBinOp, ExprBlock, ExprCall, ExprCast, ExprElaboratedLiteral, ExprError, ExprFieldAccess, + ExprForEach, ExprIf, ExprIndex, ExprLambda, ExprLet, ExprListLit, ExprLiteral, ExprMatch, + ExprMethodCall, ExprRecordLit, ExprReturn, ExprSlice, ExprStringInterp, ExprUnaryOp, ExprVar, + NoExprData, }; use crate::v1_std_core::ExprErrorKind::{ CensusHeadsBodyStripped, InternalExprError, ParseRecoveryError, SemanticExprError, @@ -7672,6 +7688,289 @@ pub fn qualified_value_projection( } } +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[serde(tag = "_variant")] +pub enum LiteralBoundary { + LiteralBoundaryPlain, + LiteralBoundaryElaborated { + elaboration: Rc, + destination_type: Rc, + }, + LiteralBoundaryRefused { + message: String, + }, +} + +pub fn literal_boundary_elaboration( + lit: Rc, + expected: Option>, + scope: Rc, +) -> Rc { + match expected.clone() { + None => Rc::new(LiteralBoundary::LiteralBoundaryPlain), + Some(exp) => { + if (exp.return_cardinality.clone() == Cardinality::CardOptional) { + Rc::new(LiteralBoundary::LiteralBoundaryPlain) + } else { + match crate::v1_compiler_infer_env::type_reference_declaration_ref( + exp.clone(), + scope.type_env.clone().source_indices.clone(), + scope.type_env.clone(), + ) { + None => Rc::new(LiteralBoundary::LiteralBoundaryPlain), + Some(destination) => { + let kind = + crate::std_literal_elaboration::literal_source_kind_of(lit.clone()); + let natively = crate::v1_compiler_coercion::decl_file_realizes_natively( + crate::v1_compiler_coercion::type_reference_decl_file(exp.clone()), + ); + match (*crate::std_literal_elaboration::elaborate_literal_at(literal_homomorphism_rows(), kind.clone(), destination.clone(), natively.clone())).clone() { + LiteralElaborationOutcome::DirectLiteral => Rc::new(LiteralBoundary::LiteralBoundaryPlain), + LiteralElaborationOutcome::ViaHomomorphism { homomorphism: h, .. } => Rc::new(LiteralBoundary::LiteralBoundaryElaborated { + elaboration: Rc::new(LiteralElaboration { + source_kind: kind.clone(), + destination: destination.clone(), + homomorphism: h.clone(), +}), + destination_type: exp.clone(), +}), + LiteralElaborationOutcome::LiteralElaborationRefused { cause: c, .. } => Rc::new(LiteralBoundary::LiteralBoundaryRefused { + message: crate::std_literal_elaboration::literal_elaboration_refusal_message(c.clone()), +}), +} + } + } + } + } + } +} + +pub fn elaborated_span(name: String) -> Rc { + Rc::new(SourceSpan { + file: "".to_string(), + start: 0, + end: v1_rt::string_length(&name), + }) +} + +pub fn elaborated_expr_node( + name: String, + expr_data: Rc, + children: Rc>>, + destination_type: Rc, + span: Rc, +) -> Rc { + Rc::new(Node { + occurrence_identity: Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), + name: name.clone(), + span: span.clone(), + ident_span: Some(elaborated_span(name.clone())), + children: children.clone(), + connective: Connective::NoConnective, + params: Rc::new(vec![]), + inferred: Some(Rc::new(InferredNode::Resolved { + node: destination_type.clone(), + })), + return_cardinality: Cardinality::Required, + uses: Rc::new(vec![]), + body: std::option::Option::None, + transport: std::option::Option::None, + properties: Rc::new(vec![]), + type_annotation: std::option::Option::None, + is_self_recursive: false, + has_non_tail_self_call: false, + match_pattern: std::option::Option::None, + expr_data: expr_data.clone(), + ident: None, + }) +} + +pub fn unfold_peano_image( + n: i64, + zero: String, + succ: String, + prev_field: String, + parent: String, + destination_type: Rc, + span: Rc, +) -> Rc { + stacker::maybe_grow(512 * 1024, 2 * 1024 * 1024, || { + if (n.clone() <= 0) { + elaborated_expr_node( + zero.clone(), + Rc::new(ExprData::ExprVar { + binding_kind: Some(Rc::new(VarBindingKind::VariantValueBinding { + parent_enum: parent.clone(), + })), + }), + Rc::new(vec![]), + destination_type.clone(), + span.clone(), + ) + } else { + { + let prev = unfold_peano_image( + (n.clone() - 1), + zero.clone(), + succ.clone(), + prev_field.clone(), + parent.clone(), + destination_type.clone(), + span.clone(), + ); + let field = crate::v1_std_core::make_field_init_node( + Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), + prev_field.clone(), + prev.clone(), + span.clone(), + elaborated_span(prev_field.clone()), + ); + elaborated_expr_node( + succ.clone(), + Rc::new(ExprData::ExprRecordLit { + parent_enum: Some(parent.clone()), + }), + Rc::new(vec![field.clone()]), + destination_type.clone(), + span.clone(), + ) + } + } + }) +} + +pub fn unfold_literal_image( + lit: Rc, + elaboration: Rc, + destination_type: Rc, + span: Rc, +) -> Rc { + match (*elaboration.homomorphism.clone().producer.clone()).clone() { + LiteralUnfolding::PeanoUnfold { zero, succ, prev_field, .. } => match (*lit.clone()).clone() { + LiteralValue::LitInt { value: n, .. } => unfold_peano_image(n.clone(), zero.decl_name.clone(), succ.decl_name.clone(), prev_field.clone(), elaboration.destination.clone().decl_name.clone(), destination_type.clone(), span.clone()), + _ => crate::v1_std_core::make_expr_error_node(Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), ExprErrorKind::InternalExprError, "literal elaboration: a Peano unfolding row was selected for a non-integer literal (gunbc.structural_realization_bindings keys the row on KernelIntLiteral, so this row is malformed)".to_string(), span.clone()), +}, + LiteralUnfolding::BooleanUnfold { true_variant: t, false_variant: f, .. } => match (*lit.clone()).clone() { + LiteralValue::LitBool { value: b, .. } => elaborated_expr_node(if b.clone() { + t.decl_name.clone() + } else { + f.decl_name.clone() + }, Rc::new(ExprData::ExprVar { + binding_kind: Some(Rc::new(VarBindingKind::VariantValueBinding { + parent_enum: elaboration.destination.clone().decl_name.clone(), +})), +}), Rc::new(vec![]), destination_type.clone(), span.clone()), + _ => crate::v1_std_core::make_expr_error_node(Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), ExprErrorKind::InternalExprError, "literal elaboration: a Boolean unfolding row was selected for a non-boolean literal (gunbc.structural_realization_bindings keys the row on KernelBoolLiteral, so this row is malformed)".to_string(), span.clone()), +}, +} +} + +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct BinopOperands { + pub left: Rc, + pub right: Rc, +} + +pub fn operand_declaration_of_type( + mut rt: Rc, + mut scope: Rc, + mut fuel: i64, +) -> Option> { + loop { + if ((fuel.clone() > 0) && is_where_refinement_type(rt.clone())) { + match rt.children.clone().first().cloned() { + Some(base) => { + let base_resolved = match crate::v1_compiler_infer_env::lookup_type_for( + scope.type_env.clone(), + base.clone(), + ) { + Some(r) => r.clone(), + None => base.clone(), + }; + { + let __tco_0 = base_resolved.clone(); + let __tco_1 = (fuel - 1); + rt = __tco_0; + fuel = __tco_1; + continue; + } + } + None => { + break crate::v1_compiler_infer_env::type_reference_declaration( + rt.clone(), + scope.type_env.clone().source_indices.clone(), + scope.type_env.clone(), + ); + } + } + } else { + break crate::v1_compiler_infer_env::type_reference_declaration( + rt.clone(), + scope.type_env.clone().source_indices.clone(), + scope.type_env.clone(), + ); + } + } +} + +pub fn infer_operand_literal( + lit_expr: Rc, + other: Rc, + scope: Rc, +) -> Rc { + { + let other_type = match other.inferred.clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: rt, .. }) => Some(rt.clone()), + _ => std::option::Option::None, + }; + infer_expr_body(lit_expr.clone(), scope.clone(), other_type.clone()) + } +} + +pub fn infer_binop_operands( + left_expr: Rc, + right_expr: Rc, + scope: Rc, +) -> Rc { + { + let left_is_literal = expr_is_any_literal(left_expr.clone()); + let right_is_literal = expr_is_any_literal(right_expr.clone()); + if (right_is_literal.clone() && !left_is_literal.clone()) { + { + let l = infer_expr(left_expr.clone(), scope.clone(), std::option::Option::None); + Rc::new(BinopOperands { + left: l.clone(), + right: infer_operand_literal( + right_expr.clone(), + l.typed.clone(), + scope.clone(), + ), + }) + } + } else { + if (left_is_literal.clone() && !right_is_literal.clone()) { + { + let r = + infer_expr(right_expr.clone(), scope.clone(), std::option::Option::None); + Rc::new(BinopOperands { + left: infer_operand_literal( + left_expr.clone(), + r.typed.clone(), + scope.clone(), + ), + right: r.clone(), + }) + } + } else { + Rc::new(BinopOperands { + left: infer_expr(left_expr.clone(), scope.clone(), std::option::Option::None), + right: infer_expr(right_expr.clone(), scope.clone(), std::option::Option::None), + }) + } + } + } +} + pub fn infer_expr_body( texpr: Rc, scope: Rc, @@ -7680,7 +7979,7 @@ pub fn infer_expr_body( match (*texpr.expr_data.clone()).clone() { ExprData::ExprLiteral { value: lit, .. } => { let span = texpr.span.clone(); - ok_infer(crate::v1_std_core::make_expr_node( + let plain = crate::v1_std_core::make_expr_node( texpr.occurrence_identity.clone(), Rc::new(ExprData::ExprLiteral { value: lit.clone() }), Rc::new(vec![]), @@ -7688,8 +7987,43 @@ pub fn infer_expr_body( node: crate::v1_compiler_infer_types::infer_literal_node(lit.clone()), })), span.clone(), - )) + ); + match (*literal_boundary_elaboration(lit.clone(), expected.clone(), scope.clone())) + .clone() + { + LiteralBoundary::LiteralBoundaryPlain => ok_infer(plain.clone()), + LiteralBoundary::LiteralBoundaryElaborated { + elaboration: e, + destination_type: dt, + .. + } => ok_infer(crate::v1_std_core::make_expr_node( + texpr.occurrence_identity.clone(), + Rc::new(ExprData::ExprElaboratedLiteral { + value: lit.clone(), + elaboration: e.clone(), + }), + Rc::new(vec![unfold_literal_image( + lit.clone(), + e.clone(), + dt.clone(), + span.clone(), + )]), + Some(Rc::new(InferredNode::Resolved { node: dt.clone() })), + span.clone(), + )), + LiteralBoundary::LiteralBoundaryRefused { message: m, .. } => { + Rc::new(InferResult { + typed: plain.clone(), + diagnostics: Rc::new(vec![inference_error( + m.clone(), + span.clone(), + scope.module_name.clone(), + )]), + }) + } + } } + ExprData::ExprElaboratedLiteral { .. } => ok_infer(texpr.clone()), ExprData::ExprError { kind, message, .. } => { let span = texpr.span.clone(); let diagnostics = match kind.clone() { @@ -9683,12 +10017,12 @@ crate::v1_compiler_infer_types::resolve_type_variables_from_template(t.clone(), let span = texpr.span.clone(); let left_expr = crate::v1_std_core::binop_left(texpr.clone()); let right_expr = crate::v1_std_core::binop_right(texpr.clone()); - let left_result = - infer_expr(left_expr.clone(), scope.clone(), std::option::Option::None); + let operands = + infer_binop_operands(left_expr.clone(), right_expr.clone(), scope.clone()); + let left_result = operands.left.clone(); let left_typed = left_result.typed.clone(); let left_diags = left_result.diagnostics.clone(); - let right_result = - infer_expr(right_expr.clone(), scope.clone(), std::option::Option::None); + let right_result = operands.right.clone(); let right_typed = right_result.typed.clone(); let right_diags = right_result.diagnostics.clone(); let binop_info = crate::v1_compiler_infer_types::infer_binop_type_node( @@ -9701,6 +10035,11 @@ crate::v1_compiler_infer_types::resolve_type_variables_from_template(t.clone(), Rc::new(ExprData::ExprBinOp { op: op.clone(), algebra_field: binop_info.algebra_field.clone(), + operand: operand_declaration_of_type( + crate::v1_compiler_infer_types::resolved_type(left_typed.clone()), + scope.clone(), + 8, + ), }), Rc::new(vec![left_typed.clone(), right_typed.clone()]), Some(Rc::new(InferredNode::Resolved { diff --git a/src/v1/stage0/src/v1_compiler_infer_env.rs b/src/v1/stage0/src/v1_compiler_infer_env.rs index 6d5ab844299..4103b09d53b 100644 --- a/src/v1/stage0/src/v1_compiler_infer_env.rs +++ b/src/v1/stage0/src/v1_compiler_infer_env.rs @@ -3,6 +3,8 @@ use self::GlobalBareLookupState::*; pub use crate::std_algebra::FreeMonoid; +pub use crate::std_decl_ref::decl_ref; +pub use crate::std_decl_ref::DeclarationRef; use crate::std_induction::RecursionShape::{ DirectRecursion, ListRecursion, MapValueRecursion, OptionalRecursion, SetRecursion, }; @@ -10,6 +12,7 @@ use crate::std_induction::SubValueRelation::{PreservedValue, SubValueUnknown}; pub use crate::std_induction::{InductiveField, RecursionShape, SubValueRelation}; pub use crate::std_occurrence_identity::NodeOccurrenceIdentity; use crate::std_occurrence_identity::NodeOccurrenceIdentity::OccurrenceSynthetic; +pub use crate::std_operator_realization::OperandDeclaration; pub use crate::std_types::is_kernel_type; pub use crate::std_types::SourceSpan; pub use crate::v1_compiler_infer_occurrence_binding::ModulePathBindingProjection; @@ -27,11 +30,11 @@ use crate::v1_std_core::Cardinality::*; use crate::v1_std_core::CompilerDiagnostic::{AmbiguousReference, UnresolvedType}; use crate::v1_std_core::Connective::*; use crate::v1_std_core::ExprData::*; -use crate::v1_std_core::InferredNode::*; +use crate::v1_std_core::InferredNode::Resolved; pub use crate::v1_std_core::{ authored_name_at, empty_intern_table, find_child_named, intern, intern_find, intern_str, kernel_span, merge_intern_tables, module_path_segments, param_node_name_at, - param_node_type_expr, source_text_at, + param_node_type_expr, qualified_last_segment, source_text_at, }; pub use crate::v1_std_core::{ Cardinality, CompilerDiagnostic, Connective, ExprData, InferredNode, InternTable, NewlineIndex, @@ -2142,3 +2145,96 @@ pub fn env_with_type_variable_bindings(env: Rc, tp_names: Rc, sp: Rc) -> bool { + match binding.resolved.clone().ident_span.clone() { + Some(s) => ((s.file.clone() == sp.file.clone()) && (s.start.clone() == sp.start.clone())), + None => false, + } +} + +pub fn type_reference_declaration( + n: Rc, + source_indices: Rc>>, + env: Rc, +) -> Option> { + { + let rt = match n.inferred.clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: r, .. }) => r.clone(), + _ => match lookup_type_for(env.clone(), n.clone()) { + Some(bound) => bound.clone(), + None => n.clone(), + }, + }; + let decl_name = crate::v1_std_core::qualified_last_segment( + crate::v1_std_core::authored_name_at(source_indices.clone(), rt.clone()), + ); + if (decl_name.clone() == "".to_string()) { + return std::option::Option::None; + } + match rt.ident_span.clone() { + None => std::option::Option::None, + Some(sp) => match v1_rt::map_get( + &env.symbol_index.clone().global_bare.clone(), + decl_name.clone(), + ) + .as_deref() + .cloned() + { + Some(GlobalBareLookupState::GlobalBareUniqueBinding { + module_path: mp, + binding: b, + .. + }) => { + if binding_declares_span(b.clone(), sp.clone()) { + Some(Rc::new(OperandDeclaration { + declaration: crate::std_decl_ref::decl_ref( + mp.clone(), + decl_name.clone(), + ), + decl_file: sp.file.clone(), + })) + } else { + std::option::Option::None + } + } + Some(GlobalBareLookupState::GlobalBareAmbiguousBinding { + candidates: cands, + .. + }) => match Rc::new({ + let mut __result = Vec::new(); + for c in cands.iter().cloned() { + if binding_declares_span(c.binding.clone(), sp.clone()) { + __result.push(c); + } + } + __result + }) + .first() + .cloned() + { + Some(c) => Some(Rc::new(OperandDeclaration { + declaration: crate::std_decl_ref::decl_ref( + c.module_path.clone(), + decl_name.clone(), + ), + decl_file: sp.file.clone(), + })), + None => std::option::Option::None, + }, + None => std::option::Option::None, + }, + } + } +} + +pub fn type_reference_declaration_ref( + n: Rc, + source_indices: Rc>>, + env: Rc, +) -> Option> { + match type_reference_declaration(n.clone(), source_indices.clone(), env.clone()) { + Some(od) => Some(od.declaration.clone()), + None => std::option::Option::None, + } +} diff --git a/src/v1/stage0/src/v1_compiler_infer_resolve.rs b/src/v1/stage0/src/v1_compiler_infer_resolve.rs index bbb330650d8..80ae39d63c7 100644 --- a/src/v1/stage0/src/v1_compiler_infer_resolve.rs +++ b/src/v1/stage0/src/v1_compiler_infer_resolve.rs @@ -29,9 +29,10 @@ use crate::v1_std_core::CompilerDiagnostic::{ }; use crate::v1_std_core::Connective::{Arrow, Conj, Disj, NoConnective}; use crate::v1_std_core::ExprData::{ - ExprBinOp, ExprBlock, ExprCall, ExprCast, ExprError, ExprFieldAccess, ExprForEach, ExprIf, - ExprIndex, ExprLambda, ExprLet, ExprListLit, ExprLiteral, ExprMatch, ExprMethodCall, - ExprRecordLit, ExprReturn, ExprSlice, ExprStringInterp, ExprUnaryOp, ExprVar, NoExprData, + ExprBinOp, ExprBlock, ExprCall, ExprCast, ExprElaboratedLiteral, ExprError, ExprFieldAccess, + ExprForEach, ExprIf, ExprIndex, ExprLambda, ExprLet, ExprListLit, ExprLiteral, ExprMatch, + ExprMethodCall, ExprRecordLit, ExprReturn, ExprSlice, ExprStringInterp, ExprUnaryOp, ExprVar, + NoExprData, }; use crate::v1_std_core::ExprErrorKind::SemanticExprError; use crate::v1_std_core::InferredNode::{CompilerError, Resolved, TypeVariable}; @@ -2381,6 +2382,10 @@ pub fn resolve_expr_types( expr: texpr.clone(), diagnostics: Rc::new(vec![]), }), + ExprData::ExprElaboratedLiteral { .. } => Rc::new(ExprResolveResult { + expr: texpr.clone(), + diagnostics: Rc::new(vec![]), + }), ExprData::ExprError { kind, message, .. } => Rc::new(ExprResolveResult { expr: crate::v1_std_core::make_expr_error_node( Rc::new(NodeOccurrenceIdentity::OccurrenceSynthetic), @@ -2975,6 +2980,7 @@ pub fn resolve_expr_types( ExprData::ExprBinOp { op, algebra_field: af, + operand: od, .. } => { let ch = texpr.children.clone(); @@ -2998,6 +3004,7 @@ pub fn resolve_expr_types( Rc::new(ExprData::ExprBinOp { op: op.clone(), algebra_field: af.clone(), + operand: od.clone(), }), Rc::new(vec![lr.expr.clone(), rr.expr.clone()]), texpr.inferred.clone(), diff --git a/src/v1/stage0/src/v1_compiler_parse.rs b/src/v1/stage0/src/v1_compiler_parse.rs index 198c7cb3c54..217508d6b89 100644 --- a/src/v1/stage0/src/v1_compiler_parse.rs +++ b/src/v1/stage0/src/v1_compiler_parse.rs @@ -12391,6 +12391,8 @@ pub fn parse_expr_loop( op: binop.clone(), algebra_field: std::option::Option::None, + operand: + std::option::Option::None, }), Rc::new(vec![ lhs.clone(), @@ -14261,6 +14263,8 @@ pub fn parse_expr_loop_no_brace( op: binop.clone(), algebra_field: std::option::Option::None, + operand: + std::option::Option::None, }), Rc::new(vec![ lhs.clone(), diff --git a/src/v1/stage0/src/v1_std_core.rs b/src/v1/stage0/src/v1_std_core.rs index 7c389bb4f86..3eecf328ede 100644 --- a/src/v1/stage0/src/v1_std_core.rs +++ b/src/v1/stage0/src/v1_std_core.rs @@ -29,6 +29,7 @@ use crate::std_algebra::CostShape::*; pub use crate::std_algebra::{AlgebraFieldTemplate, CollectionSizeEffect, CostShape}; pub use crate::std_induction::SubValueRelation; use crate::std_induction::SubValueRelation::*; +pub use crate::std_literal_elaboration::LiteralElaboration; use crate::std_occurrence_identity::NodeOccurrenceIdentity::OccurrenceSynthetic; use crate::std_occurrence_identity::OccurrenceTransportRefusal::{ DuplicateAuthoredOccurrenceIdentity, DuplicateSuppliedCandidateIdentity, @@ -43,6 +44,7 @@ pub use crate::std_occurrence_identity::{ AuthoredTokenOrdinalSpace, NodeOccurrenceIdentity, OccurrenceIdAllocator, OccurrenceTransportRefusal, }; +pub use crate::std_operator_realization::OperandDeclaration; pub use crate::std_source_annotation::AnnotationAttachmentRefusal; use crate::std_source_annotation::AnnotationAttachmentRefusal::*; pub use crate::std_source_annotation::{ @@ -300,6 +302,10 @@ pub enum ExprData { ExprLiteral { value: Rc, }, + ExprElaboratedLiteral { + value: Rc, + elaboration: Rc, + }, ExprError { kind: ExprErrorKind, message: String, @@ -327,6 +333,7 @@ pub enum ExprData { ExprBinOp { op: BinOp, algebra_field: Option, + operand: Option>, }, ExprUnaryOp { op: UnaryOpKind, @@ -2859,6 +2866,10 @@ pub fn expr_literal_int_optional(expr: Rc) -> Option { LiteralValue::LitInt { value: v, .. } => Some(v.clone()), _ => std::option::Option::None, }, + ExprData::ExprElaboratedLiteral { value: lit, .. } => match (*lit.clone()).clone() { + LiteralValue::LitInt { value: v, .. } => Some(v.clone()), + _ => std::option::Option::None, + }, ExprData::ExprUnaryOp { op: UnaryOpKind::Neg, .. @@ -2902,6 +2913,9 @@ pub fn expr_is_any_literal(mut expr: Rc) -> bool { break true; } }, + ExprData::ExprElaboratedLiteral { .. } => { + break true; + } ExprData::ExprUnaryOp { op: UnaryOpKind::Neg, .. @@ -3369,6 +3383,7 @@ pub fn expr_has_non_tail_self_call( binding_kind: _, .. } => false, ExprData::ExprLiteral { value: _, .. } => false, + ExprData::ExprElaboratedLiteral { .. } => false, ExprData::ExprFieldAccess { summary: _, .. } => { let mut __found = false; for child in texpr.children.clone().iter().cloned() { From a2fe43dc7e27fd5e3ebe3961a98b7801524ccca8 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 19:41:22 +0000 Subject: [PATCH 67/75] XL-0N: roster the one namespace transition this lane makes -- type_reference_declaration_ref relocated to v1.compiler.infer_env (TargetChanged), dissolving when this PR merges Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_013koFunEtpLQCnvUiz85k7Y --- src/v1/stage0/src/namespace_wave_admission.rs | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/v1/stage0/src/namespace_wave_admission.rs b/src/v1/stage0/src/namespace_wave_admission.rs index ea6ef3d8394..cf4fa7e2979 100644 --- a/src/v1/stage0/src/namespace_wave_admission.rs +++ b/src/v1/stage0/src/namespace_wave_admission.rs @@ -424,7 +424,28 @@ pub struct TransitionAdmission { /// the shrink cannot wait for a PR that would otherwise touch this file. Removed by the trigger /// they were authored with. The roster is EMPTY and empty is not permissive: a run carrying a /// real namespace delta still refuses it as UNADJUDICATED until its author adds a row here. -pub const NAMESPACE_TRANSITION_ADMISSIONS: &[TransitionAdmission] = &[]; +/// XL-0N (`node://adhoc-aec65f93-b00`, gunbc#9719): ONE relocation, rostered by its author under +/// the rule this ledger states -- "a run carrying a real namespace delta still refuses it as +/// UNADJUDICATED until its author adds a row here". The operand's declaration must be read where +/// the type reference's SCOPED env binding is live, which is inference; `v1.compiler.emit_rust` +/// cannot be imported by `v1.compiler.infer` (emission depends on inference, not the reverse), so +/// the identity read `type_reference_declaration_ref` moves to `v1.compiler.infer_env`, where the +/// only other consumer already lives. The move is the whole change to this spelling: same function, +/// same signature, one declaring module -- not a requalification, and no second declaration is left +/// behind. `emit_rust`'s own call site now resolves to the new declarer, which is the delta below. +/// +/// DISSOLVE-ON: this pull request merging. Base and head then both carry the relocation, no run can +/// produce this delta, the row reports stale on every build, and it is removed by that trigger +/// exactly as all six shrinks above were -- a stale row here refuses every unrelated PR. +pub const NAMESPACE_TRANSITION_ADMISSIONS: &[TransitionAdmission] = &[TransitionAdmission { + label: "type_reference_declaration_ref relocated to v1.compiler.infer_env (XL-0N, gunbc#9719)", + subject: AdmissionSubject::Binding { + module: "v1.compiler.emit_rust", + in_declaration: "rust_exact_reference_spelling", + spelling: "type_reference_declaration_ref", + }, + disposition: NamespaceDeltaDisposition::TargetChanged, +}]; /// The denominators a green must name (DESIGN §5): a run that cannot say what it covered is an /// instrument failure wearing coverage's clothes. From b6ec60b58102b233cffe001b7fe66e1e705c363f Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 20:48:08 +0000 Subject: [PATCH 68/75] XL-0N (review 57660): the connective arm states what it does not check -- a declared stall with its row-family trigger; the unavailable-identity prose no longer describes the deleted widen Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_013koFunEtpLQCnvUiz85k7Y --- dag/gunbc/structural_realization_bindings.dag | 34 +++++++++++++++++++ dag/std/operator_realization.dag | 26 ++++++++++---- 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/dag/gunbc/structural_realization_bindings.dag b/dag/gunbc/structural_realization_bindings.dag index bb28e10cf8c..e4a124e361b 100644 --- a/dag/gunbc/structural_realization_bindings.dag +++ b/dag/gunbc/structural_realization_bindings.dag @@ -4,6 +4,9 @@ import std.types { List, String, Bool, NonEmptyStr } import std.decl_ref { DeclarationRef, decl_ref } import std.literal_elaboration { LiteralHomomorphism, LiteralSourceKind, KernelIntLiteral, KernelBoolLiteral, LiteralUnfolding, PeanoUnfold, BooleanUnfold } import std.operator_realization { StructuralOrderingBinding } +import gunbc.guarantee_rung_drop { + GuaranteeStall, Mitigatable, MechanicallyPreventable, AwaitsOneGrounding, BoundedPopulation +} // THE CORPUS'S HALF OF LITERAL ELABORATION AND OPERATOR REALIZATION (std.literal_elaboration, // std.operator_realization): which of THIS corpus's structural declarations supply a kernel literal, @@ -62,3 +65,34 @@ fn structural_ordering_binding(carrier_module: String, carrier: String, compare_ data structural_ordering_rows: List = [ structural_ordering_binding(carrier_module: "v2.std.nat", carrier: "Nat", compare_module: "v2.std.nat", compare: "nat_compare", ordering_module: "std.algebra", ordering: "Ordering") ] + +// THE CONNECTIVE GAP, DECLARED RATHER THAN CLAIMED (DESIGN section 4b(2): a class below its ceiling +// names its next-rung trigger). Ordering and arithmetic on a structural operand are decided by this +// roster -- a declared comparison, or a typed refusal. The logical connectives are NOT: inference +// constrains only the RESULT of `&&`/`||` to Bool (v1.compiler.types infer_binop_type_node), so a +// structural operand under a connective is authorable and renders as the host token. Found by +// review (claude/claude-opus-4-7 on gunbc#9719, 2026-08-30) reading the arm against its own prose. +// +// WHY THE OBVIOUS REPAIR IS THE WRONG ONE, measured before it was rejected: refusing every +// structural operand under a connective would refuse v2.std.logic Bool, which 593 modules import as +// their ordinary Bool -- the false-refusal cost the namespace wall's own doctrine names, and it +// would land as a corpus-wide red rather than as a wall. The repair is one more row FAMILY of the +// shape this roster already carries for ordering: the declaration names the operation that realizes +// its conjunction and disjunction, connectives on a declaration with a row realize through it, and +// only a declaration with NO row refuses -- at which point the refusal population is enumerable +// instead of being the whole corpus. +data structural_connective_stall: GuaranteeStall = GuaranteeStall { + subject: "std.operator_realization -- a logical connective (&&, ||) applied to a STRUCTURAL operand renders as the host token, because no declared-connective row family exists to realize or refuse it", + current: Mitigatable, + ceiling: MechanicallyPreventable, + blocker: AwaitsOneGrounding { + grounding: "a StructuralConnectiveBinding row family in std.operator_realization keyed on the operand's exact DeclarationRef (the shape StructuralOrderingBinding already has), plus its rows for the declarations this corpus uses under a connective -- v2.std.logic Bool first", + }, + population: BoundedPopulation { + members: [ + "a connective whose operand is a structural declaration with no host realization (v2.std.logic Bool: renders as the host token today and is the corpus's ordinary conjunction)", + "a connective whose operand is a structural declaration that is not a Boolean algebra at all (a Peano-shaped operand: authorable because inference constrains only the result type)", + ], + }, + next_rung_trigger: "std.operator_realization declaring StructuralConnectiveBinding and operator_realization_for routing And/Or through it -- realizing where a row exists and refusing, typed and located, where none does; retired by that capability and by nothing less, since a roster with no consumer would leave the host token exactly where it is today" +} diff --git a/dag/std/operator_realization.dag b/dag/std/operator_realization.dag index 22fbc080d27..89429d963c8 100644 --- a/dag/std/operator_realization.dag +++ b/dag/std/operator_realization.dag @@ -211,12 +211,26 @@ fn operator_realization_refusal_message(cause: OperatorRealizationRefusal) -> St } } -// THE DECISION. Logical connectives and null-coalescing are not operand-structure questions (their -// operands are the kernel Bool and an Optional respectively) and answer HostOperator; an operand -// whose identity is unavailable at the site is the seed's pre-existing host path and also answers -// HostOperator, because refusing there would refuse every kernel-minted operand (a literal's own -// type carries no declaration) -- the structural arm is entered only on a RESOLVED structural -// declaration, which is the only place the host token was ever wrong. +// THE DECISION, arm by arm, each stating what it is keyed on. +// +// NULL-COALESCING never reaches this fold from the Rust emitter: emit_typed_bin_op answers it from +// emit_null_coalesce before asking for a realization, because its operand is an Optional carrier and +// the question is cardinality, not operand structure. Its arm here is the fold's totality over the +// closed BinOp vocabulary, not a second decision about it. +// +// LOGICAL CONNECTIVES answer HostOperator on a structural operand, and that arm is HONEST ABOUT +// WHAT IT DOES NOT CHECK. Inference types `&&`/`||` as returning Bool without constraining its +// OPERANDS to be one (v1.compiler.types infer_binop_type_node: the And and Or arms name only the +// result), so `a && b` with a Peano-shaped `a` is authorable and this arm would emit the host token +// for it. It is not repaired by refusing every structural operand: v2.std.logic Bool is a declared +// structural coproduct that 593 modules import as their ordinary Bool, so a blanket refusal would +// refuse the corpus's ordinary conjunction -- the wall paid for in false refusals. The repair is a +// declared-connective row family beside the ordering rows, and it is a DECLARED STALL with that +// trigger (gunbc.structural_realization_bindings structural_connective_stall), not a claim this +// authority already covers connectives. +// +// AN OPERAND WHOSE DECLARATION COULD NOT BE READ is not a widen and not a guess: it decides by +// operator class, below. fn operator_realization_for( op: BinOp, operand: OperandRealization, From 28c3ac89e3eee7dd96aeca384feac726df972fe3 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 21:08:10 +0000 Subject: [PATCH 69/75] XL-0N (review 57660 follow-through): the arithmetic refusal is for a NAMED declaration that would not resolve -- an unnamed synthesized type node (a field access, a generic match-arm binder) is host by construction; this lane's own refusal had reddened v2.compiler.02_parse parse_current_position Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_013koFunEtpLQCnvUiz85k7Y --- dag/std/operator_realization.dag | 17 ++++++++++++++--- src/v1/05_emit_rust.dag | 5 ++++- .../peano_nat_structural_realization_test.dag | 16 +++++++++++++++- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/dag/std/operator_realization.dag b/dag/std/operator_realization.dag index 89429d963c8..7bc7a031809 100644 --- a/dag/std/operator_realization.dag +++ b/dag/std/operator_realization.dag @@ -50,13 +50,24 @@ type OperandRealization // AN OPERAND THAT REALIZES AS A HOST VALUE BY CONSTRUCTION, without a declaration to ask: the type // the parser mints for a kernel literal or a builtin's result (a `` file, not a -// declaration in the corpus), a generic type parameter (the host bound carries the operator), and a -// host container (Vec/HashMap realize the container and its comparisons). Each is a decidable arm, -// named so that "no identity" never stands in for "host by construction". +// declaration in the corpus), a generic type parameter (the host bound carries the operator), a +// host container (Vec/HashMap realize the container and its comparisons), and a type node inference +// SYNTHESIZED with no authored name at all. Each is a decidable arm, named so that "no identity" +// never stands in for "host by construction". +// +// THE UNNAMED ARM IS A DISCRIMINATOR, NOT A CATCH-ALL, and it was measured before it was written. +// A structural declaration is reached by a NAME -- that is what a declaration reference is -- so a +// resolved type node whose authored name is empty is not a reference to one; it is a node inference +// built for a field access or a match-arm binder over a generic coproduct (measured: v2.compiler.02_parse +// parse_current_position, `t.start + 1` where t binds the value of ListHeadResult, is the whole +// unnamed-operand population of the v2 closure under an arithmetic operator). Refusing there would +// refuse an operand nothing suggests is structural. What still refuses is the case the refusal is +// FOR: a type node that DOES name a declaration whose identity the caller could not resolve. type HostRealizationReason = KernelMintedType | GenericTypeParameter | HostContainer + | UnnamedSynthesizedType // AN OPERAND WITHOUT A READABLE DECLARATION decides BY OPERATOR CLASS, never by guessing a // declaration. Equality and the connectives do not depend on the declaration at all: every diff --git a/src/v1/05_emit_rust.dag b/src/v1/05_emit_rust.dag index dee7b1a3a94..13c6283f17a 100644 --- a/src/v1/05_emit_rust.dag +++ b/src/v1/05_emit_rust.dag @@ -125,7 +125,8 @@ import v1.compiler.infer_env { TypeEnv, TypeBinding, authored_name, lookup_type_ import std.operator_realization { OperatorRealization, HostOperator, StructuralEquality, StructuralComparison, OperatorRealizationRefused, OperandRealization, HostNumericOperand, StructuralOperand, OperandIdentityUnavailable, - HostRealizedOperand, KernelMintedType, GenericTypeParameter, HostContainer, OperandShapeFacts, OperandDeclaration, + HostRealizedOperand, KernelMintedType, GenericTypeParameter, HostContainer, UnnamedSynthesizedType, + OperandShapeFacts, OperandDeclaration, StructuralOrderingBinding, OrderingTest, OrderingIs, OrderingIsNot, operator_realization_for, operator_realization_refusal_message } @@ -12327,6 +12328,8 @@ fn rust_operand_realization_of_type(rt: Node, scope: InferScope, fuel: Int) -> O HostRealizedOperand { reason: GenericTypeParameter } } else if is_container_type(name: qualified_last_segment(name: authored)) { HostRealizedOperand { reason: HostContainer } + } else if authored == "" { + HostRealizedOperand { reason: UnnamedSynthesizedType } } else { match type_reference_declaration_ref(n: rt, source_indices: scope.type_env.source_indices, env: scope.type_env) { Absent => OperandIdentityUnavailable { facts: OperandShapeFacts { diff --git a/src/v2/test/claim/self_host/peano_nat_structural_realization_test.dag b/src/v2/test/claim/self_host/peano_nat_structural_realization_test.dag index 13830b3542e..eb5992093f2 100644 --- a/src/v2/test/claim/self_host/peano_nat_structural_realization_test.dag +++ b/src/v2/test/claim/self_host/peano_nat_structural_realization_test.dag @@ -12,12 +12,13 @@ import std.literal_elaboration { } import std.operator_realization { HostNumericOperand, StructuralOperand, OperandIdentityUnavailable, HostRealizedOperand, KernelMintedType, + UnnamedSynthesizedType, OperandShapeFacts, OperandIdentityUnavailableAt, HostOperator, StructuralEquality, StructuralComparison, OperatorRealizationRefused, NoStructuralOperationDeclared, OrderingIs, OrderingIsNot, operator_realization_for } -import std.syntax { BinOp, Lt, Le, Gt, Ge, Eq, Div, Mod, Sub, And } +import std.syntax { BinOp, Lt, Le, Gt, Ge, Eq, Div, Mod, Sub, And, Add } import gunbc.structural_realization_bindings { literal_homomorphism_rows, structural_ordering_rows } import v2.std.nat { Nat, Zero, Succ, @@ -281,6 +282,19 @@ test fn operand_without_a_readable_declaration_refuses() -> Bool { ordering_refuses && arithmetic_refuses } +// AN UNNAMED SYNTHESIZED TYPE NODE IS HOST BY CONSTRUCTION UNDER EVERY OPERATOR, including the +// arithmetic ones that refuse on a NAMED unreadable declaration. A structural declaration is reached +// by a name, so a node with none is not a reference to one -- the discriminator, not a catch-all. +// Its live subject is v2.compiler.02_parse parse_current_position (`t.start + 1`, t bound by a +// match arm over the generic ListHeadResult), which this lane's own refusal arm reddened before +// the arm was narrowed to named operands. +test fn an_unnamed_synthesized_operand_is_host_under_arithmetic() -> Bool { + match operator_realization_for(op: Add, operand: HostRealizedOperand { reason: UnnamedSynthesizedType }, ordering_rows: structural_ordering_rows) { + HostOperator => true + _ => false + } +} + // EQUALITY ON THE SAME OPERAND IS THE HOST TOKEN BY CONSTRUCTION: structural and host equality are // one token on the target, so the decision does not need the declaration. This is a decided arm, // not the widen above -- ordering on the same operand refuses (the row before this one). From c8651c8571aef7043f56df0509d03547bfe4e981 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 21:25:36 +0000 Subject: [PATCH 70/75] XL-0N: host the connective stall in gunbc.guarantee_rung_drop -- the bindings roster is inside the v2 self-compile closure and importing the ladder module from there refused the regen gate with five hard diagnostics Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_013koFunEtpLQCnvUiz85k7Y --- dag/gunbc/guarantee_rung_drop.dag | 31 +++++++++++++++++ dag/gunbc/structural_realization_bindings.dag | 34 ------------------- 2 files changed, 31 insertions(+), 34 deletions(-) diff --git a/dag/gunbc/guarantee_rung_drop.dag b/dag/gunbc/guarantee_rung_drop.dag index ce4ffeadb95..b9cc0a67036 100644 --- a/dag/gunbc/guarantee_rung_drop.dag +++ b/dag/gunbc/guarantee_rung_drop.dag @@ -534,3 +534,34 @@ fn stall_roster_size(ss: List) -> Int { cons: fn(acc, s) { acc + 1 }, ) } + +// THE CONNECTIVE GAP, DECLARED RATHER THAN CLAIMED (DESIGN section 4b(2): a class below its ceiling +// names its next-rung trigger). Ordering and arithmetic on a structural operand are decided by this +// roster -- a declared comparison, or a typed refusal. The logical connectives are NOT: inference +// constrains only the RESULT of `&&`/`||` to Bool (v1.compiler.types infer_binop_type_node), so a +// structural operand under a connective is authorable and renders as the host token. Found by +// review (claude/claude-opus-4-7 on gunbc#9719, 2026-08-30) reading the arm against its own prose. +// +// WHY THE OBVIOUS REPAIR IS THE WRONG ONE, measured before it was rejected: refusing every +// structural operand under a connective would refuse v2.std.logic Bool, which 593 modules import as +// their ordinary Bool -- the false-refusal cost the namespace wall's own doctrine names, and it +// would land as a corpus-wide red rather than as a wall. The repair is one more row FAMILY of the +// shape this roster already carries for ordering: the declaration names the operation that realizes +// its conjunction and disjunction, connectives on a declaration with a row realize through it, and +// only a declaration with NO row refuses -- at which point the refusal population is enumerable +// instead of being the whole corpus. +data structural_connective_stall: GuaranteeStall = GuaranteeStall { + subject: "std.operator_realization -- a logical connective (&&, ||) applied to a STRUCTURAL operand renders as the host token, because no declared-connective row family exists to realize or refuse it", + current: Mitigatable, + ceiling: MechanicallyPreventable, + blocker: AwaitsOneGrounding { + grounding: "a StructuralConnectiveBinding row family in std.operator_realization keyed on the operand's exact DeclarationRef (the shape StructuralOrderingBinding already has), plus its rows for the declarations this corpus uses under a connective -- v2.std.logic Bool first", + }, + population: BoundedPopulation { + members: [ + "a connective whose operand is a structural declaration with no host realization (v2.std.logic Bool: renders as the host token today and is the corpus's ordinary conjunction)", + "a connective whose operand is a structural declaration that is not a Boolean algebra at all (a Peano-shaped operand: authorable because inference constrains only the result type)", + ], + }, + next_rung_trigger: "std.operator_realization declaring StructuralConnectiveBinding and operator_realization_for routing And/Or through it -- realizing where a row exists and refusing, typed and located, where none does; retired by that capability and by nothing less, since a roster with no consumer would leave the host token exactly where it is today" +} diff --git a/dag/gunbc/structural_realization_bindings.dag b/dag/gunbc/structural_realization_bindings.dag index e4a124e361b..bb28e10cf8c 100644 --- a/dag/gunbc/structural_realization_bindings.dag +++ b/dag/gunbc/structural_realization_bindings.dag @@ -4,9 +4,6 @@ import std.types { List, String, Bool, NonEmptyStr } import std.decl_ref { DeclarationRef, decl_ref } import std.literal_elaboration { LiteralHomomorphism, LiteralSourceKind, KernelIntLiteral, KernelBoolLiteral, LiteralUnfolding, PeanoUnfold, BooleanUnfold } import std.operator_realization { StructuralOrderingBinding } -import gunbc.guarantee_rung_drop { - GuaranteeStall, Mitigatable, MechanicallyPreventable, AwaitsOneGrounding, BoundedPopulation -} // THE CORPUS'S HALF OF LITERAL ELABORATION AND OPERATOR REALIZATION (std.literal_elaboration, // std.operator_realization): which of THIS corpus's structural declarations supply a kernel literal, @@ -65,34 +62,3 @@ fn structural_ordering_binding(carrier_module: String, carrier: String, compare_ data structural_ordering_rows: List = [ structural_ordering_binding(carrier_module: "v2.std.nat", carrier: "Nat", compare_module: "v2.std.nat", compare: "nat_compare", ordering_module: "std.algebra", ordering: "Ordering") ] - -// THE CONNECTIVE GAP, DECLARED RATHER THAN CLAIMED (DESIGN section 4b(2): a class below its ceiling -// names its next-rung trigger). Ordering and arithmetic on a structural operand are decided by this -// roster -- a declared comparison, or a typed refusal. The logical connectives are NOT: inference -// constrains only the RESULT of `&&`/`||` to Bool (v1.compiler.types infer_binop_type_node), so a -// structural operand under a connective is authorable and renders as the host token. Found by -// review (claude/claude-opus-4-7 on gunbc#9719, 2026-08-30) reading the arm against its own prose. -// -// WHY THE OBVIOUS REPAIR IS THE WRONG ONE, measured before it was rejected: refusing every -// structural operand under a connective would refuse v2.std.logic Bool, which 593 modules import as -// their ordinary Bool -- the false-refusal cost the namespace wall's own doctrine names, and it -// would land as a corpus-wide red rather than as a wall. The repair is one more row FAMILY of the -// shape this roster already carries for ordering: the declaration names the operation that realizes -// its conjunction and disjunction, connectives on a declaration with a row realize through it, and -// only a declaration with NO row refuses -- at which point the refusal population is enumerable -// instead of being the whole corpus. -data structural_connective_stall: GuaranteeStall = GuaranteeStall { - subject: "std.operator_realization -- a logical connective (&&, ||) applied to a STRUCTURAL operand renders as the host token, because no declared-connective row family exists to realize or refuse it", - current: Mitigatable, - ceiling: MechanicallyPreventable, - blocker: AwaitsOneGrounding { - grounding: "a StructuralConnectiveBinding row family in std.operator_realization keyed on the operand's exact DeclarationRef (the shape StructuralOrderingBinding already has), plus its rows for the declarations this corpus uses under a connective -- v2.std.logic Bool first", - }, - population: BoundedPopulation { - members: [ - "a connective whose operand is a structural declaration with no host realization (v2.std.logic Bool: renders as the host token today and is the corpus's ordinary conjunction)", - "a connective whose operand is a structural declaration that is not a Boolean algebra at all (a Peano-shaped operand: authorable because inference constrains only the result type)", - ], - }, - next_rung_trigger: "std.operator_realization declaring StructuralConnectiveBinding and operator_realization_for routing And/Or through it -- realizing where a row exists and refusing, typed and located, where none does; retired by that capability and by nothing less, since a roster with no consumer would leave the host token exactly where it is today" -} From 21774465b3cf52dbd293a7a8bc33bcd776f83942 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sun, 30 Aug 2026 21:56:16 +0000 Subject: [PATCH 71/75] XL-0N: regen mirrors for the narrowed operand arm and the relocated stall (fixed point round 2; 12/12 emitted-path, 27/27 interpreter rows) Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_013koFunEtpLQCnvUiz85k7Y --- src/v1/stage0/src/std_operator_realization.rs | 3 + src/v1/stage0/src/v1_compiler_emit_rust.rs | 140 +++++++----------- 2 files changed, 59 insertions(+), 84 deletions(-) diff --git a/src/v1/stage0/src/std_operator_realization.rs b/src/v1/stage0/src/std_operator_realization.rs index 414fa6ca5ec..be54a7282c0 100644 --- a/src/v1/stage0/src/std_operator_realization.rs +++ b/src/v1/stage0/src/std_operator_realization.rs @@ -45,6 +45,7 @@ pub enum HostRealizationReason { KernelMintedType, GenericTypeParameter, HostContainer, + UnnamedSynthesizedType, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -387,3 +388,5 @@ pub struct KernelMintedType; pub struct GenericTypeParameter; #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct HostContainer; +#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +pub struct UnnamedSynthesizedType; diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index 4edb0f6c727..1a3528c7d1c 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -48,7 +48,7 @@ pub use crate::std_nat::Nat; pub use crate::std_occurrence_identity::NodeOccurrenceIdentity; use crate::std_occurrence_identity::NodeOccurrenceIdentity::OccurrenceSynthetic; use crate::std_operator_realization::HostRealizationReason::{ - GenericTypeParameter, HostContainer, KernelMintedType, + GenericTypeParameter, HostContainer, KernelMintedType, UnnamedSynthesizedType, }; use crate::std_operator_realization::OperandRealization::{ HostNumericOperand, HostRealizedOperand, OperandIdentityUnavailable, StructuralOperand, @@ -29315,90 +29315,62 @@ pub fn rust_operand_realization_of_type( reason: HostRealizationReason::HostContainer, }); } else { - match crate::v1_compiler_infer_env::type_reference_declaration_ref( - rt.clone(), - scope.type_env.clone().source_indices.clone(), - scope.type_env.clone(), - ) { - None => { - break Rc::new(OperandRealization::OperandIdentityUnavailable { - facts: Rc::new(OperandShapeFacts { - authored_name: authored.clone(), - connective: - crate::v1_compiler_dag_collect_support::connective_name( - rt.connective.clone(), - ), - child_count: (rt.children.clone().len() as i64), - resolved: (rt.inferred.clone() != std::option::Option::None), - decl_file: decl_file.clone(), - }), - }); - } - Some(d) => { - if crate::v1_compiler_coercion::declaration_realizes_natively_on_rust( - d.clone(), - crate::v1_compiler_coercion::type_reference_decl_file(rt.clone()), - ) { - break Rc::new(OperandRealization::HostNumericOperand); - } else { - let decl = match rt.inferred.clone().as_deref().cloned() { - Some(InferredNode::Resolved { node: r, .. }) => r.clone(), - _ => rt.clone(), - }; - if ((fuel.clone() > 0) - && crate::v1_compiler_infer::is_where_refinement_type( - rt.clone(), - )) - { - match rt.children.clone().first().cloned() { - Some(base) => { - let base_resolved = - match crate::v1_compiler_infer_env::lookup_type_for( - scope.type_env.clone(), - base.clone(), - ) { - Some(r) => r.clone(), - None => base.clone(), - }; - { - let __tco_0 = base_resolved.clone(); - let __tco_1 = (fuel - 1); - rt = __tco_0; - fuel = __tco_1; - continue; - } - } - None => { - break Rc::new(OperandRealization::StructuralOperand { - declaration: d.clone(), - }); - } - } - } else { - if ((fuel.clone() > 0) - && crate::v1_compiler_emit_core_support::is_type_alias_item( - decl.clone(), - scope.type_env.clone().source_indices.clone(), - )) + if (authored.clone() == "".to_string()) { + break Rc::new(OperandRealization::HostRealizedOperand { + reason: HostRealizationReason::UnnamedSynthesizedType, + }); + } else { + match crate::v1_compiler_infer_env::type_reference_declaration_ref(rt.clone(), scope.type_env.clone().source_indices.clone(), scope.type_env.clone()) { + None => { break Rc::new(OperandRealization::OperandIdentityUnavailable { + facts: Rc::new(OperandShapeFacts { + authored_name: authored.clone(), + connective: crate::v1_compiler_dag_collect_support::connective_name(rt.connective.clone()), + child_count: (rt.children.clone().len() as i64), + resolved: (rt.inferred.clone() != std::option::Option::None), + decl_file: decl_file.clone(), +}), +}); }, + Some(d) => { if crate::v1_compiler_coercion::declaration_realizes_natively_on_rust(d.clone(), crate::v1_compiler_coercion::type_reference_decl_file(rt.clone())) { + break Rc::new(OperandRealization::HostNumericOperand); +} else { + let decl = match rt.inferred.clone().as_deref().cloned() { + Some(InferredNode::Resolved { node: r, .. }) => r.clone(), + _ => rt.clone(), +}; +if ((fuel.clone() > 0) && crate::v1_compiler_infer::is_where_refinement_type(rt.clone())) { + match rt.children.clone().first().cloned() { + Some(base) => { let base_resolved = match crate::v1_compiler_infer_env::lookup_type_for(scope.type_env.clone(), base.clone()) { + Some(r) => r.clone(), + None => base.clone(), +}; +{ + let __tco_0 = base_resolved.clone(); +let __tco_1 = (fuel - 1); +rt = __tco_0; +fuel = __tco_1; +continue; +} }, + None => { break Rc::new(OperandRealization::StructuralOperand { + declaration: d.clone(), +}); }, +} +} else { + if ((fuel.clone() > 0) && crate::v1_compiler_emit_core_support::is_type_alias_item(decl.clone(), scope.type_env.clone().source_indices.clone())) { { - { - let __tco_0 = - crate::v1_compiler_infer_types::resolved_type( - decl.clone(), - ); - let __tco_1 = (fuel - 1); - rt = __tco_0; - fuel = __tco_1; - continue; - } - } else { - break Rc::new(OperandRealization::StructuralOperand { - declaration: d.clone(), - }); - } - } - } - } + let __tco_0 = crate::v1_compiler_infer_types::resolved_type(decl.clone()); +let __tco_1 = (fuel - 1); +rt = __tco_0; +fuel = __tco_1; +continue; +} +} else { + break Rc::new(OperandRealization::StructuralOperand { + declaration: d.clone(), +}); +} +} +} }, +} } } } From b1356ab6b4b00d0c83bcc744faba5d7bb0744612 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Mon, 31 Aug 2026 02:57:53 +0000 Subject: [PATCH 72/75] XL-0N: regenerate the four merge-driver-refused mirrors from the merged sources (main 22ab698 bootstrap, fixed point round 2; 39/39 witness rows) -- main's change-denominated emit and this lane's elaborated-literal arm are both present because both were re-derived, not hand-bridged Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_013koFunEtpLQCnvUiz85k7Y --- src/v1/stage0/src/emitted_population.rs | 1 + src/v1/stage0/src/lib.rs | 1 + src/v1/stage0/src/v1_compiler_compile.rs | 41 +- src/v1/stage0/src/v1_compiler_emit_rust.rs | 485 ++++++++++++++++----- 4 files changed, 413 insertions(+), 115 deletions(-) diff --git a/src/v1/stage0/src/emitted_population.rs b/src/v1/stage0/src/emitted_population.rs index 5bcfaae7cde..daea5fb8929 100644 --- a/src/v1/stage0/src/emitted_population.rs +++ b/src/v1/stage0/src/emitted_population.rs @@ -36,6 +36,7 @@ // src/gunbc_stage0_crate_layout_generated.rs // src/gunbc_stage0_crate_partition_generated.rs // src/gunbc_stage0_emitted_population_manifest.rs +// src/gunbc_stage0_partition_package_graph.rs // src/gunbc_structural_realization_bindings.rs // src/lib.rs // src/main.rs diff --git a/src/v1/stage0/src/lib.rs b/src/v1/stage0/src/lib.rs index 9c693b75422..a5d7d33bd1f 100644 --- a/src/v1/stage0/src/lib.rs +++ b/src/v1/stage0/src/lib.rs @@ -50,6 +50,7 @@ pub mod gunbc_rust_source_type_bindings; pub mod gunbc_stage0_crate_layout_generated; pub mod gunbc_stage0_crate_partition_generated; pub mod gunbc_stage0_emitted_population_manifest; +pub mod gunbc_stage0_partition_package_graph; pub mod gunbc_structural_realization_bindings; pub mod std_algebra; pub mod std_checked_arithmetic; diff --git a/src/v1/stage0/src/v1_compiler_compile.rs b/src/v1/stage0/src/v1_compiler_compile.rs index b5167a0ad8a..925b535ed71 100644 --- a/src/v1/stage0/src/v1_compiler_compile.rs +++ b/src/v1/stage0/src/v1_compiler_compile.rs @@ -30,9 +30,12 @@ use crate::std_termination::ProportionalDivisor::{DivideByTwo, StrictlyLarger}; pub use crate::std_termination::{PositiveDescentAmount, ProportionalDivisor}; pub use crate::std_types::SourceSpan; pub use crate::v1_compiler_annotation_bind::admit_source_annotations; -pub use crate::v1_compiler_artifact::default_artifact_plan; use crate::v1_compiler_artifact::RenderTarget::Dag; -pub use crate::v1_compiler_artifact::{Artifact, ArtifactPlan, RenderTarget}; +use crate::v1_compiler_artifact::RustModuleRenderSelection::RenderEveryModule; +pub use crate::v1_compiler_artifact::{default_artifact_plan, selected_artifact_plan}; +pub use crate::v1_compiler_artifact::{ + Artifact, ArtifactPlan, RenderTarget, RustModuleRenderSelection, +}; pub use crate::v1_compiler_complexity::{build_complexity_report, empty_complexity_report}; pub use crate::v1_compiler_complexity::{ ComplexityReport, ComplexityViolation, FuncEntry, RecursionContext, @@ -45,7 +48,7 @@ pub use crate::v1_compiler_emit_core_support::escape_json_string; pub use crate::v1_compiler_emit_core_support::EmitResult; pub use crate::v1_compiler_emit_go::emit_go; pub use crate::v1_compiler_emit_python::emit_python; -pub use crate::v1_compiler_emit_rust::emit_rust; +pub use crate::v1_compiler_emit_rust::emit_rust_selected; pub use crate::v1_compiler_infer::{reconcile, reconcile_with_census_extra}; pub use crate::v1_compiler_infer_items::{ResolvedGraph, TypedModule}; pub use crate::v1_compiler_infer_types::algebra_field_kind_name; @@ -439,7 +442,10 @@ pub fn emit_artifact(typed: Rc, artifact: Rc) -> Rc crate::v1_compiler_emit_rust::emit_rust(typed.clone()), + RenderTarget::Rust => crate::v1_compiler_emit_rust::emit_rust_selected( + typed.clone(), + artifact.module_selection.clone(), + ), RenderTarget::Python => crate::v1_compiler_emit_python::emit_python(typed.clone()), RenderTarget::Go => crate::v1_compiler_emit_go::emit_go(typed.clone()), RenderTarget::Dag => emit_dag_artifact(typed.clone()), @@ -2761,6 +2767,18 @@ pub fn compile_sources( ) } +pub fn compile_sources_selected( + sources: Rc>>, + target: RenderTarget, + selection: Rc, +) -> Rc { + emit_resolved_for_target_selected( + compile_to_resolved_with_options(sources.clone(), default_compile_pipeline_options()), + target.clone(), + selection.clone(), + ) +} + pub fn compile_sources_with_options( sources: Rc>>, target: RenderTarget, @@ -2960,6 +2978,18 @@ pub fn compile_to_resolved_with_options( pub fn emit_resolved_for_target( resolved: Rc, target: RenderTarget, +) -> Rc { + emit_resolved_for_target_selected( + resolved.clone(), + target.clone(), + Rc::new(RustModuleRenderSelection::RenderEveryModule), + ) +} + +pub fn emit_resolved_for_target_selected( + resolved: Rc, + target: RenderTarget, + selection: Rc, ) -> Rc { match emittable_graph(resolved.clone()) { None => Rc::new(PipelineResult { @@ -2972,7 +3002,7 @@ pub fn emit_resolved_for_target( }), Some(emittable) => { let typed = emittable.graph(); - let artifact_plan = crate::v1_compiler_artifact::default_artifact_plan( + let artifact_plan = crate::v1_compiler_artifact::selected_artifact_plan( Rc::new({ let mut __result = Vec::new(); for m in typed.modules.clone().iter().cloned() { @@ -2984,6 +3014,7 @@ pub fn emit_resolved_for_target( __result }), target.clone(), + selection.clone(), ); let _ = v1_rt::trace_mark("compile.emit.begin".to_string()); let emit_result = emit_from_artifact_plan(emittable.clone(), artifact_plan.clone()); diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index 1a3528c7d1c..5c7f04c8914 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -84,8 +84,11 @@ use crate::std_target_representation::ExactBindingResolution::{ }; pub use crate::std_types::SourceSpan; pub use crate::std_types::{container_template_algebra, is_container_type, is_kernel_type}; -pub use crate::v1_compiler_artifact::RenderTarget; use crate::v1_compiler_artifact::RenderTarget::Rust; +use crate::v1_compiler_artifact::RustModuleRenderSelection::{ + RenderEveryModule, RenderSelectedMirrors, +}; +pub use crate::v1_compiler_artifact::{RenderTarget, RustModuleRenderSelection}; pub use crate::v1_compiler_closure_stub_v2_std_integer_rust::closure_stub_v2_std_integer_source; pub use crate::v1_compiler_closure_stub_v2_std_text_rust::closure_stub_v2_std_text_source; pub use crate::v1_compiler_coercion::decl_identity_file; @@ -5861,6 +5864,16 @@ pub fn emit_rust_reference_derived_census(typed: Rc) -> Reference } pub fn emit_rust(typed: Rc) -> Rc { + emit_rust_selected( + typed.clone(), + Rc::new(RustModuleRenderSelection::RenderEveryModule), + ) +} + +pub fn emit_rust_selected( + typed: Rc, + selection: Rc, +) -> Rc { { let ctx = build_emit_rust_context(typed.clone()); let emit_info = ctx.emit_info.clone(); @@ -5899,7 +5912,24 @@ pub fn emit_rust(typed: Rc) -> Rc { let test_projections = ctx.test_projections.clone(); let module_emissions = Rc::new({ let mut __result = Vec::new(); - for tm in typed.modules.clone().iter().cloned() { + for tm in Rc::new({ + let mut __result = Vec::new(); + for tm in typed.modules.clone().iter().cloned() { + if rust_module_render_selection_renders( + selection.clone(), + crate::v1_std_core::authored_name_at( + tm.type_env.clone().source_indices.clone(), + tm.module.clone(), + ), + ) { + __result.push(tm); + } + } + __result + }) + .iter() + .cloned() + { __result.push(emit_module_full_with_dispositions( tm.clone(), ctx.clone(), @@ -5922,30 +5952,24 @@ pub fn emit_rust(typed: Rc) -> Rc { } __result }); - let test_files = Rc::new({ + let module_paths = Rc::new({ let mut __result = Vec::new(); - for f in Rc::new({ + for tm in typed.modules.clone().iter().cloned() { + __result.push(rust_module_emit_path(crate::v1_std_core::authored_name_at( + tm.type_env.clone().source_indices.clone(), + tm.module.clone(), + ))); + } + __result + }); + let test_module_names = Rc::new({ + let mut __result = Vec::new(); + for name in Rc::new({ let mut __result = Vec::new(); for tm in typed.modules.clone().iter().cloned() { - __result.push(emit_test_file( - crate::v1_std_core::authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), - ), - Rc::new({ - let mut __result = Vec::new(); - for p in test_projections.iter().cloned() { - if (p.module_name.clone() - == crate::v1_std_core::authored_name_at( - tm.type_env.clone().source_indices.clone(), - tm.module.clone(), - )) - { - __result.push(p); - } - } - __result - }), + __result.push(crate::v1_std_core::authored_name_at( + tm.type_env.clone().source_indices.clone(), + tm.module.clone(), )); } __result @@ -5953,12 +5977,59 @@ pub fn emit_rust(typed: Rc) -> Rc { .iter() .cloned() { - if (v1_rt::string_length(&f.content.clone()) > 0) { - __result.push(f); + if ((Rc::new({ + let mut __result = Vec::new(); + for p in test_projections.iter().cloned() { + if (p.module_name.clone() == name.clone()) { + __result.push(p); + } + } + __result + }) + .len() as i64) + > 0) + { + __result.push(name); } } __result }); + let test_file_paths = Rc::new({ + let mut __result = Vec::new(); + for name in test_module_names.iter().cloned() { + __result.push(rust_test_file_path(name.clone())); + } + __result + }); + let test_files = Rc::new({ + let mut __result = Vec::new(); + for name in Rc::new({ + let mut __result = Vec::new(); + for name in test_module_names.iter().cloned() { + if rust_module_render_selection_renders(selection.clone(), name.clone()) { + __result.push(name); + } + } + __result + }) + .iter() + .cloned() + { + __result.push(emit_test_file( + name.clone(), + Rc::new({ + let mut __result = Vec::new(); + for p in test_projections.iter().cloned() { + if (p.module_name.clone() == name.clone()) { + __result.push(p); + } + } + __result + }), + )); + } + __result + }); let has_services = crate::v1_compiler_emit::has_service_items(typed.clone()); let has_pipeline = { let mut __found = false; @@ -5998,16 +6069,20 @@ pub fn emit_rust(typed: Rc) -> Rc { } else { Rc::new(vec![]) }; - let v2_std_text_stub = if (module_files_reference_v2_std_text(module_files.clone()) - && !module_files_include_v2_std_text(module_files.clone())) - { + let v2_std_text_stub = if closure_needs_module_filename_stub( + typed.clone(), + ctx.clone(), + "v2_std_text".to_string(), + ) { Rc::new(vec![emit_v2_std_text_closure_stub_module()]) } else { Rc::new(vec![]) }; - let v2_std_integer_stub = if (module_files_reference_v2_std_integer(module_files.clone()) - && !module_files_include_v2_std_integer(module_files.clone())) - { + let v2_std_integer_stub = if closure_needs_module_filename_stub( + typed.clone(), + ctx.clone(), + "v2_std_integer".to_string(), + ) { Rc::new(vec![emit_v2_std_integer_closure_stub_module()]) } else { Rc::new(vec![]) @@ -6022,7 +6097,59 @@ pub fn emit_rust(typed: Rc) -> Rc { ), dry_run_file.clone(), ); - let lib_file = emit_lib_rs_from_files(all_mod_files.clone(), has_pipeline.clone()); + let all_mod_paths = v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + module_paths.clone(), + Rc::new({ + let mut __result = Vec::new(); + for f in v2_std_text_stub.iter().cloned() { + __result.push(f.path.clone()); + } + __result + }), + ), + Rc::new({ + let mut __result = Vec::new(); + for f in v2_std_integer_stub.iter().cloned() { + __result.push(f.path.clone()); + } + __result + }), + ), + Rc::new(vec![rt_file.path.clone()]), + ), + Rc::new({ + let mut __result = Vec::new(); + for f in dry_run_file.iter().cloned() { + __result.push(f.path.clone()); + } + __result + }), + ); + let lib_file = emit_lib_rs_from_paths(all_mod_paths.clone(), has_pipeline.clone()); + let emitted_paths = v1_rt::concat( + v1_rt::concat( + v1_rt::concat( + Rc::new(vec![ + cargo.path.clone(), + lib_file.path.clone(), + main_file.path.clone(), + ]), + all_mod_paths.clone(), + ), + Rc::new({ + let mut __result = Vec::new(); + for f in compiler_tests_file.iter().cloned() { + __result.push(f.path.clone()); + } + __result + }), + ), + test_file_paths.clone(), + ); + let population_manifest = emit_emitted_population_manifest(emitted_paths.clone()); let emitted_files = v1_rt::concat( v1_rt::concat( v1_rt::concat( @@ -6033,7 +6160,6 @@ pub fn emit_rust(typed: Rc) -> Rc { ), test_files.clone(), ); - let population_manifest = emit_emitted_population_manifest(emitted_files.clone()); let files = v1_rt::concat( emitted_files.clone(), Rc::new(vec![population_manifest.clone()]), @@ -6045,20 +6171,62 @@ pub fn emit_rust(typed: Rc) -> Rc { } } +pub fn rust_module_emit_filename(module_name: String) -> String { + { + let raw = crate::v1_compiler_emit_core_support::module_to_filename(module_name.clone()); + if (raw.clone() == "main".to_string()) { + "main_mod".to_string() + } else { + raw.clone() + } + } +} + +pub fn rust_module_emit_path(module_name: String) -> String { + v1_rt::concat( + v1_rt::concat( + rust_source_root(), + rust_module_emit_filename(module_name.clone()), + ), + rust_source_ext(), + ) +} + +pub fn rust_module_render_selection_renders( + selection: Rc, + module_name: String, +) -> bool { + match (*selection.clone()).clone() { + RustModuleRenderSelection::RenderEveryModule => true, + RustModuleRenderSelection::RenderSelectedMirrors { + basenames: basenames, + .. + } => { + let mut __found = false; + for b in basenames.iter().cloned() { + if (b.clone() + == v1_rt::concat( + rust_module_emit_filename(module_name.clone()), + rust_source_ext(), + )) + { + __found = true; + break; + } + } + __found + } + } +} + pub fn emitted_population_manifest_path() -> String { v1_rt::concat(rust_source_root(), emitted_population_manifest_basename()) } -pub fn emit_emitted_population_manifest(files: Rc>>) -> Rc { +pub fn emit_emitted_population_manifest(paths: Rc>) -> Rc { { let declared = v1_rt::concat( - Rc::new({ - let mut __result = Vec::new(); - for f in files.iter().cloned() { - __result.push(f.path.clone()); - } - __result - }), + paths.clone(), Rc::new(vec![emitted_population_manifest_path()]), ); let lines = Rc::new({ @@ -6114,14 +6282,122 @@ pub fn emit_compiler_tests_module() -> Rc { }) } -pub fn emitted_files_carry_use_line(files: Rc>>, line: String) -> bool { +pub fn module_reference_candidate_names( + typed_module: Rc, + ctx: Rc, +) -> Rc> { + { + let source_indices = typed_module.type_env.clone().source_indices.clone(); + let emit_info = ctx.emit_info.clone(); + let this_module_name = crate::v1_std_core::authored_name_at( + source_indices.clone(), + typed_module.module.clone(), + ); + let items = typed_module.items.clone(); + let value_names = crate::v1_compiler_emit_core_support::unique_strings(Rc::new({ + let mut __result = Vec::new(); + for item in items.iter().cloned() { + __result.extend( + (*collect_value_ref_names( + item.clone(), + source_indices.clone(), + emit_info.type_summaries.clone(), + emit_info.variant_to_enum.clone(), + )) + .iter() + .cloned(), + ); + } + __result + })); + let item_emit_surface_names = Rc::new({ + let mut __result = Vec::new(); + for item in items.iter().cloned() { + __result.extend( + (*collect_item_emit_surface_names( + item.clone(), + source_indices.clone(), + emit_info.clone(), + )) + .iter() + .cloned(), + ); + } + __result + }); + let type_surface_names = + crate::v1_compiler_emit_core_support::unique_strings(item_emit_surface_names.clone()); + let field_surface_names = collect_items_field_import_surface_names( + item_emit_surface_names.clone(), + emit_info.clone(), + ); + let variant_payload_structs = expand_variant_payload_struct_imports( + type_surface_names.clone(), + emit_info.type_summaries.clone(), + emit_info.variant_to_enum.clone(), + ); + let realized_surface_names = + crate::v1_compiler_emit_core_support::unique_strings(Rc::new({ + let mut __result = Vec::new(); + for item in items.iter().cloned() { + __result.extend( + (*collect_item_realized_surface_names( + item.clone(), + emit_info.shared_types.clone(), + source_indices.clone(), + emit_info.clone(), + )) + .iter() + .cloned(), + ); + } + __result + })); + let unlisted_type_names = match v1_rt::map_get( + &ctx.unlisted_type_names_by_module.clone(), + this_module_name.clone(), + ) { + Some(v) => v.clone(), + None => Rc::new(vec![]), + }; + let origin_candidates = crate::std_repair_input_origin::repair_input_origin_candidates( + this_module_name.clone(), + unlisted_type_names.clone(), + value_names.clone(), + type_surface_names.clone(), + field_surface_names.clone(), + variant_payload_structs.clone(), + realized_surface_names.clone(), + ); + Rc::new({ + let mut __result = Vec::new(); + for name in crate::v1_compiler_emit_core_support::unique_strings( + crate::std_repair_input_origin::repair_input_origin_compatibility_names( + origin_candidates.clone(), + ), + ) + .iter() + .cloned() + { + if !reference_is_host_realized_builtin(name.clone()) { + __result.push(name); + } + } + __result + }) + } +} + +pub fn registry_declares_module_filename( + registry: Rc>>, + filename: String, +) -> bool { { let mut __found = false; - for f in files.iter().cloned() { - if v1_rt::string_contains( - &f.content.clone(), - v1_rt::concat("\n".to_string(), line.clone()), - ) { + for info in Rc::new(v1_rt::map_values(®istry)).iter().cloned() { + if (crate::v1_compiler_emit_core_support::module_to_filename(info.module_name.clone()) + == filename.clone()) + { __found = true; break; } @@ -6130,36 +6406,38 @@ pub fn emitted_files_carry_use_line(files: Rc>>, line: String) } } -pub fn module_files_reference_v2_std_text(files: Rc>>) -> bool { - emitted_files_carry_use_line( - files.clone(), - v1_rt::concat( - rust_visibility_prefix(), - "use crate::v2_std_text::".to_string(), - ), - ) -} - -pub fn module_files_reference_v2_std_integer(files: Rc>>) -> bool { - emitted_files_carry_use_line( - files.clone(), - v1_rt::concat( - rust_visibility_prefix(), - "use crate::v2_std_integer::".to_string(), - ), - ) -} - -pub fn module_files_include_v2_std_text(files: Rc>>) -> bool { +pub fn closure_references_module_filename( + typed: Rc, + ctx: Rc, + filename: String, +) -> bool { { - let expected = v1_rt::concat( - v1_rt::concat(rust_source_root(), "v2_std_text".to_string()), - rust_source_ext(), - ); + if !registry_declares_module_filename(ctx.registry.clone(), filename.clone()) { + return false; + } { let mut __found = false; - for f in files.iter().cloned() { - if (f.path.clone() == expected.clone()) { + for tm in typed.modules.clone().iter().cloned() { + if { + let mut __found = false; + for name in module_reference_candidate_names(tm.clone(), ctx.clone()) + .iter() + .cloned() + { + if match v1_rt::map_get(&ctx.registry.clone(), name.clone()) { + Some(info) => { + (crate::v1_compiler_emit_core_support::module_to_filename( + info.module_name.clone(), + ) == filename.clone()) + } + None => false, + } { + __found = true; + break; + } + } + __found + } { __found = true; break; } @@ -6169,23 +6447,17 @@ pub fn module_files_include_v2_std_text(files: Rc>>) -> bool { } } -pub fn module_files_include_v2_std_integer(files: Rc>>) -> bool { - { - let expected = v1_rt::concat( - v1_rt::concat(rust_source_root(), "v2_std_integer".to_string()), - rust_source_ext(), - ); - { - let mut __found = false; - for f in files.iter().cloned() { - if (f.path.clone() == expected.clone()) { - __found = true; - break; - } - } - __found - } - } +pub fn closure_needs_module_filename_stub( + typed: Rc, + ctx: Rc, + filename: String, +) -> bool { + (closure_references_module_filename(typed.clone(), ctx.clone(), filename.clone()) + && !typed_closure_includes_module_filename( + typed.modules.clone(), + filename.clone(), + merged_module_source_indices(typed.modules.clone()), + )) } pub fn emit_v2_std_integer_closure_stub_module() -> Rc { @@ -6211,13 +6483,13 @@ pub fn emit_v2_std_text_closure_stub_module() -> Rc { }) } -pub fn lib_rs_mod_name_from_file(f: Rc) -> String { +pub fn lib_rs_mod_name_from_path(path: String) -> String { { let src_prefix_len = v1_rt::string_length(&rust_source_root()); let ext_len = v1_rt::string_length(&rust_source_ext()); - let path_len = v1_rt::string_length(&f.path.clone()); + let path_len = v1_rt::string_length(&path); v1_rt::substring( - &f.path.clone(), + &path, src_prefix_len.clone(), (path_len.clone() - ext_len.clone()), ) @@ -6295,16 +6567,16 @@ pub fn order_partial_lib_rs_mod_names(mod_names: Rc>) -> Rc>>, +pub fn emit_lib_rs_from_paths( + all_module_paths: Rc>, has_compiler_tests: bool, ) -> Rc { { let file_derived_names = Rc::new( - all_module_files + all_module_paths .iter() .cloned() - .map(lib_rs_mod_name_from_file) + .map(lib_rs_mod_name_from_path) .collect::>(), ); let mod_names = if has_compiler_tests.clone() { @@ -9430,14 +9702,10 @@ pub fn emit_module_full( } else { v1_rt::concat("\n\n".to_string(), phantom_zst_markers.clone()) }; - let raw_filename = crate::v1_compiler_emit_core_support::module_to_filename( - crate::v1_compiler_infer_env::authored_name(scope.type_env.clone(), m.clone()), - ); - let filename = if (raw_filename.clone() == "main".to_string()) { - "main_mod".to_string() - } else { - raw_filename.clone() - }; + let module_emit_path = rust_module_emit_path(crate::v1_compiler_infer_env::authored_name( + scope.type_env.clone(), + m.clone(), + )); let module_attrs = if (crate::v1_compiler_infer_env::authored_name(scope.type_env.clone(), m.clone()) == "std.error_primitives".to_string()) @@ -9449,10 +9717,7 @@ pub fn emit_module_full( let content = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// Generated by v1 compiler -- do not edit.\n".to_string(), "// Source module: ".to_string()), crate::v1_compiler_infer_env::authored_name(scope.type_env.clone(), m.clone())), "\n\n".to_string()), module_attrs.clone()), prelude.clone()), imports_section.clone()), svc_imports_str.clone()), local_uses_str.clone()), "\n\n".to_string()), coproduct_wire_contract_validation_section.clone()), items_str.clone()), phantom_section.clone()), "\n".to_string()); Rc::new(ModuleEmission { file: Rc::new(TextFile { - path: v1_rt::concat( - v1_rt::concat(rust_source_root(), filename.clone()), - rust_source_ext(), - ), + path: module_emit_path.clone(), content: content.clone(), }), reference_rows: reference_plan.rows.clone(), From b27f74e1cc4dd44e0176849592bf6ea7ead39830 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Mon, 31 Aug 2026 05:40:03 +0000 Subject: [PATCH 73/75] XL-0N: delete the two consumerless BinOp Bool predicates (review 57754) binop_is_equality hand-matched the BinOp coproduct to answer a question no caller asked; binop_is_ordering wrapped ordering_test_for in a Bool and had no caller either. Both were this lane's additions (f38fdc9, db40481) with zero consumers corpus-wide, so they are redundant work by DESIGN section 2 and the substrate keeps one canonical typed query, ordering_test_for, which remains consumed at operator_realization_for. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_013koFunEtpLQCnvUiz85k7Y --- dag/std/operator_realization.dag | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/dag/std/operator_realization.dag b/dag/std/operator_realization.dag index 7bc7a031809..d1f95c2ce85 100644 --- a/dag/std/operator_realization.dag +++ b/dag/std/operator_realization.dag @@ -146,29 +146,6 @@ fn ordering_test_for(op: BinOp) -> OrderingTest? { } } -fn binop_is_equality(op: BinOp) -> Bool { - match op { - Eq => true - Ne => true - Add => false - Sub => false - Mul => false - Div => false - Mod => false - Lt => false - Gt => false - Le => false - Ge => false - And => false - Or => false - NullCoalesce => false - } -} - -fn binop_is_ordering(op: BinOp) -> Bool { - ordering_test_for(op: op) != none -} - fn binop_label(op: BinOp) -> String { match op { Add => "+" From e1e14c83e77225132ec554059562cb2accb8f26f Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Mon, 31 Aug 2026 06:02:48 +0000 Subject: [PATCH 74/75] XL-0N: refusals carry the BinOp coproduct, the Nat fork gets a stall row, prose leaves the data plane (review 57758) Three of the four findings, verified against the tree first: - src/v2/std/nat.dag carried a String data row of commentary. Converted to a module-scope // annotation on nat_max, which is the DESIGN section 4c quarantine boundary; the row predates this lane (#9238) but the file is this lane's to fix. - The same note narrated the two-Nat fork without scheduling its end. The fork is now gunbc.guarantee_rung_drop two_nat_authorities_stall, with ceiling StructurallyImpossible and a trigger naming the CAPABILITY (one Nat declaration with the other derived), not an artifact. This lane did not create the fork but made it load-bearing by giving the Peano side real operations. - OperatorRealizationRefusal typed its operator as String, a closed vocabulary flattened to text. Both variants now carry BinOp itself, producers pass the variant, and the single glyph spelling happens once at the message boundary. binop_label survives as that rendering fact with an annotation recording the corpus check: no BinOp-to-glyph producer exists elsewhere, so it is the first authority for the mapping rather than a second one. The rendered message text is unchanged, so the emitted-path witness pins the same bytes. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_013koFunEtpLQCnvUiz85k7Y --- dag/gunbc/guarantee_rung_drop.dag | 20 +++++++++++ dag/std/operator_realization.dag | 36 +++++++++++-------- src/v2/std/nat.dag | 14 ++++++-- .../peano_nat_structural_realization_test.dag | 6 ++-- 4 files changed, 58 insertions(+), 18 deletions(-) diff --git a/dag/gunbc/guarantee_rung_drop.dag b/dag/gunbc/guarantee_rung_drop.dag index 3c5189cf1f9..49e377fbcc4 100644 --- a/dag/gunbc/guarantee_rung_drop.dag +++ b/dag/gunbc/guarantee_rung_drop.dag @@ -560,6 +560,26 @@ fn stall_roster_size(ss: List) -> Int { // its conjunction and disjunction, connectives on a declaration with a row realize through it, and // only a declaration with NO row refuses -- at which point the refusal population is enumerable // instead of being the whole corpus. +// TWO Nat AUTHORITIES ARE ONE NAME ANSWERING FOR TWO CONCEPTS, and this row exists because review +// 57758 correctly refused a version of it that was narrated in prose beside one of the two nat_max +// declarations. The fork predates this lane; what this lane changed is that the Peano side now +// carries real operations, so the fork is load-bearing rather than latent. +data two_nat_authorities_stall: GuaranteeStall = GuaranteeStall { + subject: "std.nat Nat (CommutativeSemiring, realizing natively as a machine scalar) and v2.std.nat Nat (the Peano coproduct Zero | Succ) are two declarations answering for one name, so nat_add / nat_mul / nat_max / nat_compare each exist twice and a bare reference in a closure containing both modules is ambiguous", + current: Mitigatable, + ceiling: StructurallyImpossible, + blocker: AwaitsOneGrounding { + grounding: "one Nat authority: the numeric tower deciding whether the Peano coproduct IS the declaration and the semiring alias is derived from it, or the reverse -- a modeling ruling this lane cannot make from an operator-realization change", + }, + population: BoundedPopulation { + members: [ + "std.nat and v2.std.nat both declaring Nat, with per-operation forks (nat_add, nat_mul, nat_max, nat_compare) that no single function can serve because the two are different types", + "every reference site in a closure containing both modules, which must qualify the name (v2.lens.cost.valuation does) or resolve by pool precedence", + ], + }, + next_rung_trigger: "one Nat declaration in the corpus, with the other side derived from it rather than declared beside it -- retired by that capability and by nothing less, since deleting either declaration without deriving its operations would remove the operations its consumers call rather than unify the authority" +} + data structural_connective_stall: GuaranteeStall = GuaranteeStall { subject: "std.operator_realization -- a logical connective (&&, ||) applied to a STRUCTURAL operand renders as the host token, because no declared-connective row family exists to realize or refuse it", current: Mitigatable, diff --git a/dag/std/operator_realization.dag b/dag/std/operator_realization.dag index d1f95c2ce85..1b4811b0f6b 100644 --- a/dag/std/operator_realization.dag +++ b/dag/std/operator_realization.dag @@ -146,6 +146,14 @@ fn ordering_test_for(op: BinOp) -> OrderingTest? { } } +// THE ONLY GLYPH TABLE, AND IT IS A RENDERING FACT. The refusal carriers above hold the BinOp +// coproduct itself, never a spelling, so nothing downstream can compare operators by string. A +// spelling is required exactly once -- at the human-readable message boundary -- which is where +// this table sits. Corpus check before minting it (review 57758 asked whether the parser or the +// emitter already owns one): no BinOp-to-glyph producer exists anywhere in the tree; v1's +// compile.dag renders the VARIANT NAME ("Add"), and glyph recognition happens in the tokenizer +// against token kinds, not against a .dag row. So this is the first authority for the mapping, not +// a second one. fn binop_label(op: BinOp) -> String { match op { Add => "+" @@ -166,9 +174,9 @@ fn binop_label(op: BinOp) -> String { } type OperatorRealizationRefusal - = NoStructuralOperationDeclared { declaration: DeclarationRef, operator: String } + = NoStructuralOperationDeclared { declaration: DeclarationRef, operator: BinOp } | StructuralOrderingDuplicated { declaration: DeclarationRef, row_count: Int } - | OperandIdentityUnavailableAt { operator: String, facts: OperandShapeFacts } + | OperandIdentityUnavailableAt { operator: BinOp, facts: OperandShapeFacts } type OperatorRealization = HostOperator @@ -180,7 +188,7 @@ fn operator_realization_refusal_message(cause: OperatorRealizationRefusal) -> St match cause { NoStructuralOperationDeclared { declaration: d, operator: o } => concat( - "operator realization: host operator `", o, "` on structural operand ", + "operator realization: host operator `", binop_label(op: o), "` on structural operand ", d.module_path as String, ".", d.decl_name as String, " -- the declaration has no host realization and declares no operation for this operator; spell the operation as a call to the declared structural operation" ) @@ -192,7 +200,7 @@ fn operator_realization_refusal_message(cause: OperatorRealizationRefusal) -> St ) OperandIdentityUnavailableAt { operator: o, facts: f } => concat( - "operator realization: host operator `", o, "` on an operand whose declaration could not be read", + "operator realization: host operator `", binop_label(op: o), "` on an operand whose declaration could not be read", " (authored `", f.authored_name, "`, connective ", f.connective, ", children ", to_string(value: f.child_count), ", resolved ", if f.resolved { "yes" } else { "no" }, ", decl_file `", f.decl_file, "`)" ) @@ -234,15 +242,15 @@ fn operator_realization_for( And => HostOperator Or => HostOperator NullCoalesce => HostOperator - Lt => OperatorRealizationRefused { cause: OperandIdentityUnavailableAt { operator: binop_label(op: op), facts: f } } - Gt => OperatorRealizationRefused { cause: OperandIdentityUnavailableAt { operator: binop_label(op: op), facts: f } } - Le => OperatorRealizationRefused { cause: OperandIdentityUnavailableAt { operator: binop_label(op: op), facts: f } } - Ge => OperatorRealizationRefused { cause: OperandIdentityUnavailableAt { operator: binop_label(op: op), facts: f } } - Add => OperatorRealizationRefused { cause: OperandIdentityUnavailableAt { operator: binop_label(op: op), facts: f } } - Sub => OperatorRealizationRefused { cause: OperandIdentityUnavailableAt { operator: binop_label(op: op), facts: f } } - Mul => OperatorRealizationRefused { cause: OperandIdentityUnavailableAt { operator: binop_label(op: op), facts: f } } - Div => OperatorRealizationRefused { cause: OperandIdentityUnavailableAt { operator: binop_label(op: op), facts: f } } - Mod => OperatorRealizationRefused { cause: OperandIdentityUnavailableAt { operator: binop_label(op: op), facts: f } } + Lt => OperatorRealizationRefused { cause: OperandIdentityUnavailableAt { operator: op, facts: f } } + Gt => OperatorRealizationRefused { cause: OperandIdentityUnavailableAt { operator: op, facts: f } } + Le => OperatorRealizationRefused { cause: OperandIdentityUnavailableAt { operator: op, facts: f } } + Ge => OperatorRealizationRefused { cause: OperandIdentityUnavailableAt { operator: op, facts: f } } + Add => OperatorRealizationRefused { cause: OperandIdentityUnavailableAt { operator: op, facts: f } } + Sub => OperatorRealizationRefused { cause: OperandIdentityUnavailableAt { operator: op, facts: f } } + Mul => OperatorRealizationRefused { cause: OperandIdentityUnavailableAt { operator: op, facts: f } } + Div => OperatorRealizationRefused { cause: OperandIdentityUnavailableAt { operator: op, facts: f } } + Mod => OperatorRealizationRefused { cause: OperandIdentityUnavailableAt { operator: op, facts: f } } } StructuralOperand { declaration: d } => match op { @@ -265,7 +273,7 @@ fn operator_realization_for( } fn structural_arithmetic_refusal(op: BinOp, declaration: DeclarationRef) -> OperatorRealization { - OperatorRealizationRefused { cause: NoStructuralOperationDeclared { declaration: declaration, operator: binop_label(op: op) } } + OperatorRealizationRefused { cause: NoStructuralOperationDeclared { declaration: declaration, operator: op } } } // An ordering operator on a structural operand: the declared comparison, or the refusal. Reached diff --git a/src/v2/std/nat.dag b/src/v2/std/nat.dag index 90086d36995..7df36b11083 100644 --- a/src/v2/std/nat.dag +++ b/src/v2/std/nat.dag @@ -116,8 +116,18 @@ fn nat_lte(a: Nat, b: Nat) -> Bool { } } -data nat_max_two_nat_authorities_note: String = "This is NOT a duplicate of std.nat nat_max, and the distinction is worth stating because the name alone suggests otherwise. std.nat Nat is CommutativeSemiring - an algebra alias whose max is written with the host comparison operators - while v2.std.nat Nat is the Peano coproduct Zero | Succ, and the two are different types that no single function can serve. So this sits beside nat_add and nat_mul, which are forked for exactly the same reason and were not remarked on. What IS a real defect is that two Nat authorities exist at all; it predates this declaration and is the numeric-tower grounding thread's subject, not something a max function can close. Because v1-seed function names are not module-scoped, a bare nat_max reference in any closure containing both modules is ambiguous and must be qualified - v2.lens.cost.valuation does exactly that. Dissolve-on: one Nat authority, at which point one of the two nat_max declarations goes with it." - +// NOT A DUPLICATE OF std.nat nat_max, and worth saying because the name alone suggests otherwise. +// std.nat Nat is CommutativeSemiring -- an algebra alias whose max is written with the +// host comparison operators -- while v2.std.nat Nat is the Peano coproduct Zero | Succ. They are +// different types that no single function can serve, so this sits beside nat_add and nat_mul, which +// are forked for the same reason. Because v1-seed function names are not module-scoped, a bare +// nat_max reference in any closure containing both modules is ambiguous and must be qualified -- +// v2.lens.cost.valuation does exactly that. +// +// That two Nat authorities exist at all is the real defect, and it is tracked as a guarantee stall +// rather than narrated here: gunbc.guarantee_rung_drop two_nat_authorities_stall carries the rung, +// ceiling and next-rung trigger. This annotation records only why the fork is not closable from a +// max function. fn nat_max(a: Nat, b: Nat) -> Nat { match nat_compare(a: a, b: b) { Less => b diff --git a/src/v2/test/claim/self_host/peano_nat_structural_realization_test.dag b/src/v2/test/claim/self_host/peano_nat_structural_realization_test.dag index eb5992093f2..fd6cf1cf98c 100644 --- a/src/v2/test/claim/self_host/peano_nat_structural_realization_test.dag +++ b/src/v2/test/claim/self_host/peano_nat_structural_realization_test.dag @@ -272,11 +272,13 @@ test fn host_numeric_operand_keeps_the_host_operator() -> Bool { test fn operand_without_a_readable_declaration_refuses() -> Bool { let facts = OperandShapeFacts { authored_name: "Nat", connective: "NoConnective", child_count: 0, resolved: false, decl_file: "probe.dag" } let ordering_refuses = match operator_realization_for(op: Lt, operand: OperandIdentityUnavailable { facts: facts }, ordering_rows: structural_ordering_rows) { - OperatorRealizationRefused { cause: OperandIdentityUnavailableAt { operator: o, facts: f } } => o == "<" && f.authored_name == "Nat" + OperatorRealizationRefused { cause: OperandIdentityUnavailableAt { operator: o, facts: f } } => + match o { Lt => f.authored_name == "Nat" _ => false } _ => false } let arithmetic_refuses = match operator_realization_for(op: Div, operand: OperandIdentityUnavailable { facts: facts }, ordering_rows: structural_ordering_rows) { - OperatorRealizationRefused { cause: OperandIdentityUnavailableAt { operator: o, facts: _ } } => o == "/" + OperatorRealizationRefused { cause: OperandIdentityUnavailableAt { operator: o, facts: _ } } => + match o { Div => true _ => false } _ => false } ordering_refuses && arithmetic_refuses From 64d16dd147fbd7002a82e84ec5ed5d9b75a0d6eb Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Mon, 31 Aug 2026 06:56:41 +0000 Subject: [PATCH 75/75] XL-0N: regenerated stage0 mirrors and partition re-exports for the main merge The generated-artifact merge driver refused three mirrors (emitted_population, lib.rs, v1_compiler_emit_rust) because both sides changed them since the merge base, leaving them unmerged with the ours bytes in the worktree. These are the projections of the MERGED authorities, produced by a regen round rather than by taking a side. Bootstrapped from main a6d6c68 laid across src/v1/stage0 AND every src/v1/stage0_* sibling crate -- the siblings reach into stage0/src by #[path], so a stage0-only lay dangles this lane's new mirrors (rustc said so directly: couldn't read .../std_literal_elaboration.rs at stage0_std_core/src/lib.rs:130). main_wet first so the generated partition .dag reflects the merged authorities, --emit-partition-crates --write after each install, and five rounds each rebuilding the seed from the installed tree and re-verifying: first_generation_equal=true 148/148 every time. Both sides survive in lib.rs, which is the check the driver refusal exists to force: main's gunbc_stage0_executable_assembly_generated (the E0432 that made all five jobs red) and this lane's std_operator_realization are both declared. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_013koFunEtpLQCnvUiz85k7Y --- src/v1/stage0/src/emitted_population.rs | 1 + src/v1/stage0/src/lib.rs | 74 +------------------ src/v1/stage0/src/std_operator_realization.rs | 51 ++++--------- src/v1/stage0/src/v1_compiler_emit_rust.rs | 65 +++++++++++++++- src/v1/stage0_std_core/src/lib.rs | 6 -- src/v1/stage0_v1_infer/src/lib.rs | 3 - 6 files changed, 80 insertions(+), 120 deletions(-) diff --git a/src/v1/stage0/src/emitted_population.rs b/src/v1/stage0/src/emitted_population.rs index daea5fb8929..c7e149db479 100644 --- a/src/v1/stage0/src/emitted_population.rs +++ b/src/v1/stage0/src/emitted_population.rs @@ -36,6 +36,7 @@ // src/gunbc_stage0_crate_layout_generated.rs // src/gunbc_stage0_crate_partition_generated.rs // src/gunbc_stage0_emitted_population_manifest.rs +// src/gunbc_stage0_executable_assembly_generated.rs // src/gunbc_stage0_partition_package_graph.rs // src/gunbc_structural_realization_bindings.rs // src/lib.rs diff --git a/src/v1/stage0/src/lib.rs b/src/v1/stage0/src/lib.rs index a5d7d33bd1f..728a033d96d 100644 --- a/src/v1/stage0/src/lib.rs +++ b/src/v1/stage0/src/lib.rs @@ -15,96 +15,39 @@ use im::{OrdSet as BTreeSet, Vector as Vec}; +pub use v1_stage0_v1_infer::*; + pub mod extdeps_cargo; pub mod extdeps_cargo_version; -pub mod extdeps_container_oci_digest; -pub mod extdeps_currency_currency; -pub mod extdeps_external_authority; -pub mod extdeps_languages_dag_emit; -pub mod extdeps_languages_dag_syntax; -pub mod extdeps_languages_dag_types; -pub mod extdeps_languages_go_emit; -pub mod extdeps_languages_go_syntax; -pub mod extdeps_languages_go_types; -pub mod extdeps_languages_python_emit; -pub mod extdeps_languages_python_syntax; -pub mod extdeps_languages_python_types; -pub mod extdeps_languages_rust_capabilities; pub mod extdeps_languages_rust_derive_contracts; -pub mod extdeps_languages_rust_emit; -pub mod extdeps_languages_rust_representation; -pub mod extdeps_languages_rust_syntax; -pub mod extdeps_languages_rust_types; -pub mod extdeps_units_dimensionless; -pub mod extdeps_units_iec_80000_13; -pub mod extdeps_units_iso8601; -pub mod extdeps_units_iso_80000_3; -pub mod extdeps_uri; -pub mod extdeps_uri_path; pub mod extdeps_version; pub mod extdeps_version_semver; pub mod gunbc_cli_dispatch_surface; pub mod gunbc_namespace_reference_derived_closure_admission; pub mod gunbc_rust_decl_type_overlay; -pub mod gunbc_rust_source_type_bindings; pub mod gunbc_stage0_crate_layout_generated; pub mod gunbc_stage0_crate_partition_generated; pub mod gunbc_stage0_emitted_population_manifest; +pub mod gunbc_stage0_executable_assembly_generated; pub mod gunbc_stage0_partition_package_graph; pub mod gunbc_structural_realization_bindings; -pub mod std_algebra; -pub mod std_checked_arithmetic; -pub mod std_coercion; -pub mod std_computation; pub mod std_constructors; -pub mod std_content_hash; -pub mod std_decl_ref; -pub mod std_disposition; -pub mod std_dissolution; -pub mod std_effects; -pub mod std_emit_model; -pub mod std_error_primitives; -pub mod std_execution_mode; -pub mod std_graph; -pub mod std_induction; pub mod std_integer; -pub mod std_interface_summary; -pub mod std_keyed_roster; -pub mod std_keyed_row; pub mod std_literal_elaboration; pub mod std_logic; pub mod std_machine_constraints; -pub mod std_magnitude; -pub mod std_measure; -pub mod std_nat; -pub mod std_node; pub mod std_occurrence_binding; pub mod std_occurrence_binding_candidates; pub mod std_occurrence_binding_resolve; -pub mod std_occurrence_identity; pub mod std_operator_realization; -pub mod std_pareto; pub mod std_primitive_projection; -pub mod std_process_termination; -pub mod std_realization_schedule; pub mod std_reference_binding_observation; pub mod std_repair_input_origin; -pub mod std_roster_frontier; pub mod std_serialization; -pub mod std_source_annotation; -pub mod std_syntax; -pub mod std_target_representation; -pub mod std_termination; -pub mod std_trait_derive_shape; -pub mod std_types; -pub mod std_unicode_types; -pub mod std_witness_admission; pub mod std_workspace_artifact; pub mod v1_compiler_annotation_bind; -pub mod v1_compiler_artifact; pub mod v1_compiler_closure_stub_v2_std_integer_rust; pub mod v1_compiler_closure_stub_v2_std_text_rust; -pub mod v1_compiler_coercion; pub mod v1_compiler_compile; pub mod v1_compiler_compiler_tests_rust; pub mod v1_compiler_complexity; @@ -121,18 +64,10 @@ pub mod v1_compiler_frontend_observation; pub mod v1_compiler_infer; pub mod v1_compiler_infer_access; pub mod v1_compiler_infer_cycle; -pub mod v1_compiler_infer_emit_info; -pub mod v1_compiler_infer_env; -pub mod v1_compiler_infer_items; pub mod v1_compiler_infer_lookup; pub mod v1_compiler_infer_method; -pub mod v1_compiler_infer_occurrence_binding; pub mod v1_compiler_infer_patterns; pub mod v1_compiler_infer_resolve; -pub mod v1_compiler_infer_service; -pub mod v1_compiler_infer_sigs; -pub mod v1_compiler_infer_types; -pub mod v1_compiler_languages; pub mod v1_compiler_normalize; pub mod v1_compiler_ownership; pub mod v1_compiler_parse; @@ -144,13 +79,10 @@ pub mod v1_compiler_tokenize; pub mod v1_compiler_trace; pub mod v1_compiler_trait_bound_witness; pub mod v1_compiler_trait_derive_emit; -pub mod v1_compiler_type_head_exposure; pub mod v1_compiler_workspace_members; pub mod v1_gunbc_namespace_reference_derived_closure_production_observations; pub mod v1_gunbc_occurrence_binding_parser_walk; pub mod v1_probe_emit_interp; -pub mod v1_rt; -pub mod v1_std_core; pub mod v1_test_non_ascii_perf_fixture; pub mod v1_tests_claim_bare_variant_reference_occurrence_control_test; pub mod v1_tests_claim_checkpoint_identity_keying_witness_test; diff --git a/src/v1/stage0/src/std_operator_realization.rs b/src/v1/stage0/src/std_operator_realization.rs index be54a7282c0..5a63ee3f5af 100644 --- a/src/v1/stage0/src/std_operator_realization.rs +++ b/src/v1/stage0/src/std_operator_realization.rs @@ -148,29 +148,6 @@ pub fn ordering_test_for(op: BinOp) -> Option> { } } -pub fn binop_is_equality(op: BinOp) -> bool { - match op.clone() { - BinOp::Eq => true, - BinOp::Ne => true, - BinOp::Add => false, - BinOp::Sub => false, - BinOp::Mul => false, - BinOp::Div => false, - BinOp::Mod => false, - BinOp::Lt => false, - BinOp::Gt => false, - BinOp::Le => false, - BinOp::Ge => false, - BinOp::And => false, - BinOp::Or => false, - BinOp::NullCoalesce => false, - } -} - -pub fn binop_is_ordering(op: BinOp) -> bool { - (ordering_test_for(op.clone()) != std::option::Option::None) -} - pub fn binop_label(op: BinOp) -> String { match op.clone() { BinOp::Add => "+".to_string(), @@ -195,14 +172,14 @@ pub fn binop_label(op: BinOp) -> String { pub enum OperatorRealizationRefusal { NoStructuralOperationDeclared { declaration: Rc, - operator: String, + operator: BinOp, }, StructuralOrderingDuplicated { declaration: Rc, row_count: i64, }, OperandIdentityUnavailableAt { - operator: String, + operator: BinOp, facts: Rc, }, } @@ -226,9 +203,9 @@ pub enum OperatorRealization { pub fn operator_realization_refusal_message(cause: Rc) -> String { match (*cause.clone()).clone() { - OperatorRealizationRefusal::NoStructuralOperationDeclared { declaration: d, operator: o, .. } => v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("operator realization: host operator `".to_string(), o.clone()), "` on structural operand ".to_string()), d.module_path.clone()), ".".to_string()), d.decl_name.clone()), " -- the declaration has no host realization and declares no operation for this operator; spell the operation as a call to the declared structural operation".to_string()), + OperatorRealizationRefusal::NoStructuralOperationDeclared { declaration: d, operator: o, .. } => v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("operator realization: host operator `".to_string(), binop_label(o.clone())), "` on structural operand ".to_string()), d.module_path.clone()), ".".to_string()), d.decl_name.clone()), " -- the declaration has no host realization and declares no operation for this operator; spell the operation as a call to the declared structural operation".to_string()), OperatorRealizationRefusal::StructuralOrderingDuplicated { declaration: d, row_count: n, .. } => v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("operator realization: structural ordering for ".to_string(), d.module_path.clone()), ".".to_string()), d.decl_name.clone()), " has more than one declared comparison (gunbc.structural_realization_bindings authoring defect)".to_string()), - OperatorRealizationRefusal::OperandIdentityUnavailableAt { operator: o, facts: f, .. } => v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("operator realization: host operator `".to_string(), o.clone()), "` on an operand whose declaration could not be read".to_string()), " (authored `".to_string()), f.authored_name.clone()), "`, connective ".to_string()), f.connective.clone()), ", children ".to_string()), (f.child_count.clone()).to_string()), ", resolved ".to_string()), if f.resolved.clone() { + OperatorRealizationRefusal::OperandIdentityUnavailableAt { operator: o, facts: f, .. } => v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("operator realization: host operator `".to_string(), binop_label(o.clone())), "` on an operand whose declaration could not be read".to_string()), " (authored `".to_string()), f.authored_name.clone()), "`, connective ".to_string()), f.connective.clone()), ", children ".to_string()), (f.child_count.clone()).to_string()), ", resolved ".to_string()), if f.resolved.clone() { "yes".to_string() } else { "no".to_string() @@ -254,55 +231,55 @@ pub fn operator_realization_for( BinOp::NullCoalesce => Rc::new(OperatorRealization::HostOperator), BinOp::Lt => Rc::new(OperatorRealization::OperatorRealizationRefused { cause: Rc::new(OperatorRealizationRefusal::OperandIdentityUnavailableAt { - operator: binop_label(op.clone()), + operator: op.clone(), facts: f.clone(), }), }), BinOp::Gt => Rc::new(OperatorRealization::OperatorRealizationRefused { cause: Rc::new(OperatorRealizationRefusal::OperandIdentityUnavailableAt { - operator: binop_label(op.clone()), + operator: op.clone(), facts: f.clone(), }), }), BinOp::Le => Rc::new(OperatorRealization::OperatorRealizationRefused { cause: Rc::new(OperatorRealizationRefusal::OperandIdentityUnavailableAt { - operator: binop_label(op.clone()), + operator: op.clone(), facts: f.clone(), }), }), BinOp::Ge => Rc::new(OperatorRealization::OperatorRealizationRefused { cause: Rc::new(OperatorRealizationRefusal::OperandIdentityUnavailableAt { - operator: binop_label(op.clone()), + operator: op.clone(), facts: f.clone(), }), }), BinOp::Add => Rc::new(OperatorRealization::OperatorRealizationRefused { cause: Rc::new(OperatorRealizationRefusal::OperandIdentityUnavailableAt { - operator: binop_label(op.clone()), + operator: op.clone(), facts: f.clone(), }), }), BinOp::Sub => Rc::new(OperatorRealization::OperatorRealizationRefused { cause: Rc::new(OperatorRealizationRefusal::OperandIdentityUnavailableAt { - operator: binop_label(op.clone()), + operator: op.clone(), facts: f.clone(), }), }), BinOp::Mul => Rc::new(OperatorRealization::OperatorRealizationRefused { cause: Rc::new(OperatorRealizationRefusal::OperandIdentityUnavailableAt { - operator: binop_label(op.clone()), + operator: op.clone(), facts: f.clone(), }), }), BinOp::Div => Rc::new(OperatorRealization::OperatorRealizationRefused { cause: Rc::new(OperatorRealizationRefusal::OperandIdentityUnavailableAt { - operator: binop_label(op.clone()), + operator: op.clone(), facts: f.clone(), }), }), BinOp::Mod => Rc::new(OperatorRealization::OperatorRealizationRefused { cause: Rc::new(OperatorRealizationRefusal::OperandIdentityUnavailableAt { - operator: binop_label(op.clone()), + operator: op.clone(), facts: f.clone(), }), }), @@ -345,7 +322,7 @@ pub fn structural_arithmetic_refusal( Rc::new(OperatorRealization::OperatorRealizationRefused { cause: Rc::new(OperatorRealizationRefusal::NoStructuralOperationDeclared { declaration: declaration.clone(), - operator: binop_label(op.clone()), + operator: op.clone(), }), }) } diff --git a/src/v1/stage0/src/v1_compiler_emit_rust.rs b/src/v1/stage0/src/v1_compiler_emit_rust.rs index 5c7f04c8914..c160e048e53 100644 --- a/src/v1/stage0/src/v1_compiler_emit_rust.rs +++ b/src/v1/stage0/src/v1_compiler_emit_rust.rs @@ -31,10 +31,14 @@ pub use crate::gunbc_cli_dispatch_surface::{ }; pub use crate::gunbc_rust_decl_type_overlay::rust_decl_type_container_overlay_is_admitted; pub use crate::gunbc_stage0_crate_layout_generated::generated_pub_mod_block; +pub use crate::gunbc_stage0_crate_partition_generated::generated_partition_crate_rows; +pub use crate::gunbc_stage0_crate_partition_generated::GeneratedPartitionCrateRow; pub use crate::gunbc_stage0_emitted_population_manifest::{ emitted_population_manifest_basename, emitted_population_manifest_line_prefix, emitted_population_manifest_line_separator, }; +pub use crate::gunbc_stage0_executable_assembly_generated::generated_host_shell_partition_dependencies; +pub use crate::gunbc_stage0_partition_package_graph::stage0_partition_row_is_module_bearing_package; pub use crate::gunbc_structural_realization_bindings::structural_ordering_rows; pub use crate::std_algebra::trim; pub use crate::std_coercion::TypeCheckpoint; @@ -6567,6 +6571,40 @@ pub fn order_partial_lib_rs_mod_names(mod_names: Rc>) -> Rc bool { + { + let mut __found = false; + for row in generated_partition_crate_rows().iter().cloned() { + if (crate::gunbc_stage0_partition_package_graph::stage0_partition_row_is_module_bearing_package(row.clone()) && { let mut __found = false; for m in row.modules.clone().iter().cloned() { if (m.clone() == mod_name.clone()) { __found = true; break; } } __found }) { __found = true; break; } + } + __found + } +} + +pub fn stage0_package_name_to_crate_ident(package_name: String) -> String { + v1_rt::replace(package_name.clone(), "-".to_string(), "_".to_string()) +} + +pub fn stage0_host_shell_partition_reexport_block() -> String { + Rc::new({ + let mut __result = Vec::new(); + for pkg in generated_host_shell_partition_dependencies() + .iter() + .cloned() + { + __result.push(v1_rt::concat( + v1_rt::concat( + "pub use ".to_string(), + stage0_package_name_to_crate_ident(pkg.clone()), + ), + "::*;".to_string(), + )); + } + __result + }) + .join(&"\n".to_string()) +} + pub fn emit_lib_rs_from_paths( all_module_paths: Rc>, has_compiler_tests: bool, @@ -6579,10 +6617,23 @@ pub fn emit_lib_rs_from_paths( .map(lib_rs_mod_name_from_path) .collect::>(), ); + let shell_names = if has_compiler_tests.clone() { + Rc::new({ + let mut __result = Vec::new(); + for n in file_derived_names.iter().cloned() { + if !lib_rs_module_is_partition_owned(n.clone()) { + __result.push(n); + } + } + __result + }) + } else { + file_derived_names.clone() + }; let mod_names = if has_compiler_tests.clone() { - order_lib_rs_mod_names(file_derived_names.clone()) + order_lib_rs_mod_names(shell_names.clone()) } else { - order_partial_lib_rs_mod_names(file_derived_names.clone()) + order_partial_lib_rs_mod_names(shell_names.clone()) }; let mod_decls = Rc::new( mod_names @@ -6601,8 +6652,16 @@ pub fn emit_lib_rs_from_paths( } else { "".to_string() }; + let partition_reexports = if has_compiler_tests.clone() { + v1_rt::concat( + stage0_host_shell_partition_reexport_block(), + "\n\n".to_string(), + ) + } else { + "".to_string() + }; let shared_types = emit_non_empty_wrappers(); - let content = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// Generated by v1 compiler -- do not edit.\n\n".to_string(), "#![allow(unused_imports, unused_variables, unused_mut, unused_parens, dead_code, non_shorthand_field_patterns, suspicious_double_ref_op, clippy::all)]\n#![deny(unreachable_patterns)]\n".to_string()), "#![recursion_limit = \"256\"]\n\n".to_string()), "use im::{OrdSet as BTreeSet, Vector as Vec};\n\n".to_string()), mod_decls.clone().join(&"\n".to_string())), hand_maintained_mods.clone()), "\n\n".to_string()), shared_types.clone()), test_mod.clone()); + let content = v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat(v1_rt::concat("// Generated by v1 compiler -- do not edit.\n\n".to_string(), "#![allow(unused_imports, unused_variables, unused_mut, unused_parens, dead_code, non_shorthand_field_patterns, suspicious_double_ref_op, clippy::all)]\n#![deny(unreachable_patterns)]\n".to_string()), "#![recursion_limit = \"256\"]\n\n".to_string()), "use im::{OrdSet as BTreeSet, Vector as Vec};\n\n".to_string()), partition_reexports.clone()), mod_decls.clone().join(&"\n".to_string())), hand_maintained_mods.clone()), "\n\n".to_string()), shared_types.clone()), test_mod.clone()); Rc::new(TextFile { path: v1_rt::concat( v1_rt::concat(rust_source_root(), "lib".to_string()), diff --git a/src/v1/stage0_std_core/src/lib.rs b/src/v1/stage0_std_core/src/lib.rs index 51000bae6fb..7f6dcc8b681 100644 --- a/src/v1/stage0_std_core/src/lib.rs +++ b/src/v1/stage0_std_core/src/lib.rs @@ -126,11 +126,5 @@ pub mod std_source_annotation; #[path = "../../stage0/src/std_target_representation.rs"] pub mod std_target_representation; #[rustfmt::skip] -#[path = "../../stage0/src/std_literal_elaboration.rs"] -pub mod std_literal_elaboration; -#[rustfmt::skip] -#[path = "../../stage0/src/std_operator_realization.rs"] -pub mod std_operator_realization; -#[rustfmt::skip] #[path = "../../stage0/src/v1_std_core.rs"] pub mod v1_std_core; diff --git a/src/v1/stage0_v1_infer/src/lib.rs b/src/v1/stage0_v1_infer/src/lib.rs index 1ea34b7d98c..319fe110028 100644 --- a/src/v1/stage0_v1_infer/src/lib.rs +++ b/src/v1/stage0_v1_infer/src/lib.rs @@ -28,9 +28,6 @@ pub use v1_stage0_v1_artifact::*; #[path = "../../stage0/src/gunbc_rust_source_type_bindings.rs"] pub mod gunbc_rust_source_type_bindings; #[rustfmt::skip] -#[path = "../../stage0/src/gunbc_structural_realization_bindings.rs"] -pub mod gunbc_structural_realization_bindings; -#[rustfmt::skip] #[path = "../../stage0/src/v1_compiler_coercion.rs"] pub mod v1_compiler_coercion; #[rustfmt::skip]