GALA-E0028 — Type alias redeclared

What it means. A type alias (type Handler func(string) string) with the same name is declared more than once in the same package. The transformer keeps one lookup table of alias name → underlying type, so a second alias under the same name would replace the first.

Like GALA-E0027, this covers duplicates within one file and duplicates split across sibling files of the same package — the alias table is seeded from siblings when transformation begins.


Code that triggers it

package main

type Handler func(string) string
type Handler func(int) int

func main() {
    Println("unused")
}

Compiler message

error[GALA-E0028]: type alias "Handler" already declared in package "main"
  --> main.gala:4:6
  |
4 | type Handler func(int) int
  |      ^^^^^^^ remove the duplicate declaration or rename one of the aliase…
  |
  = hint: remove the duplicate declaration or rename one of the aliases

The caret points at the second alias’s name — the one to rename or remove. The annotation beside the caret is the hint truncated to fit; the = hint: footer carries it in full.


How to fix it

Give each alias a distinct name that says what it aliases:

package main

type StringHandler func(string) string
type IntHandler func(int) int

func main() {
    val upper StringHandler = (s) => s + "!"
    val double IntHandler = (n) => n * 2
    Println(upper("hi"))
    Println(double(21))
}

Note that both lambdas here are unannotated: the declared alias supplies the expected type, so the parameter types flow in. That is the typed-context rule from GALA-E0033 working in your favour.


Why the rule exists

The silent overwrite was worse than a lost declaration. Because the alias table is consulted whenever a type name needs resolving, the second alias’s underlying type would be substituted at call sites written against the first. The resulting Go either failed to compile at some unrelated line, or — when both underlying types happened to be structurally compatible — compiled and did the wrong thing. Rejecting at the declaration keeps the failure local.

Scope. Type aliases (type Foo = Bar / type Foo func(...)). Duplicate type declarations — structs, sealed types, interfaces — are GALA-E0011.


GALA-E0011 types · GALA-E0012 methods · GALA-E0027 functions · GALA-E0028 type aliases · GALA-E0029 interface method specs · GALA-E0030 struct fields · GALA-E0031 sealed cases