Skip to content
Kavachकवच

Compiler Messages

● Intermediate10 minSpec 13.6

The compiler's errors and warnings, and the panics of a running program, as the samples on this site show them: each with the page that explains it.

Each line below was printed by the real compiler, or by a program it built, when this site was built: the samples' output is checked on every build. A message says what is wrong and, most of the time, what to write instead. The compiler has more messages than the samples show.

Start here

KindMessageShown in
panicinteger overflow: 1500000000 + 2000000000 doesn't fit in Int32Classic Mistakes, Fixed
panicNaN doesn't fit in IntClassic Mistakes, Fixed
errorexpected String, found IntClassic Mistakes, Fixed
errorDog can't extend Animal: Animal is a type, not an interface, and Kavach has no inheritance (decision 0029). Give Dog a field animal: Animal, or make Animal an interfaceClassic Mistakes, Fixed
errormatch is a keyword, so it can't be a name (spec 1.5): choose another, such as match_valueClassic Mistakes, Fixed
errora lambda can't have inout parameters (spec 3.9): give the function a name, as fn bump(inout n: Int) { … }Classic Mistakes, Fixed
errorKavach has no len function: it is a method, so write prices.len()Classic Mistakes, Fixed
error[Int] has no field length: Kavach's is the method len()Classic Mistakes, Fixed
errorKavach has no let mut: a let can already change, so write let countClassic Mistakes, Fixed
errorString does not implement LogEvent: log events are records, so a log line can be searched by its fields. Declare one, as type OrderPlaced: LogEvent { order_id: Int }, and log that: log.info(OrderPlaced(order_id: 7)) (spec 14.12)Classic Mistakes, Fixed
errorKavach has no null: a value that may be missing has an optional type (String?), and the missing value is none (spec 2.7)Classic Mistakes, Fixed
errorslice takes where to start and where to end: s.slice(0, 4). Positions start at 0 and aren't negative: the last 4 are s.slice(s.len() - 4, s.len())Classic Mistakes, Fixed
errorString has no method strip: Kavach's is trim()Classic Mistakes, Fixed
errorsum takes a function that gives each item's number: prices.sum(p => p), or orders.sum(o => o.total)Classic Mistakes, Fixed
errorTask<Int> has no method join: Kavach's is wait()Classic Mistakes, Fixed
errorKavach has no ===: write ==, which compares values by their contents (spec 1.8)Classic Mistakes, Fixed
errora name can't start with a digit (spec 1.5): start it with a letter, as place_2ndClassic Mistakes, Fixed
panicindex 2 is out of range: the list has 2 itemsReading Errors
errortotl is not defined; did you mean total?Reading Errors

Basics

KindMessageShown in
errorvariables use snake_case: write total_priceNames
erroragent is a keyword, so it can't name a field: pick another nameKeywords
errortotal is already declared in this scopeVariables
errorprice is a const, so it can't change: declare it with letconst
errorvar is not Kavach: write let for a variable, or const for a value that never changeslet
warningtotal is never used: this makes a new total, hiding the one declared above. To change that one, write total = … without let (spec 1.4)Changing a value
warning7 / 2 is 3: whole numbers divide to a whole number. Write 7.0 / 2.0 for a fraction, or 7.div_floor(2) when the whole part is meant (spec 1.8)Int
panicinteger overflow: -128 / -1 doesn't fit in Int8Sized integers
error300 doesn't fit in UInt8, which holds 0 to 255: use UInt16Sized integers
errorthis always panics: integer overflow: 255 + 1 doesn't fit in UInt8 (spec 1.8)Sized integers
panicinteger overflow: 255 + 1 doesn't fit in UInt8Sized integers
errorexpected Bool, found IntOperators
warning-7 / 2 is -3: whole numbers divide to a whole number. Write -7.0 / 2.0 for a fraction, or (-7).div_floor(2) when the whole part is meant (spec 1.8)Arithmetic
errorthere are no implicit number conversions: expected Int, found Float; convert with Int(…)Comparison
errorKavach has no ! for "not": write not, as in not locked (spec 1.8)Logical
errorKavach has no &&: write and (spec 1.8)Logical
errorKavach has no ||: write or (spec 1.8)Logical
errorthis { is never closed: write \{ for a brace in text (spec 1.7)Interpolation
warningthis {…} holds only text, so the string goes on past it: write \{ for a brace, or the text itself (spec 1.7)Interpolation
errorconditions must be Bool, not Int: there is no truthiness, so compare explicitly (for example != 0)Booleans
error= sets a variable: to compare, write == (spec 4.1)If...Else
warningthis condition is never true here: score > 50 means score > 10, and that branch is taken above. Check the order of the conditions (spec 4.7)If...Else
errorthis match does not cover Status.RefundedMatch
warningthis arm never matches: the arm above it matches every value first. Remove it, or move it up (spec 4.7)Match
warningi reaches items.len(), one past the last index of items, so items[i] panics on the last turn: write .. instead of ..=, or loop over items itself (spec 4.4)Over a range
warningthis loop never ends: n doesn't change in it, and nothing in it leaves it. Change it in the loop, add a break, or write while true if it should run forever (spec 4.7)While Loop
errorbreak outer names no loop around it: it is inside a lambda or spawn, whose body is a function of its own, so it can't leave a loop outside it. A label goes before its loop, as outer: for … {, in the same function (spec 4.6)Break/Continue
errorbreak inner names no loop around it: the loops around it are named outer. A label goes before its loop, as inner: for … {, in the same function (spec 4.6)Break/Continue
errorlog.span runs a block: write it after the call, log.span(name) { … } (spec 4.8)Blocks Given to a Call
erroronly log.span(name) and random.seeded(seed) take a block after them (spec 4.8): start the block on a new line, or call one of themBlocks Given to a Call

Functions

KindMessageShown in
errorn is a parameter, so it can't change: copy it into a let firstParameters
errordouble has no ->, so it returns nothing, but its last line is a value: write -> IntReturning a value
errorthe result of add is unused: use it, or write const _ = … to throw it awayUsing Results
warninglog is a copy inside this lambda: the change doesn't reach the outside. Give the value back instead, or use Shared to share it (spec 3.3)Lambdas
warningcount is a copy inside this lambda: the change doesn't reach the outside. Give the value back instead, or use Shared to share it (spec 3.3)Lambdas
errorpositive can fail: write try before it to pass the error on from this lambda, which the call that takes the lambda then passes on (spec 3.3), or handle it here with catch or matchLambdas
errorthis lambda's return gives Int, but its last value is StringLambdas
errorfn(Int) -> Int ! ShopError can fail, so it doesn't fit fn(Int) -> Int: handle the error inside it, or write ! ErrorType in the function type (spec 3.4)Functions as Values
errortotal takes one list, prices, not separate values: put them in a list, as in total([…]) (spec 3.1)Functions as Values
panicstack overflow: calls are nested too deeply (spec 3.8)Recursion
errorn is inout, so count must be able to change: declare it with let, not const (spec 3.9)inout Parameters
warningtotal is a copy inside this lambda: the change doesn't reach the outside. Give the value back instead, or use Shared to share it (spec 3.3)inout Parameters
errorx is given as inout in this call, so it can't be another argument too (spec 3.9)inout Parameters
errorbump has inout parameters, so it can't be a function value (spec 3.9)inout Parameters
errordeprecated only goes before a function (spec 12.6)Deprecating a Function
warninghalf is deprecated: use half_of instead (spec 12.6)Deprecating a Function

Collections

KindMessageShown in
errorthis always panics: index 5 is out of range: the list has 3 items (spec 1.8)Reading by index
errorpush changes fixed, but it is a const: declare it with letChanging items
errorSet can't be called like a function: make a set with Set.of(1, 2, 3), or Set.with_capacity(n) and add (spec 2.2)Making a set
errorsort_by's key needs values with an order (numbers, text, characters, Bool, or tuples of them), and Point has noneBy a key
error[Player] has no method sortBy a key

Your Own Types

KindMessageShown in
errormissing field age for UserDeclaring
errorCircle is a variant of Shape: write Shape.Circle (decision 0070)Declaring
errorexpected Shared<Node?>, found Shared<Node>: every copy of a Shared sees one value, so its type can't change; make it as Shared<Node?> from the startWhat an optional is
errorexpected a number, found Int?: it may be none, so give a default with ?? 0, or check it with if let (spec 2.7)What an optional is
warning.unwrap() panics on none and says nothing of why. Handle none with if let, match or ?? default, or say why it can't happen: ?? panic("…") (spec 2.7)Reading one safely
errorBox takes 1 type argument, not 2Generics
errorName.get gives Int, and Getter<String>.get gives String: they must matchInterfaces
errorString does not implement Describe: write extend String: DescribeInterfaces
errorwrite the type of x: parameters always have a typeWriting Types

Errors & Contracts

KindMessageShown in
warningcatch does nothing here: this can't failKinds of Errors
errorthis always panics: division by zero. Divide by something that can't be 0 (spec 1.8)Kinds of Errors
warning== on floats compares every bit, and rounding makes most computed values differ (0.1 + 0.2 worked out while running isn't 0.3): use a.near(b), or Decimal for exact amountsKinds of Errors
errorthis always panics: integer overflow: 127 + 1 doesn't fit in Int8 (spec 1.8)Kinds of Errors
errorthis always panics: integer overflow: 64 * 2 doesn't fit in Int8 (spec 1.8)Kinds of Errors
errorthis always panics: index 3 is out of range: the list has 3 items (spec 1.8)Kinds of Errors
erroran Error can hold any error type: write FsError.NotFoundKinds of Errors
errora match on an Error needs a _ => … arm: an Error can hold any error typeKinds of Errors
warningx % 2 == 1 is wrong for a negative odd x, since -3 % 2 is -1: write x % 2 != 0Kinds of Errors
panicdivision by zeroKinds of Errors
warningdraft is never used: remove it, or start its name with _ if that is on purposeKinds of Errors
errorthis always panics: .unwrap() on none. Handle none with if let, match or ?? default (spec 1.8)Kinds of Errors
errorthis match does not cover FsError.FailedKinds of Errors
errorhalf can fail: handle the error with try, catch or matchErrors
paniclevel 7 should never be above 5Panics
errorthis call always breaks require owed > 0 of half: owed is -4 (spec 7.7)require
errorthis call always breaks require owed > 0 of half: owed is -3 (spec 7.7)require
paniccontract failed: require hours > 0.0require
errorthis always breaks ensure result >= 0 of clamp_low: result is -1 (spec 7.7)ensure
paniccontract failed: invariant balance >= 0invariant
errorinvoice.test.kav holds the tests of invoice.kav, but there is no invoice.kav beside it: name it after the module it tests (spec 11.8)test blocks
errorthis test uses Fs, but a test runs with no capabilities unless given some: write uses Fs after its name, or give it a fake with with (spec 11.8)test blocks

Memory

KindMessageShown in
errorexpected Int, found [Int]: a list holds one type; to mix numbers and lists, use a union (2.6) or Json (2.12)How it stays fast
warning_ names nothing, so this value drops here, at the end of the statement: name it _guard to keep it to the end of the block (spec 6.1)Freed immediately
paniccan't wait inside update: the Shared value stays locked until its function returns. Get what the update needs first, then update (spec 6.2)Shared State
errortime.sleep_ms waits, and the function given to update can't wait: the Shared value stays locked until it returns. Get what the update needs first, then update (spec 6.2)Shared State
errorthis value was made inside the arena and can't be stored outside it: return it as the arena's value insteadArenas

Standard Library

KindMessageShown in
errora contract can't call time.now_ms: it reads the clock, and contracts must give the same answer every time (spec 7.5)Time
errortime.freeze is only for tests: call it directly in a test block (spec 14.4)Time
paniccontract failed: invariant day >= 1 and day <= days_in_month(year, month)Time
error2 has no field months. The units that make a Duration are ms, seconds, minutes, hours, days. Months and years have no fixed length: count days instead.Time
erroran agent can't answer approvals: Approvals can't be in can (8.3)Agents
errorcount uses Approvals (through waiting), but its uses clause doesn't list it: add Approvals to uses (spec 8.1)Agents
errorcopied uses Clipboard, but its uses clause doesn't list it: add Clipboard to uses (spec 8.1)Clipboard
errorports uses Serial, but its uses clause doesn't list it: add Serial to uses (spec 8.1)Devices
paniccontract failed: require level_fits(format, level)Compression
errorwatch uses Input (through listen_input), but its uses clause doesn't list it: add Input to uses (spec 8.1)Windows
errorshow uses Window (through open), but its uses clause doesn't list it: add Window to uses (spec 8.1)Windows
errorstatus uses Process (through run), but its uses clause doesn't list it: add Process to uses (spec 8.1)Running Programs
errorpaint is pub, so it must say what it uses: add uses Window (through screen) (spec 8.1)GPU Screens
errorCard has the secret field number, so it can't be written as JSON (spec 2.11)Building
errorwrite the type of the numbers: b.as_list<Float32>()Bytes
erroras_list reads numbers of a fixed size: Int8, Int16, Int32, Int, UInt8, UInt16, UInt32, UInt64, Float32 or FloatBytes
errorread reads numbers of a fixed size: Int8, Int16, Int32, Int, UInt8, UInt16, UInt32, UInt64, Float32 or FloatBytes

Concurrency

KindMessageShown in
warningsaving is never used: remove it, or start its name with _ if that is on purposeWhen a task fails
panican item of parallel_map panicked: division by zero at src/main.kav:3Many Things at Once
panicput into a channel whose receivers are all goneChannels
panicevery task is waiting for another one (a deadlock)Deadlocks
errorspawn process takes a call of a function, not a block: put the block in a function and call it (spec 9.8)How Tasks Run
errorShared<Int> can't be written as JSON, so it can't go to another process (spec 9.8)How Tasks Run
errortasks in [package] moved into the code: write spawn thread … or spawn cores … where a task should run another way; a plain spawn is a coroutine (spec 9.8, decision 0069)How Tasks Run

Capabilities & Agents

KindMessageShown in
errorgreet is pub, so it must say what it uses: add uses Console (through shout) (spec 8.1)uses
errorload is pub, so it must say what it uses: add uses Fs.read (spec 8.1)uses
errorfetch_count uses Net, but the function type it is given as allows only Console (spec 3.4)Pure functions
errorread_config uses Fs.write, but its uses clause doesn't list it: add Fs.write to uses (spec 8.1)Narrower file access
errorPayments.refund can be refused, so its error type needs a variant Denied(reason: String) (spec 8.2)Declaring a capability
errorclaude-opus-5-5 always thinks before it answers, so thinking: false would fail: leave it out, and lower effort for fewer tokens (spec 8.4)model
errorModel has no temperature: current models take only their own, and newer API versions refuse it. Use effort (Low to Max) to trade quality against tokens (spec 8.4)model
error[agents.Support] moved into the code: give agent Support settings AgentSettings(…) (spec 8.5, decision 0060). mode = "observe" is mode: AgentMode.Observe; audit_log, audit_format and audit_otlp are audit: Audit(file: "…", format: AuditFormat.JsonLines, otlp: true); state and journal are on by default, in agents/Support/. kavach.toml keeps only [agents] foldersettings
errorthe handler tick uses Console, but the agent Counter can't: add Console to its can (spec 8.3)can
errorthe handler welcome uses Files.delete, but the agent Greeter can't: add Files.delete to its can (spec 8.3)can
errortokens counts what AI calls took: it is for limit Ai rules (spec 8.3)limit
errorsay who answers: --as <name>, written to the audit logapprove
errorno request Refunder-1-1 waits for an answer (see kavach approvals)approve
panicindex 5 is out of range: the list has 2 itemsRunning an Agent
errorGreeter.start needs an implementation of Email: Email: …Running an Agent
errorpick can fail: handle the error with try, catch or matchRunning an Agent
errora model is chosen when the program is built: write Model(name: "…") with plain values, or call a function with no parameters that gives one, such as careful() (spec 8.4)Choosing the model
errormodel in [ai] moved into the code: give the agent model Model(name: "…"), or a call model: (spec 8.4, decision 0056)Choosing the model
errorotlp: true sends the audit log to a collector: add a [log.otlp] section with its endpoint to kavach.toml (spec 8.6, 14.12)Monitoring Agents
errorpassword is secret, so it can't go into print; use reveal(…) if you really mean toSecrets
errorcard is secret, so it can't go into text; use reveal(…) if you really mean toSecrets
errorc is secret, so it can't go into the argument text of remember, which isn't secret; mark it secret, or use reveal(…) if you really mean toSecret parameters
errorapi_key is secret, and a lambda can't return a secret: return it from a named function with -> secret … (spec 8.7), or use reveal(…) if you really mean toSecret results
errorapi_key is secret, so api_key can't return it: write -> secret … for its result (spec 8.7), or use reveal(…) if you really mean toSecret results
errorkey is secret, so it can't go into text; use reveal(…) if you really mean toSecret results

Projects & Tools

KindMessageShown in
errorpub use re-exports names, not a whole module: write pub use module.{Name, …} (spec 10.2)use
errorread_text can't be named alone: write use std.fs and fs.read_text (spec 14.1)use
errorPicker is private to module bots: mark it pub there to use it here (spec 10.1)pub
errorthe method tax of Order is private to package shop: mark it pub there to call it here (spec 10.1)pub
errorInvoice has a private field (note), so only module billing.invoice can create one: add a pub fn there that makes it (spec 10.1)pub
errorgreet in the package greeter uses Console, which the package isn't granted: add "Console" to can in its entry in kavach.toml, and in the entry of each package it comes through, if you trust them (spec 10.12)pub
errorsave in the package notes uses Fs.write, which the package isn't granted: add "Fs.write" to can in its entry in kavach.toml, and in the entry of each package it comes through, if you trust them (spec 10.12)Packages
warningsql: * gets every column, even ones added later (name the columns you need)Tagged Literals
errorsql: a query starts with select, insert, update or delete (is selct misspelled?)Tagged Literals
errorsql: a query starts with select, insert, update or delete (is updte misspelled?)Tagged Literals
errorunknown key taks in [package]: expected one of name, version, edition, unsafe, tasksSettings
errorSHOP_HOSTS in [env.vars] of kavach.toml: an environment variable holds text, so write a list as text, such as "a,b,c", and split it in the program (spec 10.13)Environment Variables
errorenvironment variable SHOP_KEY is not setEnvironment Variables
errorkey is secret, so it can't go into print; use reveal(…) if you really mean toEnvironment Variables
errorKavach has no edition 2062: its editions are 2026 (spec 10.8)Editions
warningthis condition is never true here: score > 80 means score > 50, and that branch is taken above. Check the order of the conditions (spec 4.7)fix
errormain.kav has 13 lines (limit 12)Small Files

Speed

KindMessageShown in
panicinteger overflow: 250 + 10 doesn't fit in UInt8Byte-packed Lists
errorhalf gives a Float, and a gpu fn works with Float32, Int32, UInt32 and Bool, and records and tuples of 1 to 8 of them (spec 15.1)gpu fn
errorxs is a [Float32], and a gpu fn works with Float32, Int32, UInt32 and Bool, and records and tuples of 1 to 8 of them (spec 15.1)gpu fn
errora gpu fn can't use square: it isn't a gpu fn, but it fits the GPU's rules. Mark it gpu fn square; it still runs on the CPU when called there (spec 15.1)gpu fn
errora gpu fn can't use loud: it isn't a gpu fn, and can't be one, since it uses print: it reaches outside the program (files, the network, the terminal, time, AI), and on the GPU a gpu fn runs alone, item by item, with only its own values (spec 15.1)gpu fn
errora gpu fn can't use print: it reaches outside the program (files, the network, the terminal, time, AI), and on the GPU a gpu fn runs alone, item by item, with only its own values (spec 15.1)gpu fn
panicinteger overflow: 100000 * 100000 doesn't fit in Int32Same results as the CPU
panicinteger overflow: 4000000 * 2000 doesn't fit in Int32Same results as the CPU
errora gpu fn can't use try, catch or fail: it can't fail, since on the GPU there is no error to give back. Check the value first with if, and give a result for every item (spec 15.1)Can I use it on the GPU?
errora gpu fn can't use fs.read_text: it reaches outside the program (files, the network, the terminal, time, AI), and on the GPU a gpu fn runs alone, item by item, with only its own values (spec 15.1)Can I use it on the GPU?
errora gpu fn can't take inout parameters: give the new value back instead, as gpu fn bump(x: Float32) -> Float32 (spec 15.1)Can I use it on the GPU?
errorp is a Ptr<Float32>, and a gpu fn works with Float32, Int32, UInt32 and Bool, and records and tuples of 1 to 8 of them (spec 15.1)Can I use it on the GPU?
errorfactorial calls itself, directly or through other gpu fns: a GPU has no call stack (spec 15.1)Can I use it on the GPU?
panicinteger overflow: 2147483647 + 1 doesn't fit in Int32Can I use it on the GPU?