What it means. A top-level function with the same name is declared more than once in the same package, across any combination of files. GALA mirrors Go’s “redeclared in this block” rule: a package has one namespace for its top-level functions, and there is no overloading — differing parameter lists do not make two greet functions distinct.
package main
func greet(name string) string = "hello " + name
func greet(other string) string = "hi " + other
func main() {
Println(greet("world"))
}
error[GALA-E0027]: function "greet" in package "main" redeclared (also declared at line 3)
--> main.gala:5:1
|
5 | func greet(other string) string = "hi " + other
| ^^^^ remove the duplicate declaration or rename one of the functi…
|
= hint: remove the duplicate declaration or rename one of the functions
The annotation beside the caret is the hint truncated to fit; the = hint: footer carries it in full.
The check spans the whole package, so splitting the duplicates does not hide them. With greet in both a.gala and b.gala:
error[GALA-E0027]: function "greet" in package "main" redeclared (also declared at a.gala:3)
--> b.gala:3:6
|
3 | func greet(other string) string = "hi " + other
| ^^^^^ remove the duplicate declaration or rename one of the functi…
|
= hint: remove the duplicate declaration or rename one of the functions
When the other declaration lives in a different file, the header names that file and line; when it is in the same file, it gives just the line. Analysis order is not source order, so the message never claims either declaration came first — it points at the other site and leaves the choice of which to delete to you.
Delete the redundant declaration, or rename one so each name describes what it does:
package main
func greet(name string) string = "hello " + name
func greetInformally(other string) string = "hi " + other
func main() {
Println(greet("world"))
Println(greetInformally("world"))
}
If you reached for a second definition because you wanted to accept different argument shapes, GALA’s answer is not overloading but default parameters:
package main
func greet(name string, formal bool = true) string =
if (formal) s"hello $name" else s"hi $name"
func main() {
Println(greet("world"))
Println(greet("world", false))
}
…or a sealed type matched inside one function, when the shapes genuinely differ.
The analyzer keys top-level functions by name in a single per-package map, so a second declaration silently overwrote the first. The later definition won, the earlier was lost, and call sites that expected the first got the second’s body — a whole function disappearing with no diagnostic. Because the map is populated across the whole package, the same silent overwrite applied whether the duplicate sat in one file or in two.
Rejecting it in the analyzer names both sites in GALA source terms instead of leaving it to the Go compiler’s greet redeclared in this block against generated code.
Scope. Top-level functions anywhere in one package. Methods on a type are GALA-E0012; interface method specs are GALA-E0029.
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