ScarScript checks types at compile time. You can write a type annotation explicitly or let the compiler infer a type from the initializer.
Choose the right declaration
Use val for a binding that should not be reassigned, mut when its value needs to change, and const for a compile-time constant:
val language: str = "ScarScript"
mut completed: int = 0
const MAX_RETRIES: int = 3
completed = completed + 1
Trying to reassign an immutable val or const is a compile-time error. Making mutability visible in the declaration helps readers understand which values can change.
Let ScarScript infer simple types
For common literal values, the initializer supplies enough information:
val retries = 3 // int
val ratio = 3.14 // dec
val greeting = "Hi" // str
val enabled = true // bool
The primitive types include signed integers (int), 64-bit floating-point numbers (dec), strings (str), and booleans (bool). ScarScript also supports arrays written as T[] and maps written as map[K: V].
Know when annotations matter
An annotation is useful when it communicates intent or when an empty collection has no elements from which to infer its type:
val ids: int[] = []
val scores: map[str: int] = {}
val price: dec = 9
An integer literal can widen to dec in a compatible context. An already-declared int variable does not implicitly convert to dec; use types deliberately rather than relying on silent conversions.
The compiler reports incompatible assignments and invalid function arguments before the generated Go program runs. See the types and inference reference for collection and multiple-return examples.
