Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
379ac3a
WIP: Namespace PR-4d: v1 global-unique bare fallback in lookup_bindin…
briansrls Jul 14, 2026
55a5ca3
WIP: Namespace PR-4d: v1 global-unique bare fallback in lookup_bindin…
briansrls Jul 14, 2026
3fcd22a
WIP: Namespace PR-4d: v1 global-unique bare fallback in lookup_bindin…
briansrls Jul 14, 2026
d2eca0c
Fix local_binding_for_item type inference: use none, not bare Absent
briansrls Jul 14, 2026
eee11b9
WIP: Namespace PR-4d: v1 global-unique bare fallback in lookup_bindin…
briansrls Jul 14, 2026
f230226
WIP: Namespace PR-4d: v1 global-unique bare fallback in lookup_bindin…
briansrls Jul 14, 2026
57c6e9c
WIP: Namespace PR-4d: v1 global-unique bare fallback in lookup_bindin…
briansrls Jul 14, 2026
7829930
WIP: Namespace PR-4d: v1 global-unique bare fallback in lookup_bindin…
briansrls Jul 14, 2026
313d796
WIP: Namespace PR-4d: v1 global-unique bare fallback in lookup_bindin…
briansrls Jul 14, 2026
0fcd152
WIP: Namespace PR-4d: v1 global-unique bare fallback in lookup_bindin…
briansrls Jul 14, 2026
21d9f2f
WIP: Namespace PR-4d: v1 global-unique bare fallback in lookup_bindin…
briansrls Jul 14, 2026
5621a3c
WIP: Namespace PR-4d: v1 global-unique bare fallback in lookup_bindin…
briansrls Jul 14, 2026
99acb2b
Merge remote-tracking branch 'origin/main' into session/sleek-crab-599
briansrls Jul 14, 2026
f5adb74
WIP: Namespace PR-4d: v1 global-unique bare fallback in lookup_bindin…
briansrls Jul 14, 2026
1405c0a
WIP: Namespace PR-4d: v1 global-unique bare fallback in lookup_bindin…
briansrls Jul 14, 2026
e8d0b11
Merge remote-tracking branch 'origin/main' into session/sleek-crab-599
Jul 14, 2026
431b459
Fix compile-clean gate blockers merged from main: total HostEffect ma…
briansrls Jul 14, 2026
62dfa6f
Merge remote-tracking branch 'origin/main' into session/sleek-crab-599
Jul 14, 2026
48aa032
Merge origin/main into session/sleek-crab-599 — resolve fleet_converg…
briansrls Jul 14, 2026
947a63a
Merge branch 'session/sleek-crab-599' of https://github.com/gunb-ai/g…
briansrls Jul 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 29 additions & 8 deletions dag/extdeps/github/expressions.dag
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,20 @@ fn parse_args_with(args_str: String, sp: ExpressionSpellings) -> List<Expression
}
}

fn parse_atom_with(s: String, sp: ExpressionSpellings) -> Expression? {
fn parse_string_literal_atom(s: String, sp: ExpressionSpellings) -> Expression? {
if expr_is_string_literal(s: s, sp: sp) {
Present { value: StringLiteral {
value: substring(s: s, start: sp.string_quote.length(), end: s.length() - sp.string_quote.length()),
} }
} else if expr_is_call(s: s, sp: sp) {
} else {
none
}
}

fn parse_function_call_atom(s: String, sp: ExpressionSpellings) -> Expression? {
if !expr_is_call(s: s, sp: sp) {
none
} else {
let segs = split(s: s, delimiter: sp.call_open)
let after = join(segs.skip(n: 1), sp.call_open)
let args_str = if ends_with(s: after, suffix: sp.call_close) {
Expand All @@ -237,12 +245,25 @@ fn parse_atom_with(s: String, sp: ExpressionSpellings) -> Expression? {
Present { value: args } => Present { value: FunctionCall { function: fn_variant, args: args } }
}
}
} else {
let segs = split(s: s, delimiter: sp.path_sep)
match context_from_name(name: segs.first()) {
Absent => none
Present { value: ctx } => Present { value: ContextAccess { context: ctx, path: segs.skip(n: 1) } }
}
}
}

fn parse_context_access_atom(s: String, sp: ExpressionSpellings) -> Expression? {
let segs = split(s: s, delimiter: sp.path_sep)
match context_from_name(name: segs.first()) {
Absent => none
Present { value: ctx } => Present { value: ContextAccess { context: ctx, path: segs.skip(n: 1) } }
}
}

fn parse_atom_with(s: String, sp: ExpressionSpellings) -> Expression? {
match parse_string_literal_atom(s: s, sp: sp) {
Present { value: e } => Present { value: e }
Absent =>
match parse_function_call_atom(s: s, sp: sp) {
Present { value: e } => Present { value: e }
Absent => parse_context_access_atom(s: s, sp: sp)
}
}
}

Expand Down
22 changes: 20 additions & 2 deletions src/v1/04_env.dag
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type TypeEnv {
source_indices: Map<String, NewlineIndex>
intern_table: InternTable
source_visible_names: Map<String, Bool>
global_bare: Map<String, GlobalBareLookupState>
}

type TypeBinding {
Expand All @@ -23,6 +24,12 @@ type TypeBinding {
provenance: SubValueRelation
}

data global_bare_fallback_invariant: String = "Corpus-wide bare-name census (namespace-resolution-design.md §8 PR-4): keyed on the bare declared name, one authority built once by build_global_bare_census over graph.modules before any module typechecks (order-independent — mirrors v2's symbol_index_global_bare, docs/plans/namespace-resolution-design.md §7.5). lookup_binding_by_name consults it only after str_bindings/ancestry_str_bindings/intern+bindings all miss, and only a GlobalBareUniqueBinding resolves; GlobalBareAmbiguousBinding stays Absent (fail-closed, never guesses — §5). This is what unblocks the src/v1 import strip: a bare reference that used to resolve via a deleted import chain still resolves here iff its name is globally unique in the corpus."

type GlobalBareLookupState
= GlobalBareUniqueBinding { binding: TypeBinding }
| GlobalBareAmbiguousBinding

type ImportBinding {
name: String
resolved: Node
Expand Down Expand Up @@ -362,13 +369,24 @@ fn lookup_binding_by_name(env: TypeEnv, name: String) -> TypeBinding? {
Present { value: binding } => Present { value: binding }
Absent =>
match intern_find(table: env.intern_table, s: name) {
Present { value: id } => map_get(env.bindings, id)
Absent => Absent
Present { value: id } => match map_get(env.bindings, id) {
Present { value: binding } => Present { value: binding }
Absent => global_bare_lookup(env: env, name: name)
}
Absent => global_bare_lookup(env: env, name: name)
}
}
}
}

fn global_bare_lookup(env: TypeEnv, name: String) -> TypeBinding? {
match map_get(env.global_bare, name) {
Present { value: GlobalBareUniqueBinding { binding: binding } } => Present { value: binding }
Present { value: GlobalBareAmbiguousBinding } => Absent
Absent => Absent
}
}

fn lookup_binding(env: TypeEnv, ident: Int) -> TypeBinding? {
match map_get(env.bindings, ident) {
Present { value: binding } => Present { value: binding }
Expand Down
158 changes: 100 additions & 58 deletions src/v1/04_infer.dag

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/v1/04_resolve.dag
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,8 @@ fn resolve_item_types(item: Node, env: TypeEnv, module_name: String) -> ItemReso
inductive_fields: e.inductive_fields,
source_indices: e.source_indices,
intern_table: e.intern_table,
source_visible_names: map_insert(e.source_visible_names, tp_name, true)
source_visible_names: map_insert(e.source_visible_names, tp_name, true),
global_bare: e.global_bare
}
)
let param_results = map(item.params, p => resolve_param(param: p, env: env, module_name: module_name))
Expand Down
4 changes: 2 additions & 2 deletions src/v1/05_emit.dag
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import v1.std.core {
CardOptional
}

import v1.compiler.infer_env { TypeEnv, TypeBinding, authored_name }
import v1.compiler.infer_env { TypeEnv, TypeBinding, authored_name, GlobalBareLookupState }
import std.induction { InductiveField, SubValueUnknown }
import v1.compiler.infer_types { resolved_type, child_type_node, emit_map_has, node_is_collection, node_is_keyed_collection, node_is_element_collection, normalize_access_type_node, for_each_element_type_node, is_unit_like, is_declared_container_alias_spelling }
import std.types { is_container_type, container_template_algebra }
Expand Down Expand Up @@ -270,7 +270,7 @@ fn emit_simple_string_interp(parts: List<StringPart>, target: RenderTarget, sour

fn empty_emit_scope() -> InferScope {
InferScope {
type_env: TypeEnv { bindings: empty_map(), str_bindings: empty_map(), ancestry_str_bindings: empty_map(), parents: [], recursive_types: [], recursive_type_set: empty_map(), inductive_fields: empty_map(), source_indices: empty_map(), intern_table: empty_intern_table(), source_visible_names: empty_map() },
type_env: TypeEnv { bindings: empty_map(), str_bindings: empty_map(), ancestry_str_bindings: empty_map(), parents: [], recursive_types: [], recursive_type_set: empty_map(), inductive_fields: empty_map(), source_indices: empty_map(), intern_table: empty_intern_table(), source_visible_names: empty_map(), global_bare: empty_map() },
func_env: ResolvedFuncEnv { local: empty_map(), parents: [] },
locals: empty_map(),
match_bound_names: empty_map(),
Expand Down
12 changes: 6 additions & 6 deletions src/v1/05_emit_rust.dag
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ import v1.compiler.coercion { coerce_primitive_type, is_copy, lookup_checkpoint

import std.types { is_container_type, is_kernel_type }
import std.serialization { CoproductWireContract, VariantEncoding, VariantNaming }
import v1.compiler.infer_env { TypeEnv, TypeBinding, authored_name, lookup_type_by_name, lookup_type_for }
import v1.compiler.infer_env { TypeEnv, TypeBinding, authored_name, lookup_type_by_name, lookup_type_for, GlobalBareLookupState }
import v1.compiler.infer_types {
resolved_type, normalize_access_type_node, for_each_element_type_node,
child_type_node, emit_map_has,
Expand Down Expand Up @@ -154,7 +154,7 @@ fn render_rust_type(n: Node, shared_types: Set<String>, corpus_repr: RustCorpusR
match find_property(props: n.properties, prop_name: "__applied_type_args", source_indices: source_indices) {
Present { value: applied } =>
if applied.children |> count > 0 {
render_rust_applied_type_shared(n: applied, generic_param_names: [], shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices, variant_to_enum: empty_map(), env: TypeEnv { bindings: empty_map(), str_bindings: empty_map(), ancestry_str_bindings: empty_map(), parents: [], recursive_types: [], recursive_type_set: empty_map(), inductive_fields: empty_map(), source_indices: source_indices, intern_table: empty_intern_table(), source_visible_names: empty_map() })
render_rust_applied_type_shared(n: applied, generic_param_names: [], shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices, variant_to_enum: empty_map(), env: TypeEnv { bindings: empty_map(), str_bindings: empty_map(), ancestry_str_bindings: empty_map(), parents: [], recursive_types: [], recursive_type_set: empty_map(), inductive_fields: empty_map(), source_indices: source_indices, intern_table: empty_intern_table(), source_visible_names: empty_map(), global_bare: empty_map() })
} else {
render_rust_type_without_applied_binding(n: n, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices)
}
Expand All @@ -166,7 +166,7 @@ fn render_rust_type(n: Node, shared_types: Set<String>, corpus_repr: RustCorpusR
fn render_rust_type_without_applied_binding(n: Node, shared_types: Set<String>, corpus_repr: RustCorpusRepr, source_indices: Map<String, NewlineIndex>) -> String {
if is_host_text_carrier_type(n: n, source_indices: source_indices, corpus_repr: corpus_repr) { return rust_carrier_optional_wrap(n: n, rendered: "String") }
if n.connective == NoConnective && n.children |> count > 0 && !is_container_type(name: authored_name_at(source_indices: source_indices, node: n)) {
render_rust_applied_type_shared(n: n, generic_param_names: [], shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices, variant_to_enum: empty_map(), env: TypeEnv { bindings: empty_map(), str_bindings: empty_map(), ancestry_str_bindings: empty_map(), parents: [], recursive_types: [], recursive_type_set: empty_map(), inductive_fields: empty_map(), source_indices: source_indices, intern_table: empty_intern_table(), source_visible_names: empty_map() })
render_rust_applied_type_shared(n: n, generic_param_names: [], shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices, variant_to_enum: empty_map(), env: TypeEnv { bindings: empty_map(), str_bindings: empty_map(), ancestry_str_bindings: empty_map(), parents: [], recursive_types: [], recursive_type_set: empty_map(), inductive_fields: empty_map(), source_indices: source_indices, intern_table: empty_intern_table(), source_visible_names: empty_map(), global_bare: empty_map() })
} else if node_is_set_collection(n: n, source_indices: source_indices) {
match n.children |> first {
Present { value: elem_child } =>
Expand Down Expand Up @@ -3435,10 +3435,10 @@ fn render_rust_type_with_applied_binding(n: Node, shared_types: Set<String>, cor
} else if set_contains(shared_types, outer_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, corpus_repr: corpus_repr, source_indices: source_indices, variant_to_enum: empty_map(), env: TypeEnv { bindings: empty_map(), str_bindings: empty_map(), ancestry_str_bindings: empty_map(), parents: [], recursive_types: [], recursive_type_set: empty_map(), inductive_fields: empty_map(), source_indices: source_indices, intern_table: empty_intern_table(), source_visible_names: empty_map() })
render_rust_applied_type_shared(n: applied, generic_param_names: [], shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices, variant_to_enum: empty_map(), env: TypeEnv { bindings: empty_map(), str_bindings: empty_map(), ancestry_str_bindings: empty_map(), parents: [], recursive_types: [], recursive_type_set: empty_map(), inductive_fields: empty_map(), source_indices: source_indices, intern_table: empty_intern_table(), source_visible_names: empty_map(), global_bare: empty_map() })
}
} else {
render_rust_applied_type_shared(n: applied, generic_param_names: [], shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices, variant_to_enum: empty_map(), env: TypeEnv { bindings: empty_map(), str_bindings: empty_map(), ancestry_str_bindings: empty_map(), parents: [], recursive_types: [], recursive_type_set: empty_map(), inductive_fields: empty_map(), source_indices: source_indices, intern_table: empty_intern_table(), source_visible_names: empty_map() })
render_rust_applied_type_shared(n: applied, generic_param_names: [], shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices, variant_to_enum: empty_map(), env: TypeEnv { bindings: empty_map(), str_bindings: empty_map(), ancestry_str_bindings: empty_map(), parents: [], recursive_types: [], recursive_type_set: empty_map(), inductive_fields: empty_map(), source_indices: source_indices, intern_table: empty_intern_table(), source_visible_names: empty_map(), global_bare: empty_map() })
}
} else {
render_rust_type(n: n, shared_types: shared_types, corpus_repr: corpus_repr, source_indices: source_indices)
Expand Down Expand Up @@ -8328,7 +8328,7 @@ fn emit_test_file(module_name: String, projections: List<TestProjection>, corpus
}

fn rust_test_signature_comment(projection: TestProjection, corpus_repr: RustCorpusRepr) -> String {
let stub_env = TypeEnv { bindings: empty_map(), str_bindings: empty_map(), ancestry_str_bindings: empty_map(), parents: [], recursive_types: [], recursive_type_set: empty_map(), inductive_fields: empty_map(), source_indices: projection.source_indices, intern_table: empty_intern_table(), source_visible_names: empty_map() }
let stub_env = TypeEnv { bindings: empty_map(), str_bindings: empty_map(), ancestry_str_bindings: empty_map(), parents: [], recursive_types: [], recursive_type_set: empty_map(), inductive_fields: empty_map(), source_indices: projection.source_indices, intern_table: empty_intern_table(), source_visible_names: empty_map(), global_bare: empty_map() }
let params_str = projection.params
|> map(p => concat(param_node_name_at(n: p, source_indices: projection.source_indices), ": ", emit_rust_param_type(n: param_node_type_expr(n: p), generic_param_names: [], shared_types: empty_set(), corpus_repr: corpus_repr, source_indices: projection.source_indices, variant_to_enum: empty_map(), env: stub_env)))
|> join(separator: ", ")
Expand Down
2 changes: 2 additions & 0 deletions src/v1/compiler_tests_rust.dag
Original file line number Diff line number Diff line change
Expand Up @@ -1166,6 +1166,7 @@ fn ct_profile_reconcile_test() -> String {
" module_index.clone(),\n",
" source_indices.clone(),\n",
" intern_table.clone(),\n",
" std::rc::Rc::new(HashMap::new()),\n",
" );\n",
" let env_elapsed = t_env.elapsed();\n",
" let rss_after_env = get_rss_bytes();\n",
Expand Down Expand Up @@ -1200,6 +1201,7 @@ fn ct_profile_reconcile_test() -> String {
" variant_surfaces.clone(),\n",
" source_indices.clone(),\n",
" intern_table.clone(),\n",
" std::rc::Rc::new(HashMap::new()),\n",
" );\n",
" let full_elapsed = t_full.elapsed();\n",
" let rss_after = get_rss_bytes();\n",
Expand Down
6 changes: 6 additions & 0 deletions src/v1/stage0/src/bin/infer_semantics_witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ fn empty_type_env() -> Rc<TypeEnv> {
source_indices: Rc::new(im_rc::HashMap::new()),
intern_table: v1_compiler::v1_std_core::empty_intern_table(),
source_visible_names: Rc::new(im_rc::HashMap::new()),
global_bare: Rc::new(im_rc::HashMap::new()),
})
}

Expand Down Expand Up @@ -1003,6 +1004,7 @@ fn optional_match_exhaustiveness_reports_missing_absent() {
source_indices: Rc::new(im_rc::HashMap::new()),
intern_table: v1_compiler::v1_std_core::empty_intern_table(),
source_visible_names: Rc::new(im_rc::HashMap::new()),
global_bare: Rc::new(im_rc::HashMap::new()),
}),
zero_span(),
"test".to_string(),
Expand All @@ -1029,6 +1031,7 @@ fn optional_match_exhaustiveness_rejects_some_and_none() {
source_indices: Rc::new(im_rc::HashMap::new()),
intern_table: v1_compiler::v1_std_core::empty_intern_table(),
source_visible_names: Rc::new(im_rc::HashMap::new()),
global_bare: Rc::new(im_rc::HashMap::new()),
}),
zero_span(),
"test".to_string(),
Expand All @@ -1055,6 +1058,7 @@ fn optional_match_exhaustiveness_accepts_present_and_absent() {
source_indices: Rc::new(im_rc::HashMap::new()),
intern_table: v1_compiler::v1_std_core::empty_intern_table(),
source_visible_names: Rc::new(im_rc::HashMap::new()),
global_bare: Rc::new(im_rc::HashMap::new()),
}),
zero_span(),
"test".to_string(),
Expand Down Expand Up @@ -1118,6 +1122,7 @@ fn resolve_node_uses_node_name_for_lookup() {
source_indices: Rc::new(im_rc::HashMap::new()),
intern_table: user_intern.table.clone(),
source_visible_names: Rc::new(im_rc::HashMap::new()),
global_bare: Rc::new(im_rc::HashMap::new()),
});

let result = resolve_node(node_ref, env, "test".to_string());
Expand Down Expand Up @@ -1636,6 +1641,7 @@ fn resolve_applied_generic_struct_expands_to_conj_for_field_lookup() {
source_indices: empty_source_indices(),
intern_table: box_intern.table.clone(),
source_visible_names: Rc::new(im_rc::HashMap::new()),
global_bare: Rc::new(im_rc::HashMap::new()),
});

let box_nat = container_node("Box".to_string(), leaf_node("Nat".to_string()));
Expand Down
Loading
Loading