title: Compiler Errors description: Complete reference for Chasm compiler error codes E001–E008 with examples and fixes. keywords: ["chasm", "compiler", "errors", "diagnostics", "E001", "E002", "E003", "E005", "E006", "E007", "E008"]

Chasm's compiler produces structured diagnostics with a code, a source snippet, a caret pointing at the problem, and a help message. This page describes every error code, what causes it, and how to fix it.

E001, Undefined Variable

You used a name that isn't defined in the current scope.

def on_tick(dt :: float) do
  @x = @x + speeed * dt   # E001: `speeed` is not defined
end
error[E001]: undefined variable `speeed`
  --> game.chasm:2:14
  |
2 |   @x = @x + speeed * dt
  |              ^^^^^^
  = help: `speeed` is not defined in this scope

Common causes:

  • Typo in a variable name (speeed instead of speed)
  • Using a variable before declaring it
  • Referencing a parameter from the wrong function
  • Accessing a module-level name without qualifying it (Projectile.speed instead of speed in a module that doesn't import it)

Fix: Declare the variable before use, or correct the spelling.

E002, Type Mismatch

The declared type and the inferred type of the value don't match.

speed :: float = 10   # E002: expected float, found int
error[E002]: expected `float`, found `int`
  --> game.chasm:1:17
  |
1 | speed :: float = 10
  |                  ^^

Common causes:

  • Assigning an integer literal where a float is expected, use 10.0 not 10
  • Passing the wrong type to a function that has a type annotation

Fix: Match the literal to the declared type. For floats, always include a decimal point: 10.0, 0.5, -3.14.

E003, Wrong Argument Count

You called a function with too many or too few arguments.

defp add(a :: int, b :: int) :: int do
  return a + b
end

result = add(1, 2, 3)   # E003: expected 2, got 3
error[E003]: wrong argument count: expected 2, got 3
  --> game.chasm:5:10
  |
5 | result = add(1, 2, 3)
  |          ^^^
  = help: function `add` is declared in this file

Fix: Count the parameters in the function definition and match the call site.

E005, Unknown Function

You called a function that isn't defined or imported.

def on_tick(dt :: float) do
  draw_sprite(@x, @y)   # E005: no function named `draw_sprite` is defined
end
error[E005]: no function named `draw_sprite` is defined
  --> game.chasm:2:3
  |
2 |   draw_sprite(@x, @y)
  |   ^^^^^^^^^^^
  = help: did you mean `draw_texture`?

Common causes:

  • Calling an engine-specific function without the right --engine flag
  • Typo in the function name
  • Calling a function from a module without importing the module
  • Calling a defp (private) function from a different module

Fix:

  • Check the spelling of the function name
  • Run with --engine raylib if it's a Raylib function
  • Add import MyModule if it's defined elsewhere
  • Note: private functions (defp) are not callable from outside their module

E006, Return Type Mismatch

A function's return value doesn't match its declared return type.

defp clamp(v :: float, lo :: float, hi :: float) :: float do
  if v < lo do return lo end
  if v > hi do return hi end
  return to_int(v)   # E006: expected float, found int
end
error[E006]: return type mismatch in `clamp`: expected `float`, found `int`
  --> game.chasm:4:10
  |
4 |   return to_int(v)
  |          ^^^^^^^^
  = help: function `clamp` is declared to return `float`

Fix: Make sure every return path returns a value of the declared type. to_float converts an int to float.

E007, Undefined Struct Field

You accessed a field that doesn't exist on the struct.

defstruct Player do
  x :: float = 0.0
  y :: float = 0.0
end

p = Player{}
p.z   # E007: Player has no field `z`
error[E007]: `Player` has no field `z`
  --> game.chasm:7:3
  |
7 | p.z
  |   ^
  = help: known fields of `Player`: x, y

Common causes:

  • Typo in the field name
  • Accessing a field you intended to add but forgot
  • Using the wrong struct type

Fix: Check the struct definition for the correct field name. The help message lists all available fields.

E008, Lifetime Violation

You assigned a value with a shorter lifetime into an attribute with a longer lifetime.

@position :: persistent = Vec2{}   # persistent attr

def on_tick(dt :: float) do
  temp :: frame = Vec2{ x: 1.0, y: 2.0 }
  @position = temp   # E008: cannot store frame value in persistent attr
end
error[E008]: lifetime violation: cannot store a `frame` value in a `persistent` attribute
  --> game.chasm:5:3
  |
5 |   @position = temp
  |   ^^^^^^^^^
  = help: use `persist_copy(temp)` to promote the value to the persistent arena

Lifetime ordering (shortest to longest):

LifetimeResets when
frameEvery tick
scriptOn hot-reload
persistentNever

A frame value only lives for one tick. Storing it in a persistent attribute would leave a dangling pointer after the frame arena resets, E008 prevents this.

Fix: Use a promotion function to copy the value into the longer-lived arena:

To store inUse
script attrscript_copy(value)
persistent attrpersist_copy(value)
@position :: persistent = Vec2{}

def on_tick(dt :: float) do
  temp :: frame = Vec2{ x: 1.0, y: 2.0 }
  @position = persist_copy(temp)   # OK: copies into persistent arena
end

Reading Diagnostics

Every Chasm diagnostic follows the same format:

error[EABC]: short message
  --> filename.chasm:line:col
  |
N | source line text
  |     ^^^^
  = help: suggestion
  • code, the error code (e.g. E001)
  • arrow, the file, line, and column where the problem was found
  • snippet, the source line
  • caret, ^ marks pointing at the relevant token
  • help, a concrete suggestion for fixing the issue

Chasm reports all errors it finds in a single pass rather than stopping at the first one, so you can fix multiple issues at once.