You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A nested or reassigned typeless designated list is still written bare: Go Line{a: {x: 1}}, C p = { .x = 7 }; and len({ .x = 9 }), Rust p = [ x: 7, y: 8 ]; don't compile #494
#478 (fixing #473) gave a ConstructionExpression that has no type and only MemberInitialiser arguments its receiving type. It did this in C#, and in Rust for three positions: a local, a return and a constructor field. In every other position the list is still written bare, and the target languages reject it.
Repro
struct Point { int x, y }
struct Line { Point a, b }
int run() {
Line l = { a = { x = 1, y = 2 }, b = { x = 3, y = 4 } };
Point p = { x = 5, y = 6 };
p = { x = 7, y = 8 };
return len({ x = 9, y = 10 }) + p.x + l.b.y;
}
Target
Generated
Result
Go
var l Line = Line{ a: {x: 1, y: 2}, ... }
missing type in composite literal. Go only elides the type for slice, array and map elements, never for struct fields.
Go
p = {x: 7, y: 8}, len({x: 9, y: 10})
syntax error: unexpected {
C
p = { .x = 7, .y = 8 };, len({ .x = 9, .y = 10 })
gcc: expected expression before '{' token. These need the compound literal (Point){ .x = 7, .y = 8 }.
Rust
p = [ x: 7, y: 8 ];
parse error
C#, C++
new() { … } / { .x = … }
compile (checked with dotnet build and g++ -std=c++20)
Where in the code
Go:GenerateConstructionExpression (Coder/Languages/GoGenerator.cs:2162-2171) writes {…} with no type whenever Type is null. That includes a member's value inside a struct literal.
C: the list (CGenerator.cs:955, CFamilyGenerator.cs:274) is never written as a compound literal outside an initialiser.
Rust:WriteValue (RustGenerator.cs:1566-1581) is reached for a self. field assignment (:1665-1679) but not for an assignment to a local.
Related: #409 (open) covers non-designated typeless lists in Go and Rust returns, assignments and arguments, and overlaps with the Go assignment and argument cases here. This issue is the designated-list (MemberInitialiser) side, plus C and the nested Go struct-field case.
Acceptance criteria
Go: a nested designated list takes its member's declared type: Line{a: Point{x: 1, y: 2}}.
C: a typeless list used outside a declaration's initialiser (assignment, argument or return) is written (T){ … }.
Rust: an assignment to a local goes through WriteValue, as a self. field assignment already does.
The C, Go and Rust compile tests gain these cases.
Priority: Medium. The output fails to compile in Go, C and Rust, but only for a typeless designated list that is nested, assigned or passed as an argument. A typed construction is a workaround, and the common local, return and field cases already work after Write a typeless member list as new() in C# and a struct literal in Rust [patch] #478.
Area / suggested owner:GoGenerator.GenerateConstructionExpression, the C list writer (CGenerator / CFamilyGenerator), and RustGenerator.WriteValue for local assignment.
Activity
matt-edmondson commentedon Nov 12, 2026
Triage
GoGenerator.GenerateConstructionExpression, the C list writer (CGenerator/CFamilyGenerator), andRustGenerator.WriteValuefor local assignment.return {1}#409, which covers the non-designated lists in Go and Rust assignments and arguments. The receiving-type plumbing is likely shared, so the two are best fixed together. Not a duplicate.Generated by Claude Code