GALA-E0044 — type has no such method

When it fires. A method was called on a value whose GALA type declares no method of that name:

val xs = ArrayOf(1, 2, 3)
Println(xs.Sum())

Array has no Sum. The diagnostic names the nearest real method when the call looks like a typo, and otherwise lists methods the type does have.

Minimal repro.

package main

import . "martianoff/gala/collection_immutable"

func main() {
    val xs = ArrayOf(1, 2, 3)
    Println(xs.Sise())
}

Error output.

error[GALA-E0044]: Array has no method Sise
  --> main.gala:7:16
  |
7 |     Println(xs.Sise())
  |                ^^^^ did you mean `Size`?
  |
  = hint: did you mean `Size`?

When no method is close enough to suggest, the hint lists the surface instead:

error[GALA-E0044]: Array has no method Sum
  --> main.gala:7:16
  |
7 |     Println(xs.Sum())
  |                ^^^ Array declares: Append, Contains, Drop, Exists, ...

Fix. Call a method that exists. For the Sum case, GALA folds:

val total = xs.FoldLeft(0, (acc, x) => acc + x)

Rationale. The rejection is not new — this call never compiled. What was new is who reported it and in whose words. The call used to be emitted verbatim and handed to go build, which described the generated expression rather than the source:

xs.Get().Filter(func(x int) bool {…}).Sum undefined
  (type collection_immutable.Array[int] has no field or method Sum)

The .Get() in that message is the Immutable[T] auto-unwrap the transpiler inserts. The user wrote xs.Filter(...).Sum() and got back an expression containing a call they never made, described in terms of a Go type they never named. Nothing in it suggested FoldLeft.

Where it stands down. A false positive here rejects a correct program, so the check only fires when the judgement is safe. It says nothing when:

Scope. This code covers a method call on a known, concrete GALA type. It does not cover an unknown function (GALA-E0023), a type name called as a constructor (GALA-E0043), or a call with the wrong number of arguments to a method that does exist.