Reference
Error messages
How to read a compiler message, and what the common codes mean.
When something is wrong, zakac prints a message instead of running the program. Here
is one such message:
$ zakac run program.zaka
error[ZK0401]: expected isize, found f64
--> program.zaka:2:10
|
2 | အသက် ကို ၂.၅ ဟု ထားပါ။
| ^^^
= help: convert the value with "ကို <kind> အဖြစ် ပြောင်းလဲသော ရလဒ်"
| Part | Means |
|---|---|
error | the program will not run. A warning does not stop it. |
[ZK0401] | the code; look it up in the tables below |
expected isize, found f64 | what went wrong |
program.zaka:2:10 | file, line 2, character 10 |
^^^ | points at the problem in the line |
help: | a suggestion for fixing it (some messages have none) |
Fix the first error first. A single mistake can confuse the compiler into reporting more errors after it.
When a program stops while running (for example, on a division whose zero appears at
run time), the message starts with the program stopped: and has no code.
Short names for kinds
Messages use short names for kinds:
| Short name | Zaka kind |
|---|---|
isize | ကိန်းပြည့် |
i8, i16, i32, i64, i128 | ၈ ဘစ် ကိန်းပြည့် ... ၁၂၈ ဘစ် ကိန်းပြည့် |
usize | လက္ခဏာမဲ့ ကိန်းပြည့် |
u8, u16, u32, u64, u128 | လက္ခဏာမဲ့ ၈ ဘစ် ကိန်းပြည့် ... |
f16, f32, f64, f128 | ၁၆ ဘစ် ဒဿမကိန်း ... ; f64 is plain ဒဿမကိန်း |
char | စာလုံး |
bool | မှန်မှားတန်ဖိုး |
*isize, *u8, **isize, ... | ကိန်းပြည့် လိပ်စာ, ... ; one more * for each ၏ လိပ်စာ after it |
ptr | လိပ်စာ (the opaque pointer) |
[3]isize, [2][3]isize | အကွက် ၃ ခုရှိသော ကိန်းပြည့် စာရင်း, ... ; one [n] for each စာရင်း, outermost first; [] while the count is not known |
*[3]isize | အကွက် ၃ ခုရှိသော ကိန်းပြည့် စာရင်း လိပ်စာ, the address of a whole list |
null | the kind of ဗလာ |
Codes
The first two digits tell which stage found the problem. Diagnostics explains how a message is set out and when a message stops the compiler.
ZK01: reading the characters
| Code | Problem | See |
|---|---|---|
| ZK0101 | a character Zaka does not use, such as ; or ? | |
| ZK0102 | a malformed number, such as ၂.၅e3 or ၁၈ဘစ် | Writing integers |
| ZK0103 | Burmese and Western digits in one number | Writing integers |
| ZK0104 | text with no closing " | Text in quotes |
| ZK0105 | a character literal with no closing ' on its line | Characters |
| ZK0106 | unknown {...} or \ escape | Characters |
| ZK0107 | a character literal with more than one character | Characters |
| ZK0108 | a name in backticks with no closing backtick on its line | Names |
| ZK0109 | a name in backticks with nothing between them | Names |
ZK02: reading the sentences
| Code | Problem | See |
|---|---|---|
| ZK0201 | something unexpected, often a missing ။ | Hello, world |
| ZK0202 | a value is missing where one was expected | |
| ZK0203 | the statement does not end in a verb such as ပြသပါ | Grouping and order |
| ZK0204 | a logical expression printed without parentheses | Logic |
| ZK0205 | a verb is missing one of its parts | Particles |
| ZK0206 | wrong or missing particle, often a name joined to ကို | Spaces between words |
| ZK0207 | two particles in a row after one operand | Particles |
| ZK0208 | operands left waiting for a verb at the end of a clause | Particles |
| ZK0209 | operands left over before a statement verb | Particles |
| ZK0210 | a comparison inside a comparison | Comparison |
| ZK0211 | သို့မဟုတ်ပါက without an အကယ်၍ before it | If and else |
| ZK0212 | the ပြီးလျှင် update outside a generic loop | Generic loops |
| ZK0213 | the ပြီးလျှင် update is not last | Generic loops |
| ZK0214 | a function declared inside a block or function | Functions |
| ZK0215 | an if as the one-statement inner block of an if | If and else |
| ZK0216 | a bit count that the kind does not have, such as ၁၀ ဘစ် ကိန်းပြည့် | Integers |
| ZK0217 | a sign word before a kind that is not an integer | Integers |
| ZK0218 | a number base that is not a whole number from 2 to 36 | Writing integers |
| ZK0219 | a digit too big for the number base | Writing integers |
| ZK0220 | a number too big for its kind | Integers |
| ZK0221 | a fraction or exponent in a literal that is given an integer kind | Writing integers |
| ZK0222 | a character or true/false kind written before a number | Writing integers |
| ZK0223 | text in quotes used somewhere other than printing | Text in quotes |
| ZK0225 | a generic loop that starts with ကိန်းသေ | Generic loops |
| ZK0226 | a block closer with no block to close | Blocks and scope |
| ZK0227 | a list count that is not a whole number above zero | Lists |
ZK03: names
| Code | Problem | See |
|---|---|---|
| ZK0301 | a name that was never declared, or is out of scope | Blocks and scope |
| ZK0302 | the same name declared twice in one block | Names |
| ZK0303 | calling a function that does not exist | Functions |
| ZK0304 | two functions with one name | Functions |
| ZK0305 | two parameters of one function with one name | Parameters |
| ZK0306 | changing a constant | Constants |
| ZK0307 | changing a counted loop's counter | Counted loops |
| ZK0308 | a constant without a value | Constants |
| ZK0309 | a break outside a loop | Break and continue |
| ZK0310 | a continue outside a loop | Break and continue |
| ZK0311 | ပြန်ပေးပါ outside a function | Functions |
| ZK0312 | returning a value from a function without a result | Results |
| ZK0313 | returning without a value from a function with a result | Results |
| ZK0314 | the wrong number of arguments | Parameters |
| ZK0315 | using a function without a result as a value | Results |
ZK04: kinds
| Code | Problem | See |
|---|---|---|
| ZK0401 | a value of the wrong kind for a variable or parameter | Converting between kinds |
| ZK0402 | a condition that is not true/false | If and else |
| ZK0403 | an operator used on the wrong kind, such as မှန် + ၁ | Arithmetic |
| ZK0404 | two kinds that cannot be combined without a conversion | Arithmetic |
| ZK0405 | a counted-loop bound or step that is not an integer | Counted loops |
| ZK0406 | a number too big for the variable's kind | Integers |
| ZK0407 | a shift wider than the kind's bit count | Bitwise operators |
| ZK0408 | a conversion that is not allowed | Converting between kinds |
| ZK0409 | a counted-loop step that is zero or less | Counted loops |
| ZK0410 | an invalid assignment target: not a variable or a dereference | Changing a variable |
| ZK0411 | no address: taking the address of something that is not a variable or a dereference | Pointers and the heap |
| ZK0412 | taking the address of a fixed name: a constant or a counted-loop variable | Pointers and the heap |
| ZK0413 | not a pointer: dereferencing a value that has no pointer kind | Pointer mistakes |
| ZK0414 | an opaque pointer (လိပ်စာ) dereferenced or offset before a conversion | Pointer arithmetic |
| ZK0415 | an operator not for pointers, such as * or / on an address | Pointer arithmetic |
| ZK0416 | pointer kinds differ: comparing or subtracting pointers to different kinds | Pointer arithmetic |
| ZK0417 | a heap statement that needs a pointer but was given another kind | The heap |
| ZK0419 | a list literal with more or fewer cells than its kind | List mistakes |
| ZK0420 | စာရင်းအလွတ် where no list kind is known | List mistakes |
| ZK0421 | a list kind with no count where nothing gives one | List mistakes |
| ZK0422 | cells of a value that is no list | List mistakes |
| ZK0423 | a cell number that is not an integer | Lists |
| ZK0424 | a list as a function result | Passing and comparing lists |
| ZK0425 | a list kind too large for the VM | Lists of lists |
ZK05: natural Zaka (warnings)
These are warnings: the program runs. With --strict-particles each one is an error.
See Natural Zaka and Natural wording.
| Code | Problem | See |
|---|---|---|
| ZK0501 | a "not" verb before သို့မဟုတ် ends in သည် instead of ပါ | Natural Zaka |
| ZK0502 | a particle between a verb and an attached လျှင် or နေသရွေ့ | Natural Zaka |
| ZK0503 | မဟုတ် with သည် | Natural Zaka |
| ZK0504 | ပါ on a verb before ဖြစ်၍ | Natural Zaka |
| ZK0505 | a sentence or text printed with ကို instead of ဟု | Natural Zaka |
| ZK0506 | a plain value printed with ဟု instead of ကို | Natural Zaka |
| ZK0507 | parentheses that change nothing | Natural Zaka |
| ZK0508 | a sentence used as a value that ends in ပါ | Natural Zaka |
ZK06: working out constants
| Code | Problem | See |
|---|---|---|
| ZK0601 | a sum of constants that does not fit its kind | Arithmetic |
| ZK0602 | a constant zero as the divisor | Arithmetic |
| ZK0603 | a constant cell number outside its list | List mistakes |
ZK07: ownership and borrowing
The check of ownership and borrowing. With --mem-check warn,
ZK0701 to ZK0704 and ZK0706 to ZK0712 are warnings and the program runs; with
--mem-check off, the compiler leaves them out. The others are errors in each mode. See
Pointer checks.
| Code | Problem | See |
|---|---|---|
| ZK0701 | using an owner after its block moved to another owner | Ownership and borrowing |
| ZK0702 | giving back or resizing a block through a borrow | Pointer mistakes |
| ZK0703 | a borrow kept in a heap block, behind a pointer, or in a top-level variable from a function | Ownership and borrowing |
| ZK0704 | giving back, resizing or moving a block while a borrow of it is still in use | Pointer mistakes |
| ZK0705 | the address of a borrow | Ownership and borrowing |
| ZK0706 | a function that returns a borrow of its own variable | Changing the caller's variables |
| ZK0707 | a call that can give back a block through one argument while another argument reaches it | Pointer mistakes |
| ZK0708 | a block lost before it is given back | Pointer mistakes |
| ZK0709 | reading or writing through a pointer that is ဗလာ | Pointer mistakes |
| ZK0710 | a box or cell number past the end of its block | Pointer mistakes |
| ZK0711 | a warning, with --mem-strict alone: a pointer that can be ဗလာ | Ownership and borrowing |
| ZK0712 | subtracting pointers into different blocks | Pointer mistakes |
| ZK0713 | ငှားထားသော in the wrong place in a pointer kind | Ownership and borrowing |
| ZK0714 | a borrow given where an owner is wanted | Ownership and borrowing |
| ZK0715 | an owner given where a borrow is wanted | Ownership and borrowing |
| ZK0716 | a raw address lent with တန်ဖိုးအငှား | Ownership and borrowing |
| ZK0717 | a raw address kind under --no-raw | Ownership and borrowing |