GALA-E0090 — Anonymous Go struct type would have to be written

When it fires. A Go API hands GALA a value whose type is, or holds, an anonymous Go struct type, such as the struct{} of a signal channel (<-chan struct{} from ctx.Done()), and the generated Go would have to write that type out. That happens wherever GALA spells a type:

GALA has no syntax for an anonymous struct type, so it cannot be written in GALA source either. A value of one that only passes through is accepted: val done = ctx.Done(), a Go call’s result passed straight to another Go call, a receive such as <-done, and reading a field of a returned struct.

Minimal repro.

package main

import "context"

func main() {
    val ctx = context.Background()
    val done = Some(ctx.Done())
    Println(done.IsDefined())
}

Error output.

error[GALA-E0090]: type `<-chan struct{}` holds an anonymous Go struct type, which GALA cannot write
  --> main.gala:7:21
  |
7 |     val done = Some(ctx.Done())
  |                     ^^^ give the type a name on the Go side
  |
  = hint: give the type a name on the Go side; for a signal channel use go_interop.Signal and go_interop.WaitClosed, IsClosed or WaitClosedTimeout; for ctx.Done() use go_interop.WaitDone, IsDone or WaitDoneTimeout

Fix. Keep the value out of positions that write its type, or give the type a name:

package main

import (
    "context"

    "martianoff/gala/go_interop"
)

func main() {
    val ctx = context.Background()
    Println(go_interop.IsDone(ctx))
}

Rationale. GALA generates concrete Go types and never erases one to any. An anonymous struct type has no GALA spelling to generate from, and one with an unexported field cannot be written outside the package that declares it at all, so GALA reports the use instead of writing a type the program never named.