Error codes
Every error the Hilde compiler reports carries a code such as H4012. The code names one place in the compiler, so it stays the same when the wording of a message changes, and a code is never given to another message. The first digit tells the kind: 0 syntax, 1 command line and packages, 2 declarations, 3 types, 4 linearity, 5 entry point, 6 generic, 7 templates, 8 SQL, 9 internal. H9999 is every internal error: a fault in the compiler, not in the programme.
This page is generated from the compiler's source: the list of codes from the places that raise them, and for each code the meaning, the message and a module that fails with it from the compiler's catalog. Each code has its own address, for example /errors/#H4012.
The source of this build raises 570 codes; 570 of them have an entry in the catalog.
In the examples, red text shows where the error is.
Sections
- 1. Syntax (13)
- 2. Types (97)
- 3. Linearity (10)
- 4. Borrowing (21)
- 5. Modules (33)
- 6. Other (59)
- 7. Templates (120)
- 8. SQL (113)
- 9. Contracts (14)
- 10. Error kinds (4)
- 11. Never and slots (10)
- 12. Targets (13)
- 13. Packages (36)
- 14. Sperli (27)
1. Syntax
H0001
The source text holds a character that starts no token. Outside comments and strings only letters, digits, white space and the symbols of the language may stand.
Message:
This module fails with H0001:
module body Example is
function main(): ExitCode is
let total: Int32 := 1 $ 2;
printLn(total);
return ExitSuccess();
end;
end module body.
H0003
A string literal is opened with a double quote and never closed. The rest of the file becomes part of the string, and the file ends inside it.
Message:
This module fails with H0003:
module body Example is
function main(): ExitCode is
printLn("unclosed);
return ExitSuccess();
end;
end module body.
H0004
A string in triple quotes is opened and never closed, so the file ends inside it.
Message:
This module fails with H0004:
module body Example is
function main(): ExitCode is
printLn("""unclosed);
return ExitSuccess();
end;
end module body.
H0005
The tokens do not form a program of the grammar. A frequent cause is an expression with two operators and no parentheses: Hilde has no operator precedence.
Message:
This module fails with H0005:
module body Example is
function main(): ExitCode is
let total: Int32 := 1 +;
printLn(total);
return ExitSuccess();
end;
end module body.
H0006
The function pointer type Fn is written without type arguments. It needs at least one, the return type, and before it the parameter types.
Message:
This module fails with H0006:
module body Example is
function keep(callback: Fn): Unit is
return nil;
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H0007
A character literal holds more than one character. The lexer takes only one character or one escape between the apostrophes, so the parser never sees a longer literal; the one way in was ''', which is now the apostrophe, as '\'' is.
Message:
The catalog gives no failing example for this code.
H0008
A reserved word stands where a name belongs: the name of a function, a let, a var, a constant, the variable of a for, a parameter, or the name after as. Words such as method, from and body read like good names and are reserved all the same.
Message:
This module fails with H0008:
module body Example is
function method(count: Int32): Int32 is
return count;
end;
function main(): ExitCode is
printLn(method(1));
return ExitSuccess();
end;
end module body.
H0009
Hilde has no operator precedence: an operator takes two atomic operands. Only the associative operators +, *, and and or may form a chain of the same operator, a + b + c, read from the left. Any other operator after an operation needs that operation in parentheses. The message suggests the parentheses around the operation before the operator.
Message:
This module fails with H0009:
module body Example is
function main(): ExitCode is
let total: Int32 := 1 + 2 * 3;
printLn(total);
return ExitSuccess();
end;
end module body.
H0010
An index stands after a name. The result of a call is bound to a name first, and the name is indexed.
Message:
This module fails with H0010:
module body Example is
function digits(): Span[Nat8, Static] is
return "0123";
end;
function main(): ExitCode is
let first: Nat8 := digits()[0];
printLn(first);
return ExitSuccess();
end;
end module body.
H0011
Only a variable can be borrowed. A literal is bound to a name first, and the name is borrowed.
Message:
This module fails with H0011:
module body Example is
generic [R: Region]
function twice(value: &[Int32, R]): Int32 is
return !value * 2;
end;
function main(): ExitCode is
printLn(twice(&21));
return ExitSuccess();
end;
end module body.
H0012
A field stands after a name. The result of a call is bound to a name first, and the field of the name is taken.
Message:
This module fails with H0012:
module body Example is
record Point: Free is
x: Int32;
y: Int32;
end;
function origin(): Point is
return Point(x => 3, y => 4);
end;
function main(): ExitCode is
let x: Int32 := origin().x;
printLn(x);
return ExitSuccess();
end;
end module body.
H6018
In a string literal a backslash followed by white space joins two parts of the string, and the white space has to end in a second backslash. Here something else follows the white space.
Message:
This module fails with H6018:
module body Example is
function main(): ExitCode is
printLn("one \ two");
return ExitSuccess();
end;
end module body.
H6058
The escape \u{X} writes the code point X as UTF-8. X is one to six hexadecimal digits, at most 10FFFF, and not a surrogate, D800 to DFFF.
Message:
This module fails with H6058:
module body Example is
function main(): ExitCode is
printLn("\u{110000}");
return ExitSuccess();
end;
end module body.
2. Types
H2020
An instance names something that is not a type class.
Message:
This module fails with H2020:
module body Example is
record Point: Free is
x: Int32;
end;
instance Point(Int32) is
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H2021
An instance defines a method that its type class does not declare.
Message:
This module fails with H2021:
module body Example is
typeclass Describe(T: Free) is
method describe(value: T): Int32;
end;
instance Describe(Int32) is
method describe(value: Int32): Int32 is
return value;
end;
method explain(value: Int32): Int32 is
return value;
end;
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H2022
An instance leaves out a method of its type class. The message names the missing methods.
Message:
This module fails with H2022:
module body Example is
typeclass Describe(T: Free) is
method describe(value: T): Int32;
method explain(value: T): Int32;
end;
instance Describe(Int32) is
method describe(value: Int32): Int32 is
return value;
end;
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H2023
The parameter of a type class is declared in the Region universe. A region is not a type, so a type class cannot range over regions.
Message:
This module fails with H2023:
module body Example is
typeclass Measure(R: Region) is
method measure(value: Int32): Int32;
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H2024
A record or union is declared in the Region universe. Only type parameters can stand for regions; a declared type belongs to Free, Linear or Type.
Message:
This module fails with H2024:
module body Example is
record Point: Region is
x: Int32;
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H2025
An instance names a type class that is not declared in the module and not imported.
Message:
This module fails with H2025:
module body Example is
instance Describe(Int32) is
method describe(value: Int32): Int32 is
return value;
end;
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H2026
A type parameter of a generic function appears neither in its parameters nor in its return type, so no call could decide what it stands for.
Message:
This module fails with H2026:
module body Example is
generic [T: Free]
function answer(): Int32 is
return 42;
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H2031
A function or method ends without a return statement. A function with nothing to return still ends in return nil. Every path counts: a path ends in a return, a raise, a call of a function that returns Never such as abort, or a while whose condition is true. An if without an else that returns only in its then branch leaves a path open.
Message:
This module fails with H2031:
module body Example is
function show(n: Int32): Unit is
printLn(n);
end;
function main(): ExitCode is
show(1);
return ExitSuccess();
end;
end module body.
H2032
The argument of a generic instance uses the same type parameter twice. Each type parameter may appear only once in it.
Message:
This module fails with H2032:
module body Example is
record Pair[A: Free, B: Free]: Free is
left: A;
right: B;
end;
typeclass Describe(T: Free) is
method describe(value: T): Int32;
end;
generic [U: Free]
instance Describe(Pair[U, U]) is
method describe(value: Pair[U, U]): Int32 is
return 2;
end;
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H2033
A generic instance declares more type parameters than its argument uses. The type parameters and the variables applied in the argument must be the same in number.
Message:
This module fails with H2033:
module body Example is
record Box[A: Free]: Free is
content: A;
end;
typeclass Describe(T: Free) is
method describe(value: T): Int32;
end;
generic [U: Free, V: Free]
instance Describe(Box[U]) is
method describe(value: Box[U]): Int32 is
return 1;
end;
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H2034
The argument of an instance is a bare type parameter. An instance is for a named type, possibly with type parameters as its arguments.
Message:
This module fails with H2034:
module body Example is
typeclass Describe(T: Free) is
method describe(value: T): Int32;
end;
generic [U: Free]
instance Describe(U) is
method describe(value: U): Int32 is
return 1;
end;
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H2035
The argument of a generic instance mixes type parameters with concrete types. It uses either type parameters only or no type parameters.
Message:
This module fails with H2035:
module body Example is
record Pair[A: Free, B: Free]: Free is
left: A;
right: B;
end;
typeclass Describe(T: Free) is
method describe(value: T): Int32;
end;
generic [U: Free]
instance Describe(Pair[U, Int32]) is
method describe(value: Pair[U, Int32]): Int32 is
return 2;
end;
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H2037
A type parameter of a generic instance has the same name as the parameter of its type class. The two must be named differently.
Message:
This module fails with H2037:
module body Example is
record Box[A: Free]: Free is
content: A;
end;
typeclass Describe(T: Free) is
method describe(value: T): Int32;
end;
generic [T: Free]
instance Describe(Box[T]) is
method describe(value: Box[T]): Int32 is
return 1;
end;
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H3003
One type parameter of a generic function would have to stand for two different types in the same call.
Message:
This module fails with H3003:
module body Example is
generic [T: Free]
function first(a: T, b: T): T is
return a;
end;
function main(): ExitCode is
let n: Int32 := 1;
let flag: Bool := true;
printLn(first(n, flag));
return ExitSuccess();
end;
end module body.
H3004
A type argument lies in a universe its type parameter does not allow, for example a Linear type where the parameter is Free.
Message:
This module fails with H3004:
module body Example is
record Ticket: Linear is
number: Int32;
end;
generic [T: Free]
function keep(value: T): T is
return value;
end;
function main(): ExitCode is
let ticket: Ticket := keep(Ticket(number => 1));
let { number: Int32 } := ticket;
printLn(number);
return ExitSuccess();
end;
end module body.
H3007
An instance is given for a type whose universe the type class does not accept, for example a Linear type for a class over Free types.
Message:
This module fails with H3007:
module body Example is
record Ticket: Linear is
number: Int32;
end;
typeclass Describe(T: Free) is
method describe(value: T): Int32;
end;
instance Describe(Ticket) is
method describe(value: Ticket): Int32 is
let { number: Int32 } := value;
return number;
end;
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H3008
The two operands of an arithmetic operator have different types. Hilde converts nothing implicitly; convert one operand first.
Message:
This module fails with H3008:
module body Example is
function main(): ExitCode is
let small: Int32 := 1;
let large: Int64 := 2;
printLn(small + large);
return ExitSuccess();
end;
end module body.
H3009
An operand of an arithmetic operator is not a number.
Message:
This module fails with H3009:
module body Example is
function main(): ExitCode is
let flag: Bool := true;
printLn(flag + flag);
return ExitSuccess();
end;
end module body.
H3010
A value of an unsigned type is negated. Nat8 to Nat64, Index and ByteSize have no negative values.
Message:
This module fails with H3010:
module body Example is
function main(): ExitCode is
let n: Nat8 := 5;
printLn(-n);
return ExitSuccess();
end;
end module body.
H3012
A value is negated whose type has no instance of the type class TrappingNegation. A type of one's own can be given such an instance.
Message:
This module fails with H3012:
module body Example is
record Money: Free is
cents: Int64;
end;
function main(): ExitCode is
let debt: Money := Money(cents => 500);
let credit: Money := -debt;
printLn(credit.cents);
return ExitSuccess();
end;
end module body.
H3020
Something that is neither a function, a method nor a function pointer is called.
Message:
This module fails with H3020:
module body Example is
function main(): ExitCode is
let n: Int32 := 5;
printLn(n(1));
return ExitSuccess();
end;
end module body.
H3021
A function pointer is called with more or fewer arguments than its type has parameters. A direct call of a function with the wrong number of arguments is reported as H6026.
Message:
This module fails with H3021:
module body Example is
function add(a: Int32, b: Int32): Int32 is
return a + b;
end;
function main(): ExitCode is
let f: Fn[Int32, Int32, Int32] := add;
let sum: Int32 := f(1);
printLn(sum);
return ExitSuccess();
end;
end module body.
H3022
A case that binds by name leaves out a case of the union. Every case of the union needs its own when.
Message:
This module fails with H3022:
module body Example is
union Shape: Free is
case Dot;
case Circle is
radius: Int32;
end;
function main(): ExitCode is
let s: Shape := Dot();
case s of
when Dot do
printLn(0);
end case;
return ExitSuccess();
end;
end module body.
H3023
A case looks into a union that another module exports only as an opaque type. Only a union that is public, or declared in the same module, can be taken apart with case.
Message:
This module fails with H3023:
import Library (Shape, make);
module body Example is
function main(): ExitCode is
case make() of
when Dot do
printLn(0);
when Circle(radius: Int32) do
printLn(radius);
end case;
return ExitSuccess();
end;
end module body.
Beside it, Library.hih:
module Library is
type Shape: Free;
function make(): Shape;
end module.
Beside it, Library.hiq:
module body Library is
union Shape: Free is
case Dot;
case Circle is
radius: Int32;
end;
function make(): Shape is
return Circle(radius => 2);
end;
end module body.
H3024
A case that binds by name is given a value of a named type that is not a union, such as a record.
Message:
This module fails with H3024:
module body Example is
record Point: Free is
x: Int32;
end;
function main(): ExitCode is
let p: Point := Point(x => 1);
case p of
when Point(x: Int32) do
printLn(x);
end case;
return ExitSuccess();
end;
end module body.
H3025
A when that binds by name lists slots that the case of the union does not have, or leaves some out.
Message:
This module fails with H3025:
module body Example is
union Shape: Free is
case Dot;
case Circle is
radius: Int32;
end;
function main(): ExitCode is
let s: Shape := Circle(radius => 2);
case s of
when Dot do
printLn(0);
when Circle(diameter: Int32) do
printLn(diameter);
end case;
return ExitSuccess();
end;
end module body.
H3027
A value is converted to a type it cannot become. A type annotation e : T only gives a literal its type, turns a write reference into a read reference, or tells a generic call its return type.
Message:
This module fails with H3027:
module body Example is
function main(): ExitCode is
let flag: Bool := true;
let n: Int32 := flag : Int32;
printLn(n);
return ExitSuccess();
end;
end module body.
H3029
The condition of an if, a while or an if expression is not a Bool.
Message:
This module fails with H3029:
module body Example is
function main(): ExitCode is
let n: Int32 := 1;
if n then
printLn(n);
end if;
return ExitSuccess();
end;
end module body.
H3030
A record or a case of a union is built with positional arguments. Its constructor takes named arguments only.
Message:
This module fails with H3030:
module body Example is
record Point: Free is
x: Int32;
y: Int32;
end;
function main(): ExitCode is
let p: Point := Point(1, 2);
printLn(p.x);
return ExitSuccess();
end;
end module body.
H3031
A constructor is called with names that are not the slots of the record or of the case.
Message:
This module fails with H3031:
module body Example is
record Point: Free is
x: Int32;
y: Int32;
end;
function main(): ExitCode is
let p: Point := Point(x => 1, z => 2);
printLn(p.x);
return ExitSuccess();
end;
end module body.
H3033
A let with braces takes apart a value of a built-in type, which has no slots. A union is reported as H3053.
Message:
This module fails with H3033:
module body Example is
function main(): ExitCode is
let n: Int32 := 5;
let { value: Int32 } := n;
printLn(value);
return ExitSuccess();
end;
end module body.
H3034
A let with braces takes apart a record that another module exports only as an opaque type. Its slots are not visible outside its module.
Message:
This module fails with H3034:
import Library (Point, make);
module body Example is
function main(): ExitCode is
let { x: Int32 } := make();
printLn(x);
return ExitSuccess();
end;
end module body.
Beside it, Library.hih:
module Library is
type Point: Free;
function make(): Point;
end module.
Beside it, Library.hiq:
module body Library is
record Point: Free is
x: Int32;
end;
function make(): Point is
return Point(x => 1);
end;
end module body.
H3035
A let with braces names a set of slots that differs from the slots of the record. Every slot is named, and no other.
Message:
This module fails with H3035:
module body Example is
record Point: Free is
x: Int32;
y: Int32;
end;
function main(): ExitCode is
let p: Point := Point(x => 1, y => 2);
let { x: Int32 } := p;
printLn(x);
return ExitSuccess();
end;
end module body.
H3037
An Option or an Either is thrown away by an expression statement. Such a value carries a failure that someone must look at: handle it with case, pass it on with ?, or discard it on purpose with ignore.
Message:
This module fails with H3037:
module body Example is
function half(n: Int32): Option[Int32] is
let r: Option[Int32] := Some(value => n / 2);
return r;
end;
function main(): ExitCode is
half(4);
return ExitSuccess();
end;
end module body.
H3038
The operator ? is applied to a value that is neither an Option nor an Either, so there is no failure to pass on.
Message:
This module fails with H3038:
module body Example is
function twice(n: Int32): Option[Int32] is
let m: Int32 := n?;
let r: Option[Int32] := Some(value => m * 2);
return r;
end;
function main(): ExitCode is
ignore(twice(2));
return ExitSuccess();
end;
end module body.
H3039
The operator ? stands in a function that cannot pass the failure on: for an Option the function must return an Option, for an Either an Either with the same left type.
Message:
This module fails with H3039:
module body Example is
function half(n: Int32): Option[Int32] is
let r: Option[Int32] := Some(value => n / 2);
return r;
end;
function quarter(n: Int32): Int32 is
let h: Int32 := half(n)?;
return h / 2;
end;
function main(): ExitCode is
printLn(quarter(8));
return ExitSuccess();
end;
end module body.
H3040
The operator ? stands inside a larger expression. It may only be the whole right side of a let or a whole statement, so that the early return is visible on its own line.
Message:
This module fails with H3040:
module body Example is
function half(n: Int32): Option[Int32] is
let r: Option[Int32] := Some(value => n / 2);
return r;
end;
function quarter(n: Int32): Option[Int32] is
let q: Int32 := half(n)? / 2;
let r: Option[Int32] := Some(value => q);
return r;
end;
function main(): ExitCode is
ignore(quarter(8));
return ExitSuccess();
end;
end module body.
H3041
The value of a constant is not a constant expression, for example a function call.
Message:
This module fails with H3041:
module body Example is
function five(): Int32 is
return 5;
end;
constant limit: Int32 := five();
function main(): ExitCode is
printLn(limit);
return ExitSuccess();
end;
end module body.
H3043
A function pointer is called with named arguments. A function pointer does not keep the names of the parameters, so its arguments are given by position.
Message:
This module fails with H3043:
module body Example is
function add(a: Int32, b: Int32): Int32 is
return a + b;
end;
function main(): ExitCode is
let f: Fn[Int32, Int32, Int32] := add;
let sum: Int32 := f(a => 1, b => 2);
printLn(sum);
return ExitSuccess();
end;
end module body.
H3044
The two branches of an if expression have different types.
Message:
This module fails with H3044:
module body Example is
function main(): ExitCode is
let flag: Bool := true;
printLn(if flag then 1 else false);
return ExitSuccess();
end;
end module body.
H3045
The operand of not is not a Bool.
Message:
This module fails with H3045:
module body Example is
function main(): ExitCode is
let n: Int32 := 1;
printLn(not n);
return ExitSuccess();
end;
end module body.
H3046
An operand of and or or is not a Bool.
Message:
This module fails with H3046:
module body Example is
function main(): ExitCode is
let n: Int32 := 1;
let flag: Bool := true;
printLn(n and flag);
return ExitSuccess();
end;
end module body.
H3049
A record has no slot of the given name.
Message:
This module fails with H3049:
module body Example is
record Point: Free is
x: Int32;
y: Int32;
end;
function main(): ExitCode is
let p: Point := Point(x => 1, y => 2);
printLn(p.z);
return ExitSuccess();
end;
end module body.
H3050
A method of a type class is called with a value whose type has no instance of that class.
Message:
This module fails with H3050:
module body Example is
typeclass Describe(T: Free) is
method describe(value: T): Int32;
end;
instance Describe(Bool) is
method describe(value: Bool): Int32 is
return 1;
end;
end;
function main(): ExitCode is
let n: Int32 := 5;
printLn(describe(n));
return ExitSuccess();
end;
end module body.
H3052
A slot is read from a record that another module exports only as an opaque type.
Message:
This module fails with H3052:
import Library (Point, make);
module body Example is
function main(): ExitCode is
let p: Point := make();
printLn(p.x);
return ExitSuccess();
end;
end module body.
Beside it, Library.hih:
module Library is
type Point: Free;
function make(): Point;
end module.
Beside it, Library.hiq:
module body Library is
record Point: Free is
x: Int32;
end;
function make(): Point is
return Point(x => 1);
end;
end module body.
H3053
A slot is read from a value of a named type that is not a record, such as a union. A value of a built-in type is reported as H3057.
Message:
This module fails with H3053:
module body Example is
union Shape: Free is
case Dot;
case Circle is
radius: Int32;
end;
function main(): ExitCode is
let s: Shape := Circle(radius => 2);
printLn(s.radius);
return ExitSuccess();
end;
end module body.
H3054
A binding in a case clause declares another type than the slot has.
Message:
This module fails with H3054:
module body Example is
function main(): ExitCode is
let count: Option[Int32] := Some(value => 5);
case count of
when Some(value as number: Int64) do
printLn(number);
when None do
printLn(0);
end case;
return ExitSuccess();
end;
end module body.
H3055
A generic function whose type parameter appears only in its return type is called where no type is expected, so its type cannot be decided. An annotation with a colon decides it.
Message:
This module fails with H3055:
module body Example is
function main(): ExitCode is
ignore(None());
return ExitSuccess();
end;
end module body.
H3056
Inside a generic function a method of a type class is called on a value of a type parameter that lacks the constraint for that class.
Message:
This module fails with H3056:
module body Example is
generic [T: Free]
function show(value: T): Unit is
print(value);
return nil;
end;
function main(): ExitCode is
show(5);
return ExitSuccess();
end;
end module body.
H3057
A slot is read from a value of a built-in type, which has no slots.
Message:
This module fails with H3057:
module body Example is
function main(): ExitCode is
let n: Int32 := 5;
printLn(n.value);
return ExitSuccess();
end;
end module body.
H3058
The index operator s[i] is used on a value that is not a span.
Message:
This module fails with H3058:
module body Example is
record Box: Free is
value: Int32;
end;
function main(): ExitCode is
let b: Box := Box(value => 5);
printLn(b[0]);
return ExitSuccess();
end;
end module body.
H3060
A value has a different type from the one its place expects, for example in a return statement.
Message:
This module fails with H3060:
module body Example is
function answer(): Int32 is
return true;
end;
function main(): ExitCode is
printLn(answer());
return ExitSuccess();
end;
end module body.
H3061
A generic function requires a type class of its type parameter, and the type given for it has no instance of that class.
Message:
This module fails with H3061:
module body Example is
record Point: Free is
x: Int32;
end;
function main(): ExitCode is
let p: Point := Point(x => 1);
printLn(p);
return ExitSuccess();
end;
end module body.
H3062
An integer literal does not fit its type.
Message:
This module fails with H3062:
module body Example is
function main(): ExitCode is
let n: Nat8 := 300;
printLn(n);
return ExitSuccess();
end;
end module body.
H3063
A type argument lies in a universe its type parameter does not accept, for example a Linear type for a parameter in Free.
Message:
This module fails with H3063:
module body Example is
record Ticket: Linear is
number: Int32;
end;
record Box[T: Free]: Free is
content: T;
end;
function unpack(box: Box[Ticket]): Unit is
return nil;
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H3064
A type name is not known: it is not declared in the module, not imported and not built in.
Message:
This module fails with H3064:
module body Example is
function main(): ExitCode is
let n: Integer := 1;
printLn(n);
return ExitSuccess();
end;
end module body.
H3065
A case that binds by name is given a value that is neither a union nor a reference to a union.
Message:
This module fails with H3065:
module body Example is
function main(): ExitCode is
let n: Int32 := 1;
case n of
when Some(value: Int32) do
printLn(value);
when None do
printLn(0);
end case;
return ExitSuccess();
end;
end module body.
H3071
A case uses patterns in one when and binds slots by name and type in another. A case does one or the other in all its whens.
Message:
This module fails with H3071:
module body Example is
union Shape: Free is
case Dot;
case Circle is
radius: Int32;
end;
function main(): ExitCode is
let s: Shape := Circle(radius => 2);
case s of
when Dot | Circle(0) do
printLn(0);
when Circle(radius: Int32) do
printLn(radius);
end case;
return ExitSuccess();
end;
end module body.
H3072
A case with patterns is given a reference. Patterns match a value; a case that binds by name works on references.
Message:
This module fails with H3072:
module body Example is
union Shape: Free is
case Dot;
case Circle is
radius: Int32;
end;
function main(): ExitCode is
let s: Shape := Circle(radius => 2);
case &s of
when Dot do
printLn(0);
when Circle(r) do
printLn(r);
end case;
return ExitSuccess();
end;
end module body.
H3073
A variable stands as a whole pattern in a case over a union. It would match every value, and a case over a union has no catch-all: every variant is listed.
Message:
This module fails with H3073:
module body Example is
union Shape: Free is
case Dot;
case Circle is
radius: Int32;
end;
function main(): ExitCode is
let s: Shape := Circle(radius => 2);
case s of
when Dot do
printLn(0);
when other do
printLn(1);
end case;
return ExitSuccess();
end;
end module body.
H3074
A pattern can never be chosen, because the patterns before it already match every value it matches.
Message:
This module fails with H3074:
module body Example is
function main(): ExitCode is
let n: Nat8 := 5;
case n of
when 0 .. 9 do
printLn(1);
when 5 do
printLn(2);
when _ do
printLn(3);
end case;
return ExitSuccess();
end;
end module body.
H3075
A case with patterns leaves out values. The message gives one of them; a variable or _ at the end completes a case over an integer.
Message:
This module fails with H3075:
module body Example is
function main(): ExitCode is
let n: Nat8 := 5;
case n of
when 0 .. 9 do
printLn(1);
end case;
return ExitSuccess();
end;
end module body.
H3076
An integer pattern stands where the value is not an integer.
Message:
This module fails with H3076:
module body Example is
function main(): ExitCode is
let flag: Bool := true;
case flag of
when 1 do
printLn(1);
when _ do
printLn(0);
end case;
return ExitSuccess();
end;
end module body.
H3077
A Bool pattern, true or false, stands where the value is not a Bool.
Message:
This module fails with H3077:
module body Example is
function main(): ExitCode is
let n: Int32 := 1;
case n of
when true do
printLn(1);
when _ do
printLn(0);
end case;
return ExitSuccess();
end;
end module body.
H3078
A literal or a bound of a range lies outside the type of the value. A pattern never truncates or wraps a literal.
Message:
This module fails with H3078:
module body Example is
function main(): ExitCode is
let n: Nat8 := 5;
case n of
when 256 do
printLn(1);
when _ do
printLn(0);
end case;
return ExitSuccess();
end;
end module body.
H3079
The lower bound of a range is above its upper bound, so the range is empty.
Message:
This module fails with H3079:
module body Example is
function main(): ExitCode is
let n: Nat8 := 5;
case n of
when 9 .. 0 do
printLn(1);
when _ do
printLn(0);
end case;
return ExitSuccess();
end;
end module body.
H3080
A float literal stands as a pattern. Two floats that print alike need not be equal, so floats are not patterns; bind the value and compare it in the body.
Message:
This module fails with H3080:
module body Example is
function main(): ExitCode is
let x: Int32 := 1;
case x of
when 1.5 do
printLn(1);
when _ do
printLn(0);
end case;
return ExitSuccess();
end;
end module body.
H3081
A string literal stands as a pattern. Only integer and Bool literals are patterns.
Message:
This module fails with H3081:
module body Example is
function main(): ExitCode is
let x: Int32 := 1;
case x of
when "one" do
printLn(1);
when _ do
printLn(0);
end case;
return ExitSuccess();
end;
end module body.
H3082
The pattern _ stands where the value is not Free. It would drop a linear value that nobody consumes; bind it to a variable and consume it.
Message:
This module fails with H3082:
module body Example is
record Ticket: Linear is
number: Int32;
end;
union Slot: Linear is
case Empty;
case Full is
ticket: Ticket;
end;
function main(): ExitCode is
let s: Slot := Empty();
case s of
when Empty do
printLn(0);
when Full(_) do
printLn(1);
end case;
return ExitSuccess();
end;
end module body.
H3083
A variant pattern gives more or fewer sub-patterns than the variant has slots. Every slot gets one, in the order the union declares them.
Message:
This module fails with H3083:
module body Example is
union Shape: Free is
case Dot;
case Rectangle is
width: Int32;
height: Int32;
end;
function main(): ExitCode is
let s: Shape := Dot();
case s of
when Dot do
printLn(0);
when Rectangle(w) do
printLn(w);
end case;
return ExitSuccess();
end;
end module body.
H3084
The alternatives of one when bind different variables. The body runs after any of them, so all bind the same variables.
Message:
This module fails with H3084:
module body Example is
union Shape: Free is
case Square is
side: Int32;
case Rectangle is
width: Int32;
height: Int32;
end;
function main(): ExitCode is
let s: Shape := Square(side => 2);
case s of
when Square(a) | Rectangle(b, _) do
printLn(1);
end case;
return ExitSuccess();
end;
end module body.
H3085
A variable has one type in one alternative of a when and another type in another.
Message:
This module fails with H3085:
module body Example is
union Value: Free is
case Small is
n: Int8;
case Large is
n: Int64;
end;
function main(): ExitCode is
let v: Value := Small(n => 1);
case v of
when Small(x) | Large(x) do
printLn(1);
end case;
return ExitSuccess();
end;
end module body.
H3086
One pattern binds the same variable twice. To compare two parts, bind both under different names and compare them in the body.
Message:
This module fails with H3086:
module body Example is
union Shape: Free is
case Rectangle is
width: Int32;
height: Int32;
end;
function main(): ExitCode is
let s: Shape := Rectangle(width => 2, height => 2);
case s of
when Rectangle(a, a) do
printLn(a);
end case;
return ExitSuccess();
end;
end module body.
H3087
A name that begins with a lower-case letter takes sub-patterns. Such a name is a variable; only a variant, with an upper-case initial, takes sub-patterns.
Message:
This module fails with H3087:
module body Example is
union Shape: Free is
case Dot;
case circle is
radius: Int32;
end;
function main(): ExitCode is
let s: Shape := Dot();
case s of
when Dot do
printLn(0);
when circle(r) do
printLn(r);
end case;
return ExitSuccess();
end;
end module body.
H3088
A variant pattern names a case the union does not have. The message lists the variants it has.
Message:
This module fails with H3088:
module body Example is
union Shape: Free is
case Dot;
case Circle is
radius: Int32;
end;
function main(): ExitCode is
let s: Shape := Dot();
case s of
when Dot do
printLn(0);
when Square(r) do
printLn(r);
end case;
return ExitSuccess();
end;
end module body.
H3089
A variant pattern stands where the value is not a union.
Message:
This module fails with H3089:
module body Example is
function main(): ExitCode is
let n: Int32 := 1;
case n of
when Some(x) do
printLn(x);
when _ do
printLn(0);
end case;
return ExitSuccess();
end;
end module body.
H3090
A case with patterns is given a value of a type it cannot decide on. Patterns decide on a union, an integer or a Bool.
Message:
This module fails with H3090:
module body Example is
function main(): ExitCode is
let x: Float64 := 1.0;
case x of
when y do
printLn(y);
end case;
return ExitSuccess();
end;
end module body.
H3091
The pattern _ stands as a whole pattern in a case over a union. A case over a union has no catch-all: every variant is listed.
Message:
This module fails with H3091:
module body Example is
union Shape: Free is
case Dot;
case Circle is
radius: Int32;
end;
function main(): ExitCode is
let s: Shape := Dot();
case s of
when Dot do
printLn(0);
when _ do
printLn(1);
end case;
return ExitSuccess();
end;
end module body.
H3092
A range stands where the value is not an integer.
Message:
This module fails with H3092:
module body Example is
function main(): ExitCode is
let flag: Bool := true;
case flag of
when 0 .. 1 do
printLn(1);
when _ do
printLn(0);
end case;
return ExitSuccess();
end;
end module body.
H3093
A write reference to part of a value is taken through a read reference. &!(path) needs the path to start from a write reference; through a read reference only &(path) reads the part.
Message:
This module fails with H3093:
module body Example is
record Inner: Linear is
value: Int32;
end;
record Pair: Linear is
first: Inner;
second: Inner;
end;
generic [R: Region]
function setValue(inner: &![Inner, R], value: Int32): Unit is
inner->value := value;
return nil;
end;
generic [R: Region]
function clear(pair: &[Pair, R]): Unit is
setValue(&!(pair->first), 0);
return nil;
end;
function main(): ExitCode is
let pair: Pair := Pair(first => Inner(value => 5), second => Inner(value => 0));
clear(&pair);
let { first: Inner, second: Inner } := pair;
let { value as a: Int32 } := first;
let { value as b: Int32 } := second;
return ExitSuccess();
end;
end module body.
H3094
A function returns a reference to one of its local variables in a region its caller chooses. The caller's region outlives the call, and the local variable does not.
Message:
This module fails with H3094:
module body Example is
generic [R: Region]
function local(n: Int32): &[Int32, R] is
let x: Int32 := n;
return &x;
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H3095
The body of a generic function fixes one of the function's own type parameters. The caller chooses what a type parameter stands for, so the body must work for every choice.
Message:
This module fails with H3095:
module body Example is
generic [T: Type]
function pretend(n: Int32): T is
return n;
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H4001
A record or union declared Free contains a slot of a Linear type, or has a type parameter that is not Free. A Free value could be copied, and the linear value inside it with it.
Message:
This module fails with H4001:
module body Example is
record Ticket: Linear is
number: Int32;
end;
record Wallet: Free is
ticket: Ticket;
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H6026
A function, a method or a constructor is called with more or fewer arguments than it has parameters.
Message:
This module fails with H6026:
module body Example is
function add(a: Int32, b: Int32): Int32 is
return a + b;
end;
function main(): ExitCode is
printLn(add(1));
return ExitSuccess();
end;
end module body.
H6032
An instance joins a type class and a type that both come from other modules. An instance belongs to the module of its type class or of its type.
Message:
This module fails with H6032:
module body Example is
instance Printable(ExitCode) is
method print(value: ExitCode): Unit is
return nil;
end;
generic [R: Region]
method printSpan(value: Span[ExitCode, R]): Unit is
return nil;
end;
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H6037
An instance of a type class from another module is given for a built-in type. A built-in type belongs to the language, so it counts as foreign in every module; define a type of your own and give that the instance.
Message:
This module fails with H6037:
module body Example is
instance TrappingNegation(Nat8) is
method trappingNegate(value: Nat8): Nat8 is
return value;
end;
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H6038
A type gets a second instance of the same type class. In one program a type has at most one instance of a type class, whichever module declares it.
Message:
This module fails with H6038:
module body Example is
typeclass Describe(T: Free) is
method describe(value: T): Int32;
end;
instance Describe(Bool) is
method describe(value: Bool): Int32 is
return 1;
end;
end;
instance Describe(Bool) is
method describe(value: Bool): Int32 is
return 2;
end;
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H6039
A name that is called is neither a function nor a method nor a variable in scope.
Message:
This module fails with H6039:
module body Example is
function main(): ExitCode is
printLn(twice(2));
return ExitSuccess();
end;
end module body.
H6041
An assignment has a function parameter on its left side. Parameters cannot be changed; copy the value into a var first.
Message:
This module fails with H6041:
module body Example is
function next(n: Int32): Int32 is
n := n + 1;
return n;
end;
function main(): ExitCode is
printLn(next(1));
return ExitSuccess();
end;
end module body.
H6042
An assignment changes a variable bound with let. A variable that changes is bound with var.
Message:
This module fails with H6042:
module body Example is
function main(): ExitCode is
let n: Int32 := 1;
n := 2;
printLn(n);
return ExitSuccess();
end;
end module body.
H6045
A variable has the same name as a declaration of the module, such as a function or a constant.
Message:
This module fails with H6045:
module body Example is
constant limit: Int32 := 5;
function main(): ExitCode is
let limit: Int32 := 6;
printLn(limit);
return ExitSuccess();
end;
end module body.
H6048
A generic type or a built-in type such as Pointer is given the wrong number of type arguments.
Message:
This module fails with H6048:
module body Example is
function main(): ExitCode is
let n: Option[Int32, Bool] := None();
ignore(n);
return ExitSuccess();
end;
end module body.
H3105
A constraint of a generic function names a typeclass that the module which declares the function imports neither in its interface nor in its body. The module imports every typeclass its constraints name; without this check the compiler would stop with an internal error.
Message:
This module fails with H3105:
import Shape (Sized);
import Measure (measure);
module body Example is
function main(): ExitCode is
printLn(measure(5));
return ExitSuccess();
end;
end module body.
Beside it, Shape.hih:
module Shape is
typeclass Sized(T: Free) is
method sizeOf(value: T): Int32;
end;
instance Sized(Int32);
end module.
Beside it, Shape.hiq:
module body Shape is
instance Sized(Int32) is
method sizeOf(value: Int32): Int32 is
return 4;
end;
end;
end module body.
Beside it, Measure.hih:
module Measure is
generic [T: Free(Sized)]
function measure(value: T): Int32;
end module.
Beside it, Measure.hiq:
module body Measure is
generic [T: Free(Sized)]
function measure(value: T): Int32 is
return 0;
end;
end module body.
H3106
The compiler declares a function imported from C under a name of its own, so the C name is not declared in the text of an @embed, and cc refused the programme with an implicit declaration. The Hilde function that imports it is called instead. A function that the runtime declares is declared under its C name as well, and an @embed may call it while a module imports it.
Message:
This module fails with H3106:
pragma Unsafe_Module;
module body Example is
pragma Foreign_Import(External_Name => "abs");
function cAbs(n: Int32): Int32 is
end;
function main(): ExitCode is
let n: Int32 := @embed(Int32, "abs($1)", -3);
printLn(n);
return ExitSuccess();
end;
end module body.
H3107
A comparison becomes the operator of C, which compares scalars and pointers only. Two spans, two records or two unions would pass the type checker without this check, and cc would refuse the generated C with invalid operands. Two texts are compared by their bytes with Standard.Text.equal, a record by a function that compares its slots. A type variable passes here; H3108 is the same check where a call gives it its type.
Message:
This module fails with H3107:
module body Example is
function main(): ExitCode is
let text: Span[Nat8, Static] := "export PATH";
let word: Span[Nat8, Static] := spanPart(text, 0, 7);
if word = "export " then
printLn("an export");
end if;
return ExitSuccess();
end;
end module body.
H3108
The type checker lets a comparison of values of a type variable through, since a generic function that compares numbers is right. Where a call gives the variable a span, a record or a union, the comparison is refused at that instance, as H3107 refuses it for a type written out; without it, cc would refuse the generated C.
Message:
This module fails with H3108:
module body Example is
generic [T: Free]
function same(a: T, b: T): Bool is
return a = b;
end;
function main(): ExitCode is
let left: Span[Nat8, Static] := "a";
let right: Span[Nat8, Static] := "a";
printLn(same(left, right));
return ExitSuccess();
end;
end module body.
H3111
A call of a method finds the instance it means through the type that stands for the parameter of the class: in an argument, or in the type the result is taken as. A method that names the parameter in neither leaves every call without an instance; before, the type checker reached such a call and stopped with an internal error. The method is refused where the typeclass declares it.
Message:
This module fails with H3111:
module body Example is
typeclass Sized(T: Free) is
method size(): Index;
end;
instance Sized(Int32) is
method size(): Index is
return 4;
end;
end;
function main(): ExitCode is
printLn(size());
return ExitSuccess();
end;
end module body.
3. Linearity
H3036
An expression statement throws away a value of a Linear type. A linear value is consumed: passed to a function, returned or taken apart.
Message:
This module fails with H3036:
module body Example is
record Ticket: Linear is
number: Int32;
end;
function main(): ExitCode is
Ticket(number => 1);
return ExitSuccess();
end;
end module body.
H4002
A linear variable goes out of scope without being consumed, for example a variable a when binds that its body does not use.
Message:
This module fails with H4002:
module body Example is
record Ticket: Linear is
number: Int32;
end;
function main(): ExitCode is
let ticket: Ticket := Ticket(number => 1);
let held: Option[Ticket] := Some(value => ticket);
case held of
when Some(value: Ticket) do
skip;
when None do
skip;
end case;
return ExitSuccess();
end;
end module body.
H4003
A linear variable from outside a loop is consumed in the loop body and not given a new value before the body ends. The next pass would use it a second time.
Message:
This module fails with H4003:
module body Example is
record Ticket: Linear is
number: Int32;
end;
function redeem(ticket: Ticket): Int32 is
let { number: Int32 } := ticket;
return number;
end;
function main(): ExitCode is
let ticket: Ticket := Ticket(number => 7);
for i from 1 to 3 do
printLn(redeem(ticket));
end for;
return ExitSuccess();
end;
end module body.
H4004
The branches of an if or a case treat a linear variable differently: one consumes it and another does not.
Message:
This module fails with H4004:
module body Example is
record Ticket: Linear is
number: Int32;
end;
function redeem(ticket: Ticket): Int32 is
let { number: Int32 } := ticket;
return number;
end;
function main(): ExitCode is
let ticket: Ticket := Ticket(number => 7);
let lucky: Bool := true;
if lucky then
printLn(redeem(ticket));
else
skip;
end if;
return ExitSuccess();
end;
end module body.
H4005
One expression consumes the same linear variable twice, for example as two arguments of one call.
Message:
This module fails with H4005:
module body Example is
record Ticket: Linear is
number: Int32;
end;
function both(a: Ticket, b: Ticket): Int32 is
let { number as x: Int32 } := a;
let { number as y: Int32 } := b;
return x + y;
end;
function main(): ExitCode is
let ticket: Ticket := Ticket(number => 7);
printLn(both(ticket, ticket));
return ExitSuccess();
end;
end module body.
H4008
A linear variable is consumed a second time, in a later statement.
Message:
This module fails with H4008:
module body Example is
record Ticket: Linear is
number: Int32;
end;
function redeem(ticket: Ticket): Int32 is
let { number: Int32 } := ticket;
return number;
end;
function main(): ExitCode is
let ticket: Ticket := Ticket(number => 7);
printLn(redeem(ticket));
printLn(redeem(ticket));
return ExitSuccess();
end;
end module body.
H4010
A var holding a linear value is given a new value before the old one is consumed. The old value would be lost.
Message:
This module fails with H4010:
module body Example is
record Ticket: Linear is
number: Int32;
end;
function redeem(ticket: Ticket): Int32 is
let { number: Int32 } := ticket;
return number;
end;
function main(): ExitCode is
var ticket: Ticket := Ticket(number => 1);
ticket := Ticket(number => 2);
printLn(redeem(ticket));
return ExitSuccess();
end;
end module body.
H4012
A linear variable is not consumed when the function returns.
Message:
This module fails with H4012:
module body Example is
record Ticket: Linear is
number: Int32;
end;
function main(): ExitCode is
let ticket: Ticket := Ticket(number => 7);
return ExitSuccess();
end;
end module body.
H4014
An assignment to a slot writes a value of a type that is not Free. The old value in the slot would be lost without being consumed.
Message:
This module fails with H4014:
module body Example is
record Ticket: Linear is
number: Int32;
end;
record Wallet: Linear is
ticket: Ticket;
end;
function main(): ExitCode is
var wallet: Wallet := Wallet(ticket => Ticket(number => 1));
wallet.ticket := Ticket(number => 2);
let { ticket: Ticket } := wallet;
let { number: Int32 } := ticket;
printLn(number);
return ExitSuccess();
end;
end module body.
H4015
One branch of an if expression runs, so a linear variable that only one branch consumes is left unconsumed on the other path. Both branches consume it, or it is consumed before the if.
Message:
This module fails with H4015:
module body Example is
record Box: Linear is
content: Int32;
end;
function open(box: Box): Int32 is
let { content: Int32 } := box;
return content;
end;
function main(): ExitCode is
let box: Box := Box(content => 7);
let full: Bool := true;
let value: Int32 := if full then open(box) else 0;
printLn(value);
return ExitSuccess();
end;
end module body.
4. Borrowing
H3002
A reference or a span is handed to a task. A task can outlive the borrow the reference comes from, so its argument owns everything it points at.
Message:
This module fails with H3002:
import Standard.Task (Scope, openScope, closeScope, Task, spawn, join);
module body Example is
generic [R: Region]
function read(n: &[Index, R]): Index is
return !n;
end;
function main(): ExitCode is
let n: Index := 5;
case openScope() of
when Some(value as opened: Scope) do
var scope: Scope := opened;
borrow r: &[Index, rho] := &n do
let work: Fn[&[Index, rho], Index] := read;
case spawn(&!scope, work, r) of
when Right(right as task: Task[Index]) do
printLn(join(task));
when Left(left as back: &[Index, rho]) do
printLn(0);
end case;
end borrow;
closeScope(scope);
when None do
skip;
end case;
return ExitSuccess();
end;
end module body.
H3005
The arrow -> reads a slot through a reference, and the value before it is not a reference. A slot of a record value is read with a point.
Message:
This module fails with H3005:
module body Example is
record Point: Free is
x: Int32;
end;
function main(): ExitCode is
let p: Point := Point(x => 1);
printLn(p->x);
return ExitSuccess();
end;
end module body.
H3018
A variable bound with let is lent for writing. A variable that is lent for writing is bound with var.
Message:
This module fails with H3018:
module body Example is
record Counter: Linear is
count: Int32;
end;
generic [R: Region]
function bump(counter: &![Counter, R]): Unit is
counter->count := counter->count + 1;
return nil;
end;
function main(): ExitCode is
let counter: Counter := Counter(count => 0);
bump(&!counter);
let { count: Int32 } := counter;
printLn(count);
return ExitSuccess();
end;
end module body.
H3019
A function parameter is lent for writing. Parameters cannot be changed; move the value into a var first, as the message suggests.
Message:
This module fails with H3019:
module body Example is
record Counter: Linear is
count: Int32;
end;
generic [R: Region]
function bump(counter: &![Counter, R]): Unit is
counter->count := counter->count + 1;
return nil;
end;
function bumped(counter: Counter): Counter is
bump(&!counter);
return counter;
end;
function main(): ExitCode is
let counter: Counter := bumped(Counter(count => 0));
let { count: Int32 } := counter;
printLn(count);
return ExitSuccess();
end;
end module body.
H3026
A write reference is converted with a colon to a read reference of another type or another region. The conversion keeps both.
Message:
This module fails with H3026:
module body Example is
record Account: Linear is
balance: Int64;
end;
generic [R: Region]
function peek(account: &![Account, R]): Int64 is
let r: &[Int64, R] := account : &[Int64, R];
return !r;
end;
function main(): ExitCode is
var account: Account := Account(balance => 5);
printLn(peek(&!account));
let { balance: Int64 } := account;
printLn(balance);
return ExitSuccess();
end;
end module body.
H3028
A write reference is converted with a colon to something that is not a read reference.
Message:
This module fails with H3028:
module body Example is
record Account: Linear is
balance: Int64;
end;
generic [R: Region]
function peek(account: &![Account, R]): Int64 is
let n: Int64 := account : Int64;
return n;
end;
function main(): ExitCode is
var account: Account := Account(balance => 5);
printLn(peek(&!account));
let { balance: Int64 } := account;
printLn(balance);
return ExitSuccess();
end;
end module body.
H3032
The operator ! reads the value behind a reference, and it is applied to something that is not a reference.
Message:
This module fails with H3032:
module body Example is
function main(): ExitCode is
let n: Int32 := 5;
printLn(!n);
return ExitSuccess();
end;
end module body.
H3066
A task of a lending scope is handed a reference of another borrow than the one the scope lends from. That other borrow can end before the scope is closed.
Message:
This module fails with H3066:
import Standard.Task (Lending, openLending, closeLending, Task, spawnLending, join);
module body Example is
generic [R: Region]
function read(n: &[Index, R]): Index is
return !n;
end;
function main(): ExitCode is
let outer: Index := 1;
let inner: Index := 2;
borrow o: &[Index, rho] := &outer do
case openLending(o) of
when Some(value as opened: Lending[rho]) do
var scope: Lending[rho] := opened;
borrow i: &[Index, sigma] := &inner do
let work: Fn[&[Index, sigma], Index] := read;
case spawnLending(&!scope, work, i) of
when Right(right as task: Task[Index]) do
printLn(join(task));
when Left(left as back: &[Index, sigma]) do
printLn(0);
end case;
end borrow;
closeLending(scope);
when None do
skip;
end case;
end borrow;
return ExitSuccess();
end;
end module body.
H3067
A task of a lending scope is handed a write reference. Tasks of a lending scope may only read what they are lent.
Message:
This module fails with H3067:
import Standard.Task (Lending, openLending, closeLending, Task, spawnLending, join);
module body Example is
generic [R: Region]
function read(n: &![Index, R]): Index is
return !n;
end;
function main(): ExitCode is
let anchor: Index := 1;
var value: Index := 2;
borrow a: &[Index, rho] := &anchor do
case openLending(a) of
when Some(value as opened: Lending[rho]) do
var scope: Lending[rho] := opened;
borrow w: &![Index, sigma] := &!value do
let work: Fn[&![Index, sigma], Index] := read;
case spawnLending(&!scope, work, w) of
when Right(right as task: Task[Index]) do
printLn(join(task));
when Left(left as back: &![Index, sigma]) do
printLn(0);
end case;
end borrow;
closeLending(scope);
when None do
skip;
end case;
end borrow;
return ExitSuccess();
end;
end module body.
H3068
A task of a lending scope is started with an argument whose type is a type variable. What it stands for is not known where the task is started, so the regions cannot be checked there.
Message:
This module fails with H3068:
import Standard.Task (Lending, openLending, closeLending, Task, spawnLending, join);
module body Example is
generic [R: Region]
function read(n: &[Index, R]): Index is
return !n;
end;
generic [T: Free, R: Region, S: Region]
function start(scope: &![Lending[R], S], work: Fn[T, Index], argument: T): Index is
case spawnLending(scope, work, argument) of
when Right(right as task: Task[Index]) do
return join(task);
when Left(left as back: T) do
return 0;
end case;
end;
function main(): ExitCode is
let n: Index := 5;
borrow w: &[Index, rho] := &n do
case openLending(w) of
when Some(value as opened: Lending[rho]) do
var scope: Lending[rho] := opened;
let work: Fn[&[Index, rho], Index] := read;
printLn(start(&!scope, work, w));
closeLending(scope);
when None do
skip;
end case;
end borrow;
return ExitSuccess();
end;
end module body.
H3069
A lending scope is handed to a task of another lending scope. A task that held a scope could keep it open after its borrow ended; a scope is closed where it was opened.
Message:
This module fails with H3069:
import Standard.Task (Lending, openLending, closeLending, Task, spawnLending, join);
module body Example is
generic [R: Region]
function finish(scope: Lending[R]): Unit is
closeLending(scope);
return nil;
end;
function main(): ExitCode is
let n: Index := 5;
borrow w: &[Index, rho] := &n do
case openLending(w) of
when Some(value as opened: Lending[rho]) do
var scope: Lending[rho] := opened;
case openLending(w) of
when Some(value as other: Lending[rho]) do
let work: Fn[Lending[rho], Unit] := finish;
case spawnLending(&!scope, work, other) of
when Right(right as task: Task[Unit]) do
let done: Unit := join(task);
when Left(left as back: Lending[rho]) do
closeLending(back);
end case;
when None do
skip;
end case;
closeLending(scope);
when None do
skip;
end case;
end borrow;
return ExitSuccess();
end;
end module body.
H3070
A lending scope is handed to a task of a plain scope. The task could keep the lending scope open after the borrow it lends from has ended.
Message:
This module fails with H3070:
import Standard.Task (Scope, openScope, closeScope, Lending, openLending, closeLending, Task, spawn, join);
module body Example is
generic [R: Region]
function finish(scope: Lending[R]): Unit is
closeLending(scope);
return nil;
end;
function main(): ExitCode is
let n: Index := 5;
case openScope() of
when Some(value as opened: Scope) do
var plain: Scope := opened;
borrow w: &[Index, rho] := &n do
case openLending(w) of
when Some(value as lending: Lending[rho]) do
let work: Fn[Lending[rho], Unit] := finish;
case spawn(&!plain, work, lending) of
when Right(right as task: Task[Unit]) do
let done: Unit := join(task);
when Left(left as back: Lending[rho]) do
closeLending(back);
end case;
when None do
skip;
end case;
end borrow;
closeScope(plain);
when None do
skip;
end case;
return ExitSuccess();
end;
end module body.
H3112
A value of a type marked with pragma Thread_Bound, or of a type that holds one, is handed to a task, sent through a channel or guarded by a mutex. Such a value keeps state of the thread that made it, and a task may run on any worker thread. The check is made on the instantiated type, so a generic function that passes the value on is refused as well. The functions checked are Standard.Task.spawn and spawnLending (argument and result), Standard.Task.openChannel and Standard.Shared.makeMutex.
Message:
This module fails with H3112:
import Standard.Task (Scope, openScope, closeScope, Task, spawn, join);
module body Example is
pragma Thread_Bound;
record Handle: Free is
number: Int32;
end;
function read(handle: Handle): Int32 is
return handle.number;
end;
function main(): ExitCode is
case openScope() of
when Some(value as opened: Scope) do
var scope: Scope := opened;
let work: Fn[Handle, Int32] := read;
case spawn(&!scope, work, Handle(number => 7)) of
when Right(right as task: Task[Int32]) do
printLn(join(task));
when Left(left as back: Handle) do
printLn(back.number);
end case;
closeScope(scope);
when None do
skip;
end case;
return ExitSuccess();
end;
end module body.
H4006
A variable is consumed while it is lent for reading.
Message:
This module fails with H4006:
module body Example is
record Ticket: Linear is
number: Int32;
end;
function redeem(ticket: Ticket): Int32 is
let { number: Int32 } := ticket;
return number;
end;
function main(): ExitCode is
let ticket: Ticket := Ticket(number => 7);
borrow view: &[Ticket, R] := &ticket do
printLn(redeem(ticket));
end borrow;
return ExitSuccess();
end;
end module body.
H4007
A variable is consumed while it is lent for writing.
Message:
This module fails with H4007:
module body Example is
record Ticket: Linear is
number: Int32;
end;
function redeem(ticket: Ticket): Int32 is
let { number: Int32 } := ticket;
return number;
end;
function main(): ExitCode is
var ticket: Ticket := Ticket(number => 7);
borrow view: &![Ticket, R] := &!ticket do
printLn(redeem(ticket));
end borrow;
return ExitSuccess();
end;
end module body.
H4011
A variable is borrowed that is already consumed, or borrowed in a way its current state does not allow.
Message:
This module fails with H4011:
module body Example is
record Ticket: Linear is
number: Int32;
end;
function redeem(ticket: Ticket): Int32 is
let { number: Int32 } := ticket;
return number;
end;
function main(): ExitCode is
let ticket: Ticket := Ticket(number => 7);
printLn(redeem(ticket));
borrow view: &[Ticket, R] := &ticket do
printLn(view->number);
end borrow;
return ExitSuccess();
end;
end module body.
H4013
The operator ! reads the value behind a reference to a type that is not Free. Reading it would copy a linear value.
Message:
This module fails with H4013:
module body Example is
record Ticket: Linear is
number: Int32;
end;
function main(): ExitCode is
let ticket: Ticket := Ticket(number => 7);
borrow view: &[Ticket, R] := &ticket do
let copy: Ticket := !view;
let { number: Int32 } := copy;
printLn(number);
end borrow;
let { number: Int32 } := ticket;
return ExitSuccess();
end;
end module body.
H6043
A reference transform &( ... ) takes a path whose head is not a reference. The head is a reference, and the path goes on with an arrow.
Message:
This module fails with H6043:
module body Example is
record Point: Free is
x: Int32;
end;
function main(): ExitCode is
let p: Point := Point(x => 1);
let r: &[Int32, Static] := &(p.x);
printLn(!r);
return ExitSuccess();
end;
end module body.
H6054
An assignment writes through a read reference held in a var. Only a write reference allows a change: borrow for writing, and hold the write reference in the var.
Message:
This module fails with H6054:
module body Example is
record Point: Free is
x: Int32;
end;
function main(): ExitCode is
let p: Point := Point(x => 1);
borrow q: &[Point, R] := &p do
var r: &[Point, R] := q;
r->x := 0;
end borrow;
printLn(p.x);
return ExitSuccess();
end;
end module body.
H6055
A borrow statement reborrows with &~ a variable that is not a write reference.
Message:
This module fails with H6055:
module body Example is
record Point: Free is
x: Int32;
end;
function main(): ExitCode is
var p: Point := Point(x => 1);
borrow r: &![Point, R] := &~p do
printLn(r->x);
end borrow;
return ExitSuccess();
end;
end module body.
H6059
An index or a slot is read through a borrow of a variable, and a constant is no variable. The constant is bound to a local first, and the local is indexed.
Message:
This module fails with H6059:
module body Example is
constant digits: Span[Nat8, Static] := "0123456789";
function main(): ExitCode is
printLn(digits[1]);
return ExitSuccess();
end;
end module body.
5. Modules
H2001
The body defines a name of the interface as a different kind of declaration, for example a function where the interface declares a constant.
Message:
This module fails with H2001:
module body Example is
function limit(): Int32 is
return 5;
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, Example.hih:
module Example is
constant limit: Int32;
function main(): ExitCode;
end module.
H2002
A function has different type parameters, parameters or return type in the interface and in the body. The message says which of them differ.
Message:
This module fails with H2002:
module body Example is
function twice(n: Int64): Int64 is
return n * 2;
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, Example.hih:
module Example is
function twice(n: Int32): Int32;
function main(): ExitCode;
end module.
H2004
The interface declares something that the body does not define.
Message:
This module fails with H2004:
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, Example.hih:
module Example is
function twice(n: Int32): Int32;
function main(): ExitCode;
end module.
H2005
The interface declares an instance that the body does not define.
Message:
This module fails with H2005:
module body Example is
typeclass Describe(T: Free) is
method describe(value: T): Int32;
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, Example.hih:
module Example is
typeclass Describe(T: Free) is
method describe(value: T): Int32;
end;
instance Describe(Int32);
function main(): ExitCode;
end module.
H2006
The interface and the body given as a pair on the command line name different modules.
Message:
This module fails with H2006:
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, Example.hih:
module Sample is
function main(): ExitCode;
end module.
H2008
A declaration has a different type in the interface and in the body, for example a constant.
Message:
This module fails with H2008:
module body Example is
constant limit: Int64 := 5;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, Example.hih:
module Example is
constant limit: Int32;
function main(): ExitCode;
end module.
H2009
An opaque type is declared in one universe in the interface and defined in another in the body.
Message:
This module fails with H2009:
module body Example is
record Ticket: Linear is
number: Int32;
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, Example.hih:
module Example is
type Ticket: Free;
function main(): ExitCode;
end module.
H2010
The compilation was started with --forbid-unsafe-modules, and one of its modules is unsafe.
Message:
This module fails with H2010:
pragma Unsafe_Module;
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
With this command:
H2011
A pragma is given the wrong arguments. The message says which argument it takes, or that it takes none.
Message:
This module fails with H2011:
pragma Unsafe_Module;
module body Example is
pragma Foreign_Import(Name => "hilde_put_character");
function putCharacter(character: Nat8): Int32 is
end;
function main(): ExitCode is
putCharacter('a');
return ExitSuccess();
end;
end module body.
H2012
A pragma has a name the compiler does not know. The pragmas are Unsafe_Module, Foreign_Library, Foreign_Header, Foreign_Import and Foreign_Export.
Message:
This module fails with H2012:
pragma Unsafe_Modul;
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H2013
A safe module names a C library. Only a module with pragma Unsafe_Module has C to link against.
Message:
This module fails with H2013:
pragma Foreign_Library(Name => "m");
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H2014
The name in pragma Foreign_Library is empty. It is the name of a library, the z of -lz.
Message:
This module fails with H2014:
pragma Unsafe_Module;
pragma Foreign_Library(Name => "");
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H2015
A module declares the same name twice.
Message:
This module fails with H2015:
module body Example is
function twice(n: Int32): Int32 is
return n * 2;
end;
function twice(n: Int64): Int64 is
return n * 2;
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H2016
Two modules of one compilation have the same name.
Message:
This module fails with H2016:
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, Library.hih:
module Example is
function answer(): Int32;
end module.
Beside it, Library.hiq:
module body Example is
function answer(): Int32 is
return 42;
end;
end module body.
H2017
An import names a module that is not part of the compilation. When a module of the compilation has a name a few letters away, the message adds Did you mean and that name.
Message:
This module fails with H2017:
import Library (answer);
module body Example is
function main(): ExitCode is
printLn(answer());
return ExitSuccess();
end;
end module body.
H2018
A function generic over a type carries pragma Foreign_Export. C cannot call it, because it has no single form. An exported function may be generic over regions only: a region has nothing to pass at run time, and the function is made once, for the static region.
Message:
This module fails with H2018:
pragma Unsafe_Module;
module body Example is
pragma Foreign_Export(External_Name => "example_keep");
generic [T: Free]
function keep(value: T): T is
return value;
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H2027
Two imports give the same local name. Give one of them another name with as.
Message:
This module fails with H2027:
import Library (answer, question as answer);
module body Example is
function main(): ExitCode is
printLn(answer());
return ExitSuccess();
end;
end module body.
Beside it, Library.hih:
module Library is
function answer(): Int32;
function question(): Int32;
end module.
Beside it, Library.hiq:
module body Library is
function answer(): Int32 is
return 42;
end;
function question(): Int32 is
return 6;
end;
end module body.
H2028
A safe module imports from Hilde.Memory, whose raw pointers only unsafe modules may use.
Message:
This module fails with H2028:
import Hilde.Memory (Pointer);
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H2029
An import names something that its module defines only in the body. What the interface does not declare is private.
Message:
This module fails with H2029:
import Library (secret);
module body Example is
function main(): ExitCode is
printLn(secret());
return ExitSuccess();
end;
end module body.
Beside it, Library.hih:
module Library is
function answer(): Int32;
end module.
Beside it, Library.hiq:
module body Library is
function answer(): Int32 is
return secret();
end;
function secret(): Int32 is
return 42;
end;
end module body.
H2030
An import names something that its module does not have at all.
Message:
This module fails with H2030:
import Library (question);
module body Example is
function main(): ExitCode is
printLn(question());
return ExitSuccess();
end;
end module body.
Beside it, Library.hih:
module Library is
function answer(): Int32;
end module.
Beside it, Library.hiq:
module body Library is
function answer(): Int32 is
return 42;
end;
end module body.
H2038
A safe module uses @embed, which pastes C that the compiler does not check. Only a module with pragma Unsafe_Module may do so.
Message:
This module fails with H2038:
module body Example is
function main(): ExitCode is
let n: Int32 := @embed(Int32, "42");
printLn(n);
return ExitSuccess();
end;
end module body.
H2039
A safe module binds a C function with pragma Foreign_Import.
Message:
This module fails with H2039:
module body Example is
pragma Foreign_Import(External_Name => "hilde_put_character");
function putCharacter(character: Nat8): Int32 is
end;
function main(): ExitCode is
putCharacter('a');
return ExitSuccess();
end;
end module body.
H2040
A function bound to C with Foreign_Import has type parameters. A C function has one fixed signature.
Message:
This module fails with H2040:
pragma Unsafe_Module;
module body Example is
pragma Foreign_Import(External_Name => "hilde_put_character");
generic [T: Free]
function putCharacter(character: T): Int32 is
end;
function main(): ExitCode is
let c: Nat8 := 'a';
putCharacter(c);
return ExitSuccess();
end;
end module body.
H2041
A pragma other than Foreign_Import or Foreign_Export stands before a function. Module pragmas stand before module body.
Message:
This module fails with H2041:
module body Example is
pragma Unsafe_Module;
function answer(): Int32 is
return 42;
end;
function main(): ExitCode is
printLn(answer());
return ExitSuccess();
end;
end module body.
H2042
A safe module names a C header with pragma Foreign_Header.
Message:
This module fails with H2042:
pragma Foreign_Header(Name => "sys/utsname.h");
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H2043
The name in pragma Foreign_Header is not a header name. It is what stands between the angle brackets of an include: letters, digits and _ . / + -, not starting with a slash and without a .. part.
Message:
This module fails with H2043:
pragma Unsafe_Module;
pragma Foreign_Header(Name => "../secret.h");
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H2044
A program imports both Standard.Sqlite and Standard.SqlCipher. The two C libraries export the same functions, so a program links only one of them.
Message:
This module fails with H2044:
import Standard.Sqlite (Connection);
import Standard.SqlCipher (Connection as CipherConnection);
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H2045
A program imports a module whose name begins with Bindings. Such a module binds C and is unsafe, and what makes it safe to call is checked at the Standard module built on it, which is the one a program imports. Only a module whose name begins with Standard. or Bindings. may import it.
Message:
This module fails with H2045:
import Bindings.Time (wallNanos);
module body Example is
function main(): ExitCode is
printLn(wallNanos() > 0);
return ExitSuccess();
end;
end module body.
H2050
The name a function is exported under is one that C cannot give it: not a C identifier, a keyword of C or main, a name beginning with hilde_, which the runtime keeps for its own, or a name another function is exported under already.
Message:
This module fails with H2050:
module body Example is
pragma Foreign_Export(External_Name => "hilde_keep");
function keep(value: Int32): Int32 is
return value;
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H2059
A function bound to C with Foreign_Import returns Bool. A C function gives a truth value as an int, which may be any value but 0 for true, and the generated C reads only the lowest byte of it: isalpha of glibc answers 1024 for a letter, whose lowest byte is 0. The C result is imported as Int32 and compared with /= 0 in Hilde.
Message:
This module fails with H2059:
pragma Unsafe_Module;
module body Example is
pragma Foreign_Import(External_Name => "isatty");
function isTerminal(descriptor: Int32): Bool is
end;
function main(): ExitCode is
let terminal: Bool := isTerminal(0);
return ExitSuccess();
end;
end module body.
H2074
pragma Thread_Bound stands before something that is not the declaration of a type. It marks a record, a union or an opaque type of an interface; before a function, a constant, a typeclass, an instance or a module it means nothing.
Message:
This module fails with H2074:
module body Example is
pragma Thread_Bound;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H3001
A function exported to C with Foreign_Export has a parameter or return type that cannot cross to C, such as a span of anything but Nat8, a record with type parameters or a reference to a number. What crosses, and how, stands in the syntax, where a library is built.
Message:
This module fails with H3001:
module body Example is
pragma Foreign_Export(External_Name => "example_sum");
generic [R: Region]
function sum(words: Span[Int32, R]): Int32 is
return 0;
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H6060
The function exists in another module, which the message names, but it is not imported here. An interface imports what its own requires and ensures call: an import of the module body does not reach the interface.
Message:
This module fails with H6060:
import Other (size);
module body Example is
function count(n: Int32): Int32 is
return size(n);
end;
function main(): ExitCode is
printLn(count(3));
return ExitSuccess();
end;
end module body.
Beside it, Example.hih:
module Example is
function count(n: Int32): Int32
ensures size(result) >= 0;
function main(): ExitCode;
end module.
Beside it, Other.hih:
module Other is
function size(n: Int32): Int32;
end module.
Beside it, Other.hiq:
module body Other is
function size(n: Int32): Int32 is
return n;
end;
end module body.
6. Other
H1001
The value of --entrypoint is not of the form Module:function.
Message:
This module fails with H1001:
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
With this command:
H1002
A module on the command line is given as neither one body file nor an interface and a body joined by a comma.
Message:
This module fails with H1002:
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
With this command:
H1003
The compile command has no --entrypoint. A program needs one; a C file without one is built with --target-type=c and --no-entrypoint.
Message:
This module fails with H1003:
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
With this command:
H1004
The compile command names no module.
Message:
This module fails with H1004:
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
With this command:
H1005
The compile command has no --output.
Message:
This module fails with H1005:
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
With this command:
H1006
The compiler is told to leave out the entrypoint, and its target is neither C nor a library. A programme without an entrypoint is written as C or built as a library, for a programme of another language to link.
Message:
This module fails with H1006:
module body Example is
function answer(): Int32 is
return 42;
end;
end module body.
With this command:
H1007
The value of --target-type is none of exe, c, tc, static and shared.
Message:
This module fails with H1007:
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
With this command:
H1008
The value of --error-format is none of plain, json, hilde-json and json-lines.
Message:
This module fails with H1008:
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
With this command:
H1009
A flag is given twice.
Message:
This module fails with H1009:
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
With this command:
H1010
The argument list of the compiler is empty, not even the name of the program is in it. A shell always passes the name, so only a program that starts the compiler without it could reach this message.
Message:
The catalog gives no failing example for this code.
H1011
A flag that takes no value is given one, as in --flag=value.
Message:
This module fails with H1011:
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
With this command:
H1012
A flag that takes a value is given without one.
Message:
This module fails with H1012:
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
With this command:
H1013
A flag holds more than one equals sign, so it is neither --flag nor --flag=value.
Message:
This module fails with H1013:
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
With this command:
H1014
The C compiler refused the C code the compiler generated. With a correct program this points at C pasted in with @embed, at a missing C library, or at a fault in the compiler. The message quotes the C compiler's command and its output. For --target-type=static the archiver ar(1) runs after the C compiler; when it fails, the code is the same and the message begins Failed to run the archiver ar.
Message:
This module fails with H1014:
pragma Unsafe_Module;
module body Example is
function main(): ExitCode is
let n: Int32 := @embed(Int32, "this is not C");
printLn(n);
return ExitSuccess();
end;
end module body.
H1015
The compiler could not open or write its output file, for example because its directory does not exist or the device is full.
Message:
This module fails with H1015:
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
With this command:
H1016
This is the message for a failure to write that is not a system error; a system error, such as a missing directory, is H1015. No way was found to make writing fail otherwise.
Message:
The catalog gives no failing example for this code.
H1017
hilde query asks about a module that is not on the command line.
Message:
This module fails with H1017:
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
With this command:
H1018
hilde query is called without --module, so it does not know which module to describe.
Message:
This module fails with H1018:
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
With this command:
H1019
hilde test is called without a path, so it has nowhere to look for tests.
Message:
This module fails with H1019:
module body Example.Test is
function testNothing(): Unit is
return nil;
end;
end module body.
With this command:
H1020
hilde test is given two flags that exclude one another: two of the instruments --race, --memory and --valgrind, or --emit-c beside one of them.
ThreadSanitizer and AddressSanitizer cannot be built into one programme, and valgrind runs a programme built without either; --emit-c writes C and builds nothing, so an instrument beside it would do nothing.
Message:
This module fails with H1020:
module body Example.Test is
function testNothing(): Unit is
return nil;
end;
end module body.
With this command:
H1021
hilde test is given an instrument, --race, --memory or --valgrind, that this system cannot run: its C compiler does not build or run a programme with the instrument's flags, valgrind cannot be started, or the C compiler does not find valgrind's header valgrind/valgrind.h.
hilde test asks before it builds anything: a programme that does nothing is compiled with the flags and run, and valgrind is asked for its version and a programme that reads its header is compiled. The runtime needs the header under --valgrind: it registers every task stack with valgrind.
Message:
The catalog gives no failing example for this code.
H1022
A path given to hilde test is neither a directory nor a .hiq file, for example because it does not exist.
Message:
This module fails with H1022:
module body Example.Test is
function testNothing(): Unit is
return nil;
end;
end module body.
With this command:
H1023
hilde test searched the directories it was given and found no test file in them.
Message:
This module fails with H1023:
module body Example is
function double(n: Nat32): Nat32 is
return n * 2;
end;
end module body.
With this command:
H1024
Two files under the paths of hilde test declare the same module, and a test file imports it.
A name that two files declare is refused only when a test programme needs it; elsewhere in the directories it does no harm.
Message:
This module fails with H1024:
module body Example is
function double(n: Nat32): Nat32 is
return n * 2;
end;
end module body.
Beside it, Other.hiq:
module body Example is
function double(n: Nat32): Nat32 is
return n + n;
end;
end module body.
Beside it, Example.test.hiq:
import Example (double);
module body Example.Test is
function testDouble(): Unit is
if double(2) /= 4 then
abort("double(2) is not 4");
end if;
return nil;
end;
end module body.
With this command:
H1025
A directory hilde test searches for modules holds an interface without the body of the same name beside it.
Message:
This module fails with H1025:
module body Example is
function double(n: Nat32): Nat32 is
return n * 2;
end;
end module body.
Beside it, Other.hih:
module Other is
function half(n: Nat32): Nat32;
end module.
Beside it, Example.test.hiq:
import Example (double);
module body Example.Test is
function testDouble(): Unit is
if double(2) /= 4 then
abort("double(2) is not 4");
end if;
return nil;
end;
end module body.
With this command:
H1026
A library is built, --target-type=static, shared or wasm, and the command line names an entrypoint as well. A library has no entrypoint: C calls the functions it exports, after hilde_start.
Message:
This module fails with H1026:
module body Example is
pragma Foreign_Export(External_Name => "example_twice");
function twice(x: Int32): Int32 is
return x * 2;
end;
end module body.
With this command:
H1027
The output of a library does not end in the suffix of its kind, .a for --target-type=static and .so for shared, or is the suffix alone. The header is written beside the library under the same name ending in .h, so the name has to say where its suffix begins.
Message:
This module fails with H1027:
module body Example is
pragma Foreign_Export(External_Name => "example_twice");
function twice(x: Int32): Int32 is
return x * 2;
end;
end module body.
With this command:
H1028
hilde test --contracts is given a seed or a number of rounds that is not a decimal number in its range.
A seed is a Nat64, from 0 to 18446744073709551615, since it is written into the programme that draws the inputs as one; the rounds are from 1 to 100000, since a run of none would test nothing.
Message:
This module fails with H1028:
module body Example.Test is
function testNothing(): Unit is
return nil;
end;
end module body.
With this command:
H1029
hilde test is given --seed or --rounds without --contracts.
Only a run that tests contracts draws inputs, so without it the flag would change nothing, and a flag that changes nothing is refused rather than ignored.
Message:
This module fails with H1029:
module body Example.Test is
function testNothing(): Unit is
return nil;
end;
end module body.
With this command:
H1030
hilde guard is given an entrypoint that is not a function of a module on its command line.
The walk over the programme's calls starts at the entrypoint, so a name that is not there would leave nothing to walk from; it is refused rather than read as no entrypoint at all.
Message:
This module fails with H1030:
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
With this command:
H1031
hilde guard is given a vulnerability database it cannot read: a path that is not there, a file that is not JSON, or a record that is not in the OSV format.
A check that could not read its database would find nothing, and a report without findings would look like a programme without vulnerabilities; so the database is read before the programme is compiled, and a fault in it ends the command.
Message:
This module fails with H1031:
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
With this command:
H1032
An entry of --library-versions is not the name of a library as it is linked, a colon and a version of numbers separated by dots.
The versions are compared number by number with the ranges of the advisories; a version in another form could not be compared, and is refused rather than taken as no version.
Message:
This module fails with H1032:
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
With this command:
H1033
A path given to hilde fmt is neither a directory, whose Hilde sources are formatted, nor a file whose name ends in .hih or .hiq. A file of another kind is not taken for a source.
Message:
This module fails with H1033:
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
With this command:
H1034
A file given to the compiler could not be opened or read: it does not exist, it is a directory, or it may not be read. hilde check, hilde compile, hilde test and hilde fmt report it so; before, the compiler ended with an exception of OCaml.
Message:
This module fails with H1034:
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
With this command:
H1035
A value given with --build-value, which a programme reads with Standard.BuildInfo's value, is written name=value. The name starts with a letter and holds letters, digits, _, . and -, at most 64 bytes; the value is printable ASCII, at most 1024 bytes; each name is given once.
Message:
This module fails with H1035:
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
With this command:
H1036
SOURCE_DATE_EPOCH gives the time of the build that Standard.BuildInfo's builtAt returns, so that two builds can give the same bytes. A value that is not a number of seconds ends hilde compile, whether or not the programme imports the module, as the specification of the variable asks.
Message:
This module fails with H1036:
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
With this command:
H1037
The first word is not a command of hilde. Before, hilde printed its usage and ended with 0, so a tool that ran a command this compiler does not have, such as check on an older one, took that for success. The message names the commands and, for a word a few letters away from one, that command. In this catalog the commands stand as the placeholder {...}: the compiler prints the ones it has, and the list changes with it.
Message:
This module fails with H1037:
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
With this command:
H1049
hilde test --suite names a suite that hilde test does not know. A suite is a test of the Hilde tree that its own script runs, such as the coherence suite, which builds the same cases with several backends and compares the results. The message names the suites there are.
Message:
This module fails with H1049:
module body Example.Test is
function testNothing(): Unit is
return nil;
end;
end module body.
With this command:
H1050
hilde test --suite names a suite that cannot run here: its script is not under the working directory, or python3 is not on the path. A suite runs from the root of the Hilde tree, where tests/coherence/coherence.py lies.
Message:
The catalog gives no failing example for this code.
H2046
A function of a test file has the name of a test and another form than a test's.
The name makes it a test: test followed by a capital letter or a digit. A test takes nothing and gives nothing back, or takes the root capability; a function with a test's name in any other form is refused rather than left out, because a test that is silently not run looks exactly like one that passed.
Message:
This module fails with H2046:
module body Example.Test is
function testLength(n: Nat32): Unit is
return nil;
end;
end module body.
With this command:
H2047
A test file declares no function with the name of a test.
Message:
This module fails with H2047:
module body Example.Test is
function helper(): Unit is
return nil;
end;
end module body.
With this command:
H2048
A pragma Foreign_Library names a system the compiler does not know. The system is compared with what uname -s prints, so it is written as uname writes it, with its capitals. A misspelt system would never match, and its library would never be linked, so it is refused instead.
Message:
This module fails with H2048:
pragma Unsafe_Module;
pragma Foreign_Library(Name => "m", System => "linux");
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H2049
A pragma Foreign_Library has arguments it does not take, or its two in the other order. It takes Name, and after it System when the library is linked on one system only.
Message:
This module fails with H2049:
pragma Unsafe_Module;
pragma Foreign_Library(System => "Linux", Name => "m");
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H3059
A literal pattern handed to compile of Standard.Regex is one that the module would refuse when the program runs. A literal pattern is checked when the program is compiled.
Message:
This module fails with H3059:
import Standard.String (String, destroyString);
import Standard.Regex (Regex, compile, destroyRegex);
module body Example is
function main(): ExitCode is
let compiled: Either[String, Regex] := compile("a(?=b)");
case compiled of
when Right(right as re: Regex) do
destroyRegex(re);
when Left(left as message: String) do
destroyString(message);
end case;
return ExitSuccess();
end;
end module body.
H5001
The entry point function takes more than one parameter. It takes none, or one of type RootCapability.
Message:
This module fails with H5001:
module body Example is
function main(root: RootCapability, n: Int32): ExitCode is
surrenderRoot(root);
return ExitSuccess();
end;
end module body.
H5002
The module named in --entrypoint has no function of the given name.
Message:
This module fails with H5002:
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
With this command:
H5003
The entry point named in --entrypoint is not a function, for example a constant.
Message:
This module fails with H5003:
module body Example is
constant start: Int32 := 1;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
With this command:
H5004
The entry point function is generic.
Message:
This module fails with H5004:
module body Example is
generic [T: Free]
function main(value: T): ExitCode is
return ExitSuccess();
end;
end module body.
H5005
The module has an interface, and the interface does not declare the entry point function. Declare it there.
Message:
This module fails with H5005:
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, Example.hih:
module Example is
end module.
H5006
The one parameter of the entry point function is not of type RootCapability.
Message:
This module fails with H5006:
module body Example is
function main(n: Int32): ExitCode is
return ExitSuccess();
end;
end module body.
H5007
The entry point function does not return ExitCode.
Message:
This module fails with H5007:
module body Example is
function main(): Int32 is
return 0;
end;
end module body.
H6001
The path in @bytes is empty, absolute or contains a .. part. A module may only embed a file beside itself or below it.
Message:
This module fails with H6001:
module body Example is
function main(): ExitCode is
let data: Span[Nat8, Static] := @bytes("../data.txt");
printLn(spanLength(data));
return ExitSuccess();
end;
end module body.
Beside it, data.txt:
Hello
H6002
The file named in @bytes cannot be read, for example because it does not exist beside the module.
Message:
This module fails with H6002:
module body Example is
function main(): ExitCode is
let data: Span[Nat8, Static] := @bytes("missing.txt");
printLn(spanLength(data));
return ExitSuccess();
end;
end module body.
H6005
The command line holds an argument the compile or query command does not use, such as an unknown flag.
Message:
This module fails with H6005:
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
With this command:
H6013
A borrow expression stands where no statement can hold the borrow, for example in the value of a constant.
Message:
This module fails with H6013:
module body Example is
constant limit: Int32 := 5;
constant view: &[Int32, Static] := &limit;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H6020
A function binds the same name twice in the same scope, for example with two lets. Hilde has no shadowing; give the second variable another name.
Message:
This module fails with H6020:
module body Example is
function main(): ExitCode is
let n: Int32 := 1;
let n: Int32 := 2;
printLn(n);
return ExitSuccess();
end;
end module body.
H6025
Two nested borrow statements give their regions the same name.
Message:
This module fails with H6025:
module body Example is
function main(): ExitCode is
let a: Int32 := 1;
let b: Int32 := 2;
borrow ra: &[Int32, R] := &a do
borrow rb: &[Int32, R] := &b do
printLn(!ra + !rb);
end borrow;
end borrow;
return ExitSuccess();
end;
end module body.
H6047
A list of type parameters names the same parameter twice.
Message:
This module fails with H6047:
module body Example is
generic [T: Free, T: Free]
function first(a: T, b: T): T is
return a;
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H9999
An internal error: the compiler reached a state its own checks should have ruled out. It is a fault in the compiler, not in the program. The way in this entry showed, a constraint naming a type class that is not imported, is now H3105.
Message:
The catalog gives no failing example for this code.
7. Templates
H7001
The name of a template is empty.
Message:
This module fails with H7001:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<p>{{ title }}</p>
H7002
The path of a template is absolute. A template is read from beside the module, or below it.
Message:
This module fails with H7002:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("/page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<p>{{ title }}</p>
H7003
The path of a template contains a .. part and so leaves the module's directory.
Message:
This module fails with H7003:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("../page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<p>{{ title }}</p>
H7004
A template file cannot be read, for example because it does not exist beside the module.
Message:
This module fails with H7004:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("missing.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<p>{{ title }}</p>
H7005
A tag {{ or {% is opened and never closed.
Message:
This module fails with H7005:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<p>{{ title</p>
H7006
A comment {# is opened and never closed with #}.
Message:
This module fails with H7006:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<p>{# a note</p>
H7007
A {% raw %} is never closed with {% endraw %}.
Message:
This module fails with H7007:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<p>{% raw %}{{ title }}</p>
H7008
The {% endraw %} tag holds something after endraw.
Message:
This module fails with H7008:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<p>{% raw %}x{% endraw now %}</p>
H7009
A number in a template is not a whole decimal number, such as 1.5.
Message:
This module fails with H7009:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<p>{{ 1.5 }}</p>
H7011
A string in a tag contains an escape the template does not know, such as \x. Only these six are allowed: \n \t \r \\ \' \"
Message:
This module fails with H7011:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<p>{{ "a\x" }}</p>
H7013
A character stands in a tag that is no part of the template language.
Message:
This module fails with H7013:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<p>{{ title; }}</p>
H7014
The expression in a tag lacks a symbol it needs, such as a closing parenthesis.
Message:
This module fails with H7014:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<p>{{ (title }}</p>
H7015
A name is expected in a tag and something else stands there, for example after a point.
Message:
This module fails with H7015:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<p>{{ title. }}</p>
H7016
An operator of Jinja2 that has no meaning here stands in a tag: / divides into a fraction, which a template here does not have, and ** raises to a power, which leaves every integer type after a few steps. // divides into a whole number.
Message:
This module fails with H7016:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<p>{{ count / 2 }}</p>
H7017
The two values of an inline if ... else are printed differently: one is marked |safe and the other is not. Or an inline if stands in a condition, where and and or say the same.
Message:
This module fails with H7017:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<p>{{ title|safe if admin else "guest" }}</p>
H7018
The operator in asks a name of the data, a string for a part of it or a buffer for an element, and it asks for a text in quotes or a name of a string.
Message:
This module fails with H7018:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<p>{% if 1 in items %}one{% endif %}</p>
H7019
The arguments of a filter are not separated by commas or not closed.
Message:
This module fails with H7019:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<p>{{ title|trim(1 2) }}</p>
H7020
A macro is called with a keyword argument, name=value. Arguments are given by position.
Message:
This module fails with H7020:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% macro show(x) %}<p>{{ x }}</p>{% endmacro %}{{ show(x=title) }}
H7021
The arguments of a macro call are not separated by commas or not closed.
Message:
This module fails with H7021:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% macro show(x, y) %}<p>{{ x }}{{ y }}</p>{% endmacro %}{{ show(title title) }}
H7022
A macro is called through a dot, and the part before it is not a name that an {% import ... as %} gave, or the file it names has no such macro. A method of a value cannot be called.
Message:
This module fails with H7022:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<p>{{ title.upper() }}</p>
H7023
Square brackets hold something other than a name in quotes. An index into a list fails when Jinja2 renders the page and the list is shorter; a compiled template does not allow that.
Message:
This module fails with H7023:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<p>{{ items[0] }}</p>
H7024
A minus sign stands before a name. A negative number is written with a minus sign before its digits; a name is subtracted from zero.
Message:
This module fails with H7024:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<p>{{ -count }}</p>
H7025
A symbol stands in a tag where an expression should begin.
Message:
This module fails with H7025:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<p>{{ ) }}</p>
H7026
A tag holds no expression.
Message:
This module fails with H7026:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<p>{{ }}</p>
H7027
An expression in a tag is followed by more text.
Message:
This module fails with H7027:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<p>{{ title title }}</p>
H7028
A {% %} tag does not begin with a keyword.
Message:
This module fails with H7028:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<p>{% = title %}</p>
H7029
A {% %} tag uses a keyword this template language does not support, such as do.
Message:
This module fails with H7029:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% do title %}<p>{{ title }}</p>
H7030
An {% include %} or {% extends %} takes the template's name and nothing after it.
Message:
This module fails with H7030:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% include "part.jinja" "more" %}
Beside it, part.jinja:
<p>{{ title }}</p>
H7031
An {% include %} or {% extends %} takes a name that is not a string literal. A template chosen when the page is rendered cannot be compiled.
Message:
This module fails with H7031:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% include title %}
Beside it, part.jinja:
<p>{{ title }}</p>
H7032
An {% import %} lacks as and a name, or asks for the template's context with with context. An imported macro does not see the template's data.
Message:
This module fails with H7032:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% import "macros.jinja" %}<p>{{ title }}</p>
Beside it, macros.jinja:
{% macro show(text) %}<b>{{ text }}</b>{% endmacro %}
H7033
A template uses {% autoescape %}. Escaping cannot be switched off for a stretch; mark the one value that goes out unescaped with |safe.
Message:
This module fails with H7033:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% autoescape false %}<p>{{ title }}</p>{% endautoescape %}
H7034
A closing or continuing tag, such as {% endif %} or {% else %}, stands without its opening tag.
Message:
This module fails with H7034:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<p>{{ title }}</p>{% endif %}
H7035
An {% else %} of an {% if %} is not followed by {% endif %}.
Message:
This module fails with H7035:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% if admin %}<p>admin</p>{% else %}<p>guest</p>
H7036
An {% if %} is never closed with {% endif %}.
Message:
This module fails with H7036:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% if admin %}<p>admin</p>
H7037
A {% for %} names more than three names. One name takes the element; two or three unpack a Pair or a Triple of Standard.Tuples.
Message:
This module fails with H7037:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% for a, b, c, d in items %}{{ a }}{% endfor %}
H7038
A {% for %} lacks the word in.
Message:
This module fails with H7038:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% for item of items %}{{ item }}{% endfor %}
H7039
Something other than if and a condition follows the sequence of a {% for %}, such as recursive.
Message:
This module fails with H7039:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% for item in items recursive %}{{ item }}{% endfor %}
H7040
An {% else %} of a {% for %} is not followed by {% endfor %}.
Message:
This module fails with H7040:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% for item in items %}{{ item }}{% else %}<p>none</p>
H7041
A {% for %} is never closed with {% endfor %}.
Message:
This module fails with H7041:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% for item in items %}{{ item }}
H7042
A block is marked required.
Message:
This module fails with H7042:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% block main required %}<p>{{ title }}</p>{% endblock %}
H7043
A {% block %} has no name, or something other than scoped after it.
Message:
This module fails with H7043:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% block %}<p>{{ title }}</p>{% endblock %}
H7044
A {% block %} is never closed with {% endblock %}.
Message:
This module fails with H7044:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% block main %}<p>{{ title }}</p>
H7045
An {% endblock %} names another block than the one it closes.
Message:
This module fails with H7045:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% block main %}<p>{{ title }}</p>{% endblock side %}
H7046
The default of a macro parameter is not a literal.
Message:
This module fails with H7046:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% macro show(x=title) %}{{ x }}{% endmacro %}<p>{{ show() }}</p>
H7047
The parameters of a macro are not separated by commas.
Message:
This module fails with H7047:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% macro show(x y) %}{{ x }}{% endmacro %}<p>{{ show(title, title) }}</p>
H7048
Text follows the parameter list of a macro.
Message:
This module fails with H7048:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% macro show(x) now %}{{ x }}{% endmacro %}<p>{{ show(title) }}</p>
H7049
A {% macro %} is never closed with {% endmacro %}.
Message:
This module fails with H7049:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% macro show(x) %}{{ x }}
H7050
A {% from ... import %} gives an imported macro another name with as.
Message:
This module fails with H7050:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% from "macros.jinja" import show as display %}<p>{{ display(title) }}</p>
Beside it, macros.jinja:
{% macro show(x) %}{{ x }}{% endmacro %}
H7051
A {% from ... import %} names something other than macros.
Message:
This module fails with H7051:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% from "macros.jinja" import 1 %}<p>{{ title }}</p>
Beside it, macros.jinja:
{% macro show(x) %}{{ x }}{% endmacro %}
H7052
A {% from %} lacks the file name as a string, or the word import.
Message:
This module fails with H7052:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% from macros import show %}<p>{{ show(title) }}</p>
Beside it, macros.jinja:
{% macro show(x) %}{{ x }}{% endmacro %}
H7054
A macro is defined twice with two bodies.
Message:
This module fails with H7054:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% macro show(x) %}{{ x }}{% endmacro %}{% macro show(x) %}<b>{{ x }}</b>{% endmacro %}<p>{{ show(title) }}</p>
H7055
A template imports macros from itself.
Message:
This module fails with H7055:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% from "macros.jinja" import show %}<p>{{ show(title) }}</p>
Beside it, macros.jinja:
{% from "macros.jinja" import show %}{% macro show(x) %}{{ x }}{% endmacro %}
H7056
A {% from ... import %} names a macro the file does not define.
Message:
This module fails with H7056:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% from "macros.jinja" import display %}<p>{{ title }}</p>
Beside it, macros.jinja:
{% macro show(x) %}{{ x }}{% endmacro %}
H7057
A template includes or extends itself, directly or through others.
Message:
This module fails with H7057:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% include "part.jinja" %}
Beside it, part.jinja:
<p>{{ title }}</p>{% include "page.jinja" %}
H7058
A template extends a second time.
Message:
This module fails with H7058:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% extends "base.jinja" %}{% extends "base.jinja" %}{% block main %}{{ title }}{% endblock %}
Beside it, base.jinja:
<html>{% block main %}{% endblock %}</html>
H7059
Text stands after {% extends %} outside a block. Jinja2 would drop it; here it is refused.
Message:
This module fails with H7059:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% extends "base.jinja" %}lost text{% block main %}{{ title }}{% endblock %}
Beside it, base.jinja:
<html>{% block main %}{% endblock %}</html>
H7060
A value stands after {% extends %} outside a block.
Message:
This module fails with H7060:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% extends "base.jinja" %}{{ title }}{% block main %}{{ title }}{% endblock %}
Beside it, base.jinja:
<html>{% block main %}{% endblock %}</html>
H7061
An {% if %} or a {% for %} stands after {% extends %} outside a block.
Message:
This module fails with H7061:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% extends "base.jinja" %}{% if admin %}{% endif %}{% block main %}{{ title }}{% endblock %}
Beside it, base.jinja:
<html>{% block main %}{% endblock %}</html>
H7062
An {% include %} stands after {% extends %} outside a block.
Message:
This module fails with H7062:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% extends "base.jinja" %}{% include "part.jinja" %}{% block main %}{{ title }}{% endblock %}
Beside it, base.jinja:
<html>{% block main %}{% endblock %}</html>
Beside it, part.jinja:
<p>{{ title }}</p>
H7063
super() stands in a block that no template above this one has.
Message:
This module fails with H7063:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% block main %}{{ super() }}<p>{{ title }}</p>{% endblock %}
H7064
super() is given arguments.
Message:
This module fails with H7064:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% extends "base.jinja" %}{% block main %}{{ super(1) }}{{ title }}{% endblock %}
Beside it, base.jinja:
<html>{% block main %}{% endblock %}</html>
H7065
An {% extends %} stands inside another tag, such as an {% if %}. It stands at the top level, once.
Message:
This module fails with H7065:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% if admin %}{% extends "base.jinja" %}{% endif %}<p>{{ title }}</p>
Beside it, base.jinja:
<html>{% block main %}{% endblock %}</html>
H7066
A template defines a block that no template it extends has. Jinja2 would drop it; here it is refused.
Message:
This module fails with H7066:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% extends "base.jinja" %}{% block side %}{{ title }}{% endblock %}
Beside it, base.jinja:
<html>{% block main %}{% endblock %}</html>
H7067
A value stands in a place of the HTML where no escaping makes it safe, such as inside a tag's name or attribute list.
Message:
This module fails with H7067:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<div {{ title }}>x</div>
H7069
loop is used for something other than loop.index, loop.index0, loop.length, loop.first or loop.last.
Message:
This module fails with H7069:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% for item in items %}{{ loop }}{% endfor %}
H7070
A macro brought in with {% from ... import %} uses the template's data. Such a macro sees only its arguments.
Message:
This module fails with H7070:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% from "macros.jinja" import show %}<p>{{ show() }}</p>
Beside it, macros.jinja:
{% macro show() %}{{ title }}{% endmacro %}
H7071
loop is used outside a {% for %}.
Message:
This module fails with H7071:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<p>{{ loop.index }}</p>
H7072
A number compared in a condition is too large.
Message:
This module fails with H7072:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% if count > 99999999999999999999 %}many{% endif %}
H7073
A loop attribute is printed that cannot be printed.
Message:
This module fails with H7073:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% for item in items %}{{ loop.cycle }}{% endfor %}
H7075
|length is applied to something that is not a name of the data.
Message:
This module fails with H7075:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<p>{{ "abc"|length }}</p>
H7076
A filter is used that this template language does not support.
Message:
This module fails with H7076:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<p>{{ title|wordcount }}</p>
H7077
none is printed. An Option is printed after asking is not none.
Message:
This module fails with H7077:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<p>{{ none }}</p>
H7079
A macro call stands with a filter in {{ }}. A macro call stands alone.
Message:
This module fails with H7079:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% macro show(x) %}{{ x }}{% endmacro %}<p>{{ show(title)|upper }}</p>
H7080
A loop attribute that is not a number stands where a number goes, in a comparison or in arithmetic. loop.first and loop.last are conditions.
Message:
This module fails with H7080:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% for item in items %}{% if loop.first > 0 %}{{ item }}{% endif %}{% endfor %}
H7082
A condition asks is defined. The template is compiled against one data type, so every name is known when the program is compiled.
Message:
This module fails with H7082:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% if title is defined %}<p>{{ title }}</p>{% endif %}
H7083
is none is asked of something that is not a name of the data.
Message:
This module fails with H7083:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% if "x" is none %}<p>none</p>{% endif %}
H7084
A condition uses a test this template language does not support.
Message:
This module fails with H7084:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% if count is even %}<p>even</p>{% endif %}
H7085
A string is compared with an operator other than == and !=.
Message:
This module fails with H7085:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% if title < "m" %}<p>early</p>{% endif %}
H7086
A comparison does not compare a name with a literal.
Message:
This module fails with H7086:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% if count > count %}<p>more</p>{% endif %}
H7087
Something that is not a condition stands as one, such as a string.
Message:
This module fails with H7087:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% if "yes" %}<p>yes</p>{% endif %}
H7088
A macro parameter that is given a literal is used with a field, as in x.name.
Message:
This module fails with H7088:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% macro show(x) %}{{ x.name }}{% endmacro %}<p>{{ show("a") }}</p>
H7089
A macro is called that is not defined.
Message:
This module fails with H7089:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<p>{{ show(title) }}</p>
H7090
A macro calls itself. A template is expanded when the program is compiled, and a recursion would not end.
Message:
This module fails with H7090:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% macro show(x) %}{{ show(x) }}{% endmacro %}<p>{{ show(title) }}</p>
H7091
A macro is called with more arguments than it has parameters.
Message:
This module fails with H7091:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% macro show(x) %}{{ x }}{% endmacro %}<p>{{ show(title, title) }}</p>
H7092
A macro is called without a value for a parameter that has no default.
Message:
This module fails with H7092:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% macro show(x) %}{{ x }}{% endmacro %}<p>{{ show() }}</p>
H7093
A macro argument is neither a name nor a literal.
Message:
This module fails with H7093:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% macro show(x) %}{{ x }}{% endmacro %}<p>{{ show(title|upper) }}</p>
H7095
The branches of an {% if %} end in different places of the HTML, for example one inside a script and one outside.
Message:
This module fails with H7095:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% if admin %}<script>{% endif %}<p>{{ title }}</p>
H7096
A {% for %} walks over something that is not a name of the data.
Message:
This module fails with H7096:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% for c in "abc" %}{{ c }}{% endfor %}
H7097
The body of a {% for %} ends in a different place of the HTML than it begins.
Message:
This module fails with H7097:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% for item in items %}<script>{% endfor %}
H7098
The {% else %} of a {% for %} ends in a different place of the HTML than it begins.
Message:
This module fails with H7098:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% for item in items %}{{ item }}{% else %}<script>{% endfor %}
H7099
A module that uses @template does not import Standard.Template. The generated code calls it, and its instances come with the import.
Message:
This module fails with H7099:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<p>{{ title }}</p>
H7100
A {% set %} block, a {% with %}, a {% filter %} or a {% call %} is not closed by its end tag.
Message:
This module fails with H7100:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% with name = title %}<p>{{ name }}</p>
H7101
The tag of a {% set %}, a {% with %}, a {% filter %} or a {% call %} is not in its form: set takes one name, = and a value; with takes names with = and values, separated by commas; filter takes filters separated by |; call takes one macro call, and caller() takes no parameters.
Message:
This module fails with H7101:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% set a b = title %}<p>{{ a }}</p>
H7102
The name an {% import ... as %} gave is printed, or given to two imports. It stands for the macros of a file, and hides a field of the data with the same name, as in Jinja2.
Message:
This module fails with H7102:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% import "macros.jinja" as lib %}<p>{{ lib }}</p>
Beside it, macros.jinja:
{% macro show(text) %}<b>{{ text }}</b>{% endmacro %}
H7103
A {% set %} stands after {% extends %} and outside every block. Whether a block of the parent sees the name depends on the order in which Jinja2 runs the two templates; set it inside the block.
Message:
This module fails with H7103:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% extends "base.jinja" %}{% set name = title %}{% block main %}{{ name }}{% endblock %}
Beside it, base.jinja:
<main>{% block main %}{% endblock %}</main>
H7104
A field is asked of a name that a {% set %} or a {% with %} bound to a computed value, such as a text joined with ~. Only a name of the data has fields.
Message:
This module fails with H7104:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% set name = title ~ "!" %}<p>{{ name.length }}</p>
H7105
// or % divides by a name of the data, or by zero. A divisor from the data could be zero, and a division by zero stops the programme; the divisor is a number written in the template.
Message:
This module fails with H7105:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<p>{{ count // count }}</p>
H7106
An operand of + - * // % is something other than a number: a text, a filter or a condition.
Message:
This module fails with H7106:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<p>{{ count + "1" }}</p>
H7107
The operator ~ joins a value marked |safe, or the text of a {% set %} block, to a text that is escaped when printed. What comes out would be half escaped; print the |safe value on its own.
Message:
This module fails with H7107:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<p>{{ title|safe ~ "!" }}</p>
H7108
The arguments of |replace, |truncate, |center, |join or loop.cycle are not literals of the kind the filter takes, or not in their range: the length of |truncate is at least the length of its ending.
Message:
This module fails with H7108:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<p>{{ title|truncate(2) }}</p>
H7109
A {% filter %} block names a filter that applies to a value, such as |join or |length, not to the text the block writes.
Message:
This module fails with H7109:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% filter join %}<p>{{ title }}</p>{% endfilter %}
H7110
A {% set %} stands inside an {% if %}. In Jinja2 the name is still there after the {% endif %} when the branch ran, and missing when it did not; a compiled template cannot follow that. Set the name before the {% if %}, or use {% with %}.
Message:
This module fails with H7110:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% if admin %}{% set name = title %}{% endif %}<p>{{ title }}</p>
H7111
A {% filter %} block stands somewhere other than in HTML text, or the text a {% set %} or {% filter %} block writes ends somewhere other than where it began. What such a block writes is escaped as HTML text.
Message:
This module fails with H7111:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<a title="{% filter upper %}{{ title }}{% endfilter %}">x</a>
H7112
caller() stands in a macro that is called without a {% call %} block, or it is given arguments. Jinja2 fails when it renders such a call.
Message:
This module fails with H7112:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% macro box() %}<div>{{ caller() }}</div>{% endmacro %}<p>{{ box() }}</p>
H7113
The text a {% set %} block wrote is printed somewhere other than in HTML text, such as in an attribute. It is HTML, escaped already, and is printed as it stands.
Message:
This module fails with H7113:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% set cell %}<b>{{ title }}</b>{% endset %}<a title="{{ cell }}">x</a>
H7114
The fourth argument of @template names an option other than trim_blocks and lstrip_blocks.
Message:
This module fails with H7114:
import Standard.Buffer (Buffer);
import Standard.String (String);
import Standard.StringBuilder (StringBuilder, makeStringBuilder, finalize);
import Standard.Template (Render);
module body Example is
record Page: Linear is
title: String;
motto: Option[String];
items: Buffer[Index];
admin: Bool;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out, "strict");
return finalize(out);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<p>{{ title }}</p>
H7115
The first argument of _( ) is the key, written as a string literal: the name of a case of the catalog's keys. A name of the data or an expression in its place would be a key chosen when the page is rendered, which the compiler cannot check.
Message:
This module fails with H7115:
import Standard.String (
String,
fromLiteral,
destroyString
);
import Standard.StringBuilder (
StringBuilder,
makeStringBuilder,
finalize
);
import Standard.Template (
Render
);
import Standard.I18n (
Message,
Text,
Plural,
Language,
Catalog,
englishPlural,
germanPlural
);
module body Example is
union Key: Free is
case Greeting;
case Items;
end;
function english(key: Key): Message is
case key of
when Greeting do
return Text(text => "Hello, {name}!");
when Items do
return Plural(one => "{count} item", other => "{count} items");
end case;
end;
function german(key: Key): Message is
case key of
when Greeting do
return Text(text => "Hallo, {name}!");
when Items do
return Plural(one => "{count} Teil", other => "{count} Teile");
end case;
end;
function others(i: Index): Option[Language[Key]] is
if i = 0 then
return Some(value => Language(code => "de", texts => german, plural => germanPlural));
end if;
return None();
end;
function messages(): Catalog[Key] is
return Catalog(default => Language(code => "en", texts => english, plural => englishPlural), others => others);
end;
record Page: Linear is
lang: String;
user: String;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
let page: Page := Page(lang => fromLiteral("de"), user => fromLiteral("Ada"), count => 2);
let text: String := render(&page);
destroyString(text);
let { lang: String, user: String, count: Int32 } := page;
destroyString(lang);
destroyString(user);
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% catalog messages %}<p>{{ _(user) }}</p>
H7116
Each argument of _( ) has a name of its own; the same name twice would leave open which value the placeholder takes.
Message:
This module fails with H7116:
import Standard.String (
String,
fromLiteral,
destroyString
);
import Standard.StringBuilder (
StringBuilder,
makeStringBuilder,
finalize
);
import Standard.Template (
Render
);
import Standard.I18n (
Message,
Text,
Plural,
Language,
Catalog,
englishPlural,
germanPlural
);
module body Example is
union Key: Free is
case Greeting;
case Items;
end;
function english(key: Key): Message is
case key of
when Greeting do
return Text(text => "Hello, {name}!");
when Items do
return Plural(one => "{count} item", other => "{count} items");
end case;
end;
function german(key: Key): Message is
case key of
when Greeting do
return Text(text => "Hallo, {name}!");
when Items do
return Plural(one => "{count} Teil", other => "{count} Teile");
end case;
end;
function others(i: Index): Option[Language[Key]] is
if i = 0 then
return Some(value => Language(code => "de", texts => german, plural => germanPlural));
end if;
return None();
end;
function messages(): Catalog[Key] is
return Catalog(default => Language(code => "en", texts => english, plural => englishPlural), others => others);
end;
record Page: Linear is
lang: String;
user: String;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
let page: Page := Page(lang => fromLiteral("de"), user => fromLiteral("Ada"), count => 2);
let text: String := render(&page);
destroyString(text);
let { lang: String, user: String, count: Int32 } := page;
destroyString(lang);
destroyString(user);
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% catalog messages %}<p>{{ _("Greeting", name=user, name=user) }}</p>
H7117
{% catalog %} takes the name of a function of no arguments that gives the catalog, without quotes; the module that holds the @template has the function or imports it.
Message:
This module fails with H7117:
import Standard.String (
String,
fromLiteral,
destroyString
);
import Standard.StringBuilder (
StringBuilder,
makeStringBuilder,
finalize
);
import Standard.Template (
Render
);
import Standard.I18n (
Message,
Text,
Plural,
Language,
Catalog,
englishPlural,
germanPlural
);
module body Example is
union Key: Free is
case Greeting;
case Items;
end;
function english(key: Key): Message is
case key of
when Greeting do
return Text(text => "Hello, {name}!");
when Items do
return Plural(one => "{count} item", other => "{count} items");
end case;
end;
function german(key: Key): Message is
case key of
when Greeting do
return Text(text => "Hallo, {name}!");
when Items do
return Plural(one => "{count} Teil", other => "{count} Teile");
end case;
end;
function others(i: Index): Option[Language[Key]] is
if i = 0 then
return Some(value => Language(code => "de", texts => german, plural => germanPlural));
end if;
return None();
end;
function messages(): Catalog[Key] is
return Catalog(default => Language(code => "en", texts => english, plural => englishPlural), others => others);
end;
record Page: Linear is
lang: String;
user: String;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
let page: Page := Page(lang => fromLiteral("de"), user => fromLiteral("Ada"), count => 2);
let text: String := render(&page);
destroyString(text);
let { lang: String, user: String, count: Int32 } := page;
destroyString(lang);
destroyString(user);
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% catalog "messages" %}<p>{{ _("Greeting", name=user) }}</p>
H7118
The text between {% trans %} and {% pluralize %} or {% endtrans %} is the key, one name such as Greeting. The texts of the languages stand in the catalog, not in the template.
Message:
This module fails with H7118:
import Standard.String (
String,
fromLiteral,
destroyString
);
import Standard.StringBuilder (
StringBuilder,
makeStringBuilder,
finalize
);
import Standard.Template (
Render
);
import Standard.I18n (
Message,
Text,
Plural,
Language,
Catalog,
englishPlural,
germanPlural
);
module body Example is
union Key: Free is
case Greeting;
case Items;
end;
function english(key: Key): Message is
case key of
when Greeting do
return Text(text => "Hello, {name}!");
when Items do
return Plural(one => "{count} item", other => "{count} items");
end case;
end;
function german(key: Key): Message is
case key of
when Greeting do
return Text(text => "Hallo, {name}!");
when Items do
return Plural(one => "{count} Teil", other => "{count} Teile");
end case;
end;
function others(i: Index): Option[Language[Key]] is
if i = 0 then
return Some(value => Language(code => "de", texts => german, plural => germanPlural));
end if;
return None();
end;
function messages(): Catalog[Key] is
return Catalog(default => Language(code => "en", texts => english, plural => englishPlural), others => others);
end;
record Page: Linear is
lang: String;
user: String;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
let page: Page := Page(lang => fromLiteral("de"), user => fromLiteral("Ada"), count => 2);
let text: String := render(&page);
destroyString(text);
let { lang: String, user: String, count: Int32 } := page;
destroyString(lang);
destroyString(user);
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% catalog messages %}<p>{% trans name=user %}Hello, {{ name }}!{% endtrans %}</p>
H7119
The count chooses the plural form, so a {% trans %} block with {% pluralize %} names it: count=... in its tag.
Message:
This module fails with H7119:
import Standard.String (
String,
fromLiteral,
destroyString
);
import Standard.StringBuilder (
StringBuilder,
makeStringBuilder,
finalize
);
import Standard.Template (
Render
);
import Standard.I18n (
Message,
Text,
Plural,
Language,
Catalog,
englishPlural,
germanPlural
);
module body Example is
union Key: Free is
case Greeting;
case Items;
end;
function english(key: Key): Message is
case key of
when Greeting do
return Text(text => "Hello, {name}!");
when Items do
return Plural(one => "{count} item", other => "{count} items");
end case;
end;
function german(key: Key): Message is
case key of
when Greeting do
return Text(text => "Hallo, {name}!");
when Items do
return Plural(one => "{count} Teil", other => "{count} Teile");
end case;
end;
function others(i: Index): Option[Language[Key]] is
if i = 0 then
return Some(value => Language(code => "de", texts => german, plural => germanPlural));
end if;
return None();
end;
function messages(): Catalog[Key] is
return Catalog(default => Language(code => "en", texts => english, plural => englishPlural), others => others);
end;
record Page: Linear is
lang: String;
user: String;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
let page: Page := Page(lang => fromLiteral("de"), user => fromLiteral("Ada"), count => 2);
let text: String := render(&page);
destroyString(text);
let { lang: String, user: String, count: Int32 } := page;
destroyString(lang);
destroyString(user);
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% catalog messages %}<p>{% trans %}Items{% pluralize %}{% endtrans %}</p>
H7120
In Jinja2 the text after {% pluralize %} is the plural form. Here the forms of every language stand in the catalog, so nothing may stand there.
Message:
This module fails with H7120:
import Standard.String (
String,
fromLiteral,
destroyString
);
import Standard.StringBuilder (
StringBuilder,
makeStringBuilder,
finalize
);
import Standard.Template (
Render
);
import Standard.I18n (
Message,
Text,
Plural,
Language,
Catalog,
englishPlural,
germanPlural
);
module body Example is
union Key: Free is
case Greeting;
case Items;
end;
function english(key: Key): Message is
case key of
when Greeting do
return Text(text => "Hello, {name}!");
when Items do
return Plural(one => "{count} item", other => "{count} items");
end case;
end;
function german(key: Key): Message is
case key of
when Greeting do
return Text(text => "Hallo, {name}!");
when Items do
return Plural(one => "{count} Teil", other => "{count} Teile");
end case;
end;
function others(i: Index): Option[Language[Key]] is
if i = 0 then
return Some(value => Language(code => "de", texts => german, plural => germanPlural));
end if;
return None();
end;
function messages(): Catalog[Key] is
return Catalog(default => Language(code => "en", texts => english, plural => englishPlural), others => others);
end;
record Page: Linear is
lang: String;
user: String;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
let page: Page := Page(lang => fromLiteral("de"), user => fromLiteral("Ada"), count => 2);
let text: String := render(&page);
destroyString(text);
let { lang: String, user: String, count: Int32 } := page;
destroyString(lang);
destroyString(user);
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% catalog messages %}<p>{% trans count=count %}Items{% pluralize %}{{ count }} items{% endtrans %}</p>
H7121
A template takes its translations from one catalog, named once with {% catalog %}.
Message:
This module fails with H7121:
import Standard.String (
String,
fromLiteral,
destroyString
);
import Standard.StringBuilder (
StringBuilder,
makeStringBuilder,
finalize
);
import Standard.Template (
Render
);
import Standard.I18n (
Message,
Text,
Plural,
Language,
Catalog,
englishPlural,
germanPlural
);
module body Example is
union Key: Free is
case Greeting;
case Items;
end;
function english(key: Key): Message is
case key of
when Greeting do
return Text(text => "Hello, {name}!");
when Items do
return Plural(one => "{count} item", other => "{count} items");
end case;
end;
function german(key: Key): Message is
case key of
when Greeting do
return Text(text => "Hallo, {name}!");
when Items do
return Plural(one => "{count} Teil", other => "{count} Teile");
end case;
end;
function others(i: Index): Option[Language[Key]] is
if i = 0 then
return Some(value => Language(code => "de", texts => german, plural => germanPlural));
end if;
return None();
end;
function messages(): Catalog[Key] is
return Catalog(default => Language(code => "en", texts => english, plural => englishPlural), others => others);
end;
record Page: Linear is
lang: String;
user: String;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
let page: Page := Page(lang => fromLiteral("de"), user => fromLiteral("Ada"), count => 2);
let text: String := render(&page);
destroyString(text);
let { lang: String, user: String, count: Int32 } := page;
destroyString(lang);
destroyString(user);
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% catalog messages %}{% catalog messages %}<p>{{ _("Greeting", name=user) }}</p>
H7122
A translation needs the catalog it comes from: {% catalog name %} stands before the first _( ) or {% trans %} of the template.
Message:
This module fails with H7122:
import Standard.String (
String,
fromLiteral,
destroyString
);
import Standard.StringBuilder (
StringBuilder,
makeStringBuilder,
finalize
);
import Standard.Template (
Render
);
import Standard.I18n (
Message,
Text,
Plural,
Language,
Catalog,
englishPlural,
germanPlural
);
module body Example is
union Key: Free is
case Greeting;
case Items;
end;
function english(key: Key): Message is
case key of
when Greeting do
return Text(text => "Hello, {name}!");
when Items do
return Plural(one => "{count} item", other => "{count} items");
end case;
end;
function german(key: Key): Message is
case key of
when Greeting do
return Text(text => "Hallo, {name}!");
when Items do
return Plural(one => "{count} Teil", other => "{count} Teile");
end case;
end;
function others(i: Index): Option[Language[Key]] is
if i = 0 then
return Some(value => Language(code => "de", texts => german, plural => germanPlural));
end if;
return None();
end;
function messages(): Catalog[Key] is
return Catalog(default => Language(code => "en", texts => english, plural => englishPlural), others => others);
end;
record Page: Linear is
lang: String;
user: String;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
let page: Page := Page(lang => fromLiteral("de"), user => fromLiteral("Ada"), count => 2);
let text: String := render(&page);
destroyString(text);
let { lang: String, user: String, count: Int32 } := page;
destroyString(lang);
destroyString(user);
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
<p>{{ _("Greeting", name=user) }}</p>
H7123
A translation is text for HTML, escaped for the place it lands in, and cannot stand where a JavaScript expression goes.
Message:
This module fails with H7123:
import Standard.String (
String,
fromLiteral,
destroyString
);
import Standard.StringBuilder (
StringBuilder,
makeStringBuilder,
finalize
);
import Standard.Template (
Render
);
import Standard.I18n (
Message,
Text,
Plural,
Language,
Catalog,
englishPlural,
germanPlural
);
module body Example is
union Key: Free is
case Greeting;
case Items;
end;
function english(key: Key): Message is
case key of
when Greeting do
return Text(text => "Hello, {name}!");
when Items do
return Plural(one => "{count} item", other => "{count} items");
end case;
end;
function german(key: Key): Message is
case key of
when Greeting do
return Text(text => "Hallo, {name}!");
when Items do
return Plural(one => "{count} Teil", other => "{count} Teile");
end case;
end;
function others(i: Index): Option[Language[Key]] is
if i = 0 then
return Some(value => Language(code => "de", texts => german, plural => germanPlural));
end if;
return None();
end;
function messages(): Catalog[Key] is
return Catalog(default => Language(code => "en", texts => english, plural => englishPlural), others => others);
end;
record Page: Linear is
lang: String;
user: String;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
let page: Page := Page(lang => fromLiteral("de"), user => fromLiteral("Ada"), count => 2);
let text: String := render(&page);
destroyString(text);
let { lang: String, user: String, count: Int32 } := page;
destroyString(lang);
destroyString(user);
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% catalog messages %}<script>var t = {{ _("Greeting", name=user) }};</script>
H7124
A translation stands alone in {{ }} or as a {% trans %} block; a filter or a ~ would change a text that is the same for every language only in the catalog.
Message:
This module fails with H7124:
import Standard.String (
String,
fromLiteral,
destroyString
);
import Standard.StringBuilder (
StringBuilder,
makeStringBuilder,
finalize
);
import Standard.Template (
Render
);
import Standard.I18n (
Message,
Text,
Plural,
Language,
Catalog,
englishPlural,
germanPlural
);
module body Example is
union Key: Free is
case Greeting;
case Items;
end;
function english(key: Key): Message is
case key of
when Greeting do
return Text(text => "Hello, {name}!");
when Items do
return Plural(one => "{count} item", other => "{count} items");
end case;
end;
function german(key: Key): Message is
case key of
when Greeting do
return Text(text => "Hallo, {name}!");
when Items do
return Plural(one => "{count} Teil", other => "{count} Teile");
end case;
end;
function others(i: Index): Option[Language[Key]] is
if i = 0 then
return Some(value => Language(code => "de", texts => german, plural => germanPlural));
end if;
return None();
end;
function messages(): Catalog[Key] is
return Catalog(default => Language(code => "en", texts => english, plural => englishPlural), others => others);
end;
record Page: Linear is
lang: String;
user: String;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
let page: Page := Page(lang => fromLiteral("de"), user => fromLiteral("Ada"), count => 2);
let text: String := render(&page);
destroyString(text);
let { lang: String, user: String, count: Int32 } := page;
destroyString(lang);
destroyString(user);
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% catalog messages %}<p>{{ _("Greeting", name=user)|upper }}</p>
H7125
After the key, _( ) takes its arguments as name=value: the name is the placeholder {name} of the text it fills.
Message:
This module fails with H7125:
import Standard.String (
String,
fromLiteral,
destroyString
);
import Standard.StringBuilder (
StringBuilder,
makeStringBuilder,
finalize
);
import Standard.Template (
Render
);
import Standard.I18n (
Message,
Text,
Plural,
Language,
Catalog,
englishPlural,
germanPlural
);
module body Example is
union Key: Free is
case Greeting;
case Items;
end;
function english(key: Key): Message is
case key of
when Greeting do
return Text(text => "Hello, {name}!");
when Items do
return Plural(one => "{count} item", other => "{count} items");
end case;
end;
function german(key: Key): Message is
case key of
when Greeting do
return Text(text => "Hallo, {name}!");
when Items do
return Plural(one => "{count} Teil", other => "{count} Teile");
end case;
end;
function others(i: Index): Option[Language[Key]] is
if i = 0 then
return Some(value => Language(code => "de", texts => german, plural => germanPlural));
end if;
return None();
end;
function messages(): Catalog[Key] is
return Catalog(default => Language(code => "en", texts => english, plural => englishPlural), others => others);
end;
record Page: Linear is
lang: String;
user: String;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
let page: Page := Page(lang => fromLiteral("de"), user => fromLiteral("Ada"), count => 2);
let text: String := render(&page);
destroyString(text);
let { lang: String, user: String, count: Int32 } := page;
destroyString(lang);
destroyString(user);
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% catalog messages %}<p>{{ _("Greeting", user) }}</p>
H7126
Each argument in the tag of {% trans %} has a name of its own.
Message:
This module fails with H7126:
import Standard.String (
String,
fromLiteral,
destroyString
);
import Standard.StringBuilder (
StringBuilder,
makeStringBuilder,
finalize
);
import Standard.Template (
Render
);
import Standard.I18n (
Message,
Text,
Plural,
Language,
Catalog,
englishPlural,
germanPlural
);
module body Example is
union Key: Free is
case Greeting;
case Items;
end;
function english(key: Key): Message is
case key of
when Greeting do
return Text(text => "Hello, {name}!");
when Items do
return Plural(one => "{count} item", other => "{count} items");
end case;
end;
function german(key: Key): Message is
case key of
when Greeting do
return Text(text => "Hallo, {name}!");
when Items do
return Plural(one => "{count} Teil", other => "{count} Teile");
end case;
end;
function others(i: Index): Option[Language[Key]] is
if i = 0 then
return Some(value => Language(code => "de", texts => german, plural => germanPlural));
end if;
return None();
end;
function messages(): Catalog[Key] is
return Catalog(default => Language(code => "en", texts => english, plural => englishPlural), others => others);
end;
record Page: Linear is
lang: String;
user: String;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
let page: Page := Page(lang => fromLiteral("de"), user => fromLiteral("Ada"), count => 2);
let text: String := render(&page);
destroyString(text);
let { lang: String, user: String, count: Int32 } := page;
destroyString(lang);
destroyString(user);
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% catalog messages %}<p>{% trans name=user, name=user %}Greeting{% endtrans %}</p>
H7127
The code a translation becomes calls Standard.I18n, so the module that holds the @template imports it, as it imports Standard.Template.
Message:
This module fails with H7127:
import Standard.String (
String,
fromLiteral,
destroyString
);
import Standard.StringBuilder (
StringBuilder,
makeStringBuilder,
finalize
);
import Standard.Template (
Render
);
module body Example is
union Key: Free is
case Greeting;
case Items;
end;
function english(key: Key): Message is
case key of
when Greeting do
return Text(text => "Hello, {name}!");
when Items do
return Plural(one => "{count} item", other => "{count} items");
end case;
end;
function german(key: Key): Message is
case key of
when Greeting do
return Text(text => "Hallo, {name}!");
when Items do
return Plural(one => "{count} Teil", other => "{count} Teile");
end case;
end;
function others(i: Index): Option[Language[Key]] is
if i = 0 then
return Some(value => Language(code => "de", texts => german, plural => germanPlural));
end if;
return None();
end;
function messages(): Catalog[Key] is
return Catalog(default => Language(code => "en", texts => english, plural => englishPlural), others => others);
end;
record Page: Linear is
lang: String;
user: String;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
let page: Page := Page(lang => fromLiteral("de"), user => fromLiteral("Ada"), count => 2);
let text: String := render(&page);
destroyString(text);
let { lang: String, user: String, count: Int32 } := page;
destroyString(lang);
destroyString(user);
return ExitSuccess();
end;
end module body.
Beside it, page.jinja:
{% catalog messages %}<p>{{ _("Greeting", name=user) }}</p>
H7128
In a template that extends another, only the blocks are kept. {% catalog %} stands in the extended template, before the blocks it serves.
Message:
This module fails with H7128:
import Standard.String (
String,
fromLiteral,
destroyString
);
import Standard.StringBuilder (
StringBuilder,
makeStringBuilder,
finalize
);
import Standard.Template (
Render
);
import Standard.I18n (
Message,
Text,
Plural,
Language,
Catalog,
englishPlural,
germanPlural
);
module body Example is
union Key: Free is
case Greeting;
case Items;
end;
function english(key: Key): Message is
case key of
when Greeting do
return Text(text => "Hello, {name}!");
when Items do
return Plural(one => "{count} item", other => "{count} items");
end case;
end;
function german(key: Key): Message is
case key of
when Greeting do
return Text(text => "Hallo, {name}!");
when Items do
return Plural(one => "{count} Teil", other => "{count} Teile");
end case;
end;
function others(i: Index): Option[Language[Key]] is
if i = 0 then
return Some(value => Language(code => "de", texts => german, plural => germanPlural));
end if;
return None();
end;
function messages(): Catalog[Key] is
return Catalog(default => Language(code => "en", texts => english, plural => englishPlural), others => others);
end;
record Page: Linear is
lang: String;
user: String;
count: Int32;
end;
generic [R: Region]
function render(page: &[Page, R]): String is
var out: StringBuilder := makeStringBuilder();
@template("page.jinja", page, out);
return finalize(out);
end;
function main(): ExitCode is
let page: Page := Page(lang => fromLiteral("de"), user => fromLiteral("Ada"), count => 2);
let text: String := render(&page);
destroyString(text);
let { lang: String, user: String, count: Int32 } := page;
destroyString(lang);
destroyString(user);
return ExitSuccess();
end;
end module body.
Beside it, base.jinja:
<main>{% block main %}{% endblock %}</main>
Beside it, page.jinja:
{% extends "base.jinja" %}{% catalog messages %}{% block main %}{{ _("Greeting", name=user) }}{% endblock %}
8. SQL
H8001
A string or a quoted name in the SQL is not closed.
Message:
This module fails with H8001:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users WHERE name = 'ann") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8002
A comment /* in the SQL is not closed with */.
Message:
This module fails with H8002:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users /* everyone") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8003
A blob literal x'...' does not hold an even number of hexadecimal digits.
Message:
This module fails with H8003:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
let result: Either[SqlError, Nat64] := @execute(&~db, "DELETE FROM notes WHERE body = x'ABC'");
case result of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as changed: Nat64) do
printLn(changed);
end case;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8004
A number runs straight into a name, as in 18years.
Message:
This module fails with H8004:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users WHERE age > 18years") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8005
A name is quoted with backticks or brackets. Quote it with double quotes.
Message:
This module fails with H8005:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT [name] FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8006
A numbered parameter such as ?1 stands in the SQL. Write ? and give the values in order.
Message:
This module fails with H8006:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users WHERE age > ?1", 18) for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8007
A named parameter such as :age stands in the SQL. Write ? and give the values in order.
Message:
This module fails with H8007:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users WHERE age > :age", 18) for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8008
A character stands in the SQL that the compiler does not read as SQL, such as #.
Message:
This module fails with H8008:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users WHERE age >= 18 # adults") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8009
A keyword is missing where the grammar needs it, such as BY after ORDER.
Message:
This module fails with H8009:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users ORDER name") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8010
A symbol is missing where the grammar needs it, such as the parenthesis after IN.
Message:
This module fails with H8010:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users WHERE age IN 18, 21") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8011
A name is missing where the grammar needs one, such as the table after FROM.
Message:
This module fails with H8011:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM WHERE age > 18") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8012
The SQL uses something SQLite knows and this compiler does not accept, because it could not give it a type, such as a subquery.
Message:
This module fails with H8012:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users WHERE age > (SELECT avg(age) FROM users)") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8013
A function other than count is given *.
Message:
This module fails with H8013:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Tally: Free is
total: Int64;
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT sum(*) AS total FROM users") for row: Tally do
printLn(row.total);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8014
A column of the result is named without AS.
Message:
This module fails with H8014:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT upper(name) name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8015
OR in INSERT OR or UPDATE OR is followed by something other than ABORT, FAIL, IGNORE, REPLACE or ROLLBACK.
Message:
This module fails with H8015:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
let result: Either[SqlError, Nat64] := @execute(&~db, "INSERT OR SKIP INTO users (name) VALUES (?)", "ann");
case result of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as changed: Nat64) do
printLn(changed);
end case;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8016
The default of a column in a migration is not a literal, a signed number, CURRENT_TIME, CURRENT_DATE, CURRENT_TIMESTAMP or an expression in parentheses.
Message:
This module fails with H8016:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
created TEXT NOT NULL DEFAULT now
) STRICT;
H8017
A column type in a migration has a size, as in VARCHAR(40). A STRICT table knows INT, INTEGER, REAL, TEXT and BLOB, without a size.
Message:
This module fails with H8017:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name VARCHAR(40) NOT NULL
) STRICT;
H8018
After CONSTRAINT and its name, a table constraint is not PRIMARY KEY, UNIQUE, CHECK or FOREIGN KEY.
Message:
This module fails with H8018:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER,
name TEXT NOT NULL,
CONSTRAINT users_key KEY (id)
) STRICT;
H8019
WITHOUT after a table is not followed by ROWID.
Message:
This module fails with H8019:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
) STRICT, WITHOUT ROWS;
H8020
In the list of table options after a comma stands something other than STRICT or WITHOUT ROWID.
Message:
This module fails with H8020:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
) STRICT, WITHOUT_ROWID;
H8021
CREATE INDEX lacks the parenthesis with the columns after the table.
Message:
This module fails with H8021:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
) STRICT;
CREATE INDEX users_name ON users name;
H8022
ALTER TABLE is followed by something other than RENAME, ADD or DROP.
Message:
This module fails with H8022:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
) STRICT;
ALTER TABLE users MODIFY name TEXT;
H8023
A migration creates something other than a table or an index, such as a view.
Message:
This module fails with H8023:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
) STRICT;
CREATE VIEW names AS SELECT name FROM users;
H8024
A migration drops something other than a table or an index, such as a view.
Message:
This module fails with H8024:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
) STRICT;
DROP VIEW names;
H8025
A migration holds a statement other than CREATE TABLE, CREATE INDEX, ALTER TABLE, DROP TABLE, DROP INDEX, INSERT, UPDATE and DELETE, such as PRAGMA.
Message:
This module fails with H8025:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
PRAGMA foreign_keys = ON;
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
) STRICT;
H8026
A query is not SELECT, INSERT, UPDATE or DELETE. A table is created in a migration.
Message:
This module fails with H8026:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
let result: Either[SqlError, Nat64] := @execute(&~db, "CREATE TABLE tags (id INTEGER PRIMARY KEY, label TEXT NOT NULL) STRICT");
case result of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as changed: Nat64) do
printLn(changed);
end case;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8027
The SQL names a table that the migrations do not build.
Message:
This module fails with H8027:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM user") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8028
The SQL names a column that the table does not have.
Message:
This module fails with H8028:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
let result: Either[SqlError, Nat64] := @execute(&~db, "UPDATE users SET years = ? WHERE id = ?", 41, 1);
case result of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as changed: Nat64) do
printLn(changed);
end case;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8029
A parameter stands where its type cannot be told, such as in ORDER BY. A parameter takes its type from a column it is compared with or stored into.
Message:
This module fails with H8029:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users ORDER BY ?", "name") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8030
A column is qualified with a table or alias that the query does not have.
Message:
This module fails with H8030:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT u.name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8032
A query names a column and has no FROM to take it from.
Message:
This module fails with H8032:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8033
No table of the query has a column of this name.
Message:
This module fails with H8033:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users WHERE mail IS NULL") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8034
More than one table of the query has a column of this name. Name the table in front of it.
Message:
This module fails with H8034:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users JOIN notes ON user_id = id") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8035
A sign stands in front of something that is not a number.
Message:
This module fails with H8035:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users ORDER BY -name") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8036
NOT stands in front of something that is not a condition.
Message:
This module fails with H8036:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users WHERE NOT email") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8037
% takes two INTEGERs and is given a REAL.
Message:
This module fails with H8037:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users WHERE score % 2 = 0") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8038
Arithmetic is done on something that is not a number.
Message:
This module fails with H8038:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users WHERE age + '1' > 18") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8039
|| joins something that is not TEXT.
Message:
This module fails with H8039:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name || age AS name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8040
A value is compared with NULL using = or a similar operator. Such a comparison is never true; write IS NULL or IS NOT NULL.
Message:
This module fails with H8040:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users WHERE email = NULL") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8041
Two values of different types are compared, such as TEXT with INTEGER. SQLite compares them without converting, and the answer never depends on the values.
Message:
This module fails with H8041:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users WHERE name = 5") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8042
IS compares two values of different types, which can never be the same.
Message:
This module fails with H8042:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users WHERE name IS 5") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8043
A parameter is tested for NULL. Its value is known where it is given, in the program.
Message:
This module fails with H8043:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users WHERE ? IS NULL", "ann") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8044
LIKE or GLOB is given something that is not TEXT.
Message:
This module fails with H8044:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users WHERE age LIKE '3%'") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8045
A parameter stands on the left of IN. A column stands there.
Message:
This module fails with H8045:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users WHERE ? IN (name, email)", "ann") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8046
NULL stands on the left of IN. That is never true.
Message:
This module fails with H8046:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users WHERE NULL IN (email, name)") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8047
NULL stands in the list of IN. It is never matched.
Message:
This module fails with H8047:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users WHERE email IN ('[email protected]', NULL)") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8048
A value in the list of IN has another type than the value on the left, so the two can never be equal.
Message:
This module fails with H8048:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users WHERE age IN ('18', '21')") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8049
A parameter stands on the left of BETWEEN. A column stands there.
Message:
This module fails with H8049:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users WHERE ? BETWEEN age AND 99", 18) for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8050
NULL stands on the left of BETWEEN. That is never true.
Message:
This module fails with H8050:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users WHERE NULL BETWEEN 1 AND 2") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8051
A bound of BETWEEN has another type than the value it is compared with.
Message:
This module fails with H8051:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users WHERE age BETWEEN '18' AND '65'") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8052
AND or OR joins something that is not a condition.
Message:
This module fails with H8052:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users WHERE age > 18 AND email") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8053
count(*) stands outside the columns, HAVING and ORDER BY, such as in WHERE.
Message:
This module fails with H8053:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users WHERE count(*) > 1") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8054
An aggregate function stands outside the columns, HAVING and ORDER BY, such as in WHERE.
Message:
This module fails with H8054:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users WHERE max(age) > 50") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8055
DISTINCT stands inside a function that is not an aggregate.
Message:
This module fails with H8055:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT upper(DISTINCT name) AS name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8056
A function that takes one argument here is given another number.
Message:
This module fails with H8056:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Tally: Free is
total: Int64;
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT count(name, email) AS total FROM users") for row: Tally do
printLn(row.total);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8057
A function that takes a number, such as abs or sum, is given something else.
Message:
This module fails with H8057:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users WHERE abs(name) > 1") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8058
count is given a parameter.
Message:
This module fails with H8058:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Tally: Free is
total: Int64;
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT count(?) AS total FROM users", "x") for row: Tally do
printLn(row.total);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8059
min or max is given a parameter.
Message:
This module fails with H8059:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users GROUP BY name HAVING max(?) > 1", 1) for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8060
min or max is given NULL.
Message:
This module fails with H8060:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users GROUP BY name HAVING max(NULL) > 1") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8061
coalesce is given fewer than two arguments, or ifnull not exactly two.
Message:
This module fails with H8061:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users WHERE ifnull(email) = 'x'") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8062
coalesce or ifnull is given only parameters, so its type cannot be told.
Message:
This module fails with H8062:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users WHERE email = coalesce(?, ?)", "a", "b") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8063
The first value of coalesce or ifnull that is not a parameter is NULL.
Message:
This module fails with H8063:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users WHERE coalesce(NULL, email) = 'x'") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8064
coalesce or ifnull is given values of different types.
Message:
This module fails with H8064:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users WHERE coalesce(email, 0) = 'x'") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8065
length is given something other than TEXT or BLOB.
Message:
This module fails with H8065:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users WHERE length(age) > 1") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8066
lower or upper is given something other than TEXT.
Message:
This module fails with H8066:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users WHERE upper(age) = 'X'") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8067
The SQL calls a function whose type the compiler does not know. It knows count, sum, total, avg, min, max, coalesce, ifnull, length, lower, upper and abs.
Message:
This module fails with H8067:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users WHERE trim(name) = 'x'") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8068
Two parameters meet at one operator, and neither gives the other a type.
Message:
This module fails with H8068:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users WHERE ? = ?", "a", "b") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8069
A WHERE, ON, HAVING or CHECK is given something that is not a condition.
Message:
This module fails with H8069:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users WHERE email") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8070
A column of the result has a name that cannot name a field of the row record, such as a name with a space or a Hilde keyword.
Message:
This module fails with H8070:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Shout[R: Region]: Free is
shout: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT upper(name) AS \"loud name\" FROM users") for row: Shout[Q] do
printLn(row.shout);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8071
* stands in a query without a table.
Message:
This module fails with H8071:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record User[R: Region]: Free is
id: Int64;
name: Span[Nat8, R];
age: Int64;
email: Option[Span[Nat8, R]];
score: Option[Float64];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT *") for row: User[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8072
t.* names a table or alias the query does not have.
Message:
This module fails with H8072:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record User[R: Region]: Free is
id: Int64;
name: Span[Nat8, R];
age: Int64;
email: Option[Span[Nat8, R]];
score: Option[Float64];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT u.* FROM users") for row: User[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8073
A column of the result is always NULL and so has no type.
Message:
This module fails with H8073:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name, NULL AS note FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8074
A column of the result that is not a plain column has no name. Give it one with AS.
Message:
This module fails with H8074:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT upper(name) FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8075
Two columns of the result have the same name.
Message:
This module fails with H8075:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name, lower(name) AS name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8076
NULL is written into a column that is NOT NULL.
Message:
This module fails with H8076:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
let result: Either[SqlError, Nat64] := @execute(&~db, "INSERT INTO users (name) VALUES (NULL)");
case result of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as changed: Nat64) do
printLn(changed);
end case;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8077
A value of another type is written into a column. A STRICT table refuses it when the program runs.
Message:
This module fails with H8077:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
let result: Either[SqlError, Nat64] := @execute(&~db, "INSERT INTO users (name, age) VALUES (?, '40')", "ann");
case result of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as changed: Nat64) do
printLn(changed);
end case;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8078
A value that may be NULL is written into a column that is NOT NULL.
Message:
This module fails with H8078:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
let result: Either[SqlError, Nat64] := @execute(&~db, "UPDATE users SET name = email");
case result of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as changed: Nat64) do
printLn(changed);
end case;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8079
A table stands twice in FROM without an alias that tells the two apart.
Message:
This module fails with H8079:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users JOIN users ON age = age") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8081
LIMIT or OFFSET is given something other than an INTEGER that is not NULL.
Message:
This module fails with H8081:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users LIMIT '10'") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8082
The column list of an INSERT names a column twice.
Message:
This module fails with H8082:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
let result: Either[SqlError, Nat64] := @execute(&~db, "INSERT INTO users (name, name) VALUES (?, ?)", "ann", "bob");
case result of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as changed: Nat64) do
printLn(changed);
end case;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8083
An INSERT leaves out a column that is NOT NULL and has no default.
Message:
This module fails with H8083:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
let result: Either[SqlError, Nat64] := @execute(&~db, "INSERT INTO users (age) VALUES (?)", 40);
case result of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as changed: Nat64) do
printLn(changed);
end case;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8084
An INSERT has a column list and DEFAULT VALUES.
Message:
This module fails with H8084:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
let result: Either[SqlError, Nat64] := @execute(&~db, "INSERT INTO users (name) DEFAULT VALUES");
case result of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as changed: Nat64) do
printLn(changed);
end case;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8085
A row of an INSERT has another number of values than there are columns.
Message:
This module fails with H8085:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
let result: Either[SqlError, Nat64] := @execute(&~db, "INSERT INTO users (name, age) VALUES (?)", "ann");
case result of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as changed: Nat64) do
printLn(changed);
end case;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8086
A column in a migration has the type ANY. The compiler checks a query against a column that has INT, INTEGER, REAL, TEXT or BLOB.
Message:
This module fails with H8086:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
extra ANY
) STRICT;
H8087
A column in a migration has no type. A STRICT table gives every column one.
Message:
This module fails with H8087:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
nickname
) STRICT;
H8088
A column in a migration has a type that a STRICT table does not know, such as DATE.
Message:
This module fails with H8088:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
born DATE
) STRICT;
H8089
A migration creates a table that exists already.
Message:
This module fails with H8089:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
) STRICT;
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
email TEXT
) STRICT;
H8090
A table is created without STRICT. Without it SQLite stores a value of any type in any column, and the types the compiler checks would not hold.
Message:
This module fails with H8090:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
);
H8091
A table defines a column twice.
Message:
This module fails with H8091:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
name TEXT
) STRICT;
H8092
A table has more than one PRIMARY KEY.
Message:
This module fails with H8092:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL PRIMARY KEY
) STRICT;
H8093
The PRIMARY KEY of a table names a column the table does not have.
Message:
This module fails with H8093:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER,
name TEXT NOT NULL,
PRIMARY KEY (user_id)
) STRICT;
H8094
ALTER TABLE ADD COLUMN adds a column the table has already.
Message:
This module fails with H8094:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
) STRICT;
ALTER TABLE users ADD COLUMN name TEXT;
H8095
ALTER TABLE ADD COLUMN adds a PRIMARY KEY. SQLite cannot add one to an existing table.
Message:
This module fails with H8095:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
) STRICT;
ALTER TABLE users ADD COLUMN code INTEGER PRIMARY KEY;
H8096
ALTER TABLE ADD COLUMN adds a NOT NULL column without a default. SQLite refuses to add such a column to a table that has rows.
Message:
This module fails with H8096:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
) STRICT;
ALTER TABLE users ADD COLUMN city TEXT NOT NULL;
H8097
ALTER TABLE RENAME TO gives a table the name of a table that exists.
Message:
This module fails with H8097:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
) STRICT;
CREATE TABLE people (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
) STRICT;
ALTER TABLE people RENAME TO users;
H8098
ALTER TABLE RENAME COLUMN gives a column the name of a column the table has.
Message:
This module fails with H8098:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
email TEXT
) STRICT;
ALTER TABLE users RENAME COLUMN email TO name;
H8099
ALTER TABLE DROP COLUMN drops the last column of a table. Drop the table instead.
Message:
This module fails with H8099:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
) STRICT;
CREATE TABLE tags (label TEXT) STRICT;
ALTER TABLE tags DROP COLUMN label;
H8100
DROP TABLE drops a table that does not exist.
Message:
This module fails with H8100:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
) STRICT;
DROP TABLE tags;
H8101
CREATE INDEX creates an index whose name exists already.
Message:
This module fails with H8101:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
) STRICT;
CREATE INDEX users_key ON users (name);
CREATE INDEX users_key ON users (id, name);
H8102
DROP INDEX drops an index that does not exist.
Message:
This module fails with H8102:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
) STRICT;
DROP INDEX users_name;
H8103
A migration file cannot be read, for example because a directory carries the name of a migration.
Message:
This module fails with H8103:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
) STRICT;
Beside it, migrations/2-more.sql/README:
This directory is not a migration.
H8104
There is no directory migrations beside the module. The schema a query is checked against is built from the migrations in that directory.
Message:
This module fails with H8104:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migration/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
) STRICT;
H8105
The directory migrations holds no file that ends in .sql.
Message:
This module fails with H8105:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.txt:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
) STRICT;
H8106
A file in migrations is not called <number>-<name>.sql with a number from 1.
Message:
This module fails with H8106:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
) STRICT;
H8107
The migrations are not numbered 1, 2, 3 and so on without a gap, or a number stands twice.
Message:
This module fails with H8107:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
) STRICT;
Beside it, migrations/3-email.sql:
ALTER TABLE users ADD COLUMN email TEXT;
H8108
A statement in a migration is not followed by ; before the next one begins.
Message:
This module fails with H8108:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
) STRICT
CREATE INDEX users_name ON users (name);
H8109
A migration holds a parameter ?. A migration is run as it stands, so a parameter in it has nothing to stand for.
Message:
This module fails with H8109:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
) STRICT;
INSERT INTO users (name) VALUES (?);
H8110
A module that uses @query, @execute or @migrations imports neither Standard.Sqlite nor Standard.SqlCipher. The generated code calls one of them, and the import chooses which.
Message:
This module fails with H8110:
module body Example is
function main(): ExitCode is
printLn(@migrations);
return ExitSuccess();
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8111
The SQL of one @query or @execute holds more than one statement.
Message:
This module fails with H8111:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
let result: Either[SqlError, Nat64] := @execute(&~db, "DELETE FROM notes; DELETE FROM users");
case result of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as changed: Nat64) do
printLn(changed);
end case;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8112
The SQL has another number of parameters ? than values are given.
Message:
This module fails with H8112:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users WHERE age > ?") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8113
The row type of @query is not a record, written Name or Name[R] with R the region the row's text is lent under.
Message:
This module fails with H8113:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "SELECT name FROM users") for row: Span[Nat8, Q] do
printLn(row);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8115
@query is given a statement that returns no rows. Write it with @execute, or add RETURNING.
Message:
This module fails with H8115:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
record Person[R: Region]: Free is
name: Span[Nat8, R];
end;
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
@query(&~db, "DELETE FROM users WHERE age > 99") for row: Person[Q] do
printLn(row.name);
else error do
printLn(describe(error));
end for;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
H8116
@execute is given a statement that returns rows. Write it with @query ... for.
Message:
This module fails with H8116:
import Standard.Sqlite (Connection, Writing, SqlError, describe, openWriter, closeDatabase, migrate);
module body Example is
generic [R: Region]
function run(db: &![Connection[Writing], R]): Unit is
let result: Either[SqlError, Nat64] := @execute(&~db, "SELECT name FROM users");
case result of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as changed: Nat64) do
printLn(changed);
end case;
return nil;
end;
function main(): ExitCode is
case openWriter(":memory:") of
when Left(left as error: SqlError) do
printLn(describe(error));
return ExitFailure();
when Right(right as opened: Connection[Writing]) do
var db: Connection[Writing] := opened;
case migrate(&!db, @migrations) of
when Left(left as error: SqlError) do
printLn(describe(error));
when Right(right as applied: Index) do
run(&!db);
end case;
closeDatabase(db);
return ExitSuccess();
end case;
end;
end module body.
Beside it, migrations/1-schema.sql:
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL DEFAULT 0,
email TEXT,
score REAL
) STRICT;
CREATE TABLE notes (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users (id),
body BLOB NOT NULL
) STRICT;
9. Contracts
H2051
The body of a public function has requires, ensures or raises clauses. A public function's contract is written once, in its interface, where every caller reads it. The message names the place of the interface's contract, or of the declaration when the interface has none.
Message:
This module fails with H2051:
module body Example is
function half(n: Nat32): Nat32
requires n > 0
is
return n / 2;
end;
function main(): ExitCode is
printLn(half(8));
return ExitSuccess();
end;
end module body.
Beside it, Example.hih:
module Example is
function half(n: Nat32): Nat32
requires n > 0;
function main(): ExitCode;
end module.
H2052
A function imported from C has a contract. The compiler checks a contract with statements it puts into the body of the function, and a function imported with Foreign_Import has no body of its own.
Message:
This module fails with H2052:
pragma Unsafe_Module;
module body Example is
pragma Foreign_Import(External_Name => "abs");
function cAbs(value: Int32): Int32
requires value > -100
is
end;
function main(): ExitCode is
printLn(cAbs(-5));
return ExitSuccess();
end;
end module body.
H2053
An ensures names a variable that the function's body declares. An ensures is checked at every return, where the body's variables are still in scope; a name the body declares would be read there instead of the module's name of the same spelling. The ensures reads the parameters, result and old values only.
Message:
This module fails with H2053:
module body Example is
function addThree(n: Nat32): Nat32
ensures result > limit
is
let limit: Nat32 := 3;
return n + limit;
end;
function main(): ExitCode is
printLn(addThree(4));
return ExitSuccess();
end;
end module body.
H2054
A function with an ensures has a parameter named result. In an ensures the name result stands for the value the function returns, so a parameter of that name could not be read there.
Message:
This module fails with H2054:
module body Example is
function doubled(result: Nat32): Nat32
ensures result > 0
is
return result * 2;
end;
function main(): ExitCode is
printLn(doubled(4));
return ExitSuccess();
end;
end module body.
H2055
old is written where it has no meaning: in a requires, inside another old, or with other than one value. old(e) is the value e had when the function was entered, read again when it returns; in a requires, which is checked at the entrance, it would say nothing. The first line of the message says which of the three it was.
Message:
This module fails with H2055:
module body Example is
function half(n: Nat32): Nat32
requires old(n) > 0
is
return n / 2;
end;
function main(): ExitCode is
printLn(half(8));
return ExitSuccess();
end;
end module body.
H2056
A test function has a requires. A violated requires names the call that broke it, and nothing in the programme calls a test: hilde test does. A test checks what it needs in its body, with the assertions of Standard.Testing.
Message:
This module fails with H2056:
module body Example.Test is
function testHalf(): Unit
requires argumentCount() > 0
is
return nil;
end;
end module body.
With this command:
H2057
A record with an invariant can be built or written outside its module. An invariant is checked at the returns of the module's public functions, where a value leaves the module. That holds it only if no other module can build the record or assign its slots, which is so when the interface declares the type opaque or not at all. A module without an interface has no private record.
Message:
This module fails with H2057:
module body Example is
function main(): ExitCode is
let r: Range := Range(low => 1, high => 2);
printLn(r.high);
return ExitSuccess();
end;
end module body.
Beside it, Example.hih:
module Example is
record Range: Free is
low: Nat32;
high: Nat32;
invariant low <= high;
end;
function main(): ExitCode;
end module.
H3096
A condition uses a linear value itself instead of through a reference. A condition only reads. A linear value used itself is consumed, and the function would have lost it before its body ran.
Message:
This module fails with H3096:
module body Example is
record Token: Linear is
value: Nat32;
end;
function valueOf(token: Token): Nat32 is
let { value: Nat32 } := token;
return value;
end;
function spend(token: Token): Nat32
requires valueOf(token) > 0
is
return valueOf(token);
end;
function main(): ExitCode is
printLn(spend(Token(value => 3)));
return ExitSuccess();
end;
end module body.
H3097
A condition takes a reference to write through. A condition only reads, so a reference to write through has no place in it; a write reference that is a parameter is read with &.
Message:
This module fails with H3097:
module body Example is
record Counter: Linear is
count: Nat32;
end;
generic [R: Region]
function peek(counter: &[Counter, R]): Nat32 is
return counter->count;
end;
generic [R: Region]
function bump(counter: &![Counter, R]): Nat32 is
counter->count := counter->count + 1;
return counter->count;
end;
generic [R: Region]
function current(counter: &![Counter, R]): Nat32
requires bump(&~counter) > 0
is
return counter->count;
end;
function main(): ExitCode is
var c: Counter := Counter(count => 1);
printLn(current(&!c));
let { count: Nat32 } := c;
printLn(count);
return ExitSuccess();
end;
end module body.
H3098
A condition calls a function that reaches a binding module, C or a reference to write through. The compiler follows every call of a condition through the bodies of the functions it reaches, to any depth. The message gives the chain of calls and what its last function does: it stands in a module whose name begins with Bindings., it is imported from C or writes C with @embed, or it takes a reference to write through. The compiler's own module Hilde.Pervasive is not looked into; its parameters are.
Message:
This module fails with H3098:
module body Example is
record Counter: Linear is
count: Nat32;
end;
generic [R: Region]
function peek(counter: &[Counter, R]): Nat32 is
return counter->count;
end;
generic [R: Region]
function bump(counter: &![Counter, R]): Nat32 is
counter->count := counter->count + 1;
return counter->count;
end;
function countedTwice(n: Nat32): Nat32 is
var c: Counter := Counter(count => n);
let first: Nat32 := bump(&!c);
let { count: Nat32 } := c;
return first + count;
end;
function half(n: Nat32): Nat32
requires countedTwice(n) > 0
is
return n / 2;
end;
function main(): ExitCode is
printLn(half(8));
return ExitSuccess();
end;
end module body.
H3099
A condition calls through a function pointer or a method of a type parameter. Which function runs is decided later, by the value of the pointer or by the type the parameter stands for, and the compiler cannot look into it where the condition is checked.
Message:
This module fails with H3099:
module body Example is
function double(n: Nat32): Nat32 is
return n * 2;
end;
function apply(f: Fn[Nat32, Nat32], n: Nat32): Nat32
requires f(n) > 0
is
return f(n);
end;
function main(): ExitCode is
printLn(apply(double, 4));
return ExitSuccess();
end;
end module body.
H3100
old is given a value that is not free. old keeps a copy of its value from the entrance to the return, and a linear value cannot be copied.
Message:
This module fails with H3100:
module body Example is
record Token: Linear is
value: Nat32;
end;
function valueOf(token: Token): Nat32 is
let { value: Nat32 } := token;
return value;
end;
function fresh(): Token is
return Token(value => 1);
end;
function plusOne(n: Nat32): Nat32
ensures result = (n + valueOf(old(fresh())))
is
return n + 1;
end;
function main(): ExitCode is
printLn(plusOne(4));
return ExitSuccess();
end;
end module body.
H3101
A function with a requires is taken as a function pointer. The compiler hands every call of a function with a requires the place of the call, for the message of a violated condition; a call through a pointer has no such place.
Message:
This module fails with H3101:
module body Example is
function half(n: Nat32): Nat32
requires n > 0
is
return n / 2;
end;
function main(): ExitCode is
let f: Fn[Nat32, Nat32] := half;
printLn(f(8));
return ExitSuccess();
end;
end module body.
H5008
The entry point function has a requires. A violated requires names the call that broke it, and no call in the programme calls the entry point.
Message:
This module fails with H5008:
module body Example is
function main(): ExitCode
requires argumentCount() > 0
is
return ExitSuccess();
end;
end module body.
10. Error kinds
H2058
The method of an instance has a raises clause. The raises clause of a method stands once, at the method's declaration in the typeclass, where every instance and every caller reads it; an instance inherits it. A clause on the instance's method would be a second promise nothing holds to the first, so it is refused. The message names the method.
Message:
This module fails with H2058:
module body Example is
typeclass Measure(T: Free) is
method measure(value: T): Int32
raises Broken;
end;
instance Measure(Int32) is
method measure(value: Int32): Int32
raises Broken is
return value * 2;
end;
end;
function main(): ExitCode
raises Broken is
printLn(measure(21));
return ExitSuccess();
end;
end module body.
H3102
A raise names a kind that the function's raises clause does not. A function may raise only the kinds its own clause names. The message names the kind raised and the kinds the clause holds, or says that the function has no clause.
Message:
This module fails with H3102:
module body Example is
function pick(n: Int32): Int32
raises NotFound is
if n < 0 then
raise Denied;
end if;
return n;
end;
function main(): ExitCode
raises NotFound is
printLn(pick(7));
return ExitSuccess();
end;
end module body.
H3103
A call can end with an error kind that the caller's raises clause does not name. A function may call only functions whose error kinds it names itself, so a kind never reaches a caller that did not promise it; the entry point is held to the same rule. The message names the callee, the kinds that are missing and the kinds the caller names. A method call is held to the clause at the typeclass's declaration of the method.
Message:
This module fails with H3103:
module body Example is
function pick(n: Int32): Int32
raises NotFound is
return n;
end;
function main(): ExitCode is
printLn(pick(7));
return ExitSuccess();
end;
end module body.
H3104
A function with a raises clause is taken as a function pointer. A call through a pointer has no signature the compiler can hold against the caller's clause, so such a function is called by its name only.
Message:
This module fails with H3104:
module body Example is
function pick(n: Int32): Int32
raises NotFound is
return n;
end;
function main(): ExitCode
raises NotFound is
let f: Fn[Int32, Int32] := pick;
printLn(f(7));
return ExitSuccess();
end;
end module body.
11. Never and slots
H2060
A return stands in a function that returns Never. Such a function has no value to give back, so no path through it reaches a return.
Message:
This module fails with H2060:
module body Example is
function stop(): Never is
return nil;
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H2061
A function that returns Never has a path that comes to the end of its body. Here the if has no else, so the path where b is false falls through.
Message:
This module fails with H2061:
module body Example is
function stop(b: Bool): Never is
if b then
abort("stopped");
end if;
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H2062
A function that returns Never carries an ensures clause. The clause would be checked at a return, and there is none.
Message:
This module fails with H2062:
module body Example is
function stop(n: Int32): Never
ensures n > 0
is
abort("stopped");
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H2063
A slot has neither a default body nor an implementation in the programme. The check runs when the last module of the programme is compiled.
Message:
This module fails with H2063:
import Greeting (
greet
);
module body Example is
function main(): ExitCode is
greet();
return ExitSuccess();
end;
end module body.
Beside it, Greeting.hih:
module Greeting is
-- Says hello; the programme implements it.
pragma Slot;
function greet(): Unit;
end module.
Beside it, Greeting.hiq:
module body Greeting is
end module body.
H2064
Two functions of the programme implement the same slot. A slot has one implementation, so the compiler would not know which to call.
Message:
This module fails with H2064:
module body Example is
pragma Implements(Name => "Hilde.Pervasive.onOverflow");
function first(message: Span[Nat8, Static]): Never is
abort(message);
end;
pragma Implements(Name => "Hilde.Pervasive.onOverflow");
function second(message: Span[Nat8, Static]): Never is
abort(message);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H2065
An implementation of a slot has another signature than the slot. The parameters must agree in number, name and type, and the result types must be the same.
Message:
This module fails with H2065:
module body Example is
pragma Implements(Name => "Hilde.Pervasive.onOverflow");
function handled(text: Span[Nat8, Static]): Never is
abort(text);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H2066
A pragma Implements names something that is not a slot. The name is looked up among the slots of the modules compiled before this one.
Message:
This module fails with H2066:
module body Example is
pragma Implements(Name => "Hilde.Pervasive.nowhere");
function handled(message: Span[Nat8, Static]): Never is
abort(message);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H2067
A pragma Slot or pragma Implements stands where it has no meaning: Slot at a function definition, Implements at a declaration of an interface, either at a function generic over a type, or both at the same function. A slot generic over regions only is allowed: a region has no run-time form, and every instantiation is the same function. The first line of the message names which.
Message:
This module fails with H2067:
module body Example is
pragma Implements(Name => "Hilde.Pervasive.onOverflow");
generic [T: Free]
function handled(message: Span[Nat8, Static], other: T): Never is
abort(message);
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H3109
Never stands as the type of something that holds a value: a parameter, a variable, a slot of a record or union, a constant, a conversion, a size, a function pointer or a type argument. Never has no value, so only the result of a function or a method can have it.
Message:
This module fails with H3109:
module body Example is
function take(x: Never): Unit is
return nil;
end;
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
H3110
A call of a function that returns Never is an argument or an operand. The call never gives a value, so the expression around it could never be finished. A let, an assignment, a return and a branch of an if expression may still hold such a call.
Message:
This module fails with H3110:
module body Example is
function show(n: Int32): Unit is
printLn(n);
return nil;
end;
function main(): ExitCode is
show(abort("stopped"));
return ExitSuccess();
end;
end module body.
12. Targets
H1038
No compiler for wasm32-wasi is found. hilde finds it itself: zig, given as HILDE_ZIG or on the path, which brings the C library of WASI, else clang on the path with wasm-ld and the C library of WASI. HILDE_WASM_CC=zig or clang takes that one and fails when it is missing; then the message names it. The example takes the path away.
Message:
This module fails with H1038:
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
With this command:
H1039
HILDE_WASM_CC names a compiler hilde does not know for WebAssembly. It chooses between the two hilde looks for, zig and clang; a misspelt name is refused rather than taken for not set.
Message:
This module fails with H1039:
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
With this command:
H1040
hilde test --target=wasm finds no runtime for WebAssembly. The test programmes are command modules, and wasmtime runs them.
Message:
The catalog gives no failing example for this code.
H1041
--target names no target hilde builds for. The names are the five of pragma Targets; for a name a few letters away from one the message suggests that one.
Message:
This module fails with H1041:
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
With this command:
H1042
--target names another system than the one hilde runs on. A binary is built by the C compiler of the machine and linked against its C library, so it is built on a machine of the system it is for; only WebAssembly, a module that runs on every system, is built anywhere.
Message:
The catalog gives no failing example for this code.
H1043
--target=wasm is given with an archive or a shared object. WebAssembly has two forms of a module: a command, a programme with main, and a reactor, a library whose host calls it.
Message:
This module fails with H1043:
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
With this command:
H1044
The output of a programme for wasm does not end in .wasm. A module is no binary of the system: its name says what it is, and wasmtime and a host of JavaScript take it by that name.
Message:
This module fails with H1044:
module body Example is
function main(): ExitCode is
return ExitSuccess();
end;
end module body.
With this command:
H2068
A pragma Targets names no target, one twice, one that does not exist, or an Instead that is no module. Instead names a module by its full name, and only where a target is left out.
Message:
This module fails with H2068:
import Standard.Thing (
size
);
module body Example is
function main(): ExitCode is
let n: Index := size();
return ExitSuccess();
end;
end module body.
Beside it, Thing.hih:
pragma Targets(Names => "linux plan9");
module Standard.Thing is
function size(): Index;
end module.
Beside it, Thing.hiq:
module body Standard.Thing is
function size(): Index is
return 1;
end;
end module body.
H2069
Another pragma than one pragma Targets stands before a module interface. What a module binds and whether it is unsafe stands before its body.
Message:
This module fails with H2069:
import Standard.Thing (
size
);
module body Example is
function main(): ExitCode is
let n: Index := size();
return ExitSuccess();
end;
end module body.
Beside it, Thing.hih:
pragma Unsafe_Module;
pragma Targets(Names => "linux openbsd freebsd darwin wasm");
module Standard.Thing is
function size(): Index;
end module.
Beside it, Thing.hiq:
module body Standard.Thing is
function size(): Index is
return 1;
end;
end module body.
H2070
A module outside the standard library names its targets. A programme does not choose the targets it is built for: it is there for those of the modules it imports, and the compiler holds it to them. The standard library is a module whose name begins with Standard. or Bindings.
Message:
This module fails with H2070:
import Thing (
size
);
module body Example is
function main(): ExitCode is
let n: Index := size();
return ExitSuccess();
end;
end module body.
Beside it, Thing.hih:
pragma Targets(Names => "linux openbsd freebsd darwin wasm");
module Thing is
function size(): Index;
end module.
Beside it, Thing.hiq:
module body Thing is
function size(): Index is
return 1;
end;
end module body.
H2071
An interface of the standard library names no targets. Every module whose name begins with Standard. says which targets it is there for, so that a programme built for one finds out at its imports, not in the link.
Message:
This module fails with H2071:
import Standard.Thing (
size
);
module body Example is
function main(): ExitCode is
let n: Index := size();
return ExitSuccess();
end;
end module body.
Beside it, Thing.hih:
module Standard.Thing is
function size(): Index;
end module.
Beside it, Thing.hiq:
module body Standard.Thing is
function size(): Index is
return 1;
end;
end module body.
H2072
A module names a target that one of its imports is not there for. This holds whatever the programme is built for, so the targets of the standard library cannot claim more than they have.
Message:
This module fails with H2072:
import Standard.Thing (
size
);
module body Example is
function main(): ExitCode is
let n: Index := size();
return ExitSuccess();
end;
end module body.
Beside it, Thing.hih:
pragma Targets(Names => "linux openbsd freebsd darwin wasm");
import Standard.Other (
one
);
module Standard.Thing is
function size(): Index;
end module.
Beside it, Thing.hiq:
module body Standard.Thing is
function size(): Index is
return 1;
end;
end module body.
Beside it, Other.hih:
pragma Targets(Names => "linux openbsd freebsd darwin");
module Standard.Other is
function one(): Index;
end module.
Beside it, Other.hiq:
module body Standard.Other is
function one(): Index is
return 1;
end;
end module body.
H2073
A programme built for a target imports a module that is not there for it. The message names the targets the module is there for and, where its pragma Targets names one, the module to take instead; --error-format=json and hilde-json carry that module as a suggestion.
Message:
This module fails with H2073:
import Standard.Thing (
size
);
module body Example is
function main(): ExitCode is
let n: Index := size();
return ExitSuccess();
end;
end module body.
Beside it, Thing.hih:
pragma Targets(Names => "linux openbsd freebsd darwin", Instead => "Standard.Other");
module Standard.Thing is
function size(): Index;
end module.
Beside it, Thing.hiq:
module body Standard.Thing is
function size(): Index is
return 1;
end;
end module body.
With this command:
13. Packages
H1045
A package command was given, and hilde-pkg is not beside the compiler.
Message:
The catalog gives no failing example for this code.
H1046
hilde-pkg is beside the compiler and could not be started.
Message:
The catalog gives no failing example for this code.
H1501
The command needs a package, and there is no hilde.toml in the directory.
Message:
The catalog gives no failing example for this code.
H1502
hilde.toml is not TOML; the message names the line and the column.
Message:
The catalog gives no failing example for this code.
H1503
hilde.toml has a key or a table that a manifest does not have, such as a misspelt one.
Message:
The catalog gives no failing example for this code.
H1504
A key hilde.toml must have is missing: the name or the version of the package, or the git URL or the version of a requirement.
Message:
The catalog gives no failing example for this code.
H1505
A value has the wrong form: a name that is no module prefix, a version that is not vX.Y.Z, a capability that is none, or an argument of the wrong form.
Message:
The catalog gives no failing example for this code.
H1506
One prefix comes from two git URLs, or a package is named otherwise than the prefix it is required by.
Message:
The catalog gives no failing example for this code.
H1507
git is not on the PATH, and the command needs it.
Message:
The catalog gives no failing example for this code.
H1508
git failed: a wrong URL, a repository that may not be read, or a programme that could not be started.
Message:
The catalog gives no failing example for this code.
H1509
The repository has no tag of the version asked for; the suggestion names the tags nearest to it.
Message:
The catalog gives no failing example for this code.
H1510
The tree of a package holds a symbolic link or a special file.
Message:
The catalog gives no failing example for this code.
H1511
A release has no signature, and the policy of the package asks for one.
Message:
The catalog gives no failing example for this code.
H1512
A signature does not hold, the key is not the one taken on first use, or a release is unsigned after a signed one.
Message:
The catalog gives no failing example for this code.
H1513
The secret key cannot be read, is no signify key, or has a passphrase.
Message:
The catalog gives no failing example for this code.
H1514
hilde.sum is missing, has a bad line, or lacks the line of a requirement.
Message:
The catalog gives no failing example for this code.
H1515
A tree in vendor/ is missing, changed, or not named in hilde.sum.
Message:
The catalog gives no failing example for this code.
H1516
Two majors of one package are required; a new major takes a new prefix.
Message:
The catalog gives no failing example for this code.
H1517
The tree of a package is deeper than 64 directories.
Message:
The catalog gives no failing example for this code.
H1518
A directory or a file of a package cannot be read.
Message:
The catalog gives no failing example for this code.
H1519
A file or a directory cannot be written.
Message:
The catalog gives no failing example for this code.
H1521
hilde new or a key would write over something that is there.
Message:
The catalog gives no failing example for this code.
H1522
hilde doc finds no module or declaration of the name.
Message:
The catalog gives no failing example for this code.
H1523
A target of hilde.toml is not allowed by the pragma Targets of a module the package reaches.
Message:
The catalog gives no failing example for this code.
H1530
The version of a release is lower than its change of interface calls for, such as a break under a minor version.
Message:
The catalog gives no failing example for this code.
H1531
A module of the package has no test file.
Message:
The catalog gives no failing example for this code.
H1532
The tests of the package do not pass, or the compiler failed on it.
Message:
The catalog gives no failing example for this code.
H1533
An exported function is called in no test.
Message:
The catalog gives no failing example for this code.
H1534
The version of a release is not newer than the newest tag.
Message:
The catalog gives no failing example for this code.
H1535
hilde rust found no cargo: none on PATH and none named in HILDE_CARGO.
Message:
The catalog gives no failing example for this code.
H1536
The environment or a cargo configuration asks for panic = "abort", under which no bridge can catch a panic.
Message:
The catalog gives no failing example for this code.
H1537
A file of rust/bridge is no bridge module, there is none, or a function of a bridge does not start with the guard.
Message:
The catalog gives no failing example for this code.
H1538
cargo failed, wrote no static library, wrote a second one, or printed no native libraries.
Message:
The catalog gives no failing example for this code.
H1539
Message:
The catalog gives no failing example for this code.
H1540
The rust-toolchain.toml or the guard crate rust/hilde-bridge beside the compiler is missing or names no pinned version.
Message:
The catalog gives no failing example for this code.
H1541
The value of --target is not written as a target of rustc.
Message:
The catalog gives no failing example for this code.
14. Sperli
H1047
A run command was given, and hilde-launcher is not beside the compiler.
Message:
The catalog gives no failing example for this code.
H1048
hilde-launcher is beside the compiler and could not be started.
Message:
The catalog gives no failing example for this code.
H1601
The peer showed no certificate, or one that the CA of the job does not vouch for, or offered a TLS version below 1.3.
Message:
The catalog gives no failing example for this code.
H1602
The subject of the certificate of the peer is not the job and the rank the connection is for.
Message:
The catalog gives no failing example for this code.
H1603
A host is listed in SPERLI_REFUSED_HOSTS, is host-a.invalid or host-b.invalid, or a name below one of them, or is on the deny list of the operator; a deny list cannot lift the rule.
Message:
The catalog gives no failing example for this code.
H1604
The join token of a peer has expired.
Message:
The catalog gives no failing example for this code.
H1605
The join token of a peer was made for another job.
Message:
The catalog gives no failing example for this code.
H1606
The join token of a peer was made for another rank, size, incarnation or host.
Message:
The catalog gives no failing example for this code.
H1607
The join token of a peer is malformed, or its signature does not hold under the public key of the launcher.
Message:
The catalog gives no failing example for this code.
H1608
A frame announces more payload than the limit of 16 MiB; it is refused before a payload byte is read.
Message:
The catalog gives no failing example for this code.
H1609
A frame belongs to an older incarnation of the job; its payload is read and dropped, and the wait goes on.
Message:
The catalog gives no failing example for this code.
H1610
The header of a frame breaks a rule of the protocol: an unknown type, a flag, service or membership epoch that is not 0, another job, other ranks, or a newer incarnation.
Message:
The catalog gives no failing example for this code.
H1611
A peer was lost: the connection closed, or no frame came within the silence limit.
Message:
The catalog gives no failing example for this code.
H1612
A peer sent an abort frame.
Message:
The catalog gives no failing example for this code.
H1613
The hello of a peer is missing, comes twice, has another version or offers no point-to-point service.
Message:
The catalog gives no failing example for this code.
H1614
The command line of hilde run or its host list is wrong: a missing or unknown option, a number out of range, no host, or a line that is no host and port.
Message:
The catalog gives no failing example for this code.
H1615
A rank could not be started, or the keys, certificates or ports of the job could not be made.
Message:
The catalog gives no failing example for this code.
H1616
The job description a rank was given on its standard input is malformed.
Message:
The catalog gives no failing example for this code.
H1617
A collective frame does not match the call it answers: another operation, type, reduce operation, phase, root or sequence number, or contributions of gather in different length.
Message:
The catalog gives no failing example for this code.
H1618
The arguments of a collective call are wrong: a root outside the job, an element type and reduce operation that do not go together, data that is no whole number of elements or blocks, or contributions of reduce in different length.
Message:
The catalog gives no failing example for this code.
H1619
A checkpoint file has another magic or version, or a job, epoch, rank, size or length that is not the one expected, or it is too short.
Message:
The catalog gives no failing example for this code.
H1620
The SHA-256 of the state in a checkpoint file is not the one in its header, or not the one the COMMIT file lists for the rank.
Message:
The catalog gives no failing example for this code.
H1621
A COMMIT file is malformed, is for another job or epoch, or its CompositeSig signature does not hold for the public key of the job. An epoch without a valid COMMIT file does not count.
Message:
The catalog gives no failing example for this code.
H1622
A resume found no epoch with a valid COMMIT file and all rank files, or the ranks did not agree on the epoch to resume.
Message:
The catalog gives no failing example for this code.
H1623
A resume was asked for a job of another number of ranks than the checkpoint was written with. Version 1 of the format requires the same size.
Message:
The catalog gives no failing example for this code.
H1624
A checkpoint was asked for while a send or receive was still open on this rank.
Message:
The catalog gives no failing example for this code.
H1625
A checkpoint could not be written or sent, or no checkpoint directory was named.
Message:
The catalog gives no failing example for this code.