Repository navigation
Refactor container classification and zero-arg callable detection #324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
e4eb072
1e4a5b8
20e3ce0
19af457
6bdb2de
1365e88
4218462
69a4cf5
e23340c
c1971b1
a3e0936
80e9484
57efa81
b54dcae
a8ae883
0ff776c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ module v2.compiler.emit_go | |
|
|
||
| import v2.std.core { | ||
| Node, InferredNode, Resolved, CompilerError, | ||
| VarBindingKind, FunctionValueBinding, | ||
| is_import_node, import_is_all, import_specific_names, module_imports, module_items, | ||
| param_node_type_expr, | ||
| authored_name_at, NewlineIndex, | ||
|
|
@@ -94,7 +95,7 @@ import v2.compiler.emit { | |
| TypedItemDataDef, TypedItemServiceDef, TypedItemResourceDef, | ||
| emit_literal, emit_bin_op_symbol, emit_keyword, emit_primitive_type, emit_container, emit_map_type, | ||
| emit_node_type, emit_ident, emit_let_binding, emit_simple_expr, | ||
| emit_unary_op, emit_lambda, emit_error_expr, emit_return, emit_lambda_params, emit_list_lit_expr, emit_shared_expr, emit_default_bin_op, | ||
| emit_unary_op, emit_lambda, emit_error_expr, emit_return, emit_lambda_params, emit_list_lit_expr, emit_shared_expr, emit_default_bin_op, is_zero_arg_callable_ref, | ||
| emit_string_literal, escape_go_interp_text, escape_string_literal_body, | ||
| empty_emit_scope, module_emit_scope, | ||
| scope_after_expr, | ||
|
|
@@ -594,9 +595,18 @@ fn emit_go_field_access(base: Node, field: String, summary: FieldSummary?, regis | |
| fn emit_go_expr_var(expr: Node, depth: Int, source_index: NewlineIndex?) -> String { | ||
| let prefix = make_indent(level: depth) | ||
| match expr.expr_data { | ||
| ExprVar { binding_kind: _ } => | ||
| ExprVar { binding_kind: binding_kind } => | ||
| let n = expr_var_name_at(texpr: expr, source_index: source_index) | ||
| concat(prefix, emit_ident(name: n, target: Go)) | ||
| if n == "none" || n == "None" { concat(prefix, emit_keyword(key: "null", target: Go)) } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Useful? React with 👍 / 👎.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch — fixed in 19af457. Removed the uppercase Note: the Rust emitter has the same pre-existing Generated by Claude Code |
||
| else if n == "true" || n == "false" { concat(prefix, emit_keyword(key: n, target: Go)) } | ||
| else { | ||
| let ident = emit_ident(name: n, target: Go) | ||
| if is_zero_arg_callable_ref(binding_kind: binding_kind, resolved_type: expr.inferred) { | ||
| concat(prefix, ident, "()") | ||
| } else { | ||
| concat(prefix, ident) | ||
| } | ||
| } | ||
| _ => concat(prefix, emit_error_expr(message: "emit_go_expr_var expected ExprVar", target: Go)) | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ module v2.compiler.coercion | |
|
|
||
| import v2.compiler.artifact { RenderTarget, Rust, Python, Go, Dag } | ||
| import std.coercion { TypeCheckpoint, InhabitantDecl, CallableRepr } | ||
| import std.types { container_expected_arity } | ||
| import extdeps.languages.rust.types { | ||
| rust_type_checkpoints, rust_algebra_inhabitants, rust_callable, | ||
| rust_optional_template | ||
|
|
@@ -163,9 +164,20 @@ fn apply_inhabitant_template2(template: String, first: String, second: String) - | |
| replace(replace(template, "\{0\}", first), "\{1\}", second) | ||
| } | ||
|
|
||
| // ========================================================================= | ||
| // Container identity constants (hardcoded; should be derived from algebra arity) | ||
| // ========================================================================= | ||
| // Container kind classification: derived from container_type_arity in std/types.dag. | ||
| // Keyed containers (arity 2) vs element containers (arity 1). | ||
This comment was marked as resolved.
Sorry, something went wrong.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 6bdb2de. Added Generated by Claude Code |
||
| // These functions replace the hardcoded coercion_keyed_container_names and | ||
| // coercion_element_container_names data constants that were never consumed. | ||
| fn is_keyed_container(name: String) -> Bool { | ||
| match container_expected_arity(name: name) { | ||
| Some { value: arity } => arity == 2 | ||
| None => false | ||
| } | ||
| } | ||
|
|
||
| data coercion_keyed_container_names: List<String> = ["Map", "PartialFunction"] | ||
| data coercion_element_container_names: List<String> = ["List", "Set", "NonEmptyList", "NonEmptySet", "FreeMonoid"] | ||
| fn is_element_container(name: String) -> Bool { | ||
| match container_expected_arity(name: name) { | ||
| Some { value: arity } => arity == 1 | ||
| None => false | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invariant violation: is_zero_arg_callable_ref still makes an emit-time nullary-call decision by testing rt.name == "Callable", which uses a name proxy for missing upstream call structure and violates Boundary sufficiency and Emission is translation, not decision-making.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Acknowledged — this is a pre-existing L1 violation (was in
05_emit_rust.dag, moved to shared05_emit.dag). Added documentation comment on the function marking the boundary sufficiency violation and noting the dissolution path (M4/Tier 2.6: inference normalizes ExprVar→ExprCall for nullary invocation). ROADMAP TLC-1 updated to record the Go/Python progress and the remaining upstream work. Fixed in 6bdb2de.Generated by Claude Code