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

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:

Error:
  Title: Parse Error
  Error code: H0001
  Module:
    [unknown]
  Location:
    Filename: 'Example.hiq'
    From: line 3, column 30
    To: line 3, column 31
  Description:
    Character not allowed in source text: `$`
  Code:
    1 | module body Example is
    2 |     function main(): ExitCode is
    3 |         let total: Int32 := 1 $ 2;
    4 |         printLn(total);
    5 |         return ExitSuccess();

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.

↑ back to top

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:

Error:
  Title: Parse Error
  Error code: H0003
  Module:
    [unknown]
  Location:
    Filename: 'Example.hiq'
    From: line 6, column 16
    To: line 6, column 16
  Description:
    End of file in string literal.
  Code:
    4 |         return ExitSuccess();
    5 |     end;
    6 | end module body.

This module fails with H0003:

module body Example is
    function main(): ExitCode is
        printLn("unclosed);
        return ExitSuccess();
    end;
end module body.

↑ back to top

H0004

A string in triple quotes is opened and never closed, so the file ends inside it.

Message:

Error:
  Title: Parse Error
  Error code: H0004
  Module:
    [unknown]
  Location:
    Filename: 'Example.hiq'
    From: line 6, column 16
    To: line 6, column 16
  Description:
    End of file in triple string literal.
  Code:
    4 |         return ExitSuccess();
    5 |     end;
    6 | end module body.

This module fails with H0004:

module body Example is
    function main(): ExitCode is
        printLn("""unclosed);
        return ExitSuccess();
    end;
end module body.

↑ back to top

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:

Error:
  Title: Parse Error
  Error code: H0005
  Module:
    [unknown]
  Location:
    Filename: 'Example.hiq'
    From: line 3, column 31
    To: line 3, column 32
  Description:
    Error during parse.
  Code:
    1 | module body Example is
    2 |     function main(): ExitCode is
    3 |         let total: Int32 := 1 +;
    4 |         printLn(total);
    5 |         return ExitSuccess();

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.

↑ back to top

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:

Error:
  Title: Parse Error
  Error code: H0006
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 2, column 4
    To: line 4, column 8
  Description:
    Function pointer type specifier must have at least one argument.
  Code:
    1 | module body Example is
    2 |     function keep(callback: Fn): Unit is
    3 |         return nil;
    4 |     end;
    5 | 
    6 |     function main(): ExitCode is

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.

↑ back to top

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:

Character literal '`lit` is more than one character.

The catalog gives no failing example for this code.

↑ back to top

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:

Error:
  Title: Parse Error
  Error code: H0008
  Module:
    [unknown]
  Location:
    Filename: 'Example.hiq'
    From: line 2, column 13
    To: line 2, column 19
  Description:
    `method` is a reserved word and cannot be a name. Rename it, for example to `way`; docs/syntax.en.md, section 1, lists the reserved words.
    
    Suggested fix: `way`
  Code:
    1 | module body Example is
    2 |     function method(count: Int32): Int32 is
    3 |         return count;
    4 |     end;

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.

↑ back to top

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:

Error:
  Title: Parse Error
  Error code: H0009
  Module:
    [unknown]
  Location:
    Filename: 'Example.hiq'
    From: line 3, column 34
    To: line 3, column 35
  Description:
    Hilde has no operator precedence: an operator takes two operands, and only `+`, `*`, `and` and `or` can be chained with themselves. Put the operation before `*` in parentheses, as in `(a + b) * c`.
    
    Suggested fix: `(1 + 2)`
  Code:
    1 | module body Example is
    2 |     function main(): ExitCode is
    3 |         let total: Int32 := 1 + 2 * 3;
    4 |         printLn(total);
    5 |         return ExitSuccess();

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.

↑ back to top

H0010

An index stands after a name. The result of a call is bound to a name first, and the name is indexed.

Message:

Error:
  Title: Parse Error
  Error code: H0010
  Module:
    [unknown]
  Location:
    Filename: 'Example.hiq'
    From: line 7, column 35
    To: line 7, column 36
  Description:
    An index stands after a name, not after a call. Bind the result of the call to a name first, `let text: Span[Nat8, R] := asSpan(&s);`, and index the name, `text[i]`.
  Code:
    5 | 
    6 |     function main(): ExitCode is
    7 |         let first: Nat8 := digits()[0];
    8 |         printLn(first);
    9 |         return ExitSuccess();

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.

↑ back to top

H0011

Only a variable can be borrowed. A literal is bound to a name first, and the name is borrowed.

Message:

Error:
  Title: Parse Error
  Error code: H0011
  Module:
    [unknown]
  Location:
    Filename: 'Example.hiq'
    From: line 8, column 23
    To: line 8, column 25
  Description:
    Only a variable can be borrowed, not the literal `21`. Bind the value to a name first, `let key: Nat64 := 21;`, and borrow the name, `&key`.
  Code:
     6 | 
     7 |     function main(): ExitCode is
     8 |         printLn(twice(&21));
     9 |         return ExitSuccess();
    10 |     end;

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.

↑ back to top

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:

Error:
  Title: Parse Error
  Error code: H0012
  Module:
    [unknown]
  Location:
    Filename: 'Example.hiq'
    From: line 12, column 32
    To: line 12, column 33
  Description:
    A field stands after a name, not after a call. Bind the result of the call to a name first, `let node: Node := nodeAt();`, and take the field of the name, `node.kind`.
  Code:
    10 | 
    11 |     function main(): ExitCode is
    12 |         let x: Int32 := origin().x;
    13 |         printLn(x);
    14 |         return ExitSuccess();

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.

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H6018
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 3, column 27
    To: line 3, column 28
  Description:
    Bad whitespace escape sequence
  Code:
    1 | module body Example is
    2 |     function main(): ExitCode is
    3 |         printLn("one \  two");
    4 |         return ExitSuccess();
    5 |     end;

This module fails with H6018:

module body Example is
    function main(): ExitCode is
        printLn("one \  two");
        return ExitSuccess();
    end;
end module body.

↑ back to top

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:

Error:
  Title: Parse Error
  Error code: H6058
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 3, column 27
    To: line 3, column 28
  Description:
    A `\u{...}` escape takes one to six hexadecimal digits of a code point up to `10FFFF`, and no surrogate (`D800` to `DFFF`).
  Code:
    1 | module body Example is
    2 |     function main(): ExitCode is
    3 |         printLn("\u{110000}");
    4 |         return ExitSuccess();
    5 |     end;

This module fails with H6058:

module body Example is
    function main(): ExitCode is
        printLn("\u{110000}");
        return ExitSuccess();
    end;
end module body.

↑ back to top

2. Types

H2020

An instance names something that is not a type class.

Message:

Error:
  Title: Declaration Error
  Error code: H2020
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 6, column 4
    To: line 7, column 8
  Description:
    Cannot create an instance for `Point` because it is not a typeclass.
  Code:
    4 |     end;
    5 | 
    6 |     instance Point(Int32) is
    7 |     end;
    8 | 
    9 |     function main(): ExitCode is

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.

↑ back to top

H2021

An instance defines a method that its type class does not declare.

Message:

Error:
  Title: Declaration Error
  Error code: H2021
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 6, column 4
    To: line 14, column 8
  Description:
    The typeclass `Describe` has no method named `explain`
  Code:
     4 |     end;
     5 | 
     6 |     instance Describe(Int32) is
     7 |         method describe(value: Int32): Int32 is
     8 |             return value;
     9 |         end;
    10 | 
    11 |         method explain(value: Int32): Int32 is
    12 |             return value;
    13 |         end;
    14 |     end;
    15 | 
    16 |     function main(): ExitCode is

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.

↑ back to top

H2022

An instance leaves out a method of its type class. The message names the missing methods.

Message:

Error:
  Title: Declaration Error
  Error code: H2022
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 7, column 4
    To: line 11, column 8
  Description:
    The instance `Describe(Int32)` does not implement every method of the typeclass.
    
    Missing: `explain`.
    
    An instance has to implement every method the typeclass declares, even one whose body does nothing: a method that is simply absent cannot be reported at the call site, only much later and as an internal error.
  Code:
     5 |     end;
     6 | 
     7 |     instance Describe(Int32) is
     8 |         method describe(value: Int32): Int32 is
     9 |             return value;
    10 |         end;
    11 |     end;
    12 | 
    13 |     function main(): ExitCode is

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.

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2023
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 2, column 4
    To: line 4, column 8
  Description:
    The parameter for the typeclass `Measure` cannot be declared to be in the `Region` universe, because regions are distinct from types.
    
    Consider using one of `Type`, `Linear`, or `Free` instead.
  Code:
    1 | module body Example is
    2 |     typeclass Measure(R: Region) is
    3 |         method measure(value: Int32): Int32;
    4 |     end;
    5 | 
    6 |     function main(): ExitCode is

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.

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2024
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 2, column 4
    To: line 4, column 8
  Description:
    The record `Point` was declared to belong to the `Region` universe, but regions are distinct from types.
    
    Consider using one of `Type`, `Linear`, or `Free` instead.
  Code:
    1 | module body Example is
    2 |     record Point: Region is
    3 |         x: Int32;
    4 |     end;
    5 | 
    6 |     function main(): ExitCode is

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.

↑ back to top

H2025

An instance names a type class that is not declared in the module and not imported.

Message:

Error:
  Title: Declaration Error
  Error code: H2025
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 2, column 4
    To: line 6, column 8
  Description:
    Cannot find typeclass with the name `Describe`
  Code:
    1 | module body Example is
    2 |     instance Describe(Int32) is
    3 |         method describe(value: Int32): Int32 is
    4 |             return value;
    5 |         end;
    6 |     end;
    7 | 
    8 |     function main(): ExitCode is

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.

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2026
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 2, column 4
    To: line 5, column 8
  Description:
    The type parameter `T` does not appear anywhere in the signature of the function.
  Code:
    1 | module body Example is
    2 |     generic [T: Free]
    3 |     function answer(): Int32 is
    4 |         return 42;
    5 |     end;
    6 | 
    7 |     function main(): ExitCode is

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.

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2031
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 3, column 8
    To: line 3, column 19
  Description:
    The function `show` does not end in a return statement.
  Code:
    1 | module body Example is
    2 |     function show(n: Int32): Unit is
    3 |         printLn(n);
    4 |     end;
    5 | 

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.

↑ back to top

H2032

The argument of a generic instance uses the same type parameter twice. Each type parameter may appear only once in it.

Message:

Error:
  Title: Declaration Error
  Error code: H2032
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 11, column 4
    To: line 16, column 8
  Description:
    Generic instances can only use each type parameter once in the argument.
  Code:
     9 |     end;
    10 | 
    11 |     generic [U: Free]
    12 |     instance Describe(Pair[U, U]) is
    13 |         method describe(value: Pair[U, U]): Int32 is
    14 |             return 2;
    15 |         end;
    16 |     end;
    17 | 
    18 |     function main(): ExitCode is

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.

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2033
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 4
    To: line 15, column 8
  Description:
    The number of type parameters in the instance declaration must be the same as the number of type variables applied to the argument.
  Code:
     8 |     end;
     9 | 
    10 |     generic [U: Free, V: Free]
    11 |     instance Describe(Box[U]) is
    12 |         method describe(value: Box[U]): Int32 is
    13 |             return 1;
    14 |         end;
    15 |     end;
    16 | 
    17 |     function main(): ExitCode is

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.

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2034
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 6, column 4
    To: line 11, column 8
  Description:
    Typeclass arguments cannot be lone type parameters.
  Code:
     4 |     end;
     5 | 
     6 |     generic [U: Free]
     7 |     instance Describe(U) is
     8 |         method describe(value: U): Int32 is
     9 |             return 1;
    10 |         end;
    11 |     end;
    12 | 
    13 |     function main(): ExitCode is

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.

↑ back to top

H2035

The argument of a generic instance mixes type parameters with concrete types. It uses either type parameters only or no type parameters.

Message:

Error:
  Title: Declaration Error
  Error code: H2035
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 11, column 4
    To: line 16, column 8
  Description:
    The type `Int32` is not a type parameter, but generic instances must use either all type parameters or none of them in the argument.
    
    Consider adding another generic parameter with universe `Free`
  Code:
     9 |     end;
    10 | 
    11 |     generic [U: Free]
    12 |     instance Describe(Pair[U, Int32]) is
    13 |         method describe(value: Pair[U, Int32]): Int32 is
    14 |             return 2;
    15 |         end;
    16 |     end;
    17 | 
    18 |     function main(): ExitCode is

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.

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2037
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 4
    To: line 15, column 8
  Description:
    The type parameters in a generic instance declaration cannot have the same name as the type parameter in the corresponding typeclass. The colliding name is `T`.
    
    Give the type parameter of the instance another name.
  Code:
     8 |     end;
     9 | 
    10 |     generic [T: Free]
    11 |     instance Describe(Box[T]) is
    12 |         method describe(value: Box[T]): Int32 is
    13 |             return 1;
    14 |         end;
    15 |     end;
    16 | 
    17 |     function main(): ExitCode is

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.

↑ back to top

H3003

One type parameter of a generic function would have to stand for two different types in the same call.

Message:

Error:
  Title: Type Error
  Error code: H3003
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 10, column 32
  Description:
    The type parameter `T` cannot be bound to both `Int32` and `Bool`
  Code:
     8 |         let n: Int32 := 1;
     9 |         let flag: Bool := true;
    10 |         printLn(first(n, flag));
    11 |         return ExitSuccess();
    12 |     end;

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3004
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 12, column 8
    To: line 12, column 56
  Description:
    The type parameter `T` must be `Free` but `Ticket` is `Linear`
  Code:
    10 | 
    11 |     function main(): ExitCode is
    12 |         let ticket: Ticket := keep(Ticket(number => 1));
    13 |         let { number: Int32 } := ticket;
    14 |         printLn(number);

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3007
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 4
    To: line 15, column 8
  Description:
    Cannot define an instance with argument `Ticket` because it should belong to the `Free` universe, but it is actually in the `Linear` universe.
  Code:
     8 |     end;
     9 | 
    10 |     instance Describe(Ticket) is
    11 |         method describe(value: Ticket): Int32 is
    12 |             let { number: Int32 } := value;
    13 |             return number;
    14 |         end;
    15 |     end;
    16 | 
    17 |     function main(): ExitCode is

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.

↑ back to top

H3008

The two operands of an arithmetic operator have different types. Hilde converts nothing implicitly; convert one operand first.

Message:

Error:
  Title: Type Error
  Error code: H3008
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 5, column 8
    To: line 5, column 31
  Description:
    Both operands to an arithmetic expression must be compatible types. The LHS has type `Int32` but the RHS has type `Int64`.
  Code:
    3 |         let small: Int32 := 1;
    4 |         let large: Int64 := 2;
    5 |         printLn(small + large);
    6 |         return ExitSuccess();
    7 |     end;

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.

↑ back to top

H3009

An operand of an arithmetic operator is not a number.

Message:

Error:
  Title: Type Error
  Error code: H3009
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 4, column 8
    To: line 4, column 29
  Description:
    Both operands of an arithmetic operator must be numeric types, but `Bool` is not.
  Code:
    2 |     function main(): ExitCode is
    3 |         let flag: Bool := true;
    4 |         printLn(flag + flag);
    5 |         return ExitSuccess();
    6 |     end;

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.

↑ back to top

H3010

A value of an unsigned type is negated. Nat8 to Nat64, Index and ByteSize have no negative values.

Message:

Error:
  Title: Type Error
  Error code: H3010
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 4, column 8
    To: line 4, column 20
  Description:
    Negation is not defined for the unsigned type `Nat8`. Its values have no opposite inside the type.
  Code:
    2 |     function main(): ExitCode is
    3 |         let n: Nat8 := 5;
    4 |         printLn(-n);
    5 |         return ExitSuccess();
    6 |     end;

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3012
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 8, column 8
    To: line 8, column 35
  Description:
    Negation is not defined for the type `Money`: it does not implement the typeclass `TrappingNegation`. Give it an instance if it should have a negation.
  Code:
     6 |     function main(): ExitCode is
     7 |         let debt: Money := Money(cents => 500);
     8 |         let credit: Money := -debt;
     9 |         printLn(credit.cents);
    10 |         return ExitSuccess();

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.

↑ back to top

H3020

Something that is neither a function, a method nor a function pointer is called.

Message:

Error:
  Title: Type Error
  Error code: H3020
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 4, column 8
    To: line 4, column 22
  Description:
    The type `Int32` is neither a function, method or function pointer, and cannot be called.
  Code:
    2 |     function main(): ExitCode is
    3 |         let n: Int32 := 5;
    4 |         printLn(n(1));
    5 |         return ExitSuccess();
    6 |     end;

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3021
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 8, column 8
    To: line 8, column 31
  Description:
    The callable `f` expects 2 arguments but 1 was given.
  Code:
     6 |     function main(): ExitCode is
     7 |         let f: Fn[Int32, Int32, Int32] := add;
     8 |         let sum: Int32 := f(1);
     9 |         printLn(sum);
    10 |         return ExitSuccess();

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.

↑ back to top

H3022

A case that binds by name leaves out a case of the union. Every case of the union needs its own when.

Message:

Error:
  Title: Type Error
  Error code: H3022
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 13, column 17
  Description:
    Non-exhaustive case statement.
  Code:
     8 |     function main(): ExitCode is
     9 |         let s: Shape := Dot();
    10 |         case s of
    11 |             when Dot do
    12 |                 printLn(0);
    13 |         end case;
    14 |         return ExitSuccess();
    15 |     end;

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3023
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 5, column 8
    To: line 10, column 17
  Description:
    Union must be public or from the same module to be used in a case statement.
  Code:
     3 | module body Example is
     4 |     function main(): ExitCode is
     5 |         case make() of
     6 |             when Dot do
     7 |                 printLn(0);
     8 |             when Circle(radius: Int32) do
     9 |                 printLn(radius);
    10 |         end case;
    11 |         return ExitSuccess();
    12 |     end;

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3024
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 8, column 8
    To: line 11, column 17
  Description:
    The case expression has type `Point` which is not a union type.
  Code:
     6 |     function main(): ExitCode is
     7 |         let p: Point := Point(x => 1);
     8 |         case p of
     9 |             when Point(x: Int32) do
    10 |                 printLn(x);
    11 |         end case;
    12 |         return ExitSuccess();
    13 |     end;

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.

↑ back to top

H3025

A when that binds by name lists slots that the case of the union does not have, or leaves some out.

Message:

Error:
  Title: Type Error
  Error code: H3025
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 15, column 17
  Description:
    The set of slots (`diameter`) in the case statement doesn't match the set of slots in the union definition (`radius`).
  Code:
     8 |     function main(): ExitCode is
     9 |         let s: Shape := Circle(radius => 2);
    10 |         case s of
    11 |             when Dot do
    12 |                 printLn(0);
    13 |             when Circle(diameter: Int32) do
    14 |                 printLn(diameter);
    15 |         end case;
    16 |         return ExitSuccess();
    17 |     end;

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3027
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 4, column 8
    To: line 4, column 37
  Description:
    Cannot cast to `Int32` from `Bool`
  Code:
    2 |     function main(): ExitCode is
    3 |         let flag: Bool := true;
    4 |         let n: Int32 := flag : Int32;
    5 |         printLn(n);
    6 |         return ExitSuccess();

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.

↑ back to top

H3029

The condition of an if, a while or an if expression is not a Bool.

Message:

Error:
  Title: Type Error
  Error code: H3029
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 4, column 8
    To: line 6, column 15
  Description:
    The condition in `if`-statements should be a boolean type, but is `Int32`
  Code:
    2 |     function main(): ExitCode is
    3 |         let n: Int32 := 1;
    4 |         if n then
    5 |             printLn(n);
    6 |         end if;
    7 |         return ExitSuccess();
    8 |     end;

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.

↑ back to top

H3030

A record or a case of a union is built with positional arguments. Its constructor takes named arguments only.

Message:

Error:
  Title: Type Error
  Error code: H3030
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 8, column 8
    To: line 8, column 36
  Description:
    Arguments to record constructor must be named.
  Code:
     6 | 
     7 |     function main(): ExitCode is
     8 |         let p: Point := Point(1, 2);
     9 |         printLn(p.x);
    10 |         return ExitSuccess();

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.

↑ back to top

H3031

A constructor is called with names that are not the slots of the record or of the case.

Message:

Error:
  Title: Type Error
  Error code: H3031
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 8, column 8
    To: line 8, column 46
  Description:
    Arguments to record constructor have the wrong names.
  Code:
     6 | 
     7 |     function main(): ExitCode is
     8 |         let p: Point := Point(x => 1, z => 2);
     9 |         printLn(p.x);
    10 |         return ExitSuccess();

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3033
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 4, column 8
    To: line 4, column 34
  Description:
    The type `Int32` cannot be destructured because it is not a record.
  Code:
    2 |     function main(): ExitCode is
    3 |         let n: Int32 := 5;
    4 |         let { value: Int32 } := n;
    5 |         printLn(value);
    6 |         return ExitSuccess();

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3034
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 5, column 8
    To: line 5, column 35
  Description:
    The type `Point` is not a public record and so cannot be destructured.
  Code:
    3 | module body Example is
    4 |     function main(): ExitCode is
    5 |         let { x: Int32 } := make();
    6 |         printLn(x);
    7 |         return ExitSuccess();

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3035
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 9, column 8
    To: line 9, column 30
  Description:
    The set of slots mentioned differs from the set of slots in `Point`
  Code:
     7 |     function main(): ExitCode is
     8 |         let p: Point := Point(x => 1, y => 2);
     9 |         let { x: Int32 } := p;
    10 |         printLn(x);
    11 |         return ExitSuccess();

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3037
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 8, column 8
    To: line 8, column 16
  Description:
    The value of this expression has type `Option[Int32]`, which carries a failure the caller is meant to look at, so it may not be thrown away. Handle it with a case statement, hand it to your own caller with the ? operator, or, if the failure really is to be ignored here, say so in the program with ignore(...).
  Code:
     6 | 
     7 |     function main(): ExitCode is
     8 |         half(4);
     9 |         return ExitSuccess();
    10 |     end;

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3038
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 3, column 24
    To: line 3, column 26
  Description:
    The `?` operator hands a failure back to the caller, so it needs a value that can carry one: an `Option` or an `Either`. This expression has type `Int32`.
  Code:
    1 | module body Example is
    2 |     function twice(n: Int32): Option[Int32] is
    3 |         let m: Int32 := n?;
    4 |         let r: Option[Int32] := Some(value => m * 2);
    5 |         return r;

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3039
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 8, column 24
    To: line 8, column 32
  Description:
    The `?` operator returns the failure out of the enclosing function, so that function has to be able to carry it. The operand has type `Option[Int32]` but the function returns `Int32`. For an Option the function must return an Option; for an Either it must return an Either whose left type is the same.
  Code:
     6 | 
     7 |     function quarter(n: Int32): Int32 is
     8 |         let h: Int32 := half(n)?;
     9 |         return h / 2;
    10 |     end;

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3040
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 8, column 24
    To: line 8, column 32
  Description:
    The `?` operator may only stand as the whole right-hand side of a `let` binding or as a whole statement. It is an early return out of the enclosing function, and it is written where that return is visible on its own line rather than buried inside a larger expression.
  Code:
     6 | 
     7 |     function quarter(n: Int32): Option[Int32] is
     8 |         let q: Int32 := half(n)? / 2;
     9 |         let r: Option[Int32] := Some(value => q);
    10 |         return r;

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.

↑ back to top

H3041

The value of a constant is not a constant expression, for example a function call.

Message:

Error:
  Title: Type Error
  Error code: H3041
  Module:
    Example
  Location:
    [no span available]
  Description:
    The expression is not a valid constant expression.
  Code:
    [no span available]

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3043
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 8, column 8
    To: line 8, column 44
  Description:
    You can't call a function pointer with a named argument list, because function pointers don't preserve parameter names, so we wouldn't know how to assign arguments to parameters.
  Code:
     6 |     function main(): ExitCode is
     7 |         let f: Fn[Int32, Int32, Int32] := add;
     8 |         let sum: Int32 := f(a => 1, b => 2);
     9 |         printLn(sum);
    10 |         return ExitSuccess();

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.

↑ back to top

H3044

The two branches of an if expression have different types.

Message:

Error:
  Title: Type Error
  Error code: H3044
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 4, column 8
    To: line 4, column 43
  Description:
    The branches of the `if`-expression have different types: `Int32` and `Bool`
  Code:
    2 |     function main(): ExitCode is
    3 |         let flag: Bool := true;
    4 |         printLn(if flag then 1 else false);
    5 |         return ExitSuccess();
    6 |     end;

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.

↑ back to top

H3045

The operand of not is not a Bool.

Message:

Error:
  Title: Type Error
  Error code: H3045
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 4, column 8
    To: line 4, column 23
  Description:
    The operand of a negation operator must be a boolean expression, but it has the type `Int32`
  Code:
    2 |     function main(): ExitCode is
    3 |         let n: Int32 := 1;
    4 |         printLn(not n);
    5 |         return ExitSuccess();
    6 |     end;

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.

↑ back to top

H3046

An operand of and or or is not a Bool.

Message:

Error:
  Title: Type Error
  Error code: H3046
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 5, column 8
    To: line 5, column 28
  Description:
    Both operands of a conjunction operator must be boolean expressions, but they have types `Int32` and `Bool`
  Code:
    3 |         let n: Int32 := 1;
    4 |         let flag: Bool := true;
    5 |         printLn(n and flag);
    6 |         return ExitSuccess();
    7 |     end;

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.

↑ back to top

H3049

A record has no slot of the given name.

Message:

Error:
  Title: Type Error
  Error code: H3049
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 9, column 8
    To: line 9, column 21
  Description:
    The type `Point` has no slot with name `z`
  Code:
     7 |     function main(): ExitCode is
     8 |         let p: Point := Point(x => 1, y => 2);
     9 |         printLn(p.z);
    10 |         return ExitSuccess();
    11 |     end;

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.

↑ back to top

H3050

A method of a type class is called with a value whose type has no instance of that class.

Message:

Error:
  Title: Type Error
  Error code: H3050
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 14, column 8
    To: line 14, column 29
  Description:
    The typeclass `Describe` has no instance which matches for `Int32`
  Code:
    12 |     function main(): ExitCode is
    13 |         let n: Int32 := 5;
    14 |         printLn(describe(n));
    15 |         return ExitSuccess();
    16 |     end;

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.

↑ back to top

H3052

A slot is read from a record that another module exports only as an opaque type.

Message:

Error:
  Title: Type Error
  Error code: H3052
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 6, column 8
    To: line 6, column 21
  Description:
    The slot `x` is not publically visible in the type `Point` and so cannot be read.
  Code:
    4 |     function main(): ExitCode is
    5 |         let p: Point := make();
    6 |         printLn(p.x);
    7 |         return ExitSuccess();
    8 |     end;

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3053
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 10, column 26
  Description:
    Cannot take a path of the type `Shape` because it is not a record.
  Code:
     8 |     function main(): ExitCode is
     9 |         let s: Shape := Circle(radius => 2);
    10 |         printLn(s.radius);
    11 |         return ExitSuccess();
    12 |     end;

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.

↑ back to top

H3054

A binding in a case clause declares another type than the slot has.

Message:

Error:
  Title: Type Error
  Error code: H3054
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 4, column 8
    To: line 9, column 17
  Description:
    The slot `number` should have type `Int32` but is declared to have type `Int64`
  Code:
     2 |     function main(): ExitCode is
     3 |         let count: Option[Int32] := Some(value => 5);
     4 |         case count of
     5 |             when Some(value as number: Int64) do
     6 |                 printLn(number);
     7 |             when None do
     8 |                 printLn(0);
     9 |         end case;
    10 |         return ExitSuccess();
    11 |     end;

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3055
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 3, column 8
    To: line 3, column 23
  Description:
    `None` is generic but unconstrained, so its type is ambiguous: its type is `Option[T]`, and nothing here decides `T`.
    
    Give the value a type: declare the variable it goes into with one, or cast it.
  Code:
    1 | module body Example is
    2 |     function main(): ExitCode is
    3 |         ignore(None());
    4 |         return ExitSuccess();
    5 |     end;

This module fails with H3055:

module body Example is
    function main(): ExitCode is
        ignore(None());
        return ExitSuccess();
    end;
end module body.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3056
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 4, column 8
    To: line 4, column 21
  Description:
    The type parameter `T` does not implement the type class `Printable`
    
    Consider adding a constraint to the type parameter.
  Code:
    2 |     generic [T: Free]
    3 |     function show(value: T): Unit is
    4 |         print(value);
    5 |         return nil;
    6 |     end;

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.

↑ back to top

H3057

A slot is read from a value of a built-in type, which has no slots.

Message:

Error:
  Title: Type Error
  Error code: H3057
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 4, column 8
    To: line 4, column 25
  Description:
    Can't access the slot `value` because the type `Int32` is not a record.
  Code:
    2 |     function main(): ExitCode is
    3 |         let n: Int32 := 5;
    4 |         printLn(n.value);
    5 |         return ExitSuccess();
    6 |     end;

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.

↑ back to top

H3058

The index operator s[i] is used on a value that is not a span.

Message:

Error:
  Title: Type Error
  Error code: H3058
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 8, column 8
    To: line 8, column 22
  Description:
    I can't use the array indexing operator here, because the type `Box` is not a span.
  Code:
     6 |     function main(): ExitCode is
     7 |         let b: Box := Box(value => 5);
     8 |         printLn(b[0]);
     9 |         return ExitSuccess();
    10 |     end;

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.

↑ back to top

H3060

A value has a different type from the one its place expects, for example in a return statement.

Message:

Error:
  Title: Type Error
  Error code: H3060
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 3, column 8
    To: line 3, column 20
  Description:
    Expected a value of type `Int32`, but got a value of type `Bool`.
  Code:
    1 | module body Example is
    2 |     function answer(): Int32 is
    3 |         return true;
    4 |     end;
    5 | 

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3061
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 8, column 8
    To: line 8, column 19
  Description:
    Type constraint not satisfied: the type `Point` does not implement the typeclass `Printable`.
    
    This constraint is for the type variable `T`.
  Code:
     6 |     function main(): ExitCode is
     7 |         let p: Point := Point(x => 1);
     8 |         printLn(p);
     9 |         return ExitSuccess();
    10 |     end;

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.

↑ back to top

H3062

An integer literal does not fit its type.

Message:

Error:
  Title: Type Error
  Error code: H3062
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 3, column 8
    To: line 3, column 27
  Description:
    The integer `300` does not fit the type `Nat8`.
  Code:
    1 | module body Example is
    2 |     function main(): ExitCode is
    3 |         let n: Nat8 := 300;
    4 |         printLn(n);
    5 |         return ExitSuccess();

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3063
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 4
    To: line 12, column 8
  Description:
    The type parameter `T` is expected to be `Free` but the supplied argument is `Linear`
  Code:
     8 |     end;
     9 | 
    10 |     function unpack(box: Box[Ticket]): Unit is
    11 |         return nil;
    12 |     end;
    13 | 
    14 |     function main(): ExitCode is

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.

↑ back to top

H3064

A type name is not known: it is not declared in the module, not imported and not built in.

Message:

Error:
  Title: Type Error
  Error code: H3064
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 3, column 8
    To: line 3, column 28
  Description:
    Unable to find a type with the name `Integer`.
    
    Consider importing it, if it is defined in another module.
  Code:
    1 | module body Example is
    2 |     function main(): ExitCode is
    3 |         let n: Integer := 1;
    4 |         printLn(n);
    5 |         return ExitSuccess();

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.

↑ back to top

H3065

A case that binds by name is given a value that is neither a union nor a reference to a union.

Message:

Error:
  Title: Type Error
  Error code: H3065
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 4, column 8
    To: line 9, column 17
  Description:
    The type for the expression in a case statement must be a union or a reference to a union, but I got `Int32`
  Code:
     2 |     function main(): ExitCode is
     3 |         let n: Int32 := 1;
     4 |         case n of
     5 |             when Some(value: Int32) do
     6 |                 printLn(value);
     7 |             when None do
     8 |                 printLn(0);
     9 |         end case;
    10 |         return ExitSuccess();
    11 |     end;

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3071
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 15, column 17
  Description:
    The when of `Circle` binds its slots by name and type, but this case uses patterns in another when.
    
    A case either binds by name in every when, or uses patterns in every when: write the slots of `Circle` as patterns, one per slot in the order the union declares them.
  Code:
     8 |     function main(): ExitCode is
     9 |         let s: Shape := Circle(radius => 2);
    10 |         case s of
    11 |             when Dot | Circle(0) do
    12 |                 printLn(0);
    13 |             when Circle(radius: Int32) do
    14 |                 printLn(radius);
    15 |         end case;
    16 |         return ExitSuccess();
    17 |     end;

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.

↑ back to top

H3072

A case with patterns is given a reference. Patterns match a value; a case that binds by name works on references.

Message:

Error:
  Title: Type Error
  Error code: H3072
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 15, column 17
  Description:
    A case with patterns takes a value, but this one is given a reference of type `&[Shape, Region<55>]`.
    
    Matching through a reference is not built; pass the value, or use the case that binds by name, which works on references.
  Code:
     8 |     function main(): ExitCode is
     9 |         let s: Shape := Circle(radius => 2);
    10 |         case &s of
    11 |             when Dot do
    12 |                 printLn(0);
    13 |             when Circle(r) do
    14 |                 printLn(r);
    15 |         end case;
    16 |         return ExitSuccess();
    17 |     end;

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3073
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 13, column 17
    To: line 13, column 22
  Description:
    The variable `other` would match every value of the union `Shape`, and a case over a union has no catch-all.
    
    List the variants; the compiler says which one is missing.
  Code:
    11 |             when Dot do
    12 |                 printLn(0);
    13 |             when other do
    14 |                 printLn(1);
    15 |         end case;

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.

↑ back to top

H3074

A pattern can never be chosen, because the patterns before it already match every value it matches.

Message:

Error:
  Title: Type Error
  Error code: H3074
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 7, column 17
    To: line 7, column 18
  Description:
    The pattern `5` can never be chosen: every value it matches is matched by a pattern before it.
    
    Remove it, or move it before the pattern that covers it.
  Code:
    5 |             when 0 .. 9 do
    6 |                 printLn(1);
    7 |             when 5 do
    8 |                 printLn(2);
    9 |             when _ do

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3075
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 4, column 8
    To: line 7, column 17
  Description:
    The case does not cover every value of `Nat8`: for example `10` matches no when.
    
    Add a when for it.  A case has no else; over an integer a variable or `_` finishes it.
  Code:
    2 |     function main(): ExitCode is
    3 |         let n: Nat8 := 5;
    4 |         case n of
    5 |             when 0 .. 9 do
    6 |                 printLn(1);
    7 |         end case;
    8 |         return ExitSuccess();
    9 |     end;

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.

↑ back to top

H3076

An integer pattern stands where the value is not an integer.

Message:

Error:
  Title: Type Error
  Error code: H3076
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 5, column 17
    To: line 5, column 18
  Description:
    The integer pattern `1` stands where the value has the type `Bool`, which is not an integer type.
  Code:
    3 |         let flag: Bool := true;
    4 |         case flag of
    5 |             when 1 do
    6 |                 printLn(1);
    7 |             when _ do

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.

↑ back to top

H3077

A Bool pattern, true or false, stands where the value is not a Bool.

Message:

Error:
  Title: Type Error
  Error code: H3077
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 5, column 17
    To: line 5, column 21
  Description:
    `true` is a Bool pattern, but the value here has the type `Int32`.
  Code:
    3 |         let n: Int32 := 1;
    4 |         case n of
    5 |             when true do
    6 |                 printLn(1);
    7 |             when _ do

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3078
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 5, column 17
    To: line 5, column 20
  Description:
    The literal `256` is outside `Nat8`, whose values are `0 .. 255`.
    
    A pattern never truncates or wraps a literal.
  Code:
    3 |         let n: Nat8 := 5;
    4 |         case n of
    5 |             when 256 do
    6 |                 printLn(1);
    7 |             when _ do

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.

↑ back to top

H3079

The lower bound of a range is above its upper bound, so the range is empty.

Message:

Error:
  Title: Type Error
  Error code: H3079
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 5, column 17
    To: line 5, column 23
  Description:
    The range `9 .. 0` is empty: its lower bound is above its upper bound.
    
    A range lists its lower bound first, and both bounds belong to it.
  Code:
    3 |         let n: Nat8 := 5;
    4 |         case n of
    5 |             when 9 .. 0 do
    6 |                 printLn(1);
    7 |             when _ do

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3080
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 5, column 17
    To: line 5, column 20
  Description:
    The float literal `1.5` cannot be a pattern.
    
    A pattern compares for equality, and two floats that print alike need not be equal.  Only integer and Bool literals are patterns; bind the value to a variable and compare it in the body.
  Code:
    3 |         let x: Int32 := 1;
    4 |         case x of
    5 |             when 1.5 do
    6 |                 printLn(1);
    7 |             when _ do

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.

↑ back to top

H3081

A string literal stands as a pattern. Only integer and Bool literals are patterns.

Message:

Error:
  Title: Type Error
  Error code: H3081
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 5, column 21
    To: line 5, column 22
  Description:
    A string literal cannot be a pattern.
    
    Only integer and Bool literals are patterns; bind the value to a variable and compare it in the body.
  Code:
    3 |         let x: Int32 := 1;
    4 |         case x of
    5 |             when "one" do
    6 |                 printLn(1);
    7 |             when _ do

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3082
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 17, column 22
    To: line 17, column 23
  Description:
    `_` stands where the value has the type `Ticket`, which is not in the Free universe.
    
    It would drop that value without anyone consuming it.  Bind it to a variable and consume it in the body.
  Code:
    15 |             when Empty do
    16 |                 printLn(0);
    17 |             when Full(_) do
    18 |                 printLn(1);
    19 |         end case;

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3083
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 14, column 17
    To: line 14, column 29
  Description:
    The variant `Rectangle` has 2 slot(s), and the pattern gives 1 sub-pattern(s).
    
    A variant pattern gives one sub-pattern for every slot, in the order the union declares them, so that no slot is left out unseen.
  Code:
    12 |             when Dot do
    13 |                 printLn(0);
    14 |             when Rectangle(w) do
    15 |                 printLn(w);
    16 |         end case;

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.

↑ back to top

H3084

The alternatives of one when bind different variables. The body runs after any of them, so all bind the same variables.

Message:

Error:
  Title: Type Error
  Error code: H3084
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 13, column 29
    To: line 13, column 44
  Description:
    The alternatives of this when bind different variables: `a` is bound in one alternative and not in another.
    
    The body runs after any of them, so every alternative binds the same variables.
  Code:
    11 |         let s: Shape := Square(side => 2);
    12 |         case s of
    13 |             when Square(a) | Rectangle(b, _) do
    14 |                 printLn(1);
    15 |         end case;

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.

↑ back to top

H3085

A variable has one type in one alternative of a when and another type in another.

Message:

Error:
  Title: Type Error
  Error code: H3085
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 12, column 34
    To: line 12, column 35
  Description:
    The variable `x` has the type `Int8` in one alternative and `Int64` in another.
    
    The body runs after any of them, so a variable has one type in every alternative.
  Code:
    10 |         let v: Value := Small(n => 1);
    11 |         case v of
    12 |             when Small(x) | Large(x) do
    13 |                 printLn(1);
    14 |         end case;

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.

↑ back to top

H3086

One pattern binds the same variable twice. To compare two parts, bind both under different names and compare them in the body.

Message:

Error:
  Title: Type Error
  Error code: H3086
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 11, column 30
    To: line 11, column 31
  Description:
    The variable `a` is bound twice in one pattern.
    
    A pattern binds each variable once; to compare two parts, bind both and compare them in the body.
  Code:
     9 |         let s: Shape := Rectangle(width => 2, height => 2);
    10 |         case s of
    11 |             when Rectangle(a, a) do
    12 |                 printLn(a);
    13 |         end case;

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3087
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 13, column 17
    To: line 13, column 26
  Description:
    `circle` takes sub-patterns, but its name begins with a lower-case letter, which makes it a variable.
    
    Only a variant takes sub-patterns, and a variant's name begins with an upper-case letter.
  Code:
    11 |             when Dot do
    12 |                 printLn(0);
    13 |             when circle(r) do
    14 |                 printLn(r);
    15 |         end case;

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.

↑ back to top

H3088

A variant pattern names a case the union does not have. The message lists the variants it has.

Message:

Error:
  Title: Type Error
  Error code: H3088
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 13, column 17
    To: line 13, column 26
  Description:
    `Square` is not a variant of `Shape`.  Its variants are `Dot, Circle`.
  Code:
    11 |             when Dot do
    12 |                 printLn(0);
    13 |             when Square(r) do
    14 |                 printLn(r);
    15 |         end case;

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.

↑ back to top

H3089

A variant pattern stands where the value is not a union.

Message:

Error:
  Title: Type Error
  Error code: H3089
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 5, column 17
    To: line 5, column 24
  Description:
    `Some` is a variant pattern, but the value here has the type `Int32`, which is not a union.
  Code:
    3 |         let n: Int32 := 1;
    4 |         case n of
    5 |             when Some(x) do
    6 |                 printLn(x);
    7 |             when _ do

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3090
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 4, column 8
    To: line 7, column 17
  Description:
    A case with patterns decides on a union, an integer or a Bool, but this value has the type `Float64`.
  Code:
    2 |     function main(): ExitCode is
    3 |         let x: Float64 := 1.0;
    4 |         case x of
    5 |             when y do
    6 |                 printLn(y);
    7 |         end case;
    8 |         return ExitSuccess();
    9 |     end;

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3091
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 13, column 17
    To: line 13, column 18
  Description:
    `_` would match every value of the union `Shape`, and a case over a union has no catch-all.
    
    List the variants; the compiler says which one is missing.
  Code:
    11 |             when Dot do
    12 |                 printLn(0);
    13 |             when _ do
    14 |                 printLn(1);
    15 |         end case;

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.

↑ back to top

H3092

A range stands where the value is not an integer.

Message:

Error:
  Title: Type Error
  Error code: H3092
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 5, column 17
    To: line 5, column 23
  Description:
    The range `0 .. 1` stands where the value has the type `Bool`, which is not an integer type.
  Code:
    3 |         let flag: Bool := true;
    4 |         case flag of
    5 |             when 0 .. 1 do
    6 |                 printLn(1);
    7 |             when _ do

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3093
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 19, column 8
    To: line 19, column 37
  Description:
    A write reference to part of a value needs a write reference to the value, but the path gives `&[Inner, R]`.
    
    Start the path from a write reference, or take a read reference with `&(...)`.
  Code:
    17 |     generic [R: Region]
    18 |     function clear(pair: &[Pair, R]): Unit is
    19 |         setValue(&!(pair->first), 0);
    20 |         return nil;
    21 |     end;

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3094
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 5, column 8
    To: line 5, column 18
  Description:
    A reference made inside this function cannot be handed out as `R`.
    
    `R` is a region parameter of the function: the caller chooses it, and it outlives the call.  The reference here has the region `Region<55>`, which ends inside the function.
  Code:
    3 |     function local(n: Int32): &[Int32, R] is
    4 |         let x: Int32 := n;
    5 |         return &x;
    6 |     end;
    7 | 

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3095
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 4, column 8
    To: line 4, column 17
  Description:
    The type parameter `T` would have to be `Int32` here.
    
    The caller chooses the type parameters of a function; its body cannot fix one.
  Code:
    2 |     generic [T: Type]
    3 |     function pretend(n: Int32): T is
    4 |         return n;
    5 |     end;
    6 | 

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.

↑ back to top

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:

Error:
  Title: Linearity Error
  Error code: H4001
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 6, column 4
    To: line 8, column 8
  Description:
    `Wallet` was declared to belong to the `Free` universe, but it contains a type that belongs to the `Linear` universe.
  Code:
     4 |     end;
     5 | 
     6 |     record Wallet: Free is
     7 |         ticket: Ticket;
     8 |     end;
     9 | 
    10 |     function main(): ExitCode is

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.

↑ back to top

H6026

A function, a method or a constructor is called with more or fewer arguments than it has parameters.

Message:

Error:
  Title: Generic Error
  Error code: H6026
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 7, column 8
    To: line 7, column 24
  Description:
    Wrong number of arguments. Expected `2` and got `1`.
  Code:
    5 | 
    6 |     function main(): ExitCode is
    7 |         printLn(add(1));
    8 |         return ExitSuccess();
    9 |     end;

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.

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H6032
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 2, column 4
    To: line 11, column 8
  Description:
    Orphan rule broken: typeclass and type are both foreign.
  Code:
     1 | module body Example is
     2 |     instance Printable(ExitCode) is
     3 |         method print(value: ExitCode): Unit is
     4 |             return nil;
     5 |         end;
     6 | 
     7 |         generic [R: Region]
     8 |         method printSpan(value: Span[ExitCode, R]): Unit is
     9 |             return nil;
    10 |         end;
    11 |     end;
    12 | 
    13 |     function main(): ExitCode is

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.

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H6037
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 2, column 4
    To: line 6, column 8
  Description:
    Orphan rule broken: `Nat8` is a built-in type. It belongs to the language and not to the module that names it, so it is foreign in every module except Hilde.Pervasive and Hilde.Memory, and the typeclass is foreign here too. Define a type of your own and give that the instance.
  Code:
    1 | module body Example is
    2 |     instance TrappingNegation(Nat8) is
    3 |         method trappingNegate(value: Nat8): Nat8 is
    4 |             return value;
    5 |         end;
    6 |     end;
    7 | 
    8 |     function main(): ExitCode is

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.

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H6038
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 12, column 4
    To: line 16, column 8
  Description:
    Instance overlaps: the typeclass already has an instance for `Bool`. The existing instance is in the module `Example`, the new one is in `Example`. In one program a type may have at most one instance of a typeclass, whichever module declares it.
  Code:
    10 |     end;
    11 | 
    12 |     instance Describe(Bool) is
    13 |         method describe(value: Bool): Int32 is
    14 |             return 2;
    15 |         end;
    16 |     end;
    17 | 
    18 |     function main(): ExitCode is

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.

↑ back to top

H6039

A name that is called is neither a function nor a method nor a variable in scope.

Message:

Error:
  Title: Generic Error
  Error code: H6039
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 3, column 8
    To: line 3, column 26
  Description:
    I can't find a callable named `twice`.
  Code:
    1 | module body Example is
    2 |     function main(): ExitCode is
    3 |         printLn(twice(2));
    4 |         return ExitSuccess();
    5 |     end;

This module fails with H6039:

module body Example is
    function main(): ExitCode is
        printLn(twice(2));
        return ExitSuccess();
    end;
end module body.

↑ back to top

H6041

An assignment has a function parameter on its left side. Parameters cannot be changed; copy the value into a var first.

Message:

Error:
  Title: Generic Error
  Error code: H6041
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 3, column 8
    To: line 3, column 19
  Description:
    Cannot assign a value to a function parameter.
  Code:
    1 | module body Example is
    2 |     function next(n: Int32): Int32 is
    3 |         n := n + 1;
    4 |         return n;
    5 |     end;

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.

↑ back to top

H6042

An assignment changes a variable bound with let. A variable that changes is bound with var.

Message:

Error:
  Title: Generic Error
  Error code: H6042
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 4, column 8
    To: line 4, column 15
  Description:
    Cannot assign a value to `n` because it is immutable.
  Code:
    2 |     function main(): ExitCode is
    3 |         let n: Int32 := 1;
    4 |         n := 2;
    5 |         printLn(n);
    6 |         return ExitSuccess();

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.

↑ back to top

H6045

A variable has the same name as a declaration of the module, such as a function or a constant.

Message:

Error:
  Title: Generic Error
  Error code: H6045
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 5, column 8
    To: line 5, column 30
  Description:
    The variable `limit` collides with the name of a declaration.
  Code:
    3 | 
    4 |     function main(): ExitCode is
    5 |         let limit: Int32 := 6;
    6 |         printLn(limit);
    7 |         return ExitSuccess();

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.

↑ back to top

H6048

A generic type or a built-in type such as Pointer is given the wrong number of type arguments.

Message:

Error:
  Title: Generic Error
  Error code: H6048
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 3, column 8
    To: line 3, column 45
  Description:
    The type `Option` expects `1` type arguments, but I only found `2` arguments.
  Code:
    1 | module body Example is
    2 |     function main(): ExitCode is
    3 |         let n: Option[Int32, Bool] := None();
    4 |         ignore(n);
    5 |         return ExitSuccess();

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3105
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 6, column 8
    To: line 6, column 28
  Description:
    The typeclass `Sized` of a constraint is not imported here. A module, its interface too, imports every typeclass its constraints name, as in `import Shape (Sized);`.
  Code:
    4 | module body Example is
    5 |     function main(): ExitCode is
    6 |         printLn(measure(5));
    7 |         return ExitSuccess();
    8 |     end;

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3106
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 9, column 24
    To: line 9, column 52
  Description:
    The C text of this @embed names `abs`, a function the programme imports through pragma Foreign_Import as `cAbs`. The compiler declares an imported function under a name of its own, so in C the name `abs` is not declared. Call `cAbs` in Hilde instead.
  Code:
     7 | 
     8 |     function main(): ExitCode is
     9 |         let n: Int32 := @embed(Int32, "abs($1)", -3);
    10 |         printLn(n);
    11 |         return ExitSuccess();

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3107
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 5, column 8
    To: line 7, column 15
  Description:
    The operator `=` compares numbers, Bool, Unit, references, addresses and pointers, but its operands have the type `Span[Nat8, Static]`.
    
    Compare the bytes of two texts with `Standard.Text.equal`.
  Code:
    3 |         let text: Span[Nat8, Static] := "export PATH";
    4 |         let word: Span[Nat8, Static] := spanPart(text, 0, 7);
    5 |         if word = "export " then
    6 |             printLn("an export");
    7 |         end if;
    8 |         return ExitSuccess();
    9 |     end;

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3108
  Module:
    Example
  Location:
    [no span available]
  Description:
    The operator `=` compares numbers, Bool, Unit, references, addresses and pointers, but in a use of a generic function its operands have the type `Span[Nat8, Static]`.
    
    Take a function that compares two values as an argument, or a typeclass.
  Code:
    [no span available]

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3111
  Module:
    Example
  Location:
    [no span available]
  Description:
    The method `size` names the parameter `T` of its typeclass neither in a parameter nor in its result, so no call can tell which instance it means.
    
    Give it a parameter of that type, a witness whose value it need not read.
  Code:
    [no span available]

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3036
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 7, column 8
    To: line 7, column 28
  Description:
    Cannot discard a value in the `Linear` universe.
  Code:
    5 | 
    6 |     function main(): ExitCode is
    7 |         Ticket(number => 1);
    8 |         return ExitSuccess();
    9 |     end;

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.

↑ back to top

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:

Error:
  Title: Linearity Error
  Error code: H4002
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 9, column 8
    To: line 14, column 17
  Description:
    Forgot to consume a linear variable: `value`.
  Code:
     7 |         let ticket: Ticket := Ticket(number => 1);
     8 |         let held: Option[Ticket] := Some(value => ticket);
     9 |         case held of
    10 |             when Some(value: Ticket) do
    11 |                 skip;
    12 |             when None do
    13 |                 skip;
    14 |         end case;
    15 |         return ExitSuccess();
    16 |     end;

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.

↑ back to top

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:

Error:
  Title: Linearity Error
  Error code: H4003
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 13, column 8
    To: line 15, column 16
  Description:
    The  variable `ticket` was consumed in the loop, without afterwards being reassigned.
  Code:
    11 |     function main(): ExitCode is
    12 |         let ticket: Ticket := Ticket(number => 7);
    13 |         for i from 1 to 3 do
    14 |             printLn(redeem(ticket));
    15 |         end for;
    16 |         return ExitSuccess();
    17 |     end;

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.

↑ back to top

H4004

The branches of an if or a case treat a linear variable differently: one consumes it and another does not.

Message:

Error:
  Title: Linearity Error
  Error code: H4004
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 14, column 8
    To: line 18, column 15
  Description:
    The variable `ticket` is used inconsistently in the branches of an if statement. In one branch it is consumed while in the other it is not yet consumed.
  Code:
    12 |         let ticket: Ticket := Ticket(number => 7);
    13 |         let lucky: Bool := true;
    14 |         if lucky then
    15 |             printLn(redeem(ticket));
    16 |         else
    17 |             skip;
    18 |         end if;
    19 |         return ExitSuccess();
    20 |     end;

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.

↑ back to top

H4005

One expression consumes the same linear variable twice, for example as two arguments of one call.

Message:

Error:
  Title: Linearity Error
  Error code: H4005
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 14, column 8
    To: line 14, column 38
  Description:
    The variable `ticket` is consumed multiple times within the same expression.
  Code:
    12 |     function main(): ExitCode is
    13 |         let ticket: Ticket := Ticket(number => 7);
    14 |         printLn(both(ticket, ticket));
    15 |         return ExitSuccess();
    16 |     end;

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.

↑ back to top

H4008

A linear variable is consumed a second time, in a later statement.

Message:

Error:
  Title: Linearity Error
  Error code: H4008
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 14, column 8
    To: line 14, column 32
  Description:
    The variable `ticket` has already been consumed.
  Code:
    12 |         let ticket: Ticket := Ticket(number => 7);
    13 |         printLn(redeem(ticket));
    14 |         printLn(redeem(ticket));
    15 |         return ExitSuccess();
    16 |     end;

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.

↑ back to top

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:

Error:
  Title: Linearity Error
  Error code: H4010
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 13, column 8
    To: line 13, column 38
  Description:
    Cannot assign to the variable `ticket` because it is not yet consumed.
    
    A variable of a linear type takes a new value only after its old one is consumed, and None() of an Option of a linear type is such a value too. Consume the old value first, or give each branch its own value and return it there instead of collecting it in a var.
  Code:
    11 |     function main(): ExitCode is
    12 |         var ticket: Ticket := Ticket(number => 1);
    13 |         ticket := Ticket(number => 2);
    14 |         printLn(redeem(ticket));
    15 |         return ExitSuccess();

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.

↑ back to top

H4012

A linear variable is not consumed when the function returns.

Message:

Error:
  Title: Linearity Error
  Error code: H4012
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 8, column 8
    To: line 8, column 29
  Description:
    The variable `ticket` is not consumed by the time of the return statement. Did you forget to call a destructor, or destructure the contents?
  Code:
     6 |     function main(): ExitCode is
     7 |         let ticket: Ticket := Ticket(number => 7);
     8 |         return ExitSuccess();
     9 |     end;
    10 | end module body.

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.

↑ back to top

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:

Error:
  Title: Linearity Error
  Error code: H4014
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 12, column 8
    To: line 12, column 45
  Description:
    Cannot assign to a path that ends in a type, `Ticket`, not in the Free universe.
  Code:
    10 |     function main(): ExitCode is
    11 |         var wallet: Wallet := Wallet(ticket => Ticket(number => 1));
    12 |         wallet.ticket := Ticket(number => 2);
    13 |         let { ticket: Ticket } := wallet;
    14 |         let { number: Int32 } := ticket;

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.

↑ back to top

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:

Error:
  Title: Linearity Error
  Error code: H4015
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 14, column 8
    To: line 14, column 58
  Description:
    The variable `box` is consumed in one branch of an if expression and not in the other, so one path leaves it unconsumed.
    
    Consume it in both branches, or write the if as a statement whose branches each consume it.
  Code:
    12 |         let box: Box := Box(content => 7);
    13 |         let full: Bool := true;
    14 |         let value: Int32 := if full then open(box) else 0;
    15 |         printLn(value);
    16 |         return ExitSuccess();

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3002
  Module:
    Example
  Location:
    [no span available]
  Description:
    The argument of a task holds a reference or a span.
    
    A task can outlive the borrow the reference comes from, so what is handed to `Standard.Task.spawn` must own everything it points at.  Move the value in, or copy what the task needs.
  Code:
    [no span available]

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3005
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 8, column 8
    To: line 8, column 22
  Description:
    The type `Point` is not a reference.
  Code:
     6 |     function main(): ExitCode is
     7 |         let p: Point := Point(x => 1);
     8 |         printLn(p->x);
     9 |         return ExitSuccess();
    10 |     end;

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.

↑ back to top

H3018

A variable bound with let is lent for writing. A variable that is lent for writing is bound with var.

Message:

Error:
  Title: Type Error
  Error code: H3018
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 13, column 8
    To: line 13, column 52
  Description:
    Cannot borrow the variable `counter` mutably because the variable is immutable.
  Code:
    11 | 
    12 |     function main(): ExitCode is
    13 |         let counter: Counter := Counter(count => 0);
    14 |         bump(&!counter);
    15 |         let { count: Int32 } := counter;

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.

↑ back to top

H3019

A function parameter is lent for writing. Parameters cannot be changed; move the value into a var first, as the message suggests.

Message:

Error:
  Title: Type Error
  Error code: H3019
  Module:
    Example
  Location:
    Filename: ''
    From: line 0, column 0
    To: line 0, column 0
  Description:
    Cannot borrow the variable `counter` mutably because it is a function parameter, and therefore immutable.
    You can move it to a mutable local variable: `var mut_counter: Counter := counter;`
  Code:
    [no span available]

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.

↑ back to top

H3026

A write reference is converted with a colon to a read reference of another type or another region. The conversion keeps both.

Message:

Error:
  Title: Type Error
  Error code: H3026
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 8, column 8
    To: line 8, column 52
  Description:
    Cannot cast a reference to one with a different underlying type.
  Code:
     6 |     generic [R: Region]
     7 |     function peek(account: &![Account, R]): Int64 is
     8 |         let r: &[Int64, R] := account : &[Int64, R];
     9 |         return !r;
    10 |     end;

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.

↑ back to top

H3028

A write reference is converted with a colon to something that is not a read reference.

Message:

Error:
  Title: Type Error
  Error code: H3028
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 8, column 8
    To: line 8, column 40
  Description:
    Write references can only be casted to a read reference.
  Code:
     6 |     generic [R: Region]
     7 |     function peek(account: &![Account, R]): Int64 is
     8 |         let n: Int64 := account : Int64;
     9 |         return n;
    10 |     end;

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.

↑ back to top

H3032

The operator ! reads the value behind a reference, and it is applied to something that is not a reference.

Message:

Error:
  Title: Type Error
  Error code: H3032
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 4, column 8
    To: line 4, column 20
  Description:
    Only references can be dereferenced, but `Int32` is not.
  Code:
    2 |     function main(): ExitCode is
    3 |         let n: Int32 := 5;
    4 |         printLn(!n);
    5 |         return ExitSuccess();
    6 |     end;

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3066
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 18, column 24
    To: line 23, column 33
  Description:
    The argument of a task in a lending scope holds a reference of another region.
    
    A task started with `Standard.Task.spawnLending` may be lent only what the scope's own borrow lends -- the region the scope was opened for -- because only that borrow is sure to outlive the task.
  Code:
    16 |                     borrow i: &[Index, sigma] := &inner do
    17 |                         let work: Fn[&[Index, sigma], Index] := read;
    18 |                         case spawnLending(&!scope, work, i) of
    19 |                             when Right(right as task: Task[Index]) do
    20 |                                 printLn(join(task));
    21 |                             when Left(left as back: &[Index, sigma]) do
    22 |                                 printLn(0);
    23 |                         end case;
    24 |                     end borrow;
    25 |                     closeLending(scope);

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3067
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 18, column 24
    To: line 23, column 33
  Description:
    The argument of a task in a lending scope holds a write reference or a mutable span.
    
    Tasks of a lending scope may only read what they are lent; two tasks holding the same thing to write would each see the other's half-done change.
  Code:
    16 |                     borrow w: &![Index, sigma] := &!value do
    17 |                         let work: Fn[&![Index, sigma], Index] := read;
    18 |                         case spawnLending(&!scope, work, w) of
    19 |                             when Right(right as task: Task[Index]) do
    20 |                                 printLn(join(task));
    21 |                             when Left(left as back: &![Index, sigma]) do
    22 |                                 printLn(0);
    23 |                         end case;
    24 |                     end borrow;
    25 |                     closeLending(scope);

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3068
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 11, column 8
    To: line 16, column 17
  Description:
    The argument of a task in a lending scope is of a type variable's type.
    
    What a type variable stands for is not known where `Standard.Task.spawnLending` is called, so it cannot be checked for references of another region.  Call it where the argument's type is written out.
  Code:
     9 |     generic [T: Free, R: Region, S: Region]
    10 |     function start(scope: &![Lending[R], S], work: Fn[T, Index], argument: T): Index is
    11 |         case spawnLending(scope, work, argument) of
    12 |             when Right(right as task: Task[Index]) do
    13 |                 return join(task);
    14 |             when Left(left as back: T) do
    15 |                 return 0;
    16 |         end case;
    17 |     end;
    18 | 

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3069
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 19, column 28
    To: line 24, column 37
  Description:
    The argument of a task holds a lending scope.
    
    A task that held the scope could keep it open after the borrow it lends from has ended.  Close the scope where it was opened.
  Code:
    17 |                         when Some(value as other: Lending[rho]) do
    18 |                             let work: Fn[Lending[rho], Unit] := finish;
    19 |                             case spawnLending(&!scope, work, other) of
    20 |                                 when Right(right as task: Task[Unit]) do
    21 |                                     let done: Unit := join(task);
    22 |                                 when Left(left as back: Lending[rho]) do
    23 |                                     closeLending(back);
    24 |                             end case;
    25 |                         when None do
    26 |                             skip;

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3070
  Module:
    Example
  Location:
    [no span available]
  Description:
    The argument of a task holds a lending scope.
    
    A task that held the scope could keep it open after the borrow it lends from has ended.  Close the scope where it was opened.
  Code:
    [no span available]

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3112
  Module:
    Example
  Location:
    [no span available]
  Description:
    A value of a thread-bound type would reach another task.
    
    The type given to `Standard.Task.spawn` holds `Example.Handle`, which is marked with `pragma Thread_Bound`: its value must stay on the thread that made it, and a task may run on another thread.  Keep the value where it was made.
  Code:
    [no span available]

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.

↑ back to top

H4006

A variable is consumed while it is lent for reading.

Message:

Error:
  Title: Linearity Error
  Error code: H4006
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 14, column 12
    To: line 14, column 36
  Description:
    The variable `ticket` cannot be consumed while it is borrowed (immutably).
  Code:
    12 |         let ticket: Ticket := Ticket(number => 7);
    13 |         borrow view: &[Ticket, R] := &ticket do
    14 |             printLn(redeem(ticket));
    15 |         end borrow;
    16 |         return ExitSuccess();

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.

↑ back to top

H4007

A variable is consumed while it is lent for writing.

Message:

Error:
  Title: Linearity Error
  Error code: H4007
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 14, column 12
    To: line 14, column 36
  Description:
    The variable `ticket` cannot be consumed while it is borrowed (mutably).
  Code:
    12 |         var ticket: Ticket := Ticket(number => 7);
    13 |         borrow view: &![Ticket, R] := &!ticket do
    14 |             printLn(redeem(ticket));
    15 |         end borrow;
    16 |         return ExitSuccess();

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.

↑ back to top

H4011

A variable is borrowed that is already consumed, or borrowed in a way its current state does not allow.

Message:

Error:
  Title: Linearity Error
  Error code: H4011
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 14, column 8
    To: line 16, column 19
  Description:
    Cannot borrow (immutably) the variable `ticket` because it is already consumed.
  Code:
    12 |         let ticket: Ticket := Ticket(number => 7);
    13 |         printLn(redeem(ticket));
    14 |         borrow view: &[Ticket, R] := &ticket do
    15 |             printLn(view->number);
    16 |         end borrow;
    17 |         return ExitSuccess();
    18 |     end;

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.

↑ back to top

H4013

The operator ! reads the value behind a reference to a type that is not Free. Reading it would copy a linear value.

Message:

Error:
  Title: Linearity Error
  Error code: H4013
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 9, column 12
    To: line 9, column 38
  Description:
    Cannot dereference non-free type `Ticket`
  Code:
     7 |         let ticket: Ticket := Ticket(number => 7);
     8 |         borrow view: &[Ticket, R] := &ticket do
     9 |             let copy: Ticket := !view;
    10 |             let { number: Int32 } := copy;
    11 |             printLn(number);

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.

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H6043
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 8, column 8
    To: line 8, column 42
  Description:
    The head of a reference transform expression must be of a reference type, but I got `Point`.
    
    A path into a value is borrowed through a reference to the whole value: write a function that takes `r: &[T, R]` and returns `&(r->slot)`, and call it with `&value`.
  Code:
     6 |     function main(): ExitCode is
     7 |         let p: Point := Point(x => 1);
     8 |         let r: &[Int32, Static] := &(p.x);
     9 |         printLn(!r);
    10 |         return ExitSuccess();

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.

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H6054
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 12
    To: line 10, column 22
  Description:
    Can't assign: lvalue is not a mutable reference: &[Int32, Region<56>]
  Code:
     8 |         borrow q: &[Point, R] := &p do
     9 |             var r: &[Point, R] := q;
    10 |             r->x := 0;
    11 |         end borrow;
    12 |         printLn(p.x);

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.

↑ back to top

H6055

A borrow statement reborrows with &~ a variable that is not a write reference.

Message:

Error:
  Title: Generic Error
  Error code: H6055
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 8, column 8
    To: line 10, column 19
  Description:
    Cannot reborrow something that is not a mutable reference: Point
  Code:
     6 |     function main(): ExitCode is
     7 |         var p: Point := Point(x => 1);
     8 |         borrow r: &![Point, R] := &~p do
     9 |             printLn(r->x);
    10 |         end borrow;
    11 |         return ExitSuccess();
    12 |     end;

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.

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H6059
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 5, column 8
    To: line 5, column 27
  Description:
    `digits` is a constant of the module, and an index or a slot is taken through a variable, which a constant is not. Bind the constant to a local first, as in `let local: T := digits;`, and index the local.
  Code:
    3 | 
    4 |     function main(): ExitCode is
    5 |         printLn(digits[1]);
    6 |         return ExitSuccess();
    7 |     end;

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.

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2001
  Module:
    Example
  Location:
    Filename: 'Example.hih'
    From: line 2, column 4
    To: line 2, column 26
  Description:
    The interface requires `limit` to be a constant
  Code:
    1 | module Example is
    2 |     constant limit: Int32;
    3 | 
    4 |     function main(): ExitCode;

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.

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2002
  Module:
    Example
  Location:
    Filename: 'Example.hih'
    From: line 2, column 4
    To: line 2, column 36
  Description:
    The interface declaration for `twice` and its implementation have different parameters.
  Code:
    1 | module Example is
    2 |     function twice(n: Int32): Int32;
    3 | 
    4 |     function main(): ExitCode;

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.

↑ back to top

H2004

The interface declares something that the body does not define.

Message:

Error:
  Title: Declaration Error
  Error code: H2004
  Module:
    Example
  Location:
    [no span available]
  Description:
    `twice` has no corresponding body implementation.
  Code:
    [no span available]

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.

↑ back to top

H2005

The interface declares an instance that the body does not define.

Message:

Error:
  Title: Declaration Error
  Error code: H2005
  Module:
    Example
  Location:
    [no span available]
  Description:
    The instance `Describe` with type `Int32` has no corresponding body implementation.
  Code:
    [no span available]

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.

↑ back to top

H2006

The interface and the body given as a pair on the command line name different modules.

Message:

Error:
  Title: Declaration Error
  Error code: H2006
  Module:
    Sample
  Location:
    [no span available]
  Description:
    Module interface and body have different names: `Sample` and `Example`
  Code:
    [no span available]

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.

↑ back to top

H2008

A declaration has a different type in the interface and in the body, for example a constant.

Message:

Error:
  Title: Declaration Error
  Error code: H2008
  Module:
    Example
  Location:
    Filename: 'Example.hih'
    From: line 2, column 4
    To: line 2, column 26
  Description:
    The interface declaration for `limit` and its implementation have different types.
  Code:
    1 | module Example is
    2 |     constant limit: Int32;
    3 | 
    4 |     function main(): ExitCode;

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.

↑ back to top

H2009

An opaque type is declared in one universe in the interface and defined in another in the body.

Message:

Error:
  Title: Declaration Error
  Error code: H2009
  Module:
    Example
  Location:
    Filename: 'Example.hih'
    From: line 2, column 4
    To: line 2, column 22
  Description:
    The interface declaration for `Ticket` and its implementation have different universes.
  Code:
    1 | module Example is
    2 |     type Ticket: Free;
    3 | 
    4 |     function main(): ExitCode;

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.

↑ back to top

H2010

The compilation was started with --forbid-unsafe-modules, and one of its modules is unsafe.

Message:

Error:
  Title: Declaration Error
  Error code: H2010
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    The module `Example` is unsafe, and this compilation was run with `--forbid-unsafe-modules`.
    
    It is `Example.hiq`, and it carries `pragma Unsafe_Module;`, which is what lets a module hold a foreign function, an `@embed`, or an import from `Hilde.Memory`.
    
    The modules that ship with the compiler are exempt; this applies to the modules named on the command line.
  Code:
    [no span available]

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:

hilde compile Example.hiq --entrypoint=Example:main --output=prog --forbid-unsafe-modules

↑ back to top

H2011

A pragma is given the wrong arguments. The message says which argument it takes, or that it takes none.

Message:

Error:
  Title: Declaration Error
  Error code: H2011
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    Invalid Foreign_Import pragma.
    
    This pragma takes exactly one argument, `External_Name`
  Code:
    [no span available]

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.

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2012
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    Unknown pragma `Unsafe_Modul`
  Code:
    [no span available]

This module fails with H2012:

pragma Unsafe_Modul;

module body Example is
    function main(): ExitCode is
        return ExitSuccess();
    end;
end module body.

↑ back to top

H2013

A safe module names a C library. Only a module with pragma Unsafe_Module has C to link against.

Message:

Error:
  Title: Declaration Error
  Error code: H2013
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    Module `Example` is safe and can't name the C library `m`.
    
    A safe module has no C to link against: it can hold neither a `pragma Foreign_Import` nor an `@embed`. Write `pragma Unsafe_Module;` above `module body`, or take the library declaration out.
  Code:
    [no span available]

This module fails with H2013:

pragma Foreign_Library(Name => "m");

module body Example is
    function main(): ExitCode is
        return ExitSuccess();
    end;
end module body.

↑ back to top

H2014

The name in pragma Foreign_Library is empty. It is the name of a library, the z of -lz.

Message:

Error:
  Title: Declaration Error
  Error code: H2014
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    The name in a `pragma Foreign_Library` must not be empty.
    
    It is a library name, the `z` of `-lz`, not a linker switch.
  Code:
    [no span available]

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.

↑ back to top

H2015

A module declares the same name twice.

Message:

Error:
  Title: Declaration Error
  Error code: H2015
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 6, column 4
    To: line 8, column 8
  Description:
    A declaration with the name `twice` already exists in the module `Example`.
  Code:
     4 |     end;
     5 | 
     6 |     function twice(n: Int64): Int64 is
     7 |         return n * 2;
     8 |     end;
     9 | 
    10 |     function main(): ExitCode is

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.

↑ back to top

H2016

Two modules of one compilation have the same name.

Message:

Error:
  Title: Declaration Error
  Error code: H2016
  Module:
    Example
  Location:
    [no span available]
  Description:
    A module with the name `Example` already exists.
  Code:
    [no span available]

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.

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2017
  Module:
    Example
  Location:
    [no span available]
  Description:
    Unknown module `Library`.
  Code:
    [no span available]

This module fails with H2017:

import Library (answer);

module body Example is
    function main(): ExitCode is
        printLn(answer());
        return ExitSuccess();
    end;
end module body.

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2018
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 5, column 4
    To: line 8, column 8
  Description:
    The function `keep` cannot be exported because it is generic over a type.
    
    An exported function may be generic over regions only: a region has nothing to pass at run time.
  Code:
     3 | module body Example is
     4 |     pragma Foreign_Export(External_Name => "example_keep");
     5 |     generic [T: Free]
     6 |     function keep(value: T): T is
     7 |         return value;
     8 |     end;
     9 | 
    10 |     function main(): ExitCode is

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.

↑ back to top

H2027

Two imports give the same local name. Give one of them another name with as.

Message:

Error:
  Title: Declaration Error
  Error code: H2027
  Module:
    Example
  Location:
    [no span available]
  Description:
    Colliding imports: a declaration with name `question` has already been imported.
    
    Consider giving it a different nickname using `as`, as in `import M (question as otherQuestion);`.
  Code:
    [no span available]

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.

↑ back to top

H2028

A safe module imports from Hilde.Memory, whose raw pointers only unsafe modules may use.

Message:

Error:
  Title: Declaration Error
  Error code: H2028
  Module:
    Example
  Location:
    [no span available]
  Description:
    Cannot import from the `Hilde.Memory` module in a safe module.
    
    Consider using a safe wrapper or adding `pragma Unsafe_Module;`
  Code:
    [no span available]

This module fails with H2028:

import Hilde.Memory (Pointer);

module body Example is
    function main(): ExitCode is
        return ExitSuccess();
    end;
end module body.

↑ back to top

H2029

An import names something that its module defines only in the body. What the interface does not declare is private.

Message:

Error:
  Title: Declaration Error
  Error code: H2029
  Module:
    Example
  Location:
    [no span available]
  Description:
    `secret` is private and cannot be imported.
  Code:
    [no span available]

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.

↑ back to top

H2030

An import names something that its module does not have at all.

Message:

Error:
  Title: Declaration Error
  Error code: H2030
  Module:
    Example
  Location:
    [no span available]
  Description:
    No declaration with the name `question` in the module `Library`
  Code:
    [no span available]

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.

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2038
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 3, column 24
    To: line 3, column 43
  Description:
    `@embed` pastes C straight into the generated program, and the compiler does not check that C. It is allowed only in a module that says so: write `pragma Unsafe_Module;` above `module body`, or move the `@embed` into a module that already has the pragma.
  Code:
    1 | module body Example is
    2 |     function main(): ExitCode is
    3 |         let n: Int32 := @embed(Int32, "42");
    4 |         printLn(n);
    5 |         return ExitSuccess();

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.

↑ back to top

H2039

A safe module binds a C function with pragma Foreign_Import.

Message:

Error:
  Title: Declaration Error
  Error code: H2039
  Module:
    Example
  Location:
    [no span available]
  Description:
    Can't declare a foreign function in a safe module.
  Code:
    [no span available]

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.

↑ back to top

H2040

A function bound to C with Foreign_Import has type parameters. A C function has one fixed signature.

Message:

Error:
  Title: Declaration Error
  Error code: H2040
  Module:
    Example
  Location:
    [no span available]
  Description:
    Foreign functions can't have type parameters.
  Code:
    [no span available]

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.

↑ back to top

H2041

A pragma other than Foreign_Import or Foreign_Export stands before a function. Module pragmas stand before module body.

Message:

Error:
  Title: Declaration Error
  Error code: H2041
  Module:
    Example
  Location:
    [no span available]
  Description:
    Only import and export pragmas are allowed inside functions.
  Code:
    [no span available]

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.

↑ back to top

H2042

A safe module names a C header with pragma Foreign_Header.

Message:

Error:
  Title: Declaration Error
  Error code: H2042
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    Module `Example` is safe and can't name the C header `sys/utsname.h`.
    
    A header gives C's own constants to an `@embed`, and a safe module can hold none. Write `pragma Unsafe_Module;` above `module body`, or take the header declaration out.
  Code:
    [no span available]

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.

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2043
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    The name in a `pragma Foreign_Header` is not a header name: `../secret.h`
    
    It is what stands between the angle brackets of an `#include`, such as `openssl/evp.h`: letters, digits and `_ . / + -`, not empty, not starting with a slash, and without a `..` part.
  Code:
    [no span available]

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.

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2044
  Module:
    Bindings.C.SqlCipher
  Location:
    [no span available]
  Description:
    This programme links both `sqlite3` and `sqlcipher`, which export the same functions.
    
    Import `Standard.Sqlite` or `Standard.SqlCipher`, not both.  The module that brought the second one is `Bindings.C.SqlCipher`.
  Code:
    [no span available]

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.

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2045
  Module:
    Example
  Location:
    [no span available]
  Description:
    `Example` imports from `Bindings.Time`, a module that binds C.
    
    Only the standard library imports a module whose name begins with `Bindings.`; a program imports the safe module built on it, whose name begins with `Standard.`.
  Code:
    [no span available]

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.

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2050
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 3, column 4
    To: line 5, column 8
  Description:
    The function `keep` cannot be exported under the name `hilde_keep`: names beginning with hilde_ belong to the runtime.
  Code:
    1 | module body Example is
    2 |     pragma Foreign_Export(External_Name => "hilde_keep");
    3 |     function keep(value: Int32): Int32 is
    4 |         return value;
    5 |     end;
    6 | 
    7 |     function main(): ExitCode is

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.

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2059
  Module:
    Example
  Location:
    [no span available]
  Description:
    A foreign function can't return `Bool`. C gives a truth value as an int, and a Bool would keep only its lowest byte, so 256 would be false.
    
    Import the C result as `Int32` and compare it with `/= 0`.
  Code:
    [no span available]

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.

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2074
  Module:
    [unknown]
  Location:
    Filename: 'Example.hiq'
    From: line 3, column 4
    To: line 5, column 8
  Description:
    `pragma Thread_Bound` stands right before the declaration of a type: a record, a union or a type of an interface.
    
    It marks the type, and every type that holds it, as one whose values must stay on the thread that made them.
  Code:
    1 | module body Example is
    2 |     pragma Thread_Bound;
    3 |     function main(): ExitCode is
    4 |         return ExitSuccess();
    5 |     end;
    6 | end module body.

This module fails with H2074:

module body Example is
    pragma Thread_Bound;
    function main(): ExitCode is
        return ExitSuccess();
    end;
end module body.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3001
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    The type `Span[Int32, R]` is not allowed in the signature of an exported function.
  Code:
    [no span available]

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.

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H6060
  Module:
    Example
  Location:
    Filename: 'Example.hih'
    From: line 3, column 8
    To: line 3, column 33
  Description:
    I can't find a callable named `size` here. The module `Other` declares one; import it, as in `import Other (size);`. A module interface imports what its own contracts call, apart from its body.
  Code:
    1 | module Example is
    2 |     function count(n: Int32): Int32
    3 |         ensures size(result) >= 0;
    4 | 
    5 |     function main(): ExitCode;

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.

↑ back to top

6. Other

H1001

The value of --entrypoint is not of the form Module:function.

Message:

Error:
  Title: Command Line Arguments Error
  Error code: H1001
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    Invalid entrypoint format `Example.main`
    
    The entrypoint must be supplied in the form `Module:name`
  Code:
    [no span available]

This module fails with H1001:

module body Example is
    function main(): ExitCode is
        return ExitSuccess();
    end;
end module body.

With this command:

hilde compile Example.hiq --entrypoint=Example.main --output=prog

↑ back to top

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:

Error:
  Title: Command Line Arguments Error
  Error code: H1002
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    Invalid module source format `Example.hiq,Example.hiq,Example.hiq`
    
    Sources must be supplied as either`interface.hih,body.hiq` or `body.hiq`
  Code:
    [no span available]

This module fails with H1002:

module body Example is
    function main(): ExitCode is
        return ExitSuccess();
    end;
end module body.

With this command:

hilde compile Example.hiq,Example.hiq,Example.hiq --entrypoint=Example:main --output=prog

↑ back to top

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:

Error:
  Title: Command Line Arguments Error
  Error code: H1003
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    `--entrypoint` argument not provided.
  Code:
    [no span available]

This module fails with H1003:

module body Example is
    function main(): ExitCode is
        return ExitSuccess();
    end;
end module body.

With this command:

hilde compile Example.hiq --output=prog

↑ back to top

H1004

The compile command names no module.

Message:

Error:
  Title: Command Line Arguments Error
  Error code: H1004
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    The `compile` command must specify at least one module.
  Code:
    [no span available]

This module fails with H1004:

module body Example is
    function main(): ExitCode is
        return ExitSuccess();
    end;
end module body.

With this command:

hilde compile --entrypoint=Example:main --output=prog

↑ back to top

H1005

The compile command has no --output.

Message:

Error:
  Title: Command Line Arguments Error
  Error code: H1005
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    `--output` argument not provided.
  Code:
    [no span available]

This module fails with H1005:

module body Example is
    function main(): ExitCode is
        return ExitSuccess();
    end;
end module body.

With this command:

hilde compile Example.hiq --entrypoint=Example:main

↑ back to top

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:

Error:
  Title: Command Line Arguments Error
  Error code: H1006
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    `--no-entrypoint` requires `--target-type=c`, `static`, `shared` or `wasm`, because otherwise the compiler will try to build an executable, and will fail because there is no entrypoint function.
  Code:
    [no span available]

This module fails with H1006:

module body Example is
    function answer(): Int32 is
        return 42;
    end;
end module body.

With this command:

hilde compile Example.hiq --no-entrypoint --output=prog

↑ back to top

H1007

The value of --target-type is none of exe, c, tc, static and shared.

Message:

Error:
  Title: Command Line Arguments Error
  Error code: H1007
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    Unknown target type `binary`
  Code:
    [no span available]

This module fails with H1007:

module body Example is
    function main(): ExitCode is
        return ExitSuccess();
    end;
end module body.

With this command:

hilde compile Example.hiq --entrypoint=Example:main --output=prog --target-type=binary

↑ back to top

H1008

The value of --error-format is none of plain, json, hilde-json and json-lines.

Message:

Error:
  Title: Command Line Arguments Error
  Error code: H1008
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    Unknown error reporting mode: `xml`. Valid values are `plain`, `json`, `hilde-json` and `json-lines`.
  Code:
    [no span available]

This module fails with H1008:

module body Example is
    function main(): ExitCode is
        return ExitSuccess();
    end;
end module body.

With this command:

hilde compile Example.hiq --entrypoint=Example:main --output=prog --error-format=xml

↑ back to top

H1009

A flag is given twice.

Message:

Error:
  Title: Command Line Arguments Error
  Error code: H1009
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    The argument `output` was given multiple times
  Code:
    [no span available]

This module fails with H1009:

module body Example is
    function main(): ExitCode is
        return ExitSuccess();
    end;
end module body.

With this command:

hilde compile Example.hiq --entrypoint=Example:main --output=prog --output=other

↑ back to top

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:

Argument list must have at least one element in it, the path to the binary. Was the compiler invoked through a system call?

The catalog gives no failing example for this code.

↑ back to top

H1011

A flag that takes no value is given one, as in --flag=value.

Message:

Error:
  Title: Command Line Arguments Error
  Error code: H1011
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    Expected `forbid-unsafe-modules` to be a boolean flag, but it was given as a value flag.
  Code:
    [no span available]

This module fails with H1011:

module body Example is
    function main(): ExitCode is
        return ExitSuccess();
    end;
end module body.

With this command:

hilde compile Example.hiq --entrypoint=Example:main --output=prog --forbid-unsafe-modules=yes

↑ back to top

H1012

A flag that takes a value is given without one.

Message:

Error:
  Title: Command Line Arguments Error
  Error code: H1012
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    Expected `output` to be a value flag, but it was given as a boolean flag.
  Code:
    [no span available]

This module fails with H1012:

module body Example is
    function main(): ExitCode is
        return ExitSuccess();
    end;
end module body.

With this command:

hilde compile Example.hiq --entrypoint=Example:main --output

↑ back to top

H1013

A flag holds more than one equals sign, so it is neither --flag nor --flag=value.

Message:

Error:
  Title: Command Line Arguments Error
  Error code: H1013
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    Invalid flag argument `--output=prog=bin`
  Code:
    [no span available]

This module fails with H1013:

module body Example is
    function main(): ExitCode is
        return ExitSuccess();
    end;
end module body.

With this command:

hilde compile Example.hiq --entrypoint=Example:main --output=prog=bin

↑ back to top

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:

Error:
  Title: Command Line Arguments Error
  Error code: H1014
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    Failed to run C compiler.
    
    Command: `'cc' '-std=c17' '-Wall' '-Wextra' '-O2' '-fno-strict-aliasing' '/tmp/hilde_de5c9c.c' '-lpthread' '-o' 'prog'`
    
    Exit code: 1
    
    Standard output:
    
    
    Standard error:
    /tmp/hilde_de5c9c.c: In function 'Example__main__d319':
    /tmp/hilde_de5c9c.c:7119:28: error: 'this' undeclared (first use in this function)
     7119 |     v_n = ((hilde_int32_t)(this is not C));
          |                            ^~~~
    /tmp/hilde_de5c9c.c:7119:28: note: each undeclared identifier is reported only once for each function it appears in
    /tmp/hilde_de5c9c.c:7119:32: error: expected ')' before 'is'
     7119 |     v_n = ((hilde_int32_t)(this is not C));
          |                           ~    ^~~
          |                                )
  Code:
    [no span available]

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.

↑ back to top

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:

Error:
  Title: Command Line Arguments Error
  Error code: H1015
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    Failed to write to file `missing/Example.c`: 
    
    missing/Example.c: No such file or directory
  Code:
    [no span available]

This module fails with H1015:

module body Example is
    function main(): ExitCode is
        return ExitSuccess();
    end;
end module body.

With this command:

hilde compile Example.hiq --entrypoint=Example:main --target-type=c --output=missing/Example.c

↑ back to top

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:

Failed to write to file ...

The catalog gives no failing example for this code.

↑ back to top

H1017

hilde query asks about a module that is not on the command line.

Message:

Error:
  Title: Command Line Arguments Error
  Error code: H1017
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    The module `Sample` is not on the command line, so there is nothing to query.
  Code:
    [no span available]

This module fails with H1017:

module body Example is
    function main(): ExitCode is
        return ExitSuccess();
    end;
end module body.

With this command:

hilde query Example.hiq --module=Sample

↑ back to top

H1018

hilde query is called without --module, so it does not know which module to describe.

Message:

Error:
  Title: Command Line Arguments Error
  Error code: H1018
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    `hilde query` needs `--module=Name`: the module to describe.
  Code:
    [no span available]

This module fails with H1018:

module body Example is
    function main(): ExitCode is
        return ExitSuccess();
    end;
end module body.

With this command:

hilde query Example.hiq

↑ back to top

H1019

hilde test is called without a path, so it has nowhere to look for tests.

Message:

Error:
  Title: Command Line Arguments Error
  Error code: H1019
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    `hilde test` names no path: give the directories to search for test files, or test files by name.
  Code:
    [no span available]

This module fails with H1019:

module body Example.Test is
    function testNothing(): Unit is
        return nil;
    end;
end module body.

With this command:

hilde test

↑ back to top

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:

Error:
  Title: Command Line Arguments Error
  Error code: H1020
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    The flags `--race` and `--memory` of `hilde test` exclude one another.
    
    A run takes at most one of `--race`, `--memory` and `--valgrind`, and `--emit-c` builds and runs nothing, so it takes none of them.
  Code:
    [no span available]

This module fails with H1020:

module body Example.Test is
    function testNothing(): Unit is
        return nil;
    end;
end module body.

With this command:

hilde test --race --memory Example.hiq

↑ back to top

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:

`hilde test <flag>` cannot run on this system: <what failed>
The answer was: <the first line the C compiler or valgrind wrote>

The catalog gives no failing example for this code.

↑ back to top

H1022

A path given to hilde test is neither a directory nor a .hiq file, for example because it does not exist.

Message:

Error:
  Title: Command Line Arguments Error
  Error code: H1022
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    `missing` is neither a directory nor a file ending in .hiq.
  Code:
    [no span available]

This module fails with H1022:

module body Example.Test is
    function testNothing(): Unit is
        return nil;
    end;
end module body.

With this command:

hilde test missing

↑ back to top

H1023

hilde test searched the directories it was given and found no test file in them.

Message:

Error:
  Title: Command Line Arguments Error
  Error code: H1023
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    There is no test file under `.`.
    
    A test file is a module body whose file name ends in .test.hiq, or a .hiq file named on the command line.
  Code:
    [no span available]

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:

hilde test .

↑ back to top

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:

FAIL  ./Example.test.hiq  the test programme did not build
hilde test: 1 test file, 0 tests, 0 failed, 1 not built
Error:
  Title: Command Line Arguments Error
  Error code: H1024
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    The module `Example` is declared by two files, `./Example.hiq` and `./Other.hiq`, and a test programme imports it, so there is no telling which one it means.
  Code:
    [no span available]

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:

hilde test .

↑ back to top

H1025

A directory hilde test searches for modules holds an interface without the body of the same name beside it.

Message:

Error:
  Title: Command Line Arguments Error
  Error code: H1025
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    The interface `./Other.hih` has no body `./Other.hiq` beside it, so its module cannot be compiled.
  Code:
    [no span available]

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:

hilde test .

↑ back to top

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:

Error:
  Title: Command Line Arguments Error
  Error code: H1026
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    `--target-type=static` builds a library, and a library has no entrypoint: `--entrypoint` cannot be given with it.
    
    The functions a library offers are the ones marked `pragma Foreign_Export`, called from C after `hilde_start`.
  Code:
    [no span available]

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:

hilde compile Example.hiq --target-type=static --entrypoint=Example:main --output=libexample.a

↑ back to top

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:

Error:
  Title: Command Line Arguments Error
  Error code: H1027
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    The output of `--target-type=shared` must end in `.so`, and `libexample.a` does not.
    
    The header is written beside the library under the same name ending in `.h`.
  Code:
    [no span available]

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:

hilde compile Example.hiq --target-type=shared --output=libexample.a

↑ back to top

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:

Error:
  Title: Command Line Arguments Error
  Error code: H1028
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    The value of `--seed` is `18446744073709551616`, which is not a decimal number from 0 to 18446744073709551615.
  Code:
    [no span available]

This module fails with H1028:

module body Example.Test is
    function testNothing(): Unit is
        return nil;
    end;
end module body.

With this command:

hilde test --contracts --seed=18446744073709551616 Example.hiq

↑ back to top

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:

Error:
  Title: Command Line Arguments Error
  Error code: H1029
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    `--seed` is read only by `hilde test --contracts`, and this run has no `--contracts`.
    
    Add `--contracts`, or leave the flag out.
  Code:
    [no span available]

This module fails with H1029:

module body Example.Test is
    function testNothing(): Unit is
        return nil;
    end;
end module body.

With this command:

hilde test --seed=7 Example.hiq

↑ back to top

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:

Error:
  Title: Command Line Arguments Error
  Error code: H1030
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    The entrypoint `Example:start` is not a function of a module on the command line.
  Code:
    [no span available]

This module fails with H1030:

module body Example is
    function main(): ExitCode is
        return ExitSuccess();
    end;
end module body.

With this command:

hilde guard Example.hiq --entrypoint=Example:start

↑ back to top

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:

Error:
  Title: Command Line Arguments Error
  Error code: H1031
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    The vulnerability database `missing.json` cannot be read: there is no such file or directory.
  Code:
    [no span available]

This module fails with H1031:

module body Example is
    function main(): ExitCode is
        return ExitSuccess();
    end;
end module body.

With this command:

hilde guard Example.hiq --vulndb=missing.json

↑ back to top

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:

Error:
  Title: Command Line Arguments Error
  Error code: H1032
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    `sqlite3` in --library-versions is not a library, a colon and a version of numbers separated by dots, such as `--library-versions=sqlite3:3.46.1,tls:4.3.0`.
  Code:
    [no span available]

This module fails with H1032:

module body Example is
    function main(): ExitCode is
        return ExitSuccess();
    end;
end module body.

With this command:

hilde guard Example.hiq --library-versions=sqlite3

↑ back to top

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:

Error:
  Title: Command Line Arguments Error
  Error code: H1033
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    hilde fmt: `Example.hiq.txt` is neither a directory nor a .hih or .hiq file.
  Code:
    [no span available]

This module fails with H1033:

module body Example is
    function main(): ExitCode is
        return ExitSuccess();
    end;
end module body.

With this command:

hilde fmt Example.hiq.txt

↑ back to top

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:

Error:
  Title: Command Line Arguments Error
  Error code: H1034
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    Failed to read file `Missing.hiq`: 
    
    Missing.hiq: No such file or directory
  Code:
    [no span available]

This module fails with H1034:

module body Example is
    function main(): ExitCode is
        return ExitSuccess();
    end;
end module body.

With this command:

hilde compile Missing.hiq --entrypoint=Example:main --target-type=c --output=example.c

↑ back to top

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:

Error:
  Title: Command Line Arguments Error
  Error code: H1035
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    The build value `1channel=stable` is refused: the name is not valid.
    
    It is written --build-value=name=value, the name a letter and then letters, digits, _, . or -, at most 64 bytes, the value printable ASCII, at most 1024 bytes, each name once.
  Code:
    [no span available]

This module fails with H1035:

module body Example is
    function main(): ExitCode is
        return ExitSuccess();
    end;
end module body.

With this command:

hilde compile Example.hiq --entrypoint=Example:main --target-type=c --output=example.c --build-value=1channel=stable

↑ back to top

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:

Error:
  Title: Command Line Arguments Error
  Error code: H1036
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    SOURCE_DATE_EPOCH is `17x0`, which is not a number of seconds since 1970: one to eighteen decimal digits.
  Code:
    [no span available]

This module fails with H1036:

module body Example is
    function main(): ExitCode is
        return ExitSuccess();
    end;
end module body.

With this command:

env SOURCE_DATE_EPOCH=17x0 hilde compile Example.hiq --entrypoint=Example:main --target-type=c --output=example.c

↑ back to top

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:

Error:
  Title: Command Line Arguments Error
  Error code: H1037
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    Unknown command `chek`. The commands are build, compile, test, lsp, modules, fmt, check, query, guard, run, get, update, verify, export, new, install, doc, api-diff, rust. Did you mean `check`?
  Code:
    [no span available]

This module fails with H1037:

module body Example is
    function main(): ExitCode is
        return ExitSuccess();
    end;
end module body.

With this command:

hilde chek Example.hiq

↑ back to top

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:

Error:
  Title: Command Line Arguments Error
  Error code: H1049
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    `hilde test` knows no suite `nosuch`; the suites are coherence.
  Code:
    [no span available]

This module fails with H1049:

module body Example.Test is
    function testNothing(): Unit is
        return nil;
    end;
end module body.

With this command:

hilde test --suite=nosuch Example.hiq

↑ back to top

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 suite `name` cannot run here: it needs `script` under the working directory, the root of the Hilde tree, and `python3` on the path.

The catalog gives no failing example for this code.

↑ back to top

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:

FAIL  Example.hiq  the test programme did not build
hilde test: 1 test file, 0 tests, 0 failed, 1 not built
Error:
  Title: Declaration Error
  Error code: H2046
  Module:
    Example.Test
  Location:
    Filename: 'Example.hiq'
    From: line 2, column 4
    To: line 4, column 8
  Description:
    The function `testLength` has the name of a test, and a test has one of two forms:
    
    `function testName(): Unit`, or, for a test that needs the root capability, `generic [R: Region] function testName(root: &![RootCapability, R]): Unit`.
    
    In a test file every function whose name is test followed by a capital letter or a digit is a test.
  Code:
    1 | module body Example.Test is
    2 |     function testLength(n: Nat32): Unit is
    3 |         return nil;
    4 |     end;
    5 | end module body.

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:

hilde test Example.hiq

↑ back to top

H2047

A test file declares no function with the name of a test.

Message:

FAIL  Example.hiq  the test programme did not build
hilde test: 1 test file, 0 tests, 0 failed, 1 not built
Error:
  Title: Declaration Error
  Error code: H2047
  Module:
    Example.Test
  Location:
    [no span available]
  Description:
    The test file `Example.hiq` holds no test.
    
    A test is a function whose name is test followed by a capital letter or a digit, such as `testLength`.
  Code:
    [no span available]

This module fails with H2047:

module body Example.Test is
    function helper(): Unit is
        return nil;
    end;
end module body.

With this command:

hilde test Example.hiq

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2048
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    The system `linux` in a `pragma Foreign_Library` is not one this compiler knows.
    
    It is compared with what `uname -s` prints on the machine that compiles the programme, and must be one of `Linux, OpenBSD, FreeBSD, NetBSD, Darwin`, written as it prints them.
  Code:
    [no span available]

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.

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2049
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    Invalid `pragma Foreign_Library`.
    
    It takes the argument `Name`, and after it, for a library linked on one system only, `System`: `pragma Foreign_Library(Name => "crypt", System => "Linux");`
  Code:
    [no span available]

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3059
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 6, column 8
    To: line 6, column 65
  Description:
    This pattern can never compile: `Standard.Regex: lookaround is not supported -- it cannot be matched in linear time; Standard.Pcre has it at byte 1`.  Standard.Regex's compile would return that as its Left when the programme runs; a literal pattern is checked now.
  Code:
    4 | module body Example is
    5 |     function main(): ExitCode is
    6 |         let compiled: Either[String, Regex] := compile("a(?=b)");
    7 |         case compiled of
    8 |             when Right(right as re: Regex) do

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.

↑ back to top

H5001

The entry point function takes more than one parameter. It takes none, or one of type RootCapability.

Message:

Error:
  Title: Entrypoint Definition Error
  Error code: H5001
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    The entrypoint function should take a single parameter with type `RootCapability`, or none at all, but it has several.
  Code:
    [no span available]

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.

↑ back to top

H5002

The module named in --entrypoint has no function of the given name.

Message:

Error:
  Title: Entrypoint Definition Error
  Error code: H5002
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    No function named `start` in module `Example`
  Code:
    [no span available]

This module fails with H5002:

module body Example is
    function main(): ExitCode is
        return ExitSuccess();
    end;
end module body.

With this command:

hilde compile Example.hiq --entrypoint=Example:start --output=prog

↑ back to top

H5003

The entry point named in --entrypoint is not a function, for example a constant.

Message:

Error:
  Title: Entrypoint Definition Error
  Error code: H5003
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    The entrypoint must be a function.
  Code:
    [no span available]

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:

hilde compile Example.hiq --entrypoint=Example:start --output=prog

↑ back to top

H5004

The entry point function is generic.

Message:

Error:
  Title: Entrypoint Definition Error
  Error code: H5004
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    The entrypoint function cannot be generic.
  Code:
    [no span available]

This module fails with H5004:

module body Example is
    generic [T: Free]
    function main(value: T): ExitCode is
        return ExitSuccess();
    end;
end module body.

↑ back to top

H5005

The module has an interface, and the interface does not declare the entry point function. Declare it there.

Message:

Error:
  Title: Entrypoint Definition Error
  Error code: H5005
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    The entrypoint function is not public.
    
    Consider declaring it in the module interface.
  Code:
    [no span available]

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.

↑ back to top

H5006

The one parameter of the entry point function is not of type RootCapability.

Message:

Error:
  Title: Entrypoint Definition Error
  Error code: H5006
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    The type of the entrypoint argument must be `RootCapability` but it is `Int32`
  Code:
    [no span available]

This module fails with H5006:

module body Example is
    function main(n: Int32): ExitCode is
        return ExitSuccess();
    end;
end module body.

↑ back to top

H5007

The entry point function does not return ExitCode.

Message:

Error:
  Title: Entrypoint Definition Error
  Error code: H5007
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    The type of the entrypoint function must be `ExitCode` but it is `Int32`
  Code:
    [no span available]

This module fails with H5007:

module body Example is
    function main(): Int32 is
        return 0;
    end;
end module body.

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H6001
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 3, column 40
    To: line 3, column 61
  Description:
    @bytes("../data.txt"): the path leaves the module's own directory, which is not allowed
  Code:
    1 | module body Example is
    2 |     function main(): ExitCode is
    3 |         let data: Span[Nat8, Static] := @bytes("../data.txt");
    4 |         printLn(spanLength(data));
    5 |         return ExitSuccess();

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

↑ back to top

H6002

The file named in @bytes cannot be read, for example because it does not exist beside the module.

Message:

Error:
  Title: Generic Error
  Error code: H6002
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 3, column 40
    To: line 3, column 61
  Description:
    @bytes("missing.txt"): cannot read it: ./missing.txt: No such file or directory
  Code:
    1 | module body Example is
    2 |     function main(): ExitCode is
    3 |         let data: Span[Nat8, Static] := @bytes("missing.txt");
    4 |         printLn(spanLength(data));
    5 |         return ExitSuccess();

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.

↑ back to top

H6005

The command line holds an argument the compile or query command does not use, such as an unknown flag.

Message:

Error:
  Title: Generic Error
  Error code: H6005
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    There are leftover arguments.
  Code:
    [no span available]

This module fails with H6005:

module body Example is
    function main(): ExitCode is
        return ExitSuccess();
    end;
end module body.

With this command:

hilde compile Example.hiq --entrypoint=Example:main --output=prog --verbose

↑ back to top

H6013

A borrow expression stands where no statement can hold the borrow, for example in the value of a constant.

Message:

Error:
  Title: Generic Error
  Error code: H6013
  Module:
    Example
  Location:
    [no span available]
  Description:
    Borrow expressions not allowed in this context.
  Code:
    [no span available]

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.

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H6020
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 4, column 8
    To: line 4, column 26
  Description:
    The name `n` is bound already in this function. A name stays bound until the end of the block it was bound in, also after its value is consumed, so a second binding needs a name of its own, as in `value as otherN`.
  Code:
    2 |     function main(): ExitCode is
    3 |         let n: Int32 := 1;
    4 |         let n: Int32 := 2;
    5 |         printLn(n);
    6 |         return ExitSuccess();

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.

↑ back to top

H6025

Two nested borrow statements give their regions the same name.

Message:

Error:
  Title: Generic Error
  Error code: H6025
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 6, column 12
    To: line 8, column 23
  Description:
    Region map already has a region with this name
  Code:
     4 |         let b: Int32 := 2;
     5 |         borrow ra: &[Int32, R] := &a do
     6 |             borrow rb: &[Int32, R] := &b do
     7 |                 printLn(!ra + !rb);
     8 |             end borrow;
     9 |         end borrow;
    10 |         return ExitSuccess();

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.

↑ back to top

H6047

A list of type parameters names the same parameter twice.

Message:

Error:
  Title: Generic Error
  Error code: H6047
  Module:
    Example
  Location:
    [no span available]
  Description:
    Duplicate type parameter `T`
  Code:
    [no span available]

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.

↑ back to top

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:

Internal compiler error: ...

This is a bug in the compiler.

The catalog gives no failing example for this code.

↑ back to top

7. Templates

H7001

The name of a template is empty.

Message:

Error:
  Title: Generic Error
  Error code: H7001
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 18, column 8
    To: line 18, column 9
  Description:
    @template: the template name is empty
  Code:
    16 |     function render(page: &[Page, R]): String is
    17 |         var out: StringBuilder := makeStringBuilder();
    18 |         @template("", page, out);
    19 |         return finalize(out);
    20 |     end;

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>

↑ back to top

H7002

The path of a template is absolute. A template is read from beside the module, or below it.

Message:

Error:
  Title: Generic Error
  Error code: H7002
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 18, column 8
    To: line 18, column 9
  Description:
    @template: "/page.jinja": the path is absolute, and a template may only be read from beside the module
  Code:
    16 |     function render(page: &[Page, R]): String is
    17 |         var out: StringBuilder := makeStringBuilder();
    18 |         @template("/page.jinja", page, out);
    19 |         return finalize(out);
    20 |     end;

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>

↑ back to top

H7003

The path of a template contains a .. part and so leaves the module's directory.

Message:

Error:
  Title: Generic Error
  Error code: H7003
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 18, column 8
    To: line 18, column 9
  Description:
    @template: "../page.jinja": the path leaves the module's own directory, which is not allowed
  Code:
    16 |     function render(page: &[Page, R]): String is
    17 |         var out: StringBuilder := makeStringBuilder();
    18 |         @template("../page.jinja", page, out);
    19 |         return finalize(out);
    20 |     end;

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>

↑ back to top

H7004

A template file cannot be read, for example because it does not exist beside the module.

Message:

Error:
  Title: Generic Error
  Error code: H7004
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 18, column 8
    To: line 18, column 9
  Description:
    @template: "missing.jinja": cannot read it: ./missing.jinja: No such file or directory
  Code:
    16 |     function render(page: &[Page, R]): String is
    17 |         var out: StringBuilder := makeStringBuilder();
    18 |         @template("missing.jinja", page, out);
    19 |         return finalize(out);
    20 |     end;

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>

↑ back to top

H7005

A tag {{ or {% is opened and never closed.

Message:

Error:
  Title: Generic Error
  Error code: H7005
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 3
    To: line 1, column 4
  Description:
    @template: this tag is never closed with }}
  Code:
    [no span available]

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>

↑ back to top

H7006

A comment {# is opened and never closed with #}.

Message:

Error:
  Title: Generic Error
  Error code: H7006
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 3
    To: line 1, column 4
  Description:
    @template: this comment is never closed with #}
  Code:
    [no span available]

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>

↑ back to top

H7007

A {% raw %} is never closed with {% endraw %}.

Message:

Error:
  Title: Generic Error
  Error code: H7007
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 3
    To: line 1, column 4
  Description:
    @template: this {% raw %} is never closed with {% endraw %}
  Code:
    [no span available]

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>

↑ back to top

H7008

The {% endraw %} tag holds something after endraw.

Message:

Error:
  Title: Generic Error
  Error code: H7008
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 3
    To: line 1, column 4
  Description:
    @template: {% endraw %} is not closed with %}
  Code:
    [no span available]

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>

↑ back to top

H7009

A number in a template is not a whole decimal number, such as 1.5.

Message:

Error:
  Title: Generic Error
  Error code: H7009
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 3
    To: line 1, column 4
  Description:
    @template: only whole decimal numbers are supported
  Code:
    [no span available]

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>

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H7011
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 3
    To: line 1, column 4
  Description:
    @template: the escape \x in a string is not supported
  Code:
    [no span available]

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>

↑ back to top

H7013

A character stands in a tag that is no part of the template language.

Message:

Error:
  Title: Generic Error
  Error code: H7013
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 3
    To: line 1, column 4
  Description:
    @template: the character ; cannot stand here
  Code:
    [no span available]

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>

↑ back to top

H7014

The expression in a tag lacks a symbol it needs, such as a closing parenthesis.

Message:

Error:
  Title: Generic Error
  Error code: H7014
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 3
    To: line 1, column 4
  Description:
    @template: expected )
  Code:
    [no span available]

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>

↑ back to top

H7015

A name is expected in a tag and something else stands there, for example after a point.

Message:

Error:
  Title: Generic Error
  Error code: H7015
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 3
    To: line 1, column 4
  Description:
    @template: expected a name
  Code:
    [no span available]

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>

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H7016
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 3
    To: line 1, column 4
  Description:
    @template: the operator / divides into a fraction, and @template has no fractions; // divides into a whole number
  Code:
    [no span available]

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>

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H7017
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 3
    To: line 1, column 4
  Description:
    @template: an inline if prints its two values the same way: both |safe, or neither
  Code:
    [no span available]

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>

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H7018
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 3
    To: line 1, column 4
  Description:
    @template: `in' asks for a text in quotes or a name of a string
  Code:
    [no span available]

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>

↑ back to top

H7019

The arguments of a filter are not separated by commas or not closed.

Message:

Error:
  Title: Generic Error
  Error code: H7019
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 3
    To: line 1, column 4
  Description:
    @template: expected , or )
  Code:
    [no span available]

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>

↑ back to top

H7020

A macro is called with a keyword argument, name=value. Arguments are given by position.

Message:

Error:
  Title: Generic Error
  Error code: H7020
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 47
    To: line 1, column 48
  Description:
    @template: keyword arguments are not supported
  Code:
    [no span available]

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) }}

↑ back to top

H7021

The arguments of a macro call are not separated by commas or not closed.

Message:

Error:
  Title: Generic Error
  Error code: H7021
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 57
    To: line 1, column 58
  Description:
    @template: expected , or )
  Code:
    [no span available]

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) }}

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H7022
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 3
    To: line 1, column 4
  Description:
    @template: calling title.upper: there is no such macro; the part before the dot is not a name an {% import ... as %} gave, or the file has no macro of that name
  Code:
    [no span available]

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>

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H7023
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 3
    To: line 1, column 4
  Description:
    @template: [ ] takes a name in quotes, as in a["b"]: an index into a list fails when the page is rendered if the list is shorter, which a compiled template cannot allow
  Code:
    [no span available]

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>

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H7024
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 3
    To: line 1, column 4
  Description:
    @template: a minus sign stands before a number only; write 0 - x to subtract from zero
  Code:
    [no span available]

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>

↑ back to top

H7025

A symbol stands in a tag where an expression should begin.

Message:

Error:
  Title: Generic Error
  Error code: H7025
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 3
    To: line 1, column 4
  Description:
    @template: unexpected )
  Code:
    [no span available]

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>

↑ back to top

H7026

A tag holds no expression.

Message:

Error:
  Title: Generic Error
  Error code: H7026
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 3
    To: line 1, column 4
  Description:
    @template: an expression is missing
  Code:
    [no span available]

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>

↑ back to top

H7027

An expression in a tag is followed by more text.

Message:

Error:
  Title: Generic Error
  Error code: H7027
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 3
    To: line 1, column 4
  Description:
    @template: unexpected text after the expression
  Code:
    [no span available]

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>

↑ back to top

H7028

A {% %} tag does not begin with a keyword.

Message:

Error:
  Title: Generic Error
  Error code: H7028
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 3
    To: line 1, column 4
  Description:
    @template: a {% %} tag must begin with a keyword
  Code:
    [no span available]

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>

↑ back to top

H7029

A {% %} tag uses a keyword this template language does not support, such as do.

Message:

Error:
  Title: Generic Error
  Error code: H7029
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: {% do %} is not supported
  Code:
    [no span available]

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>

↑ back to top

H7030

An {% include %} or {% extends %} takes the template's name and nothing after it.

Message:

Error:
  Title: Generic Error
  Error code: H7030
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: {% include %} takes the template's name and nothing after it
  Code:
    [no span available]

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>

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H7031
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: {% include %} takes a string literal: a template chosen when the page is rendered cannot be compiled
  Code:
    [no span available]

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>

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H7032
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: {% import %} takes a string literal, `as' and a name: {% import "file" as name %}
  Code:
    [no span available]

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 %}

↑ back to top

H7033

A template uses {% autoescape %}. Escaping cannot be switched off for a stretch; mark the one value that goes out unescaped with |safe.

Message:

Error:
  Title: Generic Error
  Error code: H7033
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: {% autoescape %} is refused: escaping cannot be switched off for a stretch of template -- write |safe on the one value that is meant to go out unescaped, where a grep finds it
  Code:
    [no span available]

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 %}

↑ back to top

H7034

A closing or continuing tag, such as {% endif %} or {% else %}, stands without its opening tag.

Message:

Error:
  Title: Generic Error
  Error code: H7034
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 18
    To: line 1, column 19
  Description:
    @template: {% endif %} without the tag it belongs to
  Code:
    [no span available]

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 %}

↑ back to top

H7035

An {% else %} of an {% if %} is not followed by {% endif %}.

Message:

Error:
  Title: Generic Error
  Error code: H7035
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 26
    To: line 1, column 27
  Description:
    @template: {% else %} without {% endif %}
  Code:
    [no span available]

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>

↑ back to top

H7036

An {% if %} is never closed with {% endif %}.

Message:

Error:
  Title: Generic Error
  Error code: H7036
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: {% if %} without {% endif %}
  Code:
    [no span available]

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>

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H7037
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: {% for %} takes one name, or two or three that unpack a Pair or a Triple of Standard.Tuples
  Code:
    [no span available]

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 %}

↑ back to top

H7038

A {% for %} lacks the word in.

Message:

Error:
  Title: Generic Error
  Error code: H7038
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: expected `in' in {% for %}
  Code:
    [no span available]

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 %}

↑ back to top

H7039

Something other than if and a condition follows the sequence of a {% for %}, such as recursive.

Message:

Error:
  Title: Generic Error
  Error code: H7039
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: after {% for ... in ... %} only `if' and a condition may follow
  Code:
    [no span available]

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 %}

↑ back to top

H7040

An {% else %} of a {% for %} is not followed by {% endfor %}.

Message:

Error:
  Title: Generic Error
  Error code: H7040
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 33
    To: line 1, column 34
  Description:
    @template: {% else %} without {% endfor %}
  Code:
    [no span available]

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>

↑ back to top

H7041

A {% for %} is never closed with {% endfor %}.

Message:

Error:
  Title: Generic Error
  Error code: H7041
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: {% for %} without {% endfor %}
  Code:
    [no span available]

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 }}

↑ back to top

H7042

A block is marked required.

Message:

Error:
  Title: Generic Error
  Error code: H7042
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: a `required' block is not supported
  Code:
    [no span available]

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 %}

↑ back to top

H7043

A {% block %} has no name, or something other than scoped after it.

Message:

Error:
  Title: Generic Error
  Error code: H7043
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: {% block %} takes a name, and `scoped' after it
  Code:
    [no span available]

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 %}

↑ back to top

H7044

A {% block %} is never closed with {% endblock %}.

Message:

Error:
  Title: Generic Error
  Error code: H7044
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: {% block main %} without {% endblock %}
  Code:
    [no span available]

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>

↑ back to top

H7045

An {% endblock %} names another block than the one it closes.

Message:

Error:
  Title: Generic Error
  Error code: H7045
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 34
    To: line 1, column 35
  Description:
    @template: {% endblock side %} closes {% block main %}
  Code:
    [no span available]

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 %}

↑ back to top

H7046

The default of a macro parameter is not a literal.

Message:

Error:
  Title: Generic Error
  Error code: H7046
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: a macro parameter's default is a literal
  Code:
    [no span available]

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>

↑ back to top

H7047

The parameters of a macro are not separated by commas.

Message:

Error:
  Title: Generic Error
  Error code: H7047
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: expected , or ) in the macro's parameters
  Code:
    [no span available]

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>

↑ back to top

H7048

Text follows the parameter list of a macro.

Message:

Error:
  Title: Generic Error
  Error code: H7048
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: unexpected text after the macro's parameters
  Code:
    [no span available]

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>

↑ back to top

H7049

A {% macro %} is never closed with {% endmacro %}.

Message:

Error:
  Title: Generic Error
  Error code: H7049
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: {% macro show %} without {% endmacro %}
  Code:
    [no span available]

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 }}

↑ back to top

H7050

A {% from ... import %} gives an imported macro another name with as.

Message:

Error:
  Title: Generic Error
  Error code: H7050
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: `as' in {% from ... import %} is not supported
  Code:
    [no span available]

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 %}

↑ back to top

H7051

A {% from ... import %} names something other than macros.

Message:

Error:
  Title: Generic Error
  Error code: H7051
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: {% from "file" import a, b %} names the macros to import, and nothing else
  Code:
    [no span available]

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 %}

↑ back to top

H7052

A {% from %} lacks the file name as a string, or the word import.

Message:

Error:
  Title: Generic Error
  Error code: H7052
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: {% from %} takes a string literal and `import'
  Code:
    [no span available]

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 %}

↑ back to top

H7054

A macro is defined twice with two bodies.

Message:

Error:
  Title: Generic Error
  Error code: H7054
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 40
    To: line 1, column 41
  Description:
    @template: the macro show is defined twice
  Code:
    [no span available]

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>

↑ back to top

H7055

A template imports macros from itself.

Message:

Error:
  Title: Generic Error
  Error code: H7055
  Module:
    Example
  Location:
    Filename: './macros.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: "macros.jinja" imports from itself
  Code:
    [no span available]

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 %}

↑ back to top

H7056

A {% from ... import %} names a macro the file does not define.

Message:

Error:
  Title: Generic Error
  Error code: H7056
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: "macros.jinja" has no macro display
  Code:
    [no span available]

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 %}

↑ back to top

H7057

A template includes or extends itself, directly or through others.

Message:

Error:
  Title: Generic Error
  Error code: H7057
  Module:
    Example
  Location:
    Filename: './part.jinja'
    From: line 1, column 18
    To: line 1, column 19
  Description:
    @template: "page.jinja" includes or extends itself: page.jinja -> part.jinja -> page.jinja
  Code:
    [no span available]

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" %}

↑ back to top

H7058

A template extends a second time.

Message:

Error:
  Title: Generic Error
  Error code: H7058
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 26
    To: line 1, column 27
  Description:
    @template: a template extends one other template, once
  Code:
    [no span available]

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>

↑ back to top

H7059

Text stands after {% extends %} outside a block. Jinja2 would drop it; here it is refused.

Message:

Error:
  Title: Generic Error
  Error code: H7059
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 26
    To: line 1, column 27
  Description:
    @template: text after {% extends %} and outside a block is dropped by Jinja2; here it is refused
  Code:
    [no span available]

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>

↑ back to top

H7060

A value stands after {% extends %} outside a block.

Message:

Error:
  Title: Generic Error
  Error code: H7060
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 26
    To: line 1, column 27
  Description:
    @template: a value after {% extends %} and outside a block is dropped by Jinja2; here it is refused
  Code:
    [no span available]

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>

↑ back to top

H7061

An {% if %} or a {% for %} stands after {% extends %} outside a block.

Message:

Error:
  Title: Generic Error
  Error code: H7061
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: an if or a for after {% extends %} and outside a block is dropped by Jinja2; here it is refused
  Code:
    [no span available]

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>

↑ back to top

H7062

An {% include %} stands after {% extends %} outside a block.

Message:

Error:
  Title: Generic Error
  Error code: H7062
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 26
    To: line 1, column 27
  Description:
    @template: an include after {% extends %} and outside a block is dropped by Jinja2; here it is refused
  Code:
    [no span available]

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>

↑ back to top

H7063

super() stands in a block that no template above this one has.

Message:

Error:
  Title: Generic Error
  Error code: H7063
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 16
    To: line 1, column 17
  Description:
    @template: super() in a block that no template above this one has
  Code:
    [no span available]

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 %}

↑ back to top

H7064

super() is given arguments.

Message:

Error:
  Title: Generic Error
  Error code: H7064
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 42
    To: line 1, column 43
  Description:
    @template: super() takes no arguments
  Code:
    [no span available]

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>

↑ back to top

H7065

An {% extends %} stands inside another tag, such as an {% if %}. It stands at the top level, once.

Message:

Error:
  Title: Generic Error
  Error code: H7065
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 14
    To: line 1, column 15
  Description:
    @template: {% extends %} stands at the top level of a template, once
  Code:
    [no span available]

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>

↑ back to top

H7066

A template defines a block that no template it extends has. Jinja2 would drop it; here it is refused.

Message:

Error:
  Title: Generic Error
  Error code: H7066
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 26
    To: line 1, column 27
  Description:
    @template: the block side is defined here, and no template this one extends has a block of that name; Jinja2 drops it without a word, and here it is refused
  Code:
    [no span available]

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>

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H7067
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 5
    To: line 1, column 6
  Description:
    @template: a value cannot stand in a tag, between its attributes: there is no escaping that makes that safe
  Code:
    [no span available]

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>

↑ back to top

H7069

loop is used for something other than loop.index, loop.index0, loop.length, loop.first or loop.last.

Message:

Error:
  Title: Generic Error
  Error code: H7069
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 23
    To: line 1, column 24
  Description:
    @template: `loop' can only be asked for loop.index, loop.index0, loop.revindex, loop.revindex0, loop.length, loop.first, loop.last and loop.cycle(...), inside a {% for %}
  Code:
    [no span available]

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 %}

↑ back to top

H7070

A macro brought in with {% from ... import %} uses the template's data. Such a macro sees only its arguments.

Message:

Error:
  Title: Generic Error
  Error code: H7070
  Module:
    Example
  Location:
    Filename: './macros.jinja'
    From: line 1, column 18
    To: line 1, column 19
  Description:
    @template: title: a macro brought in with {% from ... import %} or {% import %} does not see the template's data, as in Jinja2 -- pass it as an argument
  Code:
    [no span available]

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 %}

↑ back to top

H7071

loop is used outside a {% for %}.

Message:

Error:
  Title: Generic Error
  Error code: H7071
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 3
    To: line 1, column 4
  Description:
    @template: `loop' only exists inside a {% for %}
  Code:
    [no span available]

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>

↑ back to top

H7072

A number compared in a condition is too large.

Message:

Error:
  Title: Generic Error
  Error code: H7072
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: this number is too large
  Code:
    [no span available]

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 %}

↑ back to top

H7073

A loop attribute is printed that cannot be printed.

Message:

Error:
  Title: Generic Error
  Error code: H7073
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 23
    To: line 1, column 24
  Description:
    @template: loop.cycle cannot be printed
  Code:
    [no span available]

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 %}

↑ back to top

H7075

|length is applied to something that is not a name of the data.

Message:

Error:
  Title: Generic Error
  Error code: H7075
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 3
    To: line 1, column 4
  Description:
    @template: |length is supported on a name of the data only
  Code:
    [no span available]

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>

↑ back to top

H7076

A filter is used that this template language does not support.

Message:

Error:
  Title: Generic Error
  Error code: H7076
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 3
    To: line 1, column 4
  Description:
    @template: the filter |wordcount is not supported
  Code:
    [no span available]

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>

↑ back to top

H7077

none is printed. An Option is printed after asking is not none.

Message:

Error:
  Title: Generic Error
  Error code: H7077
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 3
    To: line 1, column 4
  Description:
    @template: none cannot be printed: an Option is printed by asking `is not none' first
  Code:
    [no span available]

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>

↑ back to top

H7079

A macro call stands with a filter in {{ }}. A macro call stands alone.

Message:

Error:
  Title: Generic Error
  Error code: H7079
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 43
    To: line 1, column 44
  Description:
    @template: a macro call stands alone in {{ }}, without filters
  Code:
    [no span available]

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>

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H7080
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 23
    To: line 1, column 24
  Description:
    @template: loop.first is not a number
  Code:
    [no span available]

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 %}

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H7082
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: `is defined' cannot be asked: the template is compiled against one data type, so every name is known when the programme is compiled, and a name that does not exist is a compile error already
  Code:
    [no span available]

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 %}

↑ back to top

H7083

is none is asked of something that is not a name of the data.

Message:

Error:
  Title: Generic Error
  Error code: H7083
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: `is none' is supported on a name of the data only
  Code:
    [no span available]

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 %}

↑ back to top

H7084

A condition uses a test this template language does not support.

Message:

Error:
  Title: Generic Error
  Error code: H7084
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: the test `is even' is not supported
  Code:
    [no span available]

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 %}

↑ back to top

H7085

A string is compared with an operator other than == and !=.

Message:

Error:
  Title: Generic Error
  Error code: H7085
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: a string can only be compared with == and !=
  Code:
    [no span available]

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 %}

↑ back to top

H7086

A comparison does not compare a name with a literal.

Message:

Error:
  Title: Generic Error
  Error code: H7086
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: only a name compared with a literal, or with a computed number, is supported
  Code:
    [no span available]

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 %}

↑ back to top

H7087

Something that is not a condition stands as one, such as a string.

Message:

Error:
  Title: Generic Error
  Error code: H7087
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: this cannot be used as a condition
  Code:
    [no span available]

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 %}

↑ back to top

H7088

A macro parameter that is given a literal is used with a field, as in x.name.

Message:

Error:
  Title: Generic Error
  Error code: H7088
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 19
    To: line 1, column 20
  Description:
    @template: the parameter x is a literal here, and a literal has no fields
  Code:
    [no span available]

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>

↑ back to top

H7089

A macro is called that is not defined.

Message:

Error:
  Title: Generic Error
  Error code: H7089
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 3
    To: line 1, column 4
  Description:
    @template: there is no macro show
  Code:
    [no span available]

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>

↑ back to top

H7090

A macro calls itself. A template is expanded when the program is compiled, and a recursion would not end.

Message:

Error:
  Title: Generic Error
  Error code: H7090
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 19
    To: line 1, column 20
  Description:
    @template: the macro show calls itself: show -> show; a template is expanded when the programme is compiled, and a recursion would not end
  Code:
    [no span available]

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>

↑ back to top

H7091

A macro is called with more arguments than it has parameters.

Message:

Error:
  Title: Generic Error
  Error code: H7091
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 43
    To: line 1, column 44
  Description:
    @template: the macro show takes 1 arguments
  Code:
    [no span available]

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>

↑ back to top

H7092

A macro is called without a value for a parameter that has no default.

Message:

Error:
  Title: Generic Error
  Error code: H7092
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 43
    To: line 1, column 44
  Description:
    @template: the macro show needs a value for x
  Code:
    [no span available]

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>

↑ back to top

H7093

A macro argument is neither a name nor a literal.

Message:

Error:
  Title: Generic Error
  Error code: H7093
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 43
    To: line 1, column 44
  Description:
    @template: a macro argument is a name or a literal
  Code:
    [no span available]

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>

↑ back to top

H7095

The branches of an {% if %} end in different places of the HTML, for example one inside a script and one outside.

Message:

Error:
  Title: Generic Error
  Error code: H7095
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: the branches of this {% if %} end in different places in the HTML: a <script> element and HTML text
  Code:
    [no span available]

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>

↑ back to top

H7096

A {% for %} walks over something that is not a name of the data.

Message:

Error:
  Title: Generic Error
  Error code: H7096
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: {% for %} walks over a name of the data only
  Code:
    [no span available]

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 %}

↑ back to top

H7097

The body of a {% for %} ends in a different place of the HTML than it begins.

Message:

Error:
  Title: Generic Error
  Error code: H7097
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: the body of this {% for %} ends in a different place in the HTML than it begins: HTML text and a <script> element
  Code:
    [no span available]

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 %}

↑ back to top

H7098

The {% else %} of a {% for %} ends in a different place of the HTML than it begins.

Message:

Error:
  Title: Generic Error
  Error code: H7098
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: the {% else %} of this {% for %} ends in a different place in the HTML than it begins
  Code:
    [no span available]

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 %}

↑ back to top

H7099

A module that uses @template does not import Standard.Template. The generated code calls it, and its instances come with the import.

Message:

Error:
  Title: Generic Error
  Error code: H7099
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 17, column 8
    To: line 17, column 9
  Description:
    @template: a module that uses @template imports Standard.Template -- e.g. `import Standard.Template (Render);' -- because the generated code calls it, and its instances come with the import
  Code:
    15 |     function render(page: &[Page, R]): String is
    16 |         var out: StringBuilder := makeStringBuilder();
    17 |         @template("page.jinja", page, out);
    18 |         return finalize(out);
    19 |     end;

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>

↑ back to top

H7100

A {% set %} block, a {% with %}, a {% filter %} or a {% call %} is not closed by its end tag.

Message:

Error:
  Title: Generic Error
  Error code: H7100
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: {% with %} without {% endwith %}
  Code:
    [no span available]

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>

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H7101
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: {% set %} takes one name, = and one value
  Code:
    [no span available]

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>

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H7102
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 37
    To: line 1, column 38
  Description:
    @template: the name lib is an import's: it stands for the macros of a file, and a macro is called, not printed
  Code:
    [no span available]

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 %}

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H7103
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 26
    To: line 1, column 27
  Description:
    @template: a {% set %} after {% extends %} and outside a block is refused: whether a block sees it depends on the order in which Jinja2 runs the two templates
  Code:
    [no span available]

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>

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H7104
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 31
    To: line 1, column 32
  Description:
    @template: name is a value that a {% set %} or a {% with %} computed, and a computed value has no fields
  Code:
    [no span available]

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>

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H7105
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 3
    To: line 1, column 4
  Description:
    @template: // divides by a number written in the template only: a divisor from the data could be zero, and a division by zero stops the programme
  Code:
    [no span available]

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>

↑ back to top

H7106

An operand of + - * // % is something other than a number: a text, a filter or a condition.

Message:

Error:
  Title: Generic Error
  Error code: H7106
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 3
    To: line 1, column 4
  Description:
    @template: this is not a number: + - * // % take numbers, names of the data and the numbers of loop
  Code:
    [no span available]

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>

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H7107
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 3
    To: line 1, column 4
  Description:
    @template: ~ joins texts that are escaped when printed; a |safe value or a {% set %} block's text cannot be joined to them -- print it on its own
  Code:
    [no span available]

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>

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H7108
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 3
    To: line 1, column 4
  Description:
    @template: |truncate takes a length at least as long as its ending, and a leeway of at least 0
  Code:
    [no span available]

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>

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H7109
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: the filter |join cannot stand in {% filter %}: it applies to a value, not to written text
  Code:
    [no span available]

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 %}

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H7110
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 14
    To: line 1, column 15
  Description:
    @template: {% set name %} inside an {% if %} is refused: in Jinja2 the name is still there after the {% endif %} when the branch ran, and missing when it did not, which a compiled template cannot follow; set it before the {% if %}, or use {% with %}
  Code:
    [no span available]

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>

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H7111
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 10
    To: line 1, column 11
  Description:
    @template: a {% set %} or {% filter %} block stands in HTML text and ends there; this one stands in the value of the attribute title
  Code:
    [no span available]

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>

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H7112
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 22
    To: line 1, column 23
  Description:
    @template: caller() stands in a macro that a {% call %} block calls
  Code:
    [no span available]

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>

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H7113
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 54
    To: line 1, column 55
  Description:
    @template: the text of a {% set %} block is HTML, escaped already, and is printed in HTML text only, not in the value of the attribute title
  Code:
    [no span available]

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>

↑ back to top

H7114

The fourth argument of @template names an option other than trim_blocks and lstrip_blocks.

Message:

Error:
  Title: Generic Error
  Error code: H7114
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 18, column 8
    To: line 18, column 9
  Description:
    @template: "strict": @template knows the options trim_blocks and lstrip_blocks
  Code:
    16 |     function render(page: &[Page, R]): String is
    17 |         var out: StringBuilder := makeStringBuilder();
    18 |         @template("page.jinja", page, out, "strict");
    19 |         return finalize(out);
    20 |     end;

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>

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H7115
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 25
    To: line 1, column 26
  Description:
    @template: _( ) takes the key first, as a string literal, as in _("Greeting")
  Code:
    [no span available]

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>

↑ back to top

H7116

Each argument of _( ) has a name of its own; the same name twice would leave open which value the placeholder takes.

Message:

Error:
  Title: Generic Error
  Error code: H7116
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 25
    To: line 1, column 26
  Description:
    @template: _( ) is given name twice
  Code:
    [no span available]

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>

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H7117
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: {% catalog %} takes the name of a function of no arguments that gives the catalog, as in {% catalog messages %}
  Code:
    [no span available]

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>

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H7118
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 25
    To: line 1, column 26
  Description:
    @template: the text of a {% trans %} block is its key, one name such as Greeting; the texts of the languages stand in the catalog
  Code:
    [no span available]

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>

↑ back to top

H7119

The count chooses the plural form, so a {% trans %} block with {% pluralize %} names it: count=... in its tag.

Message:

Error:
  Title: Generic Error
  Error code: H7119
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 41
    To: line 1, column 42
  Description:
    @template: {% pluralize %} needs count=... in its {% trans %}: the count chooses the form
  Code:
    [no span available]

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>

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H7120
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 53
    To: line 1, column 54
  Description:
    @template: between {% pluralize %} and {% endtrans %} nothing may stand: the plural forms are in the catalog
  Code:
    [no span available]

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>

↑ back to top

H7121

A template takes its translations from one catalog, named once with {% catalog %}.

Message:

Error:
  Title: Generic Error
  Error code: H7121
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 22
    To: line 1, column 23
  Description:
    @template: a template names its catalog once, with one {% catalog %}
  Code:
    [no span available]

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>

↑ back to top

H7122

A translation needs the catalog it comes from: {% catalog name %} stands before the first _( ) or {% trans %} of the template.

Message:

Error:
  Title: Generic Error
  Error code: H7122
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 3
    To: line 1, column 4
  Description:
    @template: a translation needs the template's catalog: {% catalog name %} before it
  Code:
    [no span available]

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>

↑ back to top

H7123

A translation is text for HTML, escaped for the place it lands in, and cannot stand where a JavaScript expression goes.

Message:

Error:
  Title: Generic Error
  Error code: H7123
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 38
    To: line 1, column 39
  Description:
    @template: a translation is text for HTML and cannot stand in a <script> element
  Code:
    [no span available]

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>

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H7124
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 25
    To: line 1, column 26
  Description:
    @template: a translation stands alone in {{ }} or a {% trans %} block, without filters and without ~
  Code:
    [no span available]

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>

↑ back to top

H7125

After the key, _( ) takes its arguments as name=value: the name is the placeholder {name} of the text it fills.

Message:

Error:
  Title: Generic Error
  Error code: H7125
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 25
    To: line 1, column 26
  Description:
    @template: after the key, _( ) takes its arguments as name=value
  Code:
    [no span available]

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>

↑ back to top

H7126

Each argument in the tag of {% trans %} has a name of its own.

Message:

Error:
  Title: Generic Error
  Error code: H7126
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 25
    To: line 1, column 26
  Description:
    @template: {% trans %} is given name twice
  Code:
    [no span available]

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>

↑ back to top

H7127

The code a translation becomes calls Standard.I18n, so the module that holds the @template imports it, as it imports Standard.Template.

Message:

Error:
  Title: Generic Error
  Error code: H7127
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 0
    To: line 1, column 1
  Description:
    @template: a module whose template translates imports Standard.I18n -- e.g. import Standard.I18n (Catalog); -- because the generated code calls it
  Code:
    [no span available]

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>

↑ back to top

H7128

In a template that extends another, only the blocks are kept. {% catalog %} stands in the extended template, before the blocks it serves.

Message:

Error:
  Title: Generic Error
  Error code: H7128
  Module:
    Example
  Location:
    Filename: './page.jinja'
    From: line 1, column 26
    To: line 1, column 27
  Description:
    @template: {% catalog %} after {% extends %} stands in the template that is extended or in a block, where the text it serves is
  Code:
    [no span available]

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 %}

↑ back to top

8. SQL

H8001

A string or a quoted name in the SQL is not closed.

Message:

Error:
  Title: Generic Error
  Error code: H8001
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: a string is not closed (line 1, column 37 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users WHERE name = 'ann") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8002

A comment /* in the SQL is not closed with */.

Message:

Error:
  Title: Generic Error
  Error code: H8002
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: a comment is not closed (line 1, column 24 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users /* everyone") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8003

A blob literal x'...' does not hold an even number of hexadecimal digits.

Message:

Error:
  Title: Generic Error
  Error code: H8003
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 6, column 47
    To: line 6, column 102
  Description:
    @execute: a blob literal is an even number of hexadecimal digits (line 1, column 32 of the SQL)
  Code:
    4 |     generic [R: Region]
    5 |     function run(db: &![Connection[Writing], R]): Unit is
    6 |         let result: Either[SqlError, Nat64] := @execute(&~db, "DELETE FROM notes WHERE body = x'ABC'");
    7 |         case result of
    8 |             when Left(left as error: SqlError) do

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;

↑ back to top

H8004

A number runs straight into a name, as in 18years.

Message:

Error:
  Title: Generic Error
  Error code: H8004
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: a number runs into a name (line 1, column 36 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users WHERE age > 18years") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8005

A name is quoted with backticks or brackets. Quote it with double quotes.

Message:

Error:
  Title: Generic Error
  Error code: H8005
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: a name is quoted with double quotes here, not with ` or [ ] (line 1, column 8 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT [name] FROM users") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8006

A numbered parameter such as ?1 stands in the SQL. Write ? and give the values in order.

Message:

Error:
  Title: Generic Error
  Error code: H8006
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: a numbered parameter (?NNN) is not accepted: write ? and give the values in order (line 1, column 36 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users WHERE age > ?1", 18) for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8007

A named parameter such as :age stands in the SQL. Write ? and give the values in order.

Message:

Error:
  Title: Generic Error
  Error code: H8007
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: a named parameter is not accepted: write ? and give the values in order (line 1, column 36 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users WHERE age > :age", 18) for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8008

A character stands in the SQL that the compiler does not read as SQL, such as #.

Message:

Error:
  Title: Generic Error
  Error code: H8008
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: the character '#' is not SQL this compiler reads (line 1, column 40 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users WHERE age >= 18 # adults") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8009

A keyword is missing where the grammar needs it, such as BY after ORDER.

Message:

Error:
  Title: Generic Error
  Error code: H8009
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: expected BY, found name (line 1, column 30 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users ORDER name") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8010

A symbol is missing where the grammar needs it, such as the parenthesis after IN.

Message:

Error:
  Title: Generic Error
  Error code: H8010
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: expected (, found 18 (line 1, column 37 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users WHERE age IN 18, 21") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8011

A name is missing where the grammar needs one, such as the table after FROM.

Message:

Error:
  Title: Generic Error
  Error code: H8011
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: expected a table, found WHERE (line 1, column 18 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM WHERE age > 18") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H8012
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: a subquery is not accepted in the SQL the compiler checks (line 1, column 37 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users WHERE age > (SELECT avg(age) FROM users)") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8013

A function other than count is given *.

Message:

Error:
  Title: Generic Error
  Error code: H8013
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: sum(*): only count takes * (line 1, column 8 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT sum(*) AS total FROM users") for row: Tally do
    11 |             printLn(row.total);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8014

A column of the result is named without AS.

Message:

Error:
  Title: Generic Error
  Error code: H8014
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: a column alias is written with AS (line 1, column 20 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT upper(name) name FROM users") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8015

OR in INSERT OR or UPDATE OR is followed by something other than ABORT, FAIL, IGNORE, REPLACE or ROLLBACK.

Message:

Error:
  Title: Generic Error
  Error code: H8015
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 6, column 47
    To: line 6, column 115
  Description:
    @execute: expected ABORT, FAIL, IGNORE, REPLACE or ROLLBACK after OR (line 1, column 11 of the SQL)
  Code:
    4 |     generic [R: Region]
    5 |     function run(db: &![Connection[Writing], R]): Unit is
    6 |         let result: Either[SqlError, Nat64] := @execute(&~db, "INSERT OR SKIP INTO users (name) VALUES (?)", "ann");
    7 |         case result of
    8 |             when Left(left as error: SqlError) do

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;

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H8016
  Module:
    Example
  Location:
    Filename: './migrations/1-schema.sql'
    From: line 4, column 35
    To: line 4, column 36
  Description:
    migration: expected a default value, found now
  Code:
    [no span available]

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;

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H8017
  Module:
    Example
  Location:
    Filename: './migrations/1-schema.sql'
    From: line 3, column 17
    To: line 3, column 18
  Description:
    migration: a size after the type name is not a STRICT type (INT, INTEGER, REAL, TEXT, BLOB)
  Code:
    [no span available]

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;

↑ back to top

H8018

After CONSTRAINT and its name, a table constraint is not PRIMARY KEY, UNIQUE, CHECK or FOREIGN KEY.

Message:

Error:
  Title: Generic Error
  Error code: H8018
  Module:
    Example
  Location:
    Filename: './migrations/1-schema.sql'
    From: line 4, column 26
    To: line 4, column 27
  Description:
    migration: expected a table constraint, found KEY
  Code:
    [no span available]

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;

↑ back to top

H8019

WITHOUT after a table is not followed by ROWID.

Message:

Error:
  Title: Generic Error
  Error code: H8019
  Module:
    Example
  Location:
    Filename: './migrations/1-schema.sql'
    From: line 4, column 19
    To: line 4, column 20
  Description:
    migration: expected ROWID after WITHOUT
  Code:
    [no span available]

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;

↑ back to top

H8020

In the list of table options after a comma stands something other than STRICT or WITHOUT ROWID.

Message:

Error:
  Title: Generic Error
  Error code: H8020
  Module:
    Example
  Location:
    Filename: './migrations/1-schema.sql'
    From: line 4, column 11
    To: line 4, column 12
  Description:
    migration: expected STRICT or WITHOUT ROWID, found WITHOUT_ROWID
  Code:
    [no span available]

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;

↑ back to top

H8021

CREATE INDEX lacks the parenthesis with the columns after the table.

Message:

Error:
  Title: Generic Error
  Error code: H8021
  Module:
    Example
  Location:
    Filename: './migrations/1-schema.sql'
    From: line 6, column 34
    To: line 6, column 35
  Description:
    migration: expected ( after the table
  Code:
    [no span available]

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;

↑ back to top

H8022

ALTER TABLE is followed by something other than RENAME, ADD or DROP.

Message:

Error:
  Title: Generic Error
  Error code: H8022
  Module:
    Example
  Location:
    Filename: './migrations/1-schema.sql'
    From: line 6, column 19
    To: line 6, column 20
  Description:
    migration: expected RENAME, ADD or DROP after ALTER TABLE
  Code:
    [no span available]

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;

↑ back to top

H8023

A migration creates something other than a table or an index, such as a view.

Message:

Error:
  Title: Generic Error
  Error code: H8023
  Module:
    Example
  Location:
    Filename: './migrations/1-schema.sql'
    From: line 6, column 8
    To: line 6, column 9
  Description:
    migration: CREATE VIEW is not accepted in a migration, which creates a table (CREATE TABLE) or an index (CREATE INDEX, CREATE UNIQUE INDEX)
  Code:
    [no span available]

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;

↑ back to top

H8024

A migration drops something other than a table or an index, such as a view.

Message:

Error:
  Title: Generic Error
  Error code: H8024
  Module:
    Example
  Location:
    Filename: './migrations/1-schema.sql'
    From: line 6, column 6
    To: line 6, column 7
  Description:
    migration: DROP VIEW is not accepted in a migration
  Code:
    [no span available]

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;

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H8025
  Module:
    Example
  Location:
    Filename: './migrations/1-schema.sql'
    From: line 1, column 1
    To: line 1, column 2
  Description:
    migration: a migration may hold CREATE TABLE, CREATE INDEX, ALTER TABLE, DROP TABLE, DROP INDEX, INSERT, UPDATE and DELETE, not PRAGMA
  Code:
    [no span available]

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;

↑ back to top

H8026

A query is not SELECT, INSERT, UPDATE or DELETE. A table is created in a migration.

Message:

Error:
  Title: Generic Error
  Error code: H8026
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 6, column 47
    To: line 6, column 135
  Description:
    @execute: a query is SELECT, INSERT, UPDATE or DELETE, not CREATE (line 1, column 1 of the SQL)
  Code:
    4 |     generic [R: Region]
    5 |     function run(db: &![Connection[Writing], R]): Unit is
    6 |         let result: Either[SqlError, Nat64] := @execute(&~db, "CREATE TABLE tags (id INTEGER PRIMARY KEY, label TEXT NOT NULL) STRICT");
    7 |         case result of
    8 |             when Left(left as error: SqlError) do

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;

↑ back to top

H8027

The SQL names a table that the migrations do not build.

Message:

Error:
  Title: Generic Error
  Error code: H8027
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: there is no table user in the schema the migrations build (line 1, column 18 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM user") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8028

The SQL names a column that the table does not have.

Message:

Error:
  Title: Generic Error
  Error code: H8028
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 6, column 47
    To: line 6, column 111
  Description:
    @execute: table users has no column years (line 1, column 18 of the SQL)
  Code:
    4 |     generic [R: Region]
    5 |     function run(db: &![Connection[Writing], R]): Unit is
    6 |         let result: Either[SqlError, Nat64] := @execute(&~db, "UPDATE users SET years = ? WHERE id = ?", 41, 1);
    7 |         case result of
    8 |             when Left(left as error: SqlError) do

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;

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H8029
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: the type of parameter 1 cannot be told from where it stands: compare it with a column, or put it where a column's value goes (line 1, column 33 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users ORDER BY ?", "name") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8030

A column is qualified with a table or alias that the query does not have.

Message:

Error:
  Title: Generic Error
  Error code: H8030
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: there is no table or alias u in this query (line 1, column 8 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT u.name FROM users") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8032

A query names a column and has no FROM to take it from.

Message:

Error:
  Title: Generic Error
  Error code: H8032
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: name: this query has no table to take a column from (line 1, column 8 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8033

No table of the query has a column of this name.

Message:

Error:
  Title: Generic Error
  Error code: H8033
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: no table of this query has a column mail (users) (line 1, column 30 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users WHERE mail IS NULL") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8034

More than one table of the query has a column of this name. Name the table in front of it.

Message:

Error:
  Title: Generic Error
  Error code: H8034
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: more than one table of this query has a column id: name the table, as in t.id (line 1, column 48 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users JOIN notes ON user_id = id") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8035

A sign stands in front of something that is not a number.

Message:

Error:
  Title: Generic Error
  Error code: H8035
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: a sign in front of TEXT: only a number has one (line 1, column 33 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users ORDER BY -name") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8036

NOT stands in front of something that is not a condition.

Message:

Error:
  Title: Generic Error
  Error code: H8036
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: NOT of TEXT: NOT takes a condition (line 1, column 30 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users WHERE NOT email") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8037

% takes two INTEGERs and is given a REAL.

Message:

Error:
  Title: Generic Error
  Error code: H8037
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: % takes two INTEGERs (line 1, column 36 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users WHERE score % 2 = 0") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8038

Arithmetic is done on something that is not a number.

Message:

Error:
  Title: Generic Error
  Error code: H8038
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: INTEGER + TEXT: arithmetic takes numbers (INTEGER or REAL) (line 1, column 34 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users WHERE age + '1' > 18") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8039

|| joins something that is not TEXT.

Message:

Error:
  Title: Generic Error
  Error code: H8039
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: TEXT || INTEGER: || joins TEXT to TEXT (line 1, column 13 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name || age AS name FROM users") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H8040
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: a comparison with NULL is never true: write IS NULL or IS NOT NULL (line 1, column 36 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users WHERE email = NULL") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H8041
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: TEXT = INTEGER: SQLite compares these without converting, and the answer is always the same (line 1, column 35 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users WHERE name = 5") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8042

IS compares two values of different types, which can never be the same.

Message:

Error:
  Title: Generic Error
  Error code: H8042
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: TEXT IS INTEGER: the two can never be the same (line 1, column 35 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users WHERE name IS 5") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8043

A parameter is tested for NULL. Its value is known where it is given, in the program.

Message:

Error:
  Title: Generic Error
  Error code: H8043
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: a parameter tested for NULL: the value is known where it is given (line 1, column 32 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users WHERE ? IS NULL", "ann") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8044

LIKE or GLOB is given something that is not TEXT.

Message:

Error:
  Title: Generic Error
  Error code: H8044
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: INTEGER LIKE TEXT: LIKE compares TEXT with TEXT (line 1, column 34 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users WHERE age LIKE '3%'") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8045

A parameter stands on the left of IN. A column stands there.

Message:

Error:
  Title: Generic Error
  Error code: H8045
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: a parameter on the left of IN: put a column there (line 1, column 32 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users WHERE ? IN (name, email)", "ann") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8046

NULL stands on the left of IN. That is never true.

Message:

Error:
  Title: Generic Error
  Error code: H8046
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: NULL IN (...) is never true (line 1, column 35 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users WHERE NULL IN (email, name)") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8047

NULL stands in the list of IN. It is never matched.

Message:

Error:
  Title: Generic Error
  Error code: H8047
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: NULL in an IN list is never matched (line 1, column 59 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users WHERE email IN ('[email protected]', NULL)") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H8048
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: INTEGER IN (... TEXT ...): the two can never be equal (line 1, column 38 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users WHERE age IN ('18', '21')") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8049

A parameter stands on the left of BETWEEN. A column stands there.

Message:

Error:
  Title: Generic Error
  Error code: H8049
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: a parameter on the left of BETWEEN: put a column there (line 1, column 32 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users WHERE ? BETWEEN age AND 99", 18) for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8050

NULL stands on the left of BETWEEN. That is never true.

Message:

Error:
  Title: Generic Error
  Error code: H8050
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: NULL BETWEEN ... is never true (line 1, column 35 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users WHERE NULL BETWEEN 1 AND 2") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8051

A bound of BETWEEN has another type than the value it is compared with.

Message:

Error:
  Title: Generic Error
  Error code: H8051
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: BETWEEN compares INTEGER with TEXT (line 1, column 42 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users WHERE age BETWEEN '18' AND '65'") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8052

AND or OR joins something that is not a condition.

Message:

Error:
  Title: Generic Error
  Error code: H8052
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: INTEGER AND TEXT: AND joins conditions (line 1, column 39 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users WHERE age > 18 AND email") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8053

count(*) stands outside the columns, HAVING and ORDER BY, such as in WHERE.

Message:

Error:
  Title: Generic Error
  Error code: H8053
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: count(*) here: an aggregate stands in the columns, HAVING or ORDER BY (line 1, column 30 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users WHERE count(*) > 1") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8054

An aggregate function stands outside the columns, HAVING and ORDER BY, such as in WHERE.

Message:

Error:
  Title: Generic Error
  Error code: H8054
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: max() here: an aggregate stands in the columns, HAVING or ORDER BY (line 1, column 30 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users WHERE max(age) > 50") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8055

DISTINCT stands inside a function that is not an aggregate.

Message:

Error:
  Title: Generic Error
  Error code: H8055
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: DISTINCT inside a function that is not an aggregate (line 1, column 8 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT upper(DISTINCT name) AS name FROM users") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8056

A function that takes one argument here is given another number.

Message:

Error:
  Title: Generic Error
  Error code: H8056
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: count() takes one argument here (line 1, column 8 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT count(name, email) AS total FROM users") for row: Tally do
    11 |             printLn(row.total);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8057

A function that takes a number, such as abs or sum, is given something else.

Message:

Error:
  Title: Generic Error
  Error code: H8057
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: abs() of TEXT: it takes a number (line 1, column 30 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users WHERE abs(name) > 1") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8058

count is given a parameter.

Message:

Error:
  Title: Generic Error
  Error code: H8058
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: count() of a parameter (line 1, column 8 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT count(?) AS total FROM users", "x") for row: Tally do
    11 |             printLn(row.total);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8059

min or max is given a parameter.

Message:

Error:
  Title: Generic Error
  Error code: H8059
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: max() of a parameter (line 1, column 45 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users GROUP BY name HAVING max(?) > 1", 1) for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8060

min or max is given NULL.

Message:

Error:
  Title: Generic Error
  Error code: H8060
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: max(NULL) (line 1, column 45 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users GROUP BY name HAVING max(NULL) > 1") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8061

coalesce is given fewer than two arguments, or ifnull not exactly two.

Message:

Error:
  Title: Generic Error
  Error code: H8061
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: ifnull() takes two arguments (line 1, column 30 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users WHERE ifnull(email) = 'x'") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8062

coalesce or ifnull is given only parameters, so its type cannot be told.

Message:

Error:
  Title: Generic Error
  Error code: H8062
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: coalesce() of parameters only has no type (line 1, column 38 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users WHERE email = coalesce(?, ?)", "a", "b") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8063

The first value of coalesce or ifnull that is not a parameter is NULL.

Message:

Error:
  Title: Generic Error
  Error code: H8063
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: coalesce() whose first value is NULL (line 1, column 39 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users WHERE coalesce(NULL, email) = 'x'") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8064

coalesce or ifnull is given values of different types.

Message:

Error:
  Title: Generic Error
  Error code: H8064
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: coalesce() of TEXT and INTEGER (line 1, column 46 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users WHERE coalesce(email, 0) = 'x'") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8065

length is given something other than TEXT or BLOB.

Message:

Error:
  Title: Generic Error
  Error code: H8065
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: length() of INTEGER: it takes TEXT or BLOB (line 1, column 30 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users WHERE length(age) > 1") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8066

lower or upper is given something other than TEXT.

Message:

Error:
  Title: Generic Error
  Error code: H8066
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: upper() of INTEGER: it takes TEXT (line 1, column 30 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users WHERE upper(age) = 'X'") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H8067
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: trim() is not one of the functions whose type the compiler knows: count, sum, total, avg, min, max, coalesce, ifnull, length, lower, upper, abs (line 1, column 30 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users WHERE trim(name) = 'x'") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8068

Two parameters meet at one operator, and neither gives the other a type.

Message:

Error:
  Title: Generic Error
  Error code: H8068
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: two parameters meet, and neither says what type the other is (line 1, column 30 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users WHERE ? = ?", "a", "b") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8069

A WHERE, ON, HAVING or CHECK is given something that is not a condition.

Message:

Error:
  Title: Generic Error
  Error code: H8069
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: the WHERE condition is TEXT, and it has to be a condition (line 1, column 30 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users WHERE email") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H8070
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: the column loud name cannot name a field of the row type: give it a name with AS (line 1, column 8 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT upper(name) AS \"loud name\" FROM users") for row: Shout[Q] do
    11 |             printLn(row.shout);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8071

* stands in a query without a table.

Message:

Error:
  Title: Generic Error
  Error code: H8071
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 14, column 8
    To: line 18, column 16
  Description:
    @query: * without a table (line 1, column 8 of the SQL)
  Code:
    12 |     generic [R: Region]
    13 |     function run(db: &![Connection[Writing], R]): Unit is
    14 |         @query(&~db, "SELECT *") for row: User[Q] do
    15 |             printLn(row.name);
    16 |         else error do
    17 |             printLn(describe(error));
    18 |         end for;
    19 |         return nil;
    20 |     end;

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;

↑ back to top

H8072

t.* names a table or alias the query does not have.

Message:

Error:
  Title: Generic Error
  Error code: H8072
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 14, column 8
    To: line 18, column 16
  Description:
    @query: there is no table or alias u in this query (line 1, column 8 of the SQL)
  Code:
    12 |     generic [R: Region]
    13 |     function run(db: &![Connection[Writing], R]): Unit is
    14 |         @query(&~db, "SELECT u.* FROM users") for row: User[Q] do
    15 |             printLn(row.name);
    16 |         else error do
    17 |             printLn(describe(error));
    18 |         end for;
    19 |         return nil;
    20 |     end;

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;

↑ back to top

H8073

A column of the result is always NULL and so has no type.

Message:

Error:
  Title: Generic Error
  Error code: H8073
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: this column is always NULL and has no type (line 1, column 14 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name, NULL AS note FROM users") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8074

A column of the result that is not a plain column has no name. Give it one with AS.

Message:

Error:
  Title: Generic Error
  Error code: H8074
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: a column that is not a plain column needs a name: write AS (line 1, column 8 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT upper(name) FROM users") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8075

Two columns of the result have the same name.

Message:

Error:
  Title: Generic Error
  Error code: H8075
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: two columns of the result are called name: rename one with AS (line 1, column 8 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name, lower(name) AS name FROM users") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8076

NULL is written into a column that is NOT NULL.

Message:

Error:
  Title: Generic Error
  Error code: H8076
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 6, column 47
    To: line 6, column 103
  Description:
    @execute: NULL into name, which is NOT NULL (line 1, column 34 of the SQL)
  Code:
    4 |     generic [R: Region]
    5 |     function run(db: &![Connection[Writing], R]): Unit is
    6 |         let result: Either[SqlError, Nat64] := @execute(&~db, "INSERT INTO users (name) VALUES (NULL)");
    7 |         case result of
    8 |             when Left(left as error: SqlError) do

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;

↑ back to top

H8077

A value of another type is written into a column. A STRICT table refuses it when the program runs.

Message:

Error:
  Title: Generic Error
  Error code: H8077
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 6, column 47
    To: line 6, column 118
  Description:
    @execute: TEXT into age, a INTEGER column: a STRICT table refuses it (line 1, column 42 of the SQL)
  Code:
    4 |     generic [R: Region]
    5 |     function run(db: &![Connection[Writing], R]): Unit is
    6 |         let result: Either[SqlError, Nat64] := @execute(&~db, "INSERT INTO users (name, age) VALUES (?, '40')", "ann");
    7 |         case result of
    8 |             when Left(left as error: SqlError) do

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;

↑ back to top

H8078

A value that may be NULL is written into a column that is NOT NULL.

Message:

Error:
  Title: Generic Error
  Error code: H8078
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 6, column 47
    To: line 6, column 94
  Description:
    @execute: a value that may be NULL into name, which is NOT NULL (line 1, column 25 of the SQL)
  Code:
    4 |     generic [R: Region]
    5 |     function run(db: &![Connection[Writing], R]): Unit is
    6 |         let result: Either[SqlError, Nat64] := @execute(&~db, "UPDATE users SET name = email");
    7 |         case result of
    8 |             when Left(left as error: SqlError) do

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;

↑ back to top

H8079

A table stands twice in FROM without an alias that tells the two apart.

Message:

Error:
  Title: Generic Error
  Error code: H8079
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: users stands twice in FROM: give one an alias (line 1, column 29 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users JOIN users ON age = age") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8081

LIMIT or OFFSET is given something other than an INTEGER that is not NULL.

Message:

Error:
  Title: Generic Error
  Error code: H8081
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: LIMIT and OFFSET take an INTEGER that is not NULL (line 1, column 30 of the SQL)
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users LIMIT '10'") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8082

The column list of an INSERT names a column twice.

Message:

Error:
  Title: Generic Error
  Error code: H8082
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 6, column 47
    To: line 6, column 123
  Description:
    @execute: name is named twice (line 1, column 26 of the SQL)
  Code:
    4 |     generic [R: Region]
    5 |     function run(db: &![Connection[Writing], R]): Unit is
    6 |         let result: Either[SqlError, Nat64] := @execute(&~db, "INSERT INTO users (name, name) VALUES (?, ?)", "ann", "bob");
    7 |         case result of
    8 |             when Left(left as error: SqlError) do

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;

↑ back to top

H8083

An INSERT leaves out a column that is NOT NULL and has no default.

Message:

Error:
  Title: Generic Error
  Error code: H8083
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 6, column 47
    To: line 6, column 103
  Description:
    @execute: the INSERT leaves out name, which is NOT NULL and has no DEFAULT (line 1, column 13 of the SQL)
  Code:
    4 |     generic [R: Region]
    5 |     function run(db: &![Connection[Writing], R]): Unit is
    6 |         let result: Either[SqlError, Nat64] := @execute(&~db, "INSERT INTO users (age) VALUES (?)", 40);
    7 |         case result of
    8 |             when Left(left as error: SqlError) do

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;

↑ back to top

H8084

An INSERT has a column list and DEFAULT VALUES.

Message:

Error:
  Title: Generic Error
  Error code: H8084
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 6, column 47
    To: line 6, column 104
  Description:
    @execute: DEFAULT VALUES with a column list (line 1, column 13 of the SQL)
  Code:
    4 |     generic [R: Region]
    5 |     function run(db: &![Connection[Writing], R]): Unit is
    6 |         let result: Either[SqlError, Nat64] := @execute(&~db, "INSERT INTO users (name) DEFAULT VALUES");
    7 |         case result of
    8 |             when Left(left as error: SqlError) do

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;

↑ back to top

H8085

A row of an INSERT has another number of values than there are columns.

Message:

Error:
  Title: Generic Error
  Error code: H8085
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 6, column 47
    To: line 6, column 112
  Description:
    @execute: a row of 1 values for 2 columns (line 1, column 13 of the SQL)
  Code:
    4 |     generic [R: Region]
    5 |     function run(db: &![Connection[Writing], R]): Unit is
    6 |         let result: Either[SqlError, Nat64] := @execute(&~db, "INSERT INTO users (name, age) VALUES (?)", "ann");
    7 |         case result of
    8 |             when Left(left as error: SqlError) do

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;

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H8086
  Module:
    Example
  Location:
    Filename: './migrations/1-schema.sql'
    From: line 4, column 5
    To: line 4, column 6
  Description:
    migration: extra is ANY: a column the compiler checks against has one of INT, INTEGER, REAL, TEXT, BLOB
  Code:
    [no span available]

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;

↑ back to top

H8087

A column in a migration has no type. A STRICT table gives every column one.

Message:

Error:
  Title: Generic Error
  Error code: H8087
  Module:
    Example
  Location:
    Filename: './migrations/1-schema.sql'
    From: line 4, column 5
    To: line 4, column 6
  Description:
    migration: nickname has no type: a STRICT table gives every column one
  Code:
    [no span available]

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;

↑ back to top

H8088

A column in a migration has a type that a STRICT table does not know, such as DATE.

Message:

Error:
  Title: Generic Error
  Error code: H8088
  Module:
    Example
  Location:
    Filename: './migrations/1-schema.sql'
    From: line 4, column 5
    To: line 4, column 6
  Description:
    migration: born is DATE, which is not a STRICT type: INT, INTEGER, REAL, TEXT, BLOB
  Code:
    [no span available]

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;

↑ back to top

H8089

A migration creates a table that exists already.

Message:

Error:
  Title: Generic Error
  Error code: H8089
  Module:
    Example
  Location:
    Filename: './migrations/1-schema.sql'
    From: line 6, column 14
    To: line 6, column 15
  Description:
    migration: table users exists already
  Code:
    [no span available]

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;

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H8090
  Module:
    Example
  Location:
    Filename: './migrations/1-schema.sql'
    From: line 1, column 14
    To: line 1, column 15
  Description:
    migration: table users is not STRICT: without STRICT, SQLite stores a value of any type in any column, and the types the compiler checks would not hold
  Code:
    [no span available]

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
);

↑ back to top

H8091

A table defines a column twice.

Message:

Error:
  Title: Generic Error
  Error code: H8091
  Module:
    Example
  Location:
    Filename: './migrations/1-schema.sql'
    From: line 4, column 5
    To: line 4, column 6
  Description:
    migration: column name is defined twice
  Code:
    [no span available]

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;

↑ back to top

H8092

A table has more than one PRIMARY KEY.

Message:

Error:
  Title: Generic Error
  Error code: H8092
  Module:
    Example
  Location:
    Filename: './migrations/1-schema.sql'
    From: line 1, column 14
    To: line 1, column 15
  Description:
    migration: table users has more than one PRIMARY KEY
  Code:
    [no span available]

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;

↑ back to top

H8093

The PRIMARY KEY of a table names a column the table does not have.

Message:

Error:
  Title: Generic Error
  Error code: H8093
  Module:
    Example
  Location:
    Filename: './migrations/1-schema.sql'
    From: line 1, column 14
    To: line 1, column 15
  Description:
    migration: the PRIMARY KEY names user_id, which is not a column of users
  Code:
    [no span available]

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;

↑ back to top

H8094

ALTER TABLE ADD COLUMN adds a column the table has already.

Message:

Error:
  Title: Generic Error
  Error code: H8094
  Module:
    Example
  Location:
    Filename: './migrations/1-schema.sql'
    From: line 6, column 30
    To: line 6, column 31
  Description:
    migration: table users has a column name already
  Code:
    [no span available]

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;

↑ back to top

H8095

ALTER TABLE ADD COLUMN adds a PRIMARY KEY. SQLite cannot add one to an existing table.

Message:

Error:
  Title: Generic Error
  Error code: H8095
  Module:
    Example
  Location:
    Filename: './migrations/1-schema.sql'
    From: line 6, column 30
    To: line 6, column 31
  Description:
    migration: ALTER TABLE ADD COLUMN cannot add a PRIMARY KEY
  Code:
    [no span available]

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;

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H8096
  Module:
    Example
  Location:
    Filename: './migrations/1-schema.sql'
    From: line 6, column 30
    To: line 6, column 31
  Description:
    migration: city is NOT NULL without a DEFAULT, and SQLite refuses to add such a column to a table that has rows
  Code:
    [no span available]

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;

↑ back to top

H8097

ALTER TABLE RENAME TO gives a table the name of a table that exists.

Message:

Error:
  Title: Generic Error
  Error code: H8097
  Module:
    Example
  Location:
    Filename: './migrations/1-schema.sql'
    From: line 11, column 13
    To: line 11, column 14
  Description:
    migration: table users exists already
  Code:
    [no span available]

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;

↑ back to top

H8098

ALTER TABLE RENAME COLUMN gives a column the name of a column the table has.

Message:

Error:
  Title: Generic Error
  Error code: H8098
  Module:
    Example
  Location:
    Filename: './migrations/1-schema.sql'
    From: line 7, column 33
    To: line 7, column 34
  Description:
    migration: table users has a column name already
  Code:
    [no span available]

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;

↑ back to top

H8099

ALTER TABLE DROP COLUMN drops the last column of a table. Drop the table instead.

Message:

Error:
  Title: Generic Error
  Error code: H8099
  Module:
    Example
  Location:
    Filename: './migrations/1-schema.sql'
    From: line 8, column 30
    To: line 8, column 31
  Description:
    migration: a table cannot lose its last column
  Code:
    [no span available]

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;

↑ back to top

H8100

DROP TABLE drops a table that does not exist.

Message:

Error:
  Title: Generic Error
  Error code: H8100
  Module:
    Example
  Location:
    Filename: './migrations/1-schema.sql'
    From: line 6, column 12
    To: line 6, column 13
  Description:
    migration: there is no table tags to drop
  Code:
    [no span available]

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;

↑ back to top

H8101

CREATE INDEX creates an index whose name exists already.

Message:

Error:
  Title: Generic Error
  Error code: H8101
  Module:
    Example
  Location:
    Filename: './migrations/1-schema.sql'
    From: line 8, column 14
    To: line 8, column 15
  Description:
    migration: index users_key exists already
  Code:
    [no span available]

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);

↑ back to top

H8102

DROP INDEX drops an index that does not exist.

Message:

Error:
  Title: Generic Error
  Error code: H8102
  Module:
    Example
  Location:
    Filename: './migrations/1-schema.sql'
    From: line 6, column 12
    To: line 6, column 13
  Description:
    migration: there is no index users_name to drop
  Code:
    [no span available]

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;

↑ back to top

H8103

A migration file cannot be read, for example because a directory carries the name of a migration.

Message:

Error:
  Title: Generic Error
  Error code: H8103
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: cannot read ./migrations/2-more.sql: it is a directory, not a file
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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.

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H8104
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: there is no directory ./migrations: the schema a query is checked against is the migrations beside the module
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8105

The directory migrations holds no file that ends in .sql.

Message:

Error:
  Title: Generic Error
  Error code: H8105
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: ./migrations holds no .sql file
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8106

A file in migrations is not called <number>-<name>.sql with a number from 1.

Message:

Error:
  Title: Generic Error
  Error code: H8106
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: ./migrations/schema.sql: a migration is called <number>-<name>.sql, numbered from 1
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8107

The migrations are not numbered 1, 2, 3 and so on without a gap, or a number stands twice.

Message:

Error:
  Title: Generic Error
  Error code: H8107
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: ./migrations/3-email.sql: migration 2 is missing or doubled; they are numbered 1, 2, 3 ... without a gap
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8108

A statement in a migration is not followed by ; before the next one begins.

Message:

Error:
  Title: Generic Error
  Error code: H8108
  Module:
    Example
  Location:
    Filename: './migrations/1-schema.sql'
    From: line 6, column 1
    To: line 6, column 2
  Description:
    migration: expected ; after the statement, found CREATE
  Code:
    [no span available]

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);

↑ back to top

H8109

A migration holds a parameter ?. A migration is run as it stands, so a parameter in it has nothing to stand for.

Message:

Error:
  Title: Generic Error
  Error code: H8109
  Module:
    Example
  Location:
    Filename: './migrations/1-schema.sql'
    From: line 6, column 34
    To: line 6, column 35
  Description:
    migration: a migration has no parameters
  Code:
    [no span available]

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 (?);

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H8110
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 3, column 16
    To: line 3, column 27
  Description:
    @migrations: a module that uses @migrations imports Standard.Sqlite or Standard.SqlCipher -- e.g. `import Standard.Sqlite (Connection);' -- because the generated code calls it
  Code:
    1 | module body Example is
    2 |     function main(): ExitCode is
    3 |         printLn(@migrations);
    4 |         return ExitSuccess();
    5 |     end;

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;

↑ back to top

H8111

The SQL of one @query or @execute holds more than one statement.

Message:

Error:
  Title: Generic Error
  Error code: H8111
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 6, column 47
    To: line 6, column 101
  Description:
    @execute: one statement per query; found DELETE after it (line 1, column 20 of the SQL)
  Code:
    4 |     generic [R: Region]
    5 |     function run(db: &![Connection[Writing], R]): Unit is
    6 |         let result: Either[SqlError, Nat64] := @execute(&~db, "DELETE FROM notes; DELETE FROM users");
    7 |         case result of
    8 |             when Left(left as error: SqlError) do

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;

↑ back to top

H8112

The SQL has another number of parameters ? than values are given.

Message:

Error:
  Title: Generic Error
  Error code: H8112
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: the SQL has 1 parameter and 0 values are given
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "SELECT name FROM users WHERE age > ?") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

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:

Error:
  Title: Generic Error
  Error code: H8113
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 6, column 8
    To: line 10, column 16
  Description:
    @query: the row type is a record, written `Name' or `Name[R]' with R the region the row's text is lent under
  Code:
     4 |     generic [R: Region]
     5 |     function run(db: &![Connection[Writing], R]): Unit is
     6 |         @query(&~db, "SELECT name FROM users") for row: Span[Nat8, Q] do
     7 |             printLn(row);
     8 |         else error do
     9 |             printLn(describe(error));
    10 |         end for;
    11 |         return nil;
    12 |     end;

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;

↑ back to top

H8115

@query is given a statement that returns no rows. Write it with @execute, or add RETURNING.

Message:

Error:
  Title: Generic Error
  Error code: H8115
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 10, column 8
    To: line 14, column 16
  Description:
    @query: this statement returns no rows: write it with @execute, or add RETURNING
  Code:
     8 |     generic [R: Region]
     9 |     function run(db: &![Connection[Writing], R]): Unit is
    10 |         @query(&~db, "DELETE FROM users WHERE age > 99") for row: Person[Q] do
    11 |             printLn(row.name);
    12 |         else error do
    13 |             printLn(describe(error));
    14 |         end for;
    15 |         return nil;
    16 |     end;

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;

↑ back to top

H8116

@execute is given a statement that returns rows. Write it with @query ... for.

Message:

Error:
  Title: Generic Error
  Error code: H8116
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 6, column 47
    To: line 6, column 87
  Description:
    @execute: this statement returns rows: write it with @query ... for
  Code:
    4 |     generic [R: Region]
    5 |     function run(db: &![Connection[Writing], R]): Unit is
    6 |         let result: Either[SqlError, Nat64] := @execute(&~db, "SELECT name FROM users");
    7 |         case result of
    8 |             when Left(left as error: SqlError) do

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;

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2051
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 3, column 8
    To: line 3, column 22
  Description:
    The body of the public function `half` holds a contract.
    
    The contract of a public function stands in its interface only: it is written at `Example.hih:3`.  Remove the requires, ensures and raises clauses from the body.
  Code:
    1 | module body Example is
    2 |     function half(n: Nat32): Nat32
    3 |         requires n > 0
    4 |     is
    5 |         return n / 2;

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.

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2052
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 5, column 4
    To: line 8, column 8
  Description:
    The function `cAbs` is imported from C and has a contract.
    
    A contract is checked by statements put into the body of its function, and a foreign function has none.  Write the contract on a Hilde function that calls it.
  Code:
     3 | module body Example is
     4 |     pragma Foreign_Import(External_Name => "abs");
     5 |     function cAbs(value: Int32): Int32
     6 |         requires value > -100
     7 |     is
     8 |     end;
     9 | 
    10 |     function main(): ExitCode is

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.

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2053
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 3, column 8
    To: line 3, column 30
  Description:
    The ensures of `addThree` names `limit`, which the body of the function also declares.
    
    An ensures sees the parameters, result and the names of modules; checked at a return, it would read the body's variable instead.  Rename the variable in the body.
  Code:
    1 | module body Example is
    2 |     function addThree(n: Nat32): Nat32
    3 |         ensures result > limit
    4 |     is
    5 |         let limit: Nat32 := 3;

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.

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2054
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 2, column 4
    To: line 6, column 8
  Description:
    The function `doubled` has an ensures and a parameter named `result`.
    
    In an ensures, result is the value the function returns.  Rename the parameter.
  Code:
    1 | module body Example is
    2 |     function doubled(result: Nat32): Nat32
    3 |         ensures result > 0
    4 |     is
    5 |         return result * 2;
    6 |     end;
    7 | 
    8 |     function main(): ExitCode is

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.

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2055
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 3, column 8
    To: line 3, column 27
  Description:
    An old(e) stands in a requires.
    
    old(e) stands only in an ensures, takes one value, and does not nest: it is the value e had when the function was entered.
  Code:
    1 | module body Example is
    2 |     function half(n: Nat32): Nat32
    3 |         requires old(n) > 0
    4 |     is
    5 |         return n / 2;

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.

↑ back to top

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:

FAIL  Example.hiq  the test programme did not build
hilde test: 1 test file, 0 tests, 0 failed, 1 not built
Error:
  Title: Declaration Error
  Error code: H2056
  Module:
    Example.Test
  Location:
    Filename: 'Example.hiq'
    From: line 2, column 4
    To: line 6, column 8
  Description:
    The test `testHalf` has a requires.
    
    A violated requires names the call that broke it, and a test is called by hilde test, not by a call in the programme.  Check the condition in the test's body instead.
  Code:
    1 | module body Example.Test is
    2 |     function testHalf(): Unit
    3 |         requires argumentCount() > 0
    4 |     is
    5 |         return nil;
    6 |     end;
    7 | end module body.

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:

hilde test Example.hiq

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2057
  Module:
    Example
  Location:
    Filename: 'Example.hih'
    From: line 2, column 4
    To: line 6, column 8
  Description:
    The record `Range` has an invariant, and its slots can be reached outside its module: its slots stand in the interface.
    
    An invariant is checked where a value leaves its module, which holds only when no other module can build the record or write its slots.  Declare the type opaque in the interface, type Name: Universe;, and the record in the body.
  Code:
    1 | module Example is
    2 |     record Range: Free is
    3 |         low: Nat32;
    4 |         high: Nat32;
    5 |         invariant low <= high;
    6 |     end;
    7 | 
    8 |     function main(): ExitCode;

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3096
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 12, column 8
    To: line 12, column 35
  Description:
    This condition uses the linear value `token` itself, which would consume it.
    
    A condition only reads: read a linear value through a reference, `&token`.
  Code:
    10 | 
    11 |     function spend(token: Token): Nat32
    12 |         requires valueOf(token) > 0
    13 |     is
    14 |         return valueOf(token);

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3097
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 19, column 8
    To: line 19, column 36
  Description:
    This condition makes a reference to write through, with `&!`, `&~` or a writable span.
    
    A condition only reads: take a read reference with & instead.
  Code:
    17 |     generic [R: Region]
    18 |     function current(counter: &![Counter, R]): Nat32
    19 |         requires bump(&~counter) > 0
    20 |     is
    21 |         return counter->count;

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3098
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 25, column 8
    To: line 25, column 36
  Description:
    This condition calls `Example.countedTwice -> Example.bump`, which asks for a reference to write through.
    
    A condition only reads: every function it calls, and every function those call, stays out of the binding modules and C, and asks for no reference to write through.
  Code:
    23 | 
    24 |     function half(n: Nat32): Nat32
    25 |         requires countedTwice(n) > 0
    26 |     is
    27 |         return n / 2;

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3099
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 7, column 8
    To: line 7, column 25
  Description:
    This condition calls through the function pointer f, so the function that runs is not known where the condition is checked.
    
    A condition only reads, and the compiler has to see every function it calls to know that.  Call a function by its name.
  Code:
    5 | 
    6 |     function apply(f: Fn[Nat32, Nat32], n: Nat32): Nat32
    7 |         requires f(n) > 0
    8 |     is
    9 |         return f(n);

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3100
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 16, column 8
    To: line 16, column 52
  Description:
    old takes a value of the type `Token`, which is not in the Free universe.
    
    old copies a value when the function is entered, and only a free value can be copied.
  Code:
    14 | 
    15 |     function plusOne(n: Nat32): Nat32
    16 |         ensures result = (n + valueOf(old(fresh())))
    17 |     is
    18 |         return n + 1;

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3101
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 9, column 8
    To: line 9, column 40
  Description:
    The function `half` has a requires and cannot be taken as a function pointer.
    
    A violated requires names the call that broke it, and a call through a pointer has no place the compiler can name.  Call the function directly, or write a function without a requires that calls it.
  Code:
     7 | 
     8 |     function main(): ExitCode is
     9 |         let f: Fn[Nat32, Nat32] := half;
    10 |         printLn(f(8));
    11 |         return ExitSuccess();

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.

↑ back to top

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:

Error:
  Title: Entrypoint Definition Error
  Error code: H5008
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    The entrypoint function has a requires.
    
    A violated requires names the call that broke it, and the entrypoint is called by the system, not by a call in the programme.  Check the condition at the start of the function's body instead.
  Code:
    [no span available]

This module fails with H5008:

module body Example is
    function main(): ExitCode
        requires argumentCount() > 0
    is
        return ExitSuccess();
    end;
end module body.

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2058
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 9, column 12
    To: line 9, column 25
  Description:
    The method `measure` of an instance has a raises clause.
    
    The raises clause of a method stands in the typeclass, where every instance and every caller reads it.  Remove the clause from the instance, and write it at the method's declaration in the typeclass.
  Code:
     7 |     instance Measure(Int32) is
     8 |         method measure(value: Int32): Int32
     9 |             raises Broken is
    10 |             return value * 2;
    11 |         end;

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3102
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 5, column 12
    To: line 5, column 25
  Description:
    The raise of `Denied` is not among the kinds this function's raises clause names: `NotFound`.  Name the kind in the raises clause of this function, or raise a kind it names.
  Code:
    3 |         raises NotFound is
    4 |         if n < 0 then
    5 |             raise Denied;
    6 |         end if;
    7 |         return n;

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3103
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 8, column 8
    To: line 8, column 25
  Description:
    The call of `Example.pick` can end with the error kind(s) `NotFound`, but this function's raises clause names: `no kinds (no raises clause)`.  A function may call only the functions whose error kinds it has named; name the missing kind(s) in the raises clause of this function, or take the call out.
  Code:
     6 | 
     7 |     function main(): ExitCode is
     8 |         printLn(pick(7));
     9 |         return ExitSuccess();
    10 |     end;

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3104
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 9, column 8
    To: line 9, column 40
  Description:
    The function `pick` has a raises clause and cannot be taken as a function pointer.
    
    A call through a pointer has no signature the compiler can hold against the caller's raises clause.  Call the function directly.
  Code:
     7 |     function main(): ExitCode
     8 |         raises NotFound is
     9 |         let f: Fn[Int32, Int32] := pick;
    10 |         printLn(f(7));
    11 |         return ExitSuccess();

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.

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2060
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 3, column 8
    To: line 3, column 19
  Description:
    A return stands in a function that returns `Never`.
    
    A function that returns Never does not come back: it ends in a call of a function that returns Never, in a raise or in a loop that never ends.
  Code:
    1 | module body Example is
    2 |     function stop(): Never is
    3 |         return nil;
    4 |     end;
    5 | 

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.

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2061
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 3, column 8
    To: line 5, column 15
  Description:
    The function `stop` returns `Never` but a path through it comes to its end.
    
    Every path ends in a call of a function that returns Never, in a raise or in a while whose condition is true.
  Code:
    1 | module body Example is
    2 |     function stop(b: Bool): Never is
    3 |         if b then
    4 |             abort("stopped");
    5 |         end if;
    6 |     end;
    7 | 

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.

↑ back to top

H2062

A function that returns Never carries an ensures clause. The clause would be checked at a return, and there is none.

Message:

Error:
  Title: Declaration Error
  Error code: H2062
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 2, column 4
    To: line 6, column 8
  Description:
    The function `stop` returns `Never` and has an ensures.
    
    An ensures speaks of the state at a return, and a function that returns Never does not return: the clause would hold of nothing.  Remove it; a requires stays allowed.
  Code:
    1 | module body Example is
    2 |     function stop(n: Int32): Never
    3 |         ensures n > 0
    4 |     is
    5 |         abort("stopped");
    6 |     end;
    7 | 
    8 |     function main(): ExitCode is

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.

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2063
  Module:
    [unknown]
  Location:
    Filename: 'Greeting.hih'
    From: line 4, column 4
    To: line 4, column 27
  Description:
    The slot `Greeting.greet` has no default body and no function of the programme implements it.
    
    Give the declaration a body in the module, or mark one function with pragma Implements(Name => "Greeting.greet").
  Code:
    2 |     -- Says hello; the programme implements it.
    3 |     pragma Slot;
    4 |     function greet(): Unit;
    5 | end module.

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.

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2064
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 8, column 4
    To: line 10, column 8
  Description:
    The slot `Hilde.Pervasive.onOverflow` is implemented twice: by `Example.first` and by `Example.second`.
    
    A slot has one implementation in a programme; remove the pragma Implements from one of them.
  Code:
     6 | 
     7 |     pragma Implements(Name => "Hilde.Pervasive.onOverflow");
     8 |     function second(message: Span[Nat8, Static]): Never is
     9 |         abort(message);
    10 |     end;
    11 | 
    12 |     function main(): ExitCode is

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.

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2065
  Module:
    [unknown]
  Location:
    Filename: 'Example.hiq'
    From: line 3, column 4
    To: line 5, column 8
  Description:
    The function `Example.handled` implements the slot `Hilde.Pervasive.onOverflow` but its signature differs: the parameter message: Span[Nat8, Static] of the slot is text: Span[Nat8, Static] in the implementation.
    
    An implementation has the parameters of the slot, with their names and types, and its result type.
  Code:
    1 | module body Example is
    2 |     pragma Implements(Name => "Hilde.Pervasive.onOverflow");
    3 |     function handled(text: Span[Nat8, Static]): Never is
    4 |         abort(text);
    5 |     end;
    6 | 
    7 |     function main(): ExitCode is

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.

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2066
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 3, column 4
    To: line 5, column 8
  Description:
    The function `Example.handled` implements `Hilde.Pervasive.nowhere`, which is not a slot of a module compiled before it.
    
    The name is Module.function of a declaration with pragma Slot, and the implementing module imports that module.
  Code:
    1 | module body Example is
    2 |     pragma Implements(Name => "Hilde.Pervasive.nowhere");
    3 |     function handled(message: Span[Nat8, Static]): Never is
    4 |         abort(message);
    5 |     end;
    6 | 
    7 |     function main(): ExitCode is

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.

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2067
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 3, column 4
    To: line 6, column 8
  Description:
    A function generic over a type cannot be a slot or implement one.
    
    pragma Slot stands at a function declaration in an interface, and pragma Implements at a function definition that is not a slot; neither at a function generic over anything but regions.
  Code:
    1 | module body Example is
    2 |     pragma Implements(Name => "Hilde.Pervasive.onOverflow");
    3 |     generic [T: Free]
    4 |     function handled(message: Span[Nat8, Static], other: T): Never is
    5 |         abort(message);
    6 |     end;
    7 | 
    8 |     function main(): ExitCode is

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3109
  Module:
    Example
  Location:
    [no span available]
  Description:
    `Never` cannot be the type of a parameter: it has no value.
    
    Only the return type of a function or a method may be Never.
  Code:
    [no span available]

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.

↑ back to top

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:

Error:
  Title: Type Error
  Error code: H3110
  Module:
    Example
  Location:
    Filename: 'Example.hiq'
    From: line 8, column 8
    To: line 8, column 31
  Description:
    A call that does not come back stands where its value would be passed on.
    
    Its result is Never; call it as a statement of its own.
  Code:
     6 | 
     7 |     function main(): ExitCode is
     8 |         show(abort("stopped"));
     9 |         return ExitSuccess();
    10 |     end;

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.

↑ back to top

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:

Error:
  Title: Command Line Arguments Error
  Error code: H1038
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    No compiler for WebAssembly was found.
    
    hilde looks for zig, given as `HILDE_ZIG` or on the path, and then for clang on the path with `wasm-ld` and the C library of WASI, in `WASI_SYSROOT`, /usr/share/wasi-sysroot, /opt/wasi-sdk/share/wasi-sysroot or where Debian's wasi-libc puts it. Install zig, or clang with lld and wasi-libc.
    
    A compiler for WebAssembly is needed only for --target=wasm and --target-type=wasm; zig is taken at version 0.17.0 only.
  Code:
    [no span available]

This module fails with H1038:

module body Example is
    function main(): ExitCode is
        return ExitSuccess();
    end;
end module body.

With this command:

env HILDE_ZIG= PATH=/nonexistent hilde build Example.hiq --target=wasm --entrypoint=Example:main --output=prog.wasm

↑ back to top

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:

Error:
  Title: Command Line Arguments Error
  Error code: H1039
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    `HILDE_WASM_CC` is `gcc`, which is not a compiler hilde knows for WebAssembly.
    
    It is `zig` or `clang`, or not set, and then zig is taken when it is there.
  Code:
    [no span available]

This module fails with H1039:

module body Example is
    function main(): ExitCode is
        return ExitSuccess();
    end;
end module body.

With this command:

env HILDE_WASM_CC=gcc hilde build Example.hiq --target=wasm --entrypoint=Example:main --output=prog.wasm

↑ back to top

H1040

hilde test --target=wasm finds no runtime for WebAssembly. The test programmes are command modules, and wasmtime runs them.

Message:

No runtime for WebAssembly was found to run the tests.

hilde runs a module for wasm32-wasi with wasmtime, given as `HILDE_WASMTIME` or on the path.

The catalog gives no failing example for this code.

↑ back to top

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:

Error:
  Title: Command Line Arguments Error
  Error code: H1041
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    `--target=wsam` names no target hilde builds for.
    
    The targets are `linux, openbsd, freebsd, darwin, wasm`.
  Code:
    [no span available]

This module fails with H1041:

module body Example is
    function main(): ExitCode is
        return ExitSuccess();
    end;
end module body.

With this command:

hilde build Example.hiq --target=wsam --entrypoint=Example:main --output=prog

↑ back to top

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:

`--target=<name>` asks for a binary of another system, and hilde builds a binary only for the system it runs on, <host>.

Build on a machine of `<name>`, or build a module for WebAssembly with `--target=wasm`.

The catalog gives no failing example for this code.

↑ back to top

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:

Error:
  Title: Command Line Arguments Error
  Error code: H1043
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    `--target=wasm` cannot build `--target-type=static`: there is no archive and no shared object for WebAssembly.
    
    A programme with an entrypoint becomes a command module, `--target-type=wasm` a library module, a reactor.
  Code:
    [no span available]

This module fails with H1043:

module body Example is
    function main(): ExitCode is
        return ExitSuccess();
    end;
end module body.

With this command:

hilde build Example.hiq --target=wasm --target-type=static --output=libexample.a

↑ back to top

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:

Error:
  Title: Command Line Arguments Error
  Error code: H1044
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    The output of `--target=wasm` is a module for wasm32-wasi and must end in `.wasm`, and `prog` does not.
  Code:
    [no span available]

This module fails with H1044:

module body Example is
    function main(): ExitCode is
        return ExitSuccess();
    end;
end module body.

With this command:

hilde build Example.hiq --target=wasm --entrypoint=Example:main --output=prog

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2068
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    Invalid `pragma Targets`: plan9 is no target.
    
    It takes `Names`, the targets separated by one space each, out of `linux, openbsd, freebsd, darwin, wasm`, and after it, where another module does the work on the other targets, `Instead`: `pragma Targets(Names => "linux openbsd freebsd darwin", Instead => "Standard.Regex");`
  Code:
    [no span available]

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.

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2069
  Module:
    [unknown]
  Location:
    [no span available]
  Description:
    `pragma Unsafe_Module` cannot stand before a module interface.
    
    Only `pragma Targets` stands there, once.
  Code:
    [no span available]

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.

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2070
  Module:
    Thing
  Location:
    [no span available]
  Description:
    `Thing` names its targets with `pragma Targets`, and only a module of the standard library does.
    
    A programme is there for the targets of the modules it imports: what differs between the targets is in the standard library, and a programme holds no code for one target only.
  Code:
    [no span available]

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.

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2071
  Module:
    Standard.Thing
  Location:
    [no span available]
  Description:
    The module `Standard.Thing` of the standard library names no targets.
    
    Its interface says before its imports which targets it is there for: `pragma Targets(Names => "linux openbsd freebsd darwin wasm");`
  Code:
    [no span available]

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.

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2072
  Module:
    Standard.Thing
  Location:
    [no span available]
  Description:
    `Standard.Thing` names the target `wasm`, but imports `Standard.Other`, which is not there for it.
    
    A module is there only for targets all its imports are there for: take `wasm` out of its pragma Targets, or make the import there for it.
  Code:
    [no span available]

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.

↑ back to top

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:

Error:
  Title: Declaration Error
  Error code: H2073
  Module:
    Example
  Location:
    [no span available]
  Description:
    `Standard.Thing` is not there for the target `wasm`, and `Example` imports it.
    
    It is there for linux, openbsd, freebsd, darwin. Take `Standard.Other` instead.
    
    Suggested fix: `Standard.Other`
  Code:
    [no span available]

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:

hilde build Thing.hih,Thing.hiq Example.hiq --target=wasm --target-type=c --entrypoint=Example:main --output=prog.c

↑ back to top

13. Packages

H1045

A package command was given, and hilde-pkg is not beside the compiler.

Message:

The package commands are carried out by `path`, which is not there.
Build it beside the compiler with `make hilde-pkg`, or install both with `make install`.

The catalog gives no failing example for this code.

↑ back to top

H1046

hilde-pkg is beside the compiler and could not be started.

Message:

`path` could not be started: why.
Check that it may be run, or build it again with `make hilde-pkg`.

The catalog gives no failing example for this code.

↑ back to top

H1501

The command needs a package, and there is no hilde.toml in the directory.

Message:

no hilde.toml in .

The catalog gives no failing example for this code.

↑ back to top

H1502

hilde.toml is not TOML; the message names the line and the column.

Message:

hilde.toml is not TOML: what, at line L, column C

The catalog gives no failing example for this code.

↑ back to top

H1503

hilde.toml has a key or a table that a manifest does not have, such as a misspelt one.

Message:

hilde.toml has the key k in table, which a manifest does not have

The catalog gives no failing example for this code.

↑ back to top

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:

package.name is missing in hilde.toml

The catalog gives no failing example for this code.

↑ back to top

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:

hilde get takes [email protected], not text

The catalog gives no failing example for this code.

↑ back to top

H1506

One prefix comes from two git URLs, or a package is named otherwise than the prefix it is required by.

Message:

the package at URL is named N, and P requires it as Q

The catalog gives no failing example for this code.

↑ back to top

H1507

git is not on the PATH, and the command needs it.

Message:

git is not on PATH, and hilde export reads the tags with git

The catalog gives no failing example for this code.

↑ back to top

H1508

git failed: a wrong URL, a repository that may not be read, or a programme that could not be started.

Message:

git cannot list the tags of URL: git said: line

The catalog gives no failing example for this code.

↑ back to top

H1509

The repository has no tag of the version asked for; the suggestion names the tags nearest to it.

Message:

the repository URL has no tag vX.Y.Z

The catalog gives no failing example for this code.

↑ back to top

H1510

The tree of a package holds a symbolic link or a special file.

Message:

a package holds only files and directories, not a link or a special file: path

The catalog gives no failing example for this code.

↑ back to top

H1511

A release has no signature, and the policy of the package asks for one.

Message:

the release of P has no signature, and policy.require-signatures is true

The catalog gives no failing example for this code.

↑ back to top

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 signature of P does not hold for its tree and its key

The catalog gives no failing example for this code.

↑ back to top

H1513

The secret key cannot be read, is no signify key, or has a passphrase.

Message:

path is not a secret key of signify without a passphrase

The catalog gives no failing example for this code.

↑ back to top

H1514

hilde.sum is missing, has a bad line, or lacks the line of a requirement.

Message:

hilde.sum, line N: what

The catalog gives no failing example for this code.

↑ back to top

H1515

A tree in vendor/ is missing, changed, or not named in hilde.sum.

Message:

vendor/ has no tree P, which hilde.sum names

The catalog gives no failing example for this code.

↑ back to top

H1516

Two majors of one package are required; a new major takes a new prefix.

Message:

P is required as vA by X and as vB by Y

The catalog gives no failing example for this code.

↑ back to top

H1517

The tree of a package is deeper than 64 directories.

Message:

the tree is deeper than 64 directories at: path

The catalog gives no failing example for this code.

↑ back to top

H1518

A directory or a file of a package cannot be read.

Message:

a directory cannot be read: path

The catalog gives no failing example for this code.

↑ back to top

H1519

A file or a directory cannot be written.

Message:

llms.txt or man/man3 cannot be written in root

The catalog gives no failing example for this code.

↑ back to top

H1521

hilde new or a key would write over something that is there.

Message:

the directory is there already: path

The catalog gives no failing example for this code.

↑ back to top

H1522

hilde doc finds no module or declaration of the name.

Message:

no module or declaration X in src, vendor/ or the standard library

The catalog gives no failing example for this code.

↑ back to top

H1523

A target of hilde.toml is not allowed by the pragma Targets of a module the package reaches.

Message:

hilde.toml names the target T, and a module the package reaches does not allow it: M

The catalog gives no failing example for this code.

↑ back to top

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 interface changed as a major release does since vA, and hilde.toml says vB

The catalog gives no failing example for this code.

↑ back to top

H1531

A module of the package has no test file.

Message:

a release needs a test file for each module, and these are missing: files

The catalog gives no failing example for this code.

↑ back to top

H1532

The tests of the package do not pass, or the compiler failed on it.

Message:

the tests of the package do not pass: last line

The catalog gives no failing example for this code.

↑ back to top

H1533

An exported function is called in no test.

Message:

every exported function must be called in a test, and these are not: names

The catalog gives no failing example for this code.

↑ back to top

H1534

The version of a release is not newer than the newest tag.

Message:

hilde.toml says vA, and the newest tag is vB

The catalog gives no failing example for this code.

↑ back to top

H1535

hilde rust found no cargo: none on PATH and none named in HILDE_CARGO.

Message:

hilde.toml names Rust crates, and there is no cargo on PATH and no HILDE_CARGO

The catalog gives no failing example for this code.

↑ back to top

H1536

The environment or a cargo configuration asks for panic = "abort", under which no bridge can catch a panic.

Message:

the environment variable NAME sets panic to abort, and with abort catch_unwind catches nothing, so a panic in a bridge would end the programme

The catalog gives no failing example for this code.

↑ back to top

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:

rust/bridge holds FILE, which is no bridge module

The catalog gives no failing example for this code.

↑ back to top

H1538

cargo failed, wrote no static library, wrote a second one, or printed no native libraries.

Message:

cargo ended and wrote no libNAME.a to DIR

The catalog gives no failing example for this code.

↑ back to top

H1539

Message:

there is no rust/Cargo.lock, and cargo builds only from a lock file that is checked in

The catalog gives no failing example for this code.

↑ back to top

H1540

The rust-toolchain.toml or the guard crate rust/hilde-bridge beside the compiler is missing or names no pinned version.

Message:

the rust-toolchain.toml beside the compiler in DIR names no channel X.Y.Z

The catalog gives no failing example for this code.

↑ back to top

H1541

The value of --target is not written as a target of rustc.

Message:

the target TRIPLE is not a target of rustc

The catalog gives no failing example for this code.

↑ back to top

14. Sperli

H1047

A run command was given, and hilde-launcher is not beside the compiler.

Message:

The command run is carried out by `path`, which is not there.
Build it beside the compiler with `make hilde-launcher`, or install both with `make install`.

The catalog gives no failing example for this code.

↑ back to top

H1048

hilde-launcher is beside the compiler and could not be started.

Message:

`path` could not be started: why.
Check that it may be run, or build it again with `make hilde-launcher`.

The catalog gives no failing example for this code.

↑ back to top

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 peer has no certificate of the job CA

The catalog gives no failing example for this code.

↑ back to top

H1602

The subject of the certificate of the peer is not the job and the rank the connection is for.

Message:

the subject of the certificate is not the job and rank of the peer

The catalog gives no failing example for this code.

↑ back to top

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 host is refused

The catalog gives no failing example for this code.

↑ back to top

H1604

The join token of a peer has expired.

Message:

the join token has expired

The catalog gives no failing example for this code.

↑ back to top

H1605

The join token of a peer was made for another job.

Message:

the join token is for another job

The catalog gives no failing example for this code.

↑ back to top

H1606

The join token of a peer was made for another rank, size, incarnation or host.

Message:

the join token is for another rank, size, incarnation or host

The catalog gives no failing example for this code.

↑ back to top

H1607

The join token of a peer is malformed, or its signature does not hold under the public key of the launcher.

Message:

the join token is malformed or its signature does not hold

The catalog gives no failing example for this code.

↑ back to top

H1608

A frame announces more payload than the limit of 16 MiB; it is refused before a payload byte is read.

Message:

the frame is larger than the limit

The catalog gives no failing example for this code.

↑ back to top

H1609

A frame belongs to an older incarnation of the job; its payload is read and dropped, and the wait goes on.

Message:

the frame is from an older incarnation

The catalog gives no failing example for this code.

↑ back to top

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 header of the frame breaks the protocol

The catalog gives no failing example for this code.

↑ back to top

H1611

A peer was lost: the connection closed, or no frame came within the silence limit.

Message:

the peer was lost

The catalog gives no failing example for this code.

↑ back to top

H1612

A peer sent an abort frame.

Message:

the peer aborted the job

The catalog gives no failing example for this code.

↑ back to top

H1613

The hello of a peer is missing, comes twice, has another version or offers no point-to-point service.

Message:

the hello of the peer is missing, repeated or not acceptable

The catalog gives no failing example for this code.

↑ back to top

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 command line or the host list is wrong

The catalog gives no failing example for this code.

↑ back to top

H1615

A rank could not be started, or the keys, certificates or ports of the job could not be made.

Message:

a rank could not be started

The catalog gives no failing example for this code.

↑ back to top

H1616

The job description a rank was given on its standard input is malformed.

Message:

the job description is malformed

The catalog gives no failing example for this code.

↑ back to top

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 collective frame does not match the call

The catalog gives no failing example for this code.

↑ back to top

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 arguments of the collective call are wrong

The catalog gives no failing example for this code.

↑ back to top

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 checkpoint file is not the one expected

The catalog gives no failing example for this code.

↑ back to top

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 SHA-256 of the checkpoint file does not match

The catalog gives no failing example for this code.

↑ back to top

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 COMMIT file is malformed or its signature does not hold

The catalog gives no failing example for this code.

↑ back to top

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:

no epoch can be resumed

The catalog gives no failing example for this code.

↑ back to top

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 job has another size than the checkpoint

The catalog gives no failing example for this code.

↑ back to top

H1624

A checkpoint was asked for while a send or receive was still open on this rank.

Message:

a send or receive is still open

The catalog gives no failing example for this code.

↑ back to top

H1625

A checkpoint could not be written or sent, or no checkpoint directory was named.

Message:

the checkpoint could not be written or sent

The catalog gives no failing example for this code.

↑ back to top