# Diagnostics

> Aego 0.12.5 · development; docs build `4a32b816933e02930662f6a443cb25abe6050d090c55e237cbff5c44ae9b25f8`. [Build manifest](/docs-build.json).

Compiler diagnostics have a code, file, line and column, and often a note:

```
scripts/player/player.aes:17:21 AES2003 cannot use value of type NodeRef as float in assignment
  note: field Speed has type float
```

`AES1xxx` lexical/syntax · `AES2xxx` types · `AES3xxx` attributes · `AES4xxx` packages and imports · `AES5xxx` bindings · `AES6xxx` runtime faults. The parser recovers after an error, so one run reports every problem in a file. `aego check --explain AES2052` prints the long description of a code; the editor shows it on hover in the Problems panel.

Codes specific to coroutines, signals and script references:

| Code | Meaning |
|---|---|
| AES2050 | `yield` outside a coroutine |
| AES2051 | coroutine called without `start` |
| AES2052 | `start` target is not a coroutine of this script |
| AES2053 | coroutine is not a script method without a result |
| AES2054 | handler parameters do not match the signal |
| AES2055 | bad `Connect` handler, or `Emit` on another script's signal |
| AES2056 | lifecycle method declared as a coroutine |
| AES2057 | wrong `yield` argument type |
| AES2058 | `ScriptRef` / `GetScript` target is not a script type, or is ambiguous |
| AES2059 | lifecycle method or coroutine called through a `ScriptRef` |

Run it: the checks below avoid the runtime faults AES6004, AES6005 and AES6006.

```aes run
package demo

import "aego/log"

script Guards {
    @export var Target NodeRef

    var scores []int

    func Ready() {
        scores = append(scores, 40)
        scores = append(scores, 15)
        var none []int
        log.Info("average " + string(average(scores)) + ", of none " + string(average(none)))
        log.Info("score 5: " + string(at(5)))
        if Target == nil {
            log.Warn("Target is not set; Target.Name() would stop the script with AES6004")
        }
    }

    func average(list []int) int {
        if len(list) == 0 {
            return 0
        }
        total := 0
        for i := 0; i < len(list); i++ {
            total += list[i]
        }
        return total / len(list)
    }

    func at(i int) int {
        if i < 0 || i >= len(scores) {
            return -1
        }
        return scores[i]
    }
}
```
