What it means. A shorthand struct was constructed with call syntax, and the call omitted a field that declares no default. Both call forms are covered — named (Cfg(Name = "a")) and positional (Cfg("a")) — because both are constructor calls.
package main
struct Cfg(Name string, Tries int)
func main() {
val c = Cfg(Name = "a")
Println(c.Tries)
}
error[GALA-E0045]: missing required field "Tries" in construction of "Cfg"
--> main.gala:6:17
|
6 | val c = Cfg(Name = "a")
| ^^^^ pass "Tries", or give the field a default in the declaration
|
= hint: pass "Tries", or give the field a default in the declaration (e.g. Tries int = 0)
Every omitted field is named at once, so a call missing several takes one round trip rather than several.
Either pass the field:
val c = Cfg(Name = "a", Tries = 3)
or declare a default, which makes it optional at every call site:
struct Cfg(Name string, Tries int = 3)
val c = Cfg(Name = "a") // Tries = 3
A field default is re-evaluated at each construction, not once at declaration — the same contract function parameter defaults have.
A shorthand struct’s field list is a constructor signature, and = value on a field means what it means on a function parameter. Before this check, an omitted field silently took Go’s zero value — a defaulted rune became NUL and a defaulted int became 0, with no diagnostic. Since a zero-valued rune, int or bool is often a legal value, nothing downstream could tell “the caller omitted it” from “the caller meant 0”.
This code fires only for shorthand-declared GALA structs constructed with call syntax. Everything that is or mirrors a Go struct keeps Go’s partial-literal semantics:
url.URL(Scheme = "x") constructs partially and raises nothing.Cfg{Name: "a"} is a composite literal, not a constructor call; it stays partial.type Cfg struct { ... } mirrors a Go declaration and has no syntax for a field default.Copy — c.Copy(Name = "b") carries every other field forward from the receiver.