[
{"code":"E0001","message":"A character that starts no token, such as `$`. Spans the character.","machine_fix":false,"machine_fix_description":null,"example":"fn main() {\n    let x = $\n}\n","fix":"fn main() {\n    let x = 1\n}\n"},
{"code":"E0002","message":"A string literal that is not closed before the end of the file. Spans the literal from its opening quote.","machine_fix":false,"machine_fix_description":null,"example":"fn main() {\n    let greeting = \"hello\n}\n","fix":"fn main() {\n    let greeting = \"hello\"\n}\n"},
{"code":"E0003","message":"An invalid escape in a string: a backslash followed by anything but one of the escapes. Spans the backslash.","machine_fix":false,"machine_fix_description":null,"example":"fn main() {\n    let path = \"C:\\data\"\n}\n","fix":"fn main() {\n    let path = \"C:\\\\data\"\n}\n"},
{"code":"E0004","message":"A `{` or `}` in a sink literal such as `sql\"...\"`, which never interpolates. Write `\\{` or `\\}` for a literal brace.","machine_fix":false,"machine_fix_description":null,"example":"use std.sql\n\nfn main() {\n    let query = sql\"SELECT {id}\"\n}\n","fix":"use std.sql\n\nfn main() {\n    let query = sql\"SELECT 1\"\n}\n"},
{"code":"E0005","message":"A `;`: Oska has no semicolons, because a line break ends a statement.","machine_fix":true,"machine_fix_description":"Remove the `;` when it ends a line.","example":"fn main() {\n    let x = 1;\n}\n","fix":"fn main() {\n    let x = 1\n}\n"},
{"code":"E0100","message":"The parser expected an expression, a type, or a pattern and found something else.","machine_fix":false,"machine_fix_description":null,"example":"fn main() {\n    let x = )\n}\n","fix":"fn main() {\n    let x = 1\n}\n"},
{"code":"E0101","message":"The parser expected a specific token, such as a `)`, and found another. The message names it. Items must also be separated by a line break, so two items on one line give this code.","machine_fix":false,"machine_fix_description":null,"example":"fn first() {} fn second() {}\n","fix":"fn first() {}\nfn second() {}\n"},
{"code":"E0102","message":"A `{...}` hole in a string that holds more than a name or a field path, such as `{n + 1}`. Compute the value with `let` first.","machine_fix":false,"machine_fix_description":null,"example":"fn main() {\n    let n = 1\n    let text = \"next is {n + 1}\"\n}\n","fix":"fn main() {\n    let n = 1\n    let next = n + 1\n    let text = \"next is {next}\"\n}\n"},
{"code":"E0103","message":"A bare `{ ... }` block used as a statement.","machine_fix":false,"machine_fix_description":null,"example":"fn main() {\n    {\n        let x = 1\n    }\n}\n","fix":"fn main() {\n    let x = 1\n}\n"},
{"code":"E0104","message":"A `let` or `var` without an initializer.","machine_fix":false,"machine_fix_description":null,"example":"fn main() {\n    let x\n}\n","fix":"fn main() {\n    let x = 0\n}\n"},
{"code":"E0105","message":"A chained comparison such as `a < b < c`. Comparison operators do not chain.","machine_fix":false,"machine_fix_description":null,"example":"fn main() {\n    let a = 1\n    let ok = 0 < a < 3\n}\n","fix":"fn main() {\n    let a = 1\n    let ok = 0 < a && a < 3\n}\n"},
{"code":"E0106","message":"An assignment whose left side is not a name or a field path, such as `x + 1 = 2`.","machine_fix":false,"machine_fix_description":null,"example":"fn main() {\n    var x = 1\n    x + 1 = 2\n}\n","fix":"fn main() {\n    var x = 1\n    x = 2\n}\n"},
{"code":"E0107","message":"A statement at module level, where only items are allowed.","machine_fix":false,"machine_fix_description":null,"example":"let x = 1\n\nfn main() {}\n","fix":"fn main() {\n    let x = 1\n}\n"},
{"code":"E0110","message":"An `ensures` clause without a `|r|` binding for the return value.","machine_fix":false,"machine_fix_description":null,"example":"fn double(n: Int) -> Int\n    ensures r > 0\n{\n    n * 2\n}\n","fix":"fn double(n: Int) -> Int\n    ensures |r| r > 0\n{\n    n * 2\n}\n"},
{"code":"E0111","message":"A `self` or `var self` receiver that is not the first parameter.","machine_fix":false,"machine_fix_description":null,"example":"struct Counter { count: Int }\n\nimpl Counter {\n    fn add(n: Int, self) -> Int {\n        self.count + n\n    }\n}\n","fix":"struct Counter { count: Int }\n\nimpl Counter {\n    fn add(self, n: Int) -> Int {\n        self.count + n\n    }\n}\n"},
{"code":"E0112","message":"`var` on a parameter other than the `self` receiver. A parameter is always an immutable binding.","machine_fix":true,"machine_fix_description":"Remove `var`.","example":"fn bump(var n: Int) -> Int {\n    n + 1\n}\n","fix":"fn bump(n: Int) -> Int {\n    n + 1\n}\n"},
{"code":"E0113","message":"A `where` clause. Bounds are written inline, as in `fn f<T: Eq>(x: T)`.","machine_fix":false,"machine_fix_description":null,"example":"fn same<T>(a: T, b: T) -> Bool where T: Eq {\n    a == b\n}\n","fix":"fn same<T: Eq>(a: T, b: T) -> Bool {\n    a == b\n}\n"},
{"code":"E0120","message":"A missing comma between the declared fields of a struct or the variants of an enum.","machine_fix":true,"machine_fix_description":"Insert the `,`.","example":"struct Point {\n    x: Int\n    y: Int\n}\n","fix":"struct Point {\n    x: Int,\n    y: Int\n}\n"},
{"code":"E0130","message":"A glob import such as `use std.sql.*`. Name what you import.","machine_fix":false,"machine_fix_description":null,"example":"use std.html.*\n\nfn main() {}\n","fix":"use std.html.{text}\n\nfn main() {}\n"},
{"code":"E0131","message":"A renaming import such as `use std.sql.query as q`.","machine_fix":false,"machine_fix_description":null,"example":"use std.html.text as escape\n\nfn main() {}\n","fix":"use std.html.{text}\n\nfn main() {}\n"},
{"code":"E0132","message":"An attribute name outside the fixed set, which holds only `integration`.","machine_fix":false,"machine_fix_description":null,"example":"#[integation]\ntest \"reads a file\" {\n    t.assert(true)\n}\n","fix":"#[integration]\ntest \"reads a file\" {\n    t.assert(true)\n}\n"},
{"code":"E0133","message":"`unsafe`, which Oska does not have.","machine_fix":false,"machine_fix_description":null,"example":"unsafe fn dangerous() {}\n","fix":"fn safe() {}\n"},
{"code":"E0140","message":"An or-pattern such as `A | B`. Write one arm for each.","machine_fix":false,"machine_fix_description":null,"example":"fn name(n: Int) -> String {\n    match n {\n        1 | 2 => \"small\"\n        _ => \"big\"\n    }\n}\n","fix":"fn name(n: Int) -> String {\n    match n {\n        1 => \"small\"\n        2 => \"small\"\n        _ => \"big\"\n    }\n}\n"},
{"code":"E0141","message":"A range pattern such as `1..5`.","machine_fix":false,"machine_fix_description":null,"example":"fn name(n: Int) -> String {\n    match n {\n        1..5 => \"small\"\n        _ => \"big\"\n    }\n}\n","fix":"fn name(n: Int) -> String {\n    match n {\n        _ => if n < 5 { \"small\" } else { \"big\" }\n    }\n}\n"},
{"code":"E0142","message":"An `@` binding such as `v @ Some(_)`.","machine_fix":false,"machine_fix_description":null,"example":"fn show(x: Option<Int>) -> Int {\n    match x {\n        v @ Some(_) => 1\n        None => 0\n    }\n}\n","fix":"fn show(x: Option<Int>) -> Int {\n    match x {\n        Some(_) => 1\n        None => 0\n    }\n}\n"},
{"code":"E0143","message":"A comma between `match` arms. Each arm sits on its own line.","machine_fix":true,"machine_fix_description":"Remove the `,` when the next arm is already on its own line.","example":"fn show(x: Option<Int>) -> Int {\n    match x {\n        Some(_) => 1,\n        None => 0\n    }\n}\n","fix":"fn show(x: Option<Int>) -> Int {\n    match x {\n        Some(_) => 1\n        None => 0\n    }\n}\n"},
{"code":"E0150","message":"A `self` or `var self` receiver on a function outside an `impl` or `trait` block.","machine_fix":false,"machine_fix_description":null,"example":"fn size(self) -> Int {\n    1\n}\n","fix":"struct Box { n: Int }\n\nimpl Box {\n    fn size(self) -> Int {\n        1\n    }\n}\n"},
{"code":"E0151","message":"`pub` on an `impl` block. Mark its methods `pub` instead.","machine_fix":true,"machine_fix_description":"Remove `pub`.","example":"struct Box { n: Int }\n\npub impl Box {\n    fn size(self) -> Int {\n        1\n    }\n}\n","fix":"struct Box { n: Int }\n\nimpl Box {\n    pub fn size(self) -> Int {\n        1\n    }\n}\n"},
{"code":"E0160","message":"A string pattern with an interpolation hole. A pattern is a plain literal.","machine_fix":false,"machine_fix_description":null,"example":"fn greet(name: String) -> Int {\n    match name {\n        \"hi {name}\" => 1\n        _ => 0\n    }\n}\n","fix":"fn greet(name: String) -> Int {\n    match name {\n        \"hi\" => 1\n        _ => 0\n    }\n}\n"},
{"code":"E0161","message":"A test name with an interpolation hole.","machine_fix":false,"machine_fix_description":null,"example":"test \"adds {n}\" {\n    t.assert(true)\n}\n","fix":"test \"adds\" {\n    t.assert(true)\n}\n"},
{"code":"E0162","message":"`pub` on a trait method. A trait method takes its visibility from the trait.","machine_fix":true,"machine_fix_description":"Remove `pub`.","example":"trait Show {\n    pub fn show(self) -> String\n}\n","fix":"trait Show {\n    fn show(self) -> String\n}\n"},
{"code":"E0163","message":"`pub test`. A test is never exported.","machine_fix":true,"machine_fix_description":"Remove `pub`.","example":"pub test \"adds\" {\n    t.assert(true)\n}\n","fix":"test \"adds\" {\n    t.assert(true)\n}\n"},
{"code":"E0164","message":"`pub use`. A re-export is not defined.","machine_fix":true,"machine_fix_description":"Remove `pub`.","example":"pub use std.html\n\nfn main() {}\n","fix":"use std.html\n\nfn main() {}\n"},
{"code":"E0165","message":"`#[integration]` on an item other than a `test`.","machine_fix":false,"machine_fix_description":null,"example":"#[integration]\nfn setup() {}\n","fix":"#[integration]\ntest \"setup\" {\n    t.assert(true)\n}\n"},
{"code":"E0170","message":"`#[capability]` on an item other than a `struct`, in the prelude. In user code the attribute is `E0132` instead: no program can reach this code, so it has no example.","machine_fix":true,"machine_fix_description":"Remove the attribute.","example":null,"fix":null},
{"code":"E0200","message":"Unknown type or trait name, or a qualified path such as `sql.Query` whose first segment is not a module bound by a plain `use`.","machine_fix":true,"machine_fix_description":"Replace the name with the single closest declared name, when one is close enough.","example":"fn greet(name: Strng) {}\n","fix":"fn greet(name: String) {}\n"},
{"code":"E0201","message":"A trait where a type is expected (`x: Display`), or a type where a trait is expected (`T: Int`).","machine_fix":false,"machine_fix_description":null,"example":"fn show(x: Display) {}\n","fix":"fn show<T: Display>(x: T) {}\n"},
{"code":"E0202","message":"A type or trait name declared twice in the module, or one that redeclares a prelude name; a free function declared twice, or one that redeclares a prelude function (`dbg`, `todo`); or a method or associated function declared twice for one type, across all of its inherent `impl` blocks. Spans the second declaration's name.","machine_fix":false,"machine_fix_description":null,"example":"fn helper() {}\n\nfn helper() {}\n","fix":"fn helper() {}\n\nfn other_helper() {}\n"},
{"code":"E0210","message":"A struct or enum whose own fields name a capability-bearing type (a built-in capability, a `cap` type, or a `cap fn`, including inside written type arguments such as `List<Stdout>`) is not declared `cap`. A field typed by a type parameter, as in `struct Box<T> { value: T }`, does not count. Spans the type's name.","machine_fix":true,"machine_fix_description":"Insert `cap` before `struct` or `enum`.","example":"struct Logger { out: Stdout }\n","fix":"cap struct Logger { out: Stdout }\n"},
{"code":"E0211","message":"A `main` parameter whose type is not a built-in capability or `Args`. Spans the parameter's type.","machine_fix":false,"machine_fix_description":null,"example":"fn main(count: Int) {}\n","fix":"fn main(io: Stdout) {}\n"},
{"code":"E0212","message":"`main` returns something other than `()` or `Result<(), E>` (spans the return type), or `E` has no `impl Display` (spans `E`).","machine_fix":false,"machine_fix_description":null,"example":"fn main() -> Int {\n    0\n}\n","fix":"fn main() {}\n"},
{"code":"E0213","message":"A type, enum variant, trait, or type parameter name that does not start with an uppercase letter (ADR 0005).","machine_fix":false,"machine_fix_description":null,"example":"struct point { x: Int }\n","fix":"struct Point { x: Int }\n"},
{"code":"E0214","message":"A function, method, field, parameter, or local variable (`let`, `var`, `for`) name that starts with an uppercase letter (ADR 0005). A leading `_` is allowed. Pattern bindings need no check: an uppercase name in a pattern is a variant (`E0250`).","machine_fix":false,"machine_fix_description":null,"example":"fn Double(n: Int) -> Int {\n    n * 2\n}\n","fix":"fn double(n: Int) -> Int {\n    n * 2\n}\n"},
{"code":"E0215","message":"A struct or enum with no base case: every way to build it contains itself, as in `struct Loop { me: Loop }`. Recursion through `Option`, `List`, or an enum variant without the type needs no indirection. Each type in a cycle is reported.","machine_fix":false,"machine_fix_description":null,"example":"struct Loop { me: Loop }\n","fix":"struct Node { next: Option<Node> }\n"},
{"code":"E0216","message":"A call to `dbg(...)` when checking with `--release`. Spans the call.","machine_fix":true,"machine_fix_description":"Replace `dbg(expr)` with `expr`, when it has one argument.","example":"fn main() {\n    let x = dbg(1)\n}\n","fix":"fn main() {\n    let x = 1\n}\n"},
{"code":"E0217","message":"A `main` parameter whose type is a directory or file capability: `Dir`, `DirRead`, `DirWrite`, `FileRead`, or `FileWrite`. Only attenuation makes one, with `restrict_to` or `restrict_to_file` on `Fs`, `FsRead`, or `FsWrite`, because the runtime has no root to give. Spans the parameter's type.","machine_fix":false,"machine_fix_description":null,"example":"fn main(docs: DirRead) {}\n","fix":"fn main(fs: FsRead) {\n    let docs = fs.restrict_to(\"docs\")\n}\n"},
{"code":"E0218","message":"A `requires` or `ensures` clause on a method of `impl Trait for Type`. A trait method's contract lives on the trait's declaration and binds every impl, however it is called, so an impl declares none of its own: move the clause to the trait. A method of an inherent `impl` keeps its contract. Spans the clause.","machine_fix":false,"machine_fix_description":null,"example":"trait Shape {\n    fn size(self) -> Int\n}\n\nstruct Square { side: Int }\n\nimpl Shape for Square {\n    fn size(self) -> Int\n        ensures |r| r > 0\n    {\n        self.side\n    }\n}\n","fix":"trait Shape {\n    fn size(self) -> Int\n        ensures |r| r > 0\n}\n\nstruct Square { side: Int }\n\nimpl Shape for Square {\n    fn size(self) -> Int {\n        self.side\n    }\n}\n"},
{"code":"E0219","message":"A `requires` or `ensures` clause on `main`. Nothing in the program calls `main`, so there is no caller to blame for a false `requires`; check the condition in the body. Spans the clause.","machine_fix":false,"machine_fix_description":null,"example":"fn main()\n    requires 1 > 0\n{\n}\n","fix":"fn main() {\n    let ready = 1 > 0\n}\n"},
{"code":"E0220","message":"Type mismatch: an expression's type differs from the type expected there. There are no implicit conversions.","machine_fix":false,"machine_fix_description":null,"example":"fn main() {\n    let x: Int = \"one\"\n}\n","fix":"fn main() {\n    let x: Int = 1\n}\n"},
{"code":"E0221","message":"Unknown value name, or `self` outside a method with a receiver.","machine_fix":true,"machine_fix_description":"Replace the name with the single closest local, function, or prelude variant, when one is close enough.","example":"fn main() {\n    let count = 1\n    let total = cuont + 1\n}\n","fix":"fn main() {\n    let count = 1\n    let total = count + 1\n}\n"},
{"code":"E0222","message":"Integer literal out of range for its type, such as `300` as a `U8`.","machine_fix":false,"machine_fix_description":null,"example":"fn main() {\n    let x: U8 = 300\n}\n","fix":"fn main() {\n    let x: U8 = 200\n}\n"},
{"code":"E0223","message":"Operator not defined for its operand's type: arithmetic and ordering need numbers (`+` is not for strings), unary `-` needs a signed number, `..` needs integers.","machine_fix":false,"machine_fix_description":null,"example":"fn main() {\n    let text = \"a\" + \"b\"\n}\n","fix":"fn main() {\n    let a = \"a\"\n    let b = \"b\"\n    let text = \"{a}{b}\"\n}\n"},
{"code":"E0224","message":"Wrong number of arguments in a call or construction.","machine_fix":false,"machine_fix_description":null,"example":"fn add(a: Int, b: Int) -> Int {\n    a + b\n}\n\nfn main() {\n    let n = add(1)\n}\n","fix":"fn add(a: Int, b: Int) -> Int {\n    a + b\n}\n\nfn main() {\n    let n = add(1, 2)\n}\n"},
{"code":"E0225","message":"Argument label that does not match its parameter or field, or a label on a positional field.","machine_fix":true,"machine_fix_description":"Replace the label with the parameter's name, or remove it.","example":"fn add(a: Int, b: Int) -> Int {\n    a + b\n}\n\nfn main() {\n    let n = add(x: 1, b: 2)\n}\n","fix":"fn add(a: Int, b: Int) -> Int {\n    a + b\n}\n\nfn main() {\n    let n = add(a: 1, b: 2)\n}\n"},
{"code":"E0226","message":"Named field constructed without its label.","machine_fix":true,"machine_fix_description":"Insert the field's label.","example":"struct Point { x: Int, y: Int }\n\nfn main() {\n    let p = Point(1, 2)\n}\n","fix":"struct Point { x: Int, y: Int }\n\nfn main() {\n    let p = Point(x: 1, y: 2)\n}\n"},
{"code":"E0227","message":"Unknown field, or a method used without calling it.","machine_fix":true,"machine_fix_description":"Replace the field with the single closest field, when one is close enough.","example":"struct Point { x: Int, y: Int }\n\nfn main() {\n    let p = Point(x: 1, y: 2)\n    let z = p.z\n}\n","fix":"struct Point { x: Int, y: Int }\n\nfn main() {\n    let p = Point(x: 1, y: 2)\n    let z = p.x\n}\n"},
{"code":"E0228","message":"Unknown method, variant, or associated function, or an associated function called on a value.","machine_fix":true,"machine_fix_description":"Replace the name with the single closest member, when one is close enough.","example":"fn main() {\n    let t = \"  hi \".trimm()\n}\n","fix":"fn main() {\n    let t = \"  hi \".trim()\n}\n"},
{"code":"E0229","message":"Assignment to something that is not a `var` binding: a `let` binding, a parameter, or a field of `self` in a method without `var self`.","machine_fix":true,"machine_fix_description":"Change `let` to `var`, or `self` to `var self`. None for parameters.","example":"fn main() {\n    let x = 1\n    x = 2\n}\n","fix":"fn main() {\n    var x = 1\n    x = 2\n}\n"},
{"code":"E0230","message":"Mutating method (`var self`) called on something that is not a `var` binding.","machine_fix":true,"machine_fix_description":"Change `let` to `var`, or `self` to `var self`.","example":"struct Counter { count: Int }\n\nimpl Counter {\n    fn tick(var self) {\n        self.count = self.count + 1\n    }\n}\n\nfn main() {\n    let c = Counter(count: 0)\n    c.tick()\n}\n","fix":"struct Counter { count: Int }\n\nimpl Counter {\n    fn tick(var self) {\n        self.count = self.count + 1\n    }\n}\n\nfn main() {\n    var c = Counter(count: 0)\n    c.tick()\n}\n"},
{"code":"E0231","message":"Call of a value that is not a function.","machine_fix":false,"machine_fix_description":null,"example":"fn main() {\n    let x = 1\n    x()\n}\n","fix":"fn main() {\n    let f = || 1\n    let y = f()\n}\n"},
{"code":"E0232","message":"`break` or `continue` outside a loop.","machine_fix":false,"machine_fix_description":null,"example":"fn main() {\n    break\n}\n","fix":"fn main() {\n    while true {\n        break\n    }\n}\n"},
{"code":"E0233","message":"A type that inference cannot work out, such as `let xs = List.new()` with no later use.","machine_fix":false,"machine_fix_description":null,"example":"fn main() {\n    let xs = List.new()\n}\n","fix":"fn main() {\n    let xs: List<Int> = List.new()\n}\n"},
{"code":"E0234","message":"A type name used as a value, or a type that cannot be constructed.","machine_fix":false,"machine_fix_description":null,"example":"fn main() {\n    let x = Int\n}\n","fix":"fn main() {\n    let x = 1\n}\n"},
{"code":"E0235","message":"`for` over a value that is not a `List` or a range.","machine_fix":false,"machine_fix_description":null,"example":"fn main() {\n    for i in 5 {\n        let j = i\n    }\n}\n","fix":"fn main() {\n    for i in 0..5 {\n        let j = i\n    }\n}\n"},
{"code":"E0240","message":"An expression statement whose `Result` value is dropped. Discard one deliberately with `let _ = f()`. Spans the expression.","machine_fix":false,"machine_fix_description":null,"example":"fn main(io: Stdout) -> Result<(), IoError> {\n    io.println(\"hi\")\n    Ok(())\n}\n","fix":"fn main(io: Stdout) -> Result<(), IoError> {\n    io.println(\"hi\")?\n    Ok(())\n}\n"},
{"code":"E0241","message":"`?` on a value that is neither a `Result` nor an `Option`. Spans the `?` expression.","machine_fix":false,"machine_fix_description":null,"example":"fn first() -> Option<Int> {\n    let n = 1?\n    Some(n)\n}\n","fix":"fn first() -> Option<Int> {\n    let n = 1\n    Some(n)\n}\n"},
{"code":"E0242","message":"`?` on a `Result` whose error type is not the enclosing function's error type, with no `impl From` to convert it. Spans the `?` expression.","machine_fix":false,"machine_fix_description":null,"example":"fn parse() -> Result<Int, String> {\n    Err(\"bad\")\n}\n\nfn run() -> Result<Int, Int> {\n    let n = parse()?\n    Ok(n)\n}\n","fix":"fn parse() -> Result<Int, String> {\n    Err(\"bad\")\n}\n\nfn run() -> Result<Int, String> {\n    let n = parse()?\n    Ok(n)\n}\n"},
{"code":"E0243","message":"`?` in a function (or closure) that does not return the same kind: an `Option` in a function returning `Result` (convert with `.ok_or(err)?`), a `Result` in one returning `Option`, or either in one returning neither. Spans the `?` expression.","machine_fix":false,"machine_fix_description":null,"example":"fn double(x: Option<Int>) -> Result<Int, String> {\n    let n = x?\n    Ok(n * 2)\n}\n","fix":"fn double(x: Option<Int>) -> Result<Int, String> {\n    let n = x.ok_or(\"missing\")?\n    Ok(n * 2)\n}\n"},
{"code":"E0250","message":"A pattern that names no variant or struct. Under ADR 0005 an uppercase name in a pattern is always a fieldless variant, never a binding, so a misspelled `Nnoe` is an error rather than a catch-all. Bare names are the prelude's variants (`None`, `Some`, `Ok`, `Err`); other variants are written `Enum.Variant`. Spans the name.","machine_fix":true,"machine_fix_description":"Replace the name with the single closest variant, qualified when it belongs to a user enum (`Empty` becomes `Shape.Empty`).","example":"fn count(x: Option<Int>) -> Int {\n    match x {\n        Some(n) => n\n        Nnoe => 0\n    }\n}\n","fix":"fn count(x: Option<Int>) -> Int {\n    match x {\n        Some(n) => n\n        None => 0\n    }\n}\n"},
{"code":"E0251","message":"A constructor pattern with the wrong number of fields, such as `Some` or `Shape.Square(a, b)`. Spans the pattern.","machine_fix":false,"machine_fix_description":null,"example":"fn count(x: Option<Int>) -> Int {\n    match x {\n        Some => 1\n        None => 0\n    }\n}\n","fix":"fn count(x: Option<Int>) -> Int {\n    match x {\n        Some(_) => 1\n        None => 0\n    }\n}\n"},
{"code":"E0252","message":"A named field matched without its label (`Shape.Circle(r)`) or with the wrong one, or a label on a positional field.","machine_fix":true,"machine_fix_description":"Insert, correct, or remove the label.","example":"enum Shape {\n    Circle { radius: Int },\n    Empty,\n}\n\nfn size(s: Shape) -> Int {\n    match s {\n        Shape.Circle(r) => r\n        Shape.Empty => 0\n    }\n}\n","fix":"enum Shape {\n    Circle { radius: Int },\n    Empty,\n}\n\nfn size(s: Shape) -> Int {\n    match s {\n        Shape.Circle(radius: r) => r\n        Shape.Empty => 0\n    }\n}\n"},
{"code":"E0253","message":"A `match` that is not exhaustive, checked with the pattern-usefulness algorithm through nested constructor patterns. Guarded arms never count. `Int` and `String` matches need a `_` or binding arm. Spans the scrutinee; the message lists the missing patterns.","machine_fix":true,"machine_fix_description":"Add an arm for each missing pattern after the last arm, with `todo()` as its body.","example":"fn count(x: Option<Int>) -> Int {\n    match x {\n        Some(n) => n\n    }\n}\n","fix":"fn count(x: Option<Int>) -> Int {\n    match x {\n        Some(n) => n\n        None => 0\n    }\n}\n"},
{"code":"E0254","message":"An unreachable arm: the earlier unguarded arms already match every value it does, as with any arm after a `_` or binding arm. Spans the arm's pattern.","machine_fix":false,"machine_fix_description":null,"example":"fn count(x: Option<Int>) -> Int {\n    match x {\n        _ => 0\n        Some(n) => n\n    }\n}\n","fix":"fn count(x: Option<Int>) -> Int {\n    match x {\n        Some(n) => n\n        _ => 0\n    }\n}\n"},
{"code":"E0260","message":"A method called on a value of a generic parameter whose bounds provide no method of that name. A generic body is checked once, against its bounds only. Spans the method name.","machine_fix":true,"machine_fix_description":"Add the bound, when exactly one trait has the method.","example":"trait Measure {\n    fn size(self) -> Int\n}\n\nfn total<T>(x: T) -> Int {\n    x.size()\n}\n","fix":"trait Measure {\n    fn size(self) -> Int\n}\n\nfn total<T: Measure>(x: T) -> Int {\n    x.size()\n}\n"},
{"code":"E0261","message":"An `impl Trait for Type` that leaves out a required method (one without a default body). Spans the trait in the `impl`.","machine_fix":true,"machine_fix_description":"Insert a stub for each missing method before the `impl`'s closing brace, with the trait's signature (`Self` replaced) and `todo()` as its body. None when a missing method has generic parameters of its own.","example":"trait Shape {\n    fn area(self) -> Int\n    fn name(self) -> String\n}\n\nstruct Square { side: Int }\n\nimpl Shape for Square {\n    fn area(self) -> Int {\n        self.side * self.side\n    }\n}\n","fix":"trait Shape {\n    fn area(self) -> Int\n    fn name(self) -> String\n}\n\nstruct Square { side: Int }\n\nimpl Shape for Square {\n    fn area(self) -> Int {\n        self.side * self.side\n    }\n    fn name(self) -> String {\n        \"square\"\n    }\n}\n"},
{"code":"E0262","message":"An `impl` method whose signature differs from the trait's, once `Self` and the trait's arguments are replaced. Receiver, parameter types, and return type must all match. Spans the method name.","machine_fix":false,"machine_fix_description":null,"example":"trait Shape {\n    fn area(self) -> Int\n}\n\nstruct Square { side: Int }\n\nimpl Shape for Square {\n    fn area(self) -> String {\n        \"big\"\n    }\n}\n","fix":"trait Shape {\n    fn area(self) -> Int\n}\n\nstruct Square { side: Int }\n\nimpl Shape for Square {\n    fn area(self) -> Int {\n        self.side * self.side\n    }\n}\n"},
{"code":"E0263","message":"An `impl Trait` method that the trait does not declare. Spans the method name.","machine_fix":false,"machine_fix_description":null,"example":"trait Shape {\n    fn area(self) -> Int\n}\n\nstruct Square { side: Int }\n\nimpl Shape for Square {\n    fn area(self) -> Int {\n        self.side * self.side\n    }\n    fn name(self) -> String {\n        \"square\"\n    }\n}\n","fix":"trait Shape {\n    fn area(self) -> Int\n}\n\nstruct Square { side: Int }\n\nimpl Shape for Square {\n    fn area(self) -> Int {\n        self.side * self.side\n    }\n}\n\nimpl Square {\n    fn name(self) -> String {\n        \"square\"\n    }\n}\n"},
{"code":"E0264","message":"A method call that two or more of the receiver's traits (or a parameter's bounds) provide, when the type's own `impl` does not. Spans the method name. Call it qualified instead: `Display.to_string(x)`.","machine_fix":false,"machine_fix_description":null,"example":"trait Short {\n    fn describe(self) -> String\n}\n\ntrait Long {\n    fn describe(self) -> String\n}\n\nstruct Cat { name: String }\n\nimpl Short for Cat {\n    fn describe(self) -> String {\n        \"cat\"\n    }\n}\n\nimpl Long for Cat {\n    fn describe(self) -> String {\n        \"a cat\"\n    }\n}\n\nfn show(c: Cat) -> String {\n    c.describe()\n}\n","fix":"trait Short {\n    fn describe(self) -> String\n}\n\ntrait Long {\n    fn describe(self) -> String\n}\n\nstruct Cat { name: String }\n\nimpl Short for Cat {\n    fn describe(self) -> String {\n        \"cat\"\n    }\n}\n\nimpl Long for Cat {\n    fn describe(self) -> String {\n        \"a cat\"\n    }\n}\n\nfn show(c: Cat) -> String {\n    Short.describe(c)\n}\n"},
{"code":"E0265","message":"A type that does not implement a trait it must: `==` and `!=` need `Eq`; a call must satisfy the callee's bounds; a qualified call `Trait.method(x)` needs `x`'s type to implement `Trait`; an interpolation hole needs `Display`. Spans the operator expression, the call, or the hole.","machine_fix":true,"machine_fix_description":"On a generic parameter of the enclosing function, add the bound.","example":"struct Point { x: Int }\n\nfn main() {\n    let a = Point(x: 1)\n    let b = Point(x: 1)\n    let same = a == b\n}\n","fix":"struct Point { x: Int }\n\nfn main() {\n    let a = Point(x: 1)\n    let b = Point(x: 1)\n    let same = a.x == b.x\n}\n"},
{"code":"E0270","message":"A `cap fn` used where a plain `fn` is expected: a closure that captures a capability-bearing value (a built-in capability, a `cap` type, a `cap fn`, or a container of one, including a capability-bearing `self`), or a `cap fn` value passed on. The rule is part of type compatibility, so it holds on every route: arguments, returns, assignments, `?`, generic instantiation, and inside type arguments such as `Option<cap fn()>` or `List<cap fn()>`, which never become `Option<fn()>` or `List<fn()>`. A plain `fn` may always be used as a `cap fn`. Where values meet, a plain `fn` and a `cap fn` join to `cap fn` rather than conflicting, as trusted and untrusted text join to untrusted: the elements of a list, `if` and `match` branches, and the arguments of a generic function for one type parameter, including inside type arguments. So `[pure_fn, capturing_closure]` is a `List<cap fn() -> Int>`, and anything that calls its elements must declare `cap fn`. An annotation fixes the flag, so `let fs: List<fn() -> Int> = [pure_fn, capturing_closure]` is still `E0270`. A value already used as a plain `fn`, by flowing into a plain `fn` slot or by being called in a contract, rejects a `cap fn` that arrives later, as with `fs = [capturing_closure]` after `run_all(fs)`. A closure is a `cap fn` when anything it captures turns out capability-bearing, even if that is settled only later in the body (`let g = || xs` before `xs.push(out)`), so a closure already used as a plain `fn` is then `E0270` at the closure. A mutating method's receiver takes what the method writes into it, so `push` cannot add a `cap fn` to a `List<fn()>`.","machine_fix":false,"machine_fix_description":null,"example":"fn apply(f: fn()) {\n    f()\n}\n\nfn main(io: Stdout) {\n    apply(|| {\n        let _ = io.println(\"hi\")\n    })\n}\n","fix":"fn apply(f: cap fn()) {\n    f()\n}\n\nfn main(io: Stdout) {\n    apply(|| {\n        let _ = io.println(\"hi\")\n    })\n}\n"},
{"code":"E0271","message":"Construction of a prelude struct with private fields, such as a built-in capability (`Stdout(handle: 1)`) or `Args`. Capabilities cannot be forged; they come from `main`.","machine_fix":false,"machine_fix_description":null,"example":"fn main() {\n    let out = Stdout(handle: 1)\n}\n","fix":"fn main(out: Stdout) {}\n"},
{"code":"E0272","message":"Reading a private field of a prelude type, such as `out.handle`.","machine_fix":false,"machine_fix_description":null,"example":"fn main(out: Stdout) {\n    let h = out.handle\n}\n","fix":"fn main(out: Stdout) {\n    let _ = out.println(\"hi\")\n}\n"},
{"code":"E0273","message":"A call of `read_to_string`, `list_dir`, `write`, or `create_dir` on `Fs`, `FsRead`, or `FsWrite`, whether written `read.read_to_string(path)`, qualified as `FsRead.read_to_string(read, path)`, or taken as a value. These types only attenuate, so a file is read or written through a directory capability (`restrict_to`) or a file capability (`restrict_to_file`). The message shows the shape of the fix, such as `fs.restrict_to(\"<root>\").read_to_string(path)`. The root is the programmer's to choose, so there is no machine fix. Spans the call.","machine_fix":false,"machine_fix_description":null,"example":"fn count(fs: FsRead, path: Path) -> Result<Int, IoError> {\n    Ok(fs.read_to_string(path)?.len())\n}\n","fix":"fn count(fs: FsRead, path: Path) -> Result<Int, IoError> {\n    Ok(fs.restrict_to(\"/srv/app\").read_to_string(path)?.len())\n}\n"},
{"code":"E0274","message":"A type argument breaks what a generic body assumes of its type parameter (see above): a capability-bearing type for a parameter that a contract uses or that a plain `fn` closure captures, or a type holding a `Scope` for a parameter that an unscoped closure captures. Checked at a call of a generic function or method, where a bound is satisfied through a generic impl, and at an impl of a trait for its `Self` and its generics. A generic that instantiates the parameter with one of its own passes the assumption on. The message names the type, the parameter, and why it must stay pure. Spans the called function's or method's name, the call when a bound is satisfied through an impl, or the impl's type.","machine_fix":false,"machine_fix_description":null,"example":"trait Speak {\n    fn ok(self) -> Bool\n}\n\nimpl Speak for Stdout {\n    fn ok(self) -> Bool {\n        let _ = self.println(\"checking\")\n        true\n    }\n}\n\nfn check<T: Speak>(x: T) -> Int\n    requires x.ok()\n{\n    1\n}\n\nfn main(out: Stdout) {\n    let n = check(out)\n}\n","fix":"trait Speak {\n    fn ok(self) -> Bool\n}\n\nimpl Speak for Int {\n    fn ok(self) -> Bool {\n        self > 0\n    }\n}\n\nfn check<T: Speak>(x: T) -> Int\n    requires x.ok()\n{\n    1\n}\n\nfn main(out: Stdout) {\n    let n = check(5)\n}\n"},
{"code":"E0280","message":"A contract clause (`requires` or `ensures`) calls a function that is not pure: one with a capability-bearing parameter or receiver, or a `cap fn` value. A generic call is judged once instantiated: it is impure when any argument, parameter, or receiver type is capability-bearing after its generics are solved, as in `apply(log, out)` with `fn apply<T>(f: fn(T), x: T)` and `out: Stdout`. An operator that dispatches to a trait impl is judged the same way: `==` or `!=` on capability-bearing operands (an `Eq` impl), an interpolation hole of a capability-bearing value (a `Display` impl), and a `?` inside a closure that converts a capability-bearing error (a `From` impl). Each is judged again once the body's types are solved, so a value that turns out capability-bearing later, on a loop's next pass, is caught. Spans the call, the comparison, the hole, or the `?`.","machine_fix":false,"machine_fix_description":null,"example":"fn ready(io: Stdout) -> Bool {\n    true\n}\n\nfn run(io: Stdout) -> Int\n    requires ready(io)\n{\n    1\n}\n","fix":"fn ready(n: Int) -> Bool {\n    n > 0\n}\n\nfn run(n: Int) -> Int\n    requires ready(n)\n{\n    1\n}\n"},
{"code":"E0281","message":"A `requires` or `ensures` condition whose type is not `Bool`. Spans the condition.","machine_fix":false,"machine_fix_description":null,"example":"fn run(n: Int) -> Int\n    requires n\n{\n    n\n}\n","fix":"fn run(n: Int) -> Int\n    requires n > 0\n{\n    n\n}\n"},
{"code":"E0282","message":"A `?` or a `return` directly inside a `requires` or `ensures` expression, outside any closure. A contract is a condition that evaluates to a `Bool`, so there is no function to leave. A closure in a contract may use both for itself. Spans the `?` expression or the `return` statement.","machine_fix":false,"machine_fix_description":null,"example":"fn first(xs: List<Int>) -> Option<Int> {\n    xs.get(0)\n}\n\nfn run(xs: List<Int>) -> Int\n    requires first(xs)? > 0\n{\n    1\n}\n","fix":"fn run(xs: List<Int>) -> Int\n    requires xs.len() > 0\n{\n    1\n}\n"},
{"code":"E0290","message":"Two `impl Trait for Type` that overlap: some instantiation of each implements the same trait, with the same arguments, for the same type, as with `impl<T> Display for Box<T>` and `impl Display for Box<Int>`. An impl that overlaps a prelude impl, such as `impl Eq for Int`, conflicts too. Spans the second impl's trait.","machine_fix":false,"machine_fix_description":null,"example":"struct Box<T> { value: T }\n\nimpl<T> Display for Box<T> {\n    fn to_string(self) -> String {\n        \"box\"\n    }\n}\n\nimpl Display for Box<Int> {\n    fn to_string(self) -> String {\n        \"int box\"\n    }\n}\n","fix":"struct Box<T> { value: T }\n\nimpl<T> Display for Box<T> {\n    fn to_string(self) -> String {\n        \"box\"\n    }\n}\n"},
{"code":"E0291","message":"An inherent `impl` for a prelude type, such as `impl FsRead { ... }`: only the prelude declares methods on its types. Write a free function, or implement a trait. Spans the `impl`'s type.","machine_fix":false,"machine_fix_description":null,"example":"impl FsRead {\n    fn size(self) -> Int {\n        1\n    }\n}\n","fix":"fn size(fs: FsRead) -> Int {\n    1\n}\n"},
{"code":"E0292","message":"A `Scope` handle that could outlive its `scope` block: `Scope` in a function's or method's return type, in a struct or enum field's type, or in the type of a `scope` block's value, including inside wrappers such as `Option<Scope>` or `List<Scope>`. `Scope` stays allowed as a parameter type. A closure that captures a `Scope`, or a value holding one, is **scoped** and cannot escape either: it cannot be a `scope` block's value, be returned, be stored in a field, or be passed to a user function's parameter (a prelude or `std` function, such as `spawn` or `map`, accepts it). A `var` declared outside a `scope` block cannot be left holding the handle or such a closure; this is conservative, and also rejects keeping a closure that captures an enclosing block's handle. Nor can a `var` that already holds a handle, of an enclosing block, take one of an inner block: inside a `scope` block, assigning to a `var` (or `self`) from outside it, or calling a mutating method such as `push` on one, is rejected when the value written mentions a local of the block that holds a `Scope`, such as its handle or a closure capturing it. A closure is scoped by what its captures hold when it is checked, so one that captures a value whose type is known only later, as in `var xs = []` followed by `let g = || xs.len()` and then `xs.push(s)`, is rejected when that type turns out to hold a `Scope`; declare the value with its type first. Spans the type, the closure, or the `scope` expression.","machine_fix":false,"machine_fix_description":null,"example":"fn leak() -> Scope {\n    scope |s| { s }\n}\n","fix":"fn work() -> Int {\n    1\n}\n\nfn run() -> Int {\n    scope |s| {\n        let task = s.spawn(|| work())\n        task.join()\n    }\n}\n"},
{"code":"E0293","message":"A call to `todo()` when checking with `--release`. Spans the call.","machine_fix":false,"machine_fix_description":null,"example":"fn main() {\n    todo()\n}\n","fix":"fn main() {}\n"},
{"code":"E0294","message":"A `use` whose path does not start with `std.`: only the standard library can be imported. Spans the path.","machine_fix":false,"machine_fix_description":null,"example":"use mylib.helpers\n\nfn main() {}\n","fix":"use std.html\n\nfn main() {}\n"},
{"code":"E0295","message":"A `use std.*` of a module that does not exist. Spans the module path.","machine_fix":true,"machine_fix_description":"Replace the path with the single closest module, when one is close enough.","example":"use std.htm\n\nfn main() {}\n","fix":"use std.html\n\nfn main() {}\n"},
{"code":"E0300","message":"Untrusted text in a structural position: an `Untrusted<String>` used where trusted `String` is required, such as a `String` parameter, field, or return type. Reported instead of `E0220` when trust is the only difference. Like `E0270`, the rule is part of type compatibility, so it holds on every route, including inside type arguments such as `Option<Untrusted<String>>`. Trusted `String` may always be used as `Untrusted<String>`. The message suggests a validator or `.assume_trusted()`. Spans the expression.","machine_fix":false,"machine_fix_description":null,"example":"fn greet(name: String) -> String {\n    \"Hello, {name}\"\n}\n\nfn show(user: Untrusted<String>) -> String {\n    greet(user)\n}\n","fix":"fn greet(name: Untrusted<String>) -> Untrusted<String> {\n    \"Hello, {name}\"\n}\n\nfn show(user: Untrusted<String>) -> Untrusted<String> {\n    greet(user)\n}\n"},
{"code":"E0310","message":"A sink literal, such as `sql\"...\"`, whose module is not imported. Spans the tag.","machine_fix":true,"machine_fix_description":"Insert `use std.<module>` at the start of the file.","example":"fn main() {\n    let query = sql\"SELECT 1\"\n}\n","fix":"use std.sql\n\nfn main() {\n    let query = sql\"SELECT 1\"\n}\n"},
{"code":"E0311","message":"A sink literal whose tag no `std.*` module provides, such as `sqll\"...\"`. Spans the tag.","machine_fix":true,"machine_fix_description":"Replace the tag with the single closest known tag, when one is close enough.","example":"use std.sql\n\nfn main() {\n    let query = sqll\"SELECT 1\"\n}\n","fix":"use std.sql\n\nfn main() {\n    let query = sql\"SELECT 1\"\n}\n"},
{"code":"E0312","message":"A name that the module does not export, in a `use` brace group (`use std.sql.{Query}`) or a qualified path (`sql.Query`). Spans the name.","machine_fix":true,"machine_fix_description":"Replace the name with the single closest export, when one is close enough.","example":"use std.sql.{SqlLitreal}\n\nfn main() {}\n","fix":"use std.sql.{SqlLiteral}\n\nfn main() {}\n"},
{"code":"E0320","message":"`Untrusted<T>` where `T` is not text, such as `Untrusted<Int>`, `Untrusted<List<String>>`, or `Untrusted<T>` for a generic `T`. Trust is a flag on text only; every other type is trusted. Text inside a container is written inside it, as in `List<Untrusted<String>>`. Checked in signatures, declarations, and type annotations in bodies. Spans the `Untrusted<...>` type.","machine_fix":false,"machine_fix_description":null,"example":"fn count(n: Untrusted<Int>) {}\n","fix":"fn count(n: Int) {}\n"},
{"code":"E0340","message":"A module's export written unqualified, such as `Db` after a plain `use std.sql`, which imports only the module. Spans the name.","machine_fix":true,"machine_fix_description":"Qualify it with the module's name: `sql.Db`.","example":"use std.sql\n\nfn run(q: SqlLiteral) {}\n","fix":"use std.sql\n\nfn run(q: sql.SqlLiteral) {}\n"},
{"code":"E0341","message":"Text where a sink literal type is required, such as a `String`, an `Untrusted<String>`, a string literal, or an interpolated string passed to `Db.query` as query text. Only a `sql\"...\"` literal makes an `SqlLiteral`, so SQL can't be built from text. Reported instead of `E0220`. Spans the expression.","machine_fix":false,"machine_fix_description":null,"example":"use std.sql\n\nfn run(db: sql.Db, id: Untrusted<String>) {\n    let rows = db.query(\"SELECT * FROM users\", [id])\n}\n","fix":"use std.sql\n\nfn run(db: sql.Db, id: Untrusted<String>) {\n    let rows = db.query(sql\"SELECT * FROM users WHERE id = ?\", [id])\n}\n"},
{"code":"E0350","message":"A `Secret` interpolated into a string, such as `\"Bearer {key}\"`, or a value that holds one anywhere inside, such as a `List<Secret<String>>`, an `Option<Secret<String>>`, or a struct with a `Secret` field. Spans the hole, braces included.","machine_fix":false,"machine_fix_description":null,"example":"fn main(env: Env) {\n    let key = env.secret(\"API_KEY\")\n    let header = \"Bearer {key}\"\n}\n","fix":"fn main(env: Env) {\n    let key = env.secret(\"API_KEY\")\n    let value = key.expose()\n    let header = \"Bearer {value}\"\n}\n"},
{"code":"E0351","message":"A `Secret` compared with `==` or `!=`, on either side. Spans the comparison. Also reported, without a fix, where a `Secret` must be `Eq`: an `Eq` bound, or a call to `.eq`.","machine_fix":true,"machine_fix_description":"Rewrite `a == b` to `a.constant_time_eq(b)` and `a != b` to `!a.constant_time_eq(b)`, with the secret as the receiver (parenthesized when needed). When both sides are secrets, it rewrites to `a.constant_time_eq_secret(b)` instead, so nothing is exposed.","example":"fn main(env: Env) {\n    let key = env.secret(\"API_KEY\")\n    let ok = key == \"hunter2\"\n}\n","fix":"fn main(env: Env) {\n    let key = env.secret(\"API_KEY\")\n    let ok = key.constant_time_eq(\"hunter2\")\n}\n"},
{"code":"E0352","message":"A `Secret` used where it must be `Display`: a `Display` bound, or a call to `.to_string()`. Spans the call, or the method name.","machine_fix":false,"machine_fix_description":null,"example":"fn main(env: Env) {\n    let key = env.secret(\"API_KEY\")\n    let text = key.to_string()\n}\n","fix":"fn main(env: Env) {\n    let key = env.secret(\"API_KEY\")\n    let text = key.expose()\n}\n"},
{"code":"E0360","message":"A name declared by an imported `std` module but not exported by it, written unqualified. Spans the name. No `std` module declares a private name yet: no program can reach this code, so it has no example.","machine_fix":false,"machine_fix_description":null,"example":null,"fix":null},
{"code":"E0370","message":"`main` declares a capability that has no runtime yet: `Net`, `NetConnect`, `NetListen`, `Spawn`, or `Sched`. Spans `main`'s body. (A `main` that declares a directory or file capability is already refused by the checker, `E0217`.)","machine_fix":false,"machine_fix_description":null,"example":"fn main(net: Net) -> Result<(), IoError> {\n    Ok(())\n}\n","fix":"fn main(io: Stdout) -> Result<(), IoError> {\n    io.println(\"hello\")\n}\n"},
{"code":"E0371","message":"The program imports a `std` module that has no runtime yet: `std.proc` or `std.sql`, used or not. Spans the module path of the `use`.","machine_fix":false,"machine_fix_description":null,"example":"use std.sql\n\nfn main() {}\n","fix":"use std.html\n\nfn main() {}\n"},
{"code":"E0380","message":"The program uses something the interpreter cannot run yet: a construct the checked program cannot express, a call of a prelude function with no runtime implementation, or a parameter of `main` that is neither a capability nor `Args`. The message names the construct, as in ``the interpreter cannot run a `From`-bound conversion yet``; others are a constructor used as a function value, a call of a generic trait's method, and a `?` or `return` in a contract outside any closure (the checker rejects that first, with `E0282`, so this is a second line of defence). Spans the construct or call, or `main`'s body for a parameter.","machine_fix":false,"machine_fix_description":null,"example":"fn main() {\n    let make = Some\n    let x: Option<Int> = make(1)\n}\n","fix":"fn main() {\n    let x: Option<Int> = Some(1)\n}\n"},
{"code":"P0001","message":"Integer overflow: the result of `+`, `-`, `*`, `/`, or unary `-` does not fit its type, as with a `U8` `0 - 1` or an `I8` `-128 / -1`. Spans the operation.","machine_fix":false,"machine_fix_description":null,"example":"fn main() {\n    let x: U8 = 255\n    let y = x + 1\n}\n","fix":"fn main() {\n    let x: Int = 255\n    let y = x + 1\n}\n"},
{"code":"P0002","message":"Index out of bounds: `List.at` was given an index below 0 or not below the list's length. Spans the call.","machine_fix":false,"machine_fix_description":null,"example":"fn main() {\n    let xs: List<Int> = List.new()\n    let first = xs.at(0)\n}\n","fix":"fn main() {\n    let xs: List<Int> = List.new()\n    let first = xs.get(0)\n}\n"},
{"code":"P0003","message":"`todo()` reached. Spans the call.","machine_fix":false,"machine_fix_description":null,"example":"fn main() {\n    todo()\n}\n","fix":"fn main() {}\n"},
{"code":"P0004","message":"Division by zero: the right operand of `/` or `%` is zero. Spans the operation.","machine_fix":false,"machine_fix_description":null,"example":"fn main() {\n    let zero = 0\n    let n = 10 / zero\n}\n","fix":"fn main() {\n    let two = 2\n    let n = 10 / two\n}\n"},
{"code":"P0005","message":"`spawn` on a finished scope: the handle's `scope` block has ended, and work never runs outside a scope. Spans the call. This is a second line of defence behind the checker (`E0292`), which already stops a handle from outliving its block: no checked program can reach this code, so it has no example.","machine_fix":false,"machine_fix_description":null,"example":null,"fix":null},
{"code":"P0006","message":"Precondition violated: a `requires` clause of the function called is false, so the caller broke the contract. The message names the function and quotes the clause's condition. Spans the call. Every call evaluates the function's `requires` clauses, in every build, in the order written: after the arguments are evaluated and before the body runs. A clause sees the parameters and `self`. A panic while a clause is evaluated, such as an overflow, is reported as it is, not as `P0006`.","machine_fix":false,"machine_fix_description":null,"example":"fn double(x: Int) -> Int\n    requires x > 0\n{\n    x * 2\n}\n\nfn main() {\n    let y = double(-1)\n}\n","fix":"fn double(x: Int) -> Int\n    requires x > 0\n{\n    x * 2\n}\n\nfn main() {\n    let y = double(1)\n}\n"},
{"code":"P0007","message":"Postcondition violated: an `ensures` clause of the function that returned is false, so the function broke its promise. The message names the function, quotes the clause's condition, and names the line and column of the return that broke it, counting columns in characters from 1. Spans the `ensures` clause. Every return evaluates the function's `ensures` clauses, in every build, in the order written, with `r` bound to the value being returned. That covers falling off the end of the body (the return is its last expression, or its closing brace), an early `return`, and an early exit through `?`, where `r` is the `Err` or `None` being returned. A clause sees the parameters and `self`; a method that changes `var self` shows its clauses the receiver it ends with. A contract that calls a function with contracts checks those too, and a panic while a clause is evaluated, such as an overflow, is reported as it is, not as `P0007`.","machine_fix":false,"machine_fix_description":null,"example":"fn absolute(x: Int) -> Int\n    ensures |r| r >= 0\n{\n    x\n}\n\nfn main() {\n    let y = absolute(-1)\n}\n","fix":"fn absolute(x: Int) -> Int\n    ensures |r| r >= 0\n{\n    if x < 0 {\n        0 - x\n    } else {\n        x\n    }\n}\n\nfn main() {\n    let y = absolute(-1)\n}\n"},
{"code":"P0010","message":"`t.assert(cond)` was given `false`. Fails the test (see [Tests](#tests)). Spans the call.","machine_fix":false,"machine_fix_description":null,"example":"test \"is positive\" {\n    t.assert(1 < 0)\n}\n","fix":"test \"is positive\" {\n    t.assert(0 < 1)\n}\n"},
{"code":"P0011","message":"`t.assert_eq(actual, expected)` was given two values that differ through `Eq`. The message shows both, as `dbg` would. Spans the call.","machine_fix":false,"machine_fix_description":null,"example":"test \"adds\" {\n    t.assert_eq(1 + 1, 3)\n}\n","fix":"test \"adds\" {\n    t.assert_eq(1 + 1, 2)\n}\n"},
{"code":"P0012","message":"`t.assert_ne(actual, other)` was given two equal values. Spans the call.","machine_fix":false,"machine_fix_description":null,"example":"test \"differs\" {\n    t.assert_ne(2, 2)\n}\n","fix":"test \"differs\" {\n    t.assert_ne(2, 3)\n}\n"},
{"code":"P0013","message":"`t.fail(message)` was called. The message is `message`. Spans the call.","machine_fix":false,"machine_fix_description":null,"example":"test \"not written yet\" {\n    t.fail(\"write this test\")\n}\n","fix":"test \"written\" {\n    t.assert(true)\n}\n"},
{"code":"P0020","message":"`Env.secret` asked for a variable the environment does not set. Its signature has no room for a missing secret, and running on with a stand-in such as an empty one could let an empty password through. Spans the call.","machine_fix":false,"machine_fix_description":null,"example":"fn main(env: Env) {\n    let key = env.secret(\"API_KEY\")\n}\n","fix":"fn main(env: Env) {\n    let key = env.get(\"API_KEY\")\n}\n"},
{"code":"P0021","message":"Calls nest too deep: runaway recursion. The interpreter runs on a thread of its own with a 256 MiB stack, and a call panics instead of starting when calls already nest 50,000 deep, or when so little of that stack is left that the next call could overflow it. The process never crashes on deep recursion: `oskac run` exits with 101, and under `oskac test` only the test that recursed fails. Spans the call that would have gone too deep.","machine_fix":false,"machine_fix_description":null,"example":"fn down(n: Int) -> Int {\n    1 + down(n - 1)\n}\n\nfn main() {\n    let depth = down(10)\n}\n","fix":"fn down(n: Int) -> Int {\n    if n == 0 { 0 } else { 1 + down(n - 1) }\n}\n\nfn main() {\n    let depth = down(10)\n}\n"},
{"code":"P0035","message":"`String.slice` was given indices out of bounds: a start or end below 0 or past the text's length in characters, or a start past the end. Spans the call. Indices count characters (Unicode code points), not bytes.","machine_fix":false,"machine_fix_description":null,"example":"fn main() {\n    let part = \"abc\".slice(0, 10)\n}\n","fix":"fn main() {\n    let part = \"abc\".slice(0, 2)\n}\n"},
{"code":"P0036","message":"`String.repeat` was given a negative count. Spans the call.","machine_fix":false,"machine_fix_description":null,"example":"fn main() {\n    let line = \"ab\".repeat(-1)\n}\n","fix":"fn main() {\n    let line = \"ab\".repeat(3)\n}\n"},
{"code":"P0037","message":"`String.repeat` would build a text over 256 MiB, so the interpreter panics instead of running out of memory. Spans the call.","machine_fix":false,"machine_fix_description":null,"example":"fn main() {\n    let huge = \"ab\".repeat(300000000)\n}\n","fix":"fn main() {\n    let small = \"ab\".repeat(3000)\n}\n"}
]
