GALA-E0045 — missing required field in struct construction

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.


Code that triggers it

package main

struct Cfg(Name string, Tries int)

func main() {
    val c = Cfg(Name = "a")
    Println(c.Tries)
}

Compiler message

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.


How to fix it

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.


Why the rule exists

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”.


Where it stands down

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: