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
| Kind | Message | Shown in |
|---|---|---|
| panic | integer overflow: 1500000000 + 2000000000 doesn't fit in Int32 | Classic Mistakes, Fixed |
| panic | NaN doesn't fit in Int | Classic Mistakes, Fixed |
| error | expected String, found Int | Classic Mistakes, Fixed |
| error | Dog 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 interface | Classic Mistakes, Fixed |
| error | match is a keyword, so it can't be a name (spec 1.5): choose another, such as match_value | Classic Mistakes, Fixed |
| error | a lambda can't have inout parameters (spec 3.9): give the function a name, as fn bump(inout n: Int) { … } | Classic Mistakes, Fixed |
| error | Kavach 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 |
| error | Kavach has no let mut: a let can already change, so write let count | Classic Mistakes, Fixed |
| error | String 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 |
| error | Kavach 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 |
| error | slice 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 |
| error | String has no method strip: Kavach's is trim() | Classic Mistakes, Fixed |
| error | sum takes a function that gives each item's number: prices.sum(p => p), or orders.sum(o => o.total) | Classic Mistakes, Fixed |
| error | Task<Int> has no method join: Kavach's is wait() | Classic Mistakes, Fixed |
| error | Kavach has no ===: write ==, which compares values by their contents (spec 1.8) | Classic Mistakes, Fixed |
| error | a name can't start with a digit (spec 1.5): start it with a letter, as place_2nd | Classic Mistakes, Fixed |
| panic | index 2 is out of range: the list has 2 items | Reading Errors |
| error | totl is not defined; did you mean total? | Reading Errors |
Basics
| Kind | Message | Shown in |
|---|---|---|
| error | variables use snake_case: write total_price | Names |
| error | agent is a keyword, so it can't name a field: pick another name | Keywords |
| error | total is already declared in this scope | Variables |
| error | price is a const, so it can't change: declare it with let | const |
| error | var is not Kavach: write let for a variable, or const for a value that never changes | let |
| warning | total 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 |
| 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) | Int |
| panic | integer overflow: -128 / -1 doesn't fit in Int8 | Sized integers |
| error | 300 doesn't fit in UInt8, which holds 0 to 255: use UInt16 | Sized integers |
| error | this always panics: integer overflow: 255 + 1 doesn't fit in UInt8 (spec 1.8) | Sized integers |
| panic | integer overflow: 255 + 1 doesn't fit in UInt8 | Sized integers |
| error | expected Bool, found Int | Operators |
| 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 |
| error | there are no implicit number conversions: expected Int, found Float; convert with Int(…) | Comparison |
| error | Kavach has no ! for "not": write not, as in not locked (spec 1.8) | Logical |
| error | Kavach has no &&: write and (spec 1.8) | Logical |
| error | Kavach has no ||: write or (spec 1.8) | Logical |
| error | this { is never closed: write \{ for a brace in text (spec 1.7) | Interpolation |
| warning | this {…} holds only text, so the string goes on past it: write \{ for a brace, or the text itself (spec 1.7) | Interpolation |
| error | conditions 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 |
| warning | this 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 |
| error | this match does not cover Status.Refunded | Match |
| warning | this arm never matches: the arm above it matches every value first. Remove it, or move it up (spec 4.7) | Match |
| warning | i 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 |
| warning | this 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 |
| error | break 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 |
| error | break 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 |
| error | log.span runs a block: write it after the call, log.span(name) { … } (spec 4.8) | Blocks Given to a Call |
| error | only 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 them | Blocks Given to a Call |
Functions
| Kind | Message | Shown in |
|---|---|---|
| error | n is a parameter, so it can't change: copy it into a let first | Parameters |
| error | double has no ->, so it returns nothing, but its last line is a value: write -> Int | Returning a value |
| error | the result of add is unused: use it, or write const _ = … to throw it away | Using Results |
| warning | log 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 |
| warning | count 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 |
| error | positive 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 match | Lambdas |
| error | this lambda's return gives Int, but its last value is String | Lambdas |
| error | fn(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 |
| error | total takes one list, prices, not separate values: put them in a list, as in total([…]) (spec 3.1) | Functions as Values |
| panic | stack overflow: calls are nested too deeply (spec 3.8) | Recursion |
| error | n is inout, so count must be able to change: declare it with let, not const (spec 3.9) | inout Parameters |
| warning | total 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 |
| error | x is given as inout in this call, so it can't be another argument too (spec 3.9) | inout Parameters |
| error | bump has inout parameters, so it can't be a function value (spec 3.9) | inout Parameters |
| error | deprecated only goes before a function (spec 12.6) | Deprecating a Function |
| warning | half is deprecated: use half_of instead (spec 12.6) | Deprecating a Function |
Collections
| Kind | Message | Shown in |
|---|---|---|
| error | this always panics: index 5 is out of range: the list has 3 items (spec 1.8) | Reading by index |
| error | push changes fixed, but it is a const: declare it with let | Changing items |
| error | Set 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 |
| error | sort_by's key needs values with an order (numbers, text, characters, Bool, or tuples of them), and Point has none | By a key |
| error | [Player] has no method sort | By a key |
Your Own Types
| Kind | Message | Shown in |
|---|---|---|
| error | missing field age for User | Declaring |
| error | Circle is a variant of Shape: write Shape.Circle (decision 0070) | Declaring |
| error | expected 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 start | What an optional is |
| error | expected 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 |
| error | Box takes 1 type argument, not 2 | Generics |
| error | Name.get gives Int, and Getter<String>.get gives String: they must match | Interfaces |
| error | String does not implement Describe: write extend String: Describe | Interfaces |
| error | write the type of x: parameters always have a type | Writing Types |
Errors & Contracts
| Kind | Message | Shown in |
|---|---|---|
| warning | catch does nothing here: this can't fail | Kinds of Errors |
| error | this 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 amounts | Kinds of Errors |
| error | this always panics: integer overflow: 127 + 1 doesn't fit in Int8 (spec 1.8) | Kinds of Errors |
| error | this always panics: integer overflow: 64 * 2 doesn't fit in Int8 (spec 1.8) | Kinds of Errors |
| error | this always panics: index 3 is out of range: the list has 3 items (spec 1.8) | Kinds of Errors |
| error | an Error can hold any error type: write FsError.NotFound | Kinds of Errors |
| error | a match on an Error needs a _ => … arm: an Error can hold any error type | Kinds of Errors |
| warning | x % 2 == 1 is wrong for a negative odd x, since -3 % 2 is -1: write x % 2 != 0 | Kinds of Errors |
| panic | division by zero | Kinds of Errors |
| warning | draft is never used: remove it, or start its name with _ if that is on purpose | Kinds of Errors |
| error | this always panics: .unwrap() on none. Handle none with if let, match or ?? default (spec 1.8) | Kinds of Errors |
| error | this match does not cover FsError.Failed | Kinds of Errors |
| error | half can fail: handle the error with try, catch or match | Errors |
| panic | level 7 should never be above 5 | Panics |
| error | this call always breaks require owed > 0 of half: owed is -4 (spec 7.7) | require |
| error | this call always breaks require owed > 0 of half: owed is -3 (spec 7.7) | require |
| panic | contract failed: require hours > 0.0 | require |
| error | this always breaks ensure result >= 0 of clamp_low: result is -1 (spec 7.7) | ensure |
| panic | contract failed: invariant balance >= 0 | invariant |
| error | invoice.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 |
| error | this 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
| Kind | Message | Shown in |
|---|---|---|
| error | expected 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 |
| panic | can'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 |
| error | time.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 |
| error | this value was made inside the arena and can't be stored outside it: return it as the arena's value instead | Arenas |
Standard Library
| Kind | Message | Shown in |
|---|---|---|
| error | a contract can't call time.now_ms: it reads the clock, and contracts must give the same answer every time (spec 7.5) | Time |
| error | time.freeze is only for tests: call it directly in a test block (spec 14.4) | Time |
| panic | contract failed: invariant day >= 1 and day <= days_in_month(year, month) | Time |
| error | 2 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 |
| error | an agent can't answer approvals: Approvals can't be in can (8.3) | Agents |
| error | count uses Approvals (through waiting), but its uses clause doesn't list it: add Approvals to uses (spec 8.1) | Agents |
| error | copied uses Clipboard, but its uses clause doesn't list it: add Clipboard to uses (spec 8.1) | Clipboard |
| error | ports uses Serial, but its uses clause doesn't list it: add Serial to uses (spec 8.1) | Devices |
| panic | contract failed: require level_fits(format, level) | Compression |
| error | watch uses Input (through listen_input), but its uses clause doesn't list it: add Input to uses (spec 8.1) | Windows |
| error | show uses Window (through open), but its uses clause doesn't list it: add Window to uses (spec 8.1) | Windows |
| error | status uses Process (through run), but its uses clause doesn't list it: add Process to uses (spec 8.1) | Running Programs |
| error | paint is pub, so it must say what it uses: add uses Window (through screen) (spec 8.1) | GPU Screens |
| error | Card has the secret field number, so it can't be written as JSON (spec 2.11) | Building |
| error | write the type of the numbers: b.as_list<Float32>() | Bytes |
| error | as_list reads numbers of a fixed size: Int8, Int16, Int32, Int, UInt8, UInt16, UInt32, UInt64, Float32 or Float | Bytes |
| error | read reads numbers of a fixed size: Int8, Int16, Int32, Int, UInt8, UInt16, UInt32, UInt64, Float32 or Float | Bytes |
Concurrency
| Kind | Message | Shown in |
|---|---|---|
| warning | saving is never used: remove it, or start its name with _ if that is on purpose | When a task fails |
| panic | an item of parallel_map panicked: division by zero at src/main.kav:3 | Many Things at Once |
| panic | put into a channel whose receivers are all gone | Channels |
| panic | every task is waiting for another one (a deadlock) | Deadlocks |
| error | spawn 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 |
| error | Shared<Int> can't be written as JSON, so it can't go to another process (spec 9.8) | How Tasks Run |
| error | tasks 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
| Kind | Message | Shown in |
|---|---|---|
| error | greet is pub, so it must say what it uses: add uses Console (through shout) (spec 8.1) | uses |
| error | load is pub, so it must say what it uses: add uses Fs.read (spec 8.1) | uses |
| error | fetch_count uses Net, but the function type it is given as allows only Console (spec 3.4) | Pure functions |
| error | read_config uses Fs.write, but its uses clause doesn't list it: add Fs.write to uses (spec 8.1) | Narrower file access |
| error | Payments.refund can be refused, so its error type needs a variant Denied(reason: String) (spec 8.2) | Declaring a capability |
| error | claude-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 |
| error | Model 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] folder | settings |
| error | the handler tick uses Console, but the agent Counter can't: add Console to its can (spec 8.3) | can |
| error | the handler welcome uses Files.delete, but the agent Greeter can't: add Files.delete to its can (spec 8.3) | can |
| error | tokens counts what AI calls took: it is for limit Ai rules (spec 8.3) | limit |
| error | say who answers: --as <name>, written to the audit log | approve |
| error | no request Refunder-1-1 waits for an answer (see kavach approvals) | approve |
| panic | index 5 is out of range: the list has 2 items | Running an Agent |
| error | Greeter.start needs an implementation of Email: Email: … | Running an Agent |
| error | pick can fail: handle the error with try, catch or match | Running an Agent |
| error | a 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 |
| error | model in [ai] moved into the code: give the agent model Model(name: "…"), or a call model: (spec 8.4, decision 0056) | Choosing the model |
| error | otlp: 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 |
| error | password is secret, so it can't go into print; use reveal(…) if you really mean to | Secrets |
| error | card is secret, so it can't go into text; use reveal(…) if you really mean to | Secrets |
| error | c 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 to | Secret parameters |
| error | api_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 to | Secret results |
| error | api_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 to | Secret results |
| error | key is secret, so it can't go into text; use reveal(…) if you really mean to | Secret results |
Projects & Tools
| Kind | Message | Shown in |
|---|---|---|
| error | pub use re-exports names, not a whole module: write pub use module.{Name, …} (spec 10.2) | use |
| error | read_text can't be named alone: write use std.fs and fs.read_text (spec 14.1) | use |
| error | Picker is private to module bots: mark it pub there to use it here (spec 10.1) | pub |
| error | the method tax of Order is private to package shop: mark it pub there to call it here (spec 10.1) | pub |
| error | Invoice 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 |
| error | greet 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 |
| error | save 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 |
| warning | sql: * gets every column, even ones added later (name the columns you need) | Tagged Literals |
| error | sql: a query starts with select, insert, update or delete (is selct misspelled?) | Tagged Literals |
| error | sql: a query starts with select, insert, update or delete (is updte misspelled?) | Tagged Literals |
| error | unknown key taks in [package]: expected one of name, version, edition, unsafe, tasks | Settings |
| error | SHOP_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 |
| error | environment variable SHOP_KEY is not set | Environment Variables |
| error | key is secret, so it can't go into print; use reveal(…) if you really mean to | Environment Variables |
| error | Kavach has no edition 2062: its editions are 2026 (spec 10.8) | Editions |
| warning | this 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 |
| error | main.kav has 13 lines (limit 12) | Small Files |
Speed
| Kind | Message | Shown in |
|---|---|---|
| panic | integer overflow: 250 + 10 doesn't fit in UInt8 | Byte-packed Lists |
| error | half 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 |
| error | xs 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 |
| error | a 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 |
| error | a 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 |
| error | a 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 |
| panic | integer overflow: 100000 * 100000 doesn't fit in Int32 | Same results as the CPU |
| panic | integer overflow: 4000000 * 2000 doesn't fit in Int32 | Same results as the CPU |
| error | a 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? |
| error | a 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? |
| error | a 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? |
| error | p 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? |
| error | factorial calls itself, directly or through other gpu fns: a GPU has no call stack (spec 15.1) | Can I use it on the GPU? |
| panic | integer overflow: 2147483647 + 1 doesn't fit in Int32 | Can I use it on the GPU? |