Skip to content

Diagnostics

Jiang diagnostics are still improving as the compiler matures. The language already has a few rules that are worth checking first when a program fails to compile.

Statements generally end with semicolons:

Int x = 1;
return x;

Blocks used as expressions are the main place where the final expression may carry the value of the block.

Type-level ! is valid only on references and raw pointers: T&! is a unique mutable reference and T*! is a writable raw pointer. Other type-level forms are invalid:

Int! value; // invalid: put ! after the binding name
Int?! value; // invalid
Int!! value; // invalid

Jiang does not implicitly promote already-typed numeric values:

Int two = 2;
Float f = 0.5;
Float result = two + f; // invalid

Use an explicit target type:

Float result = Float(two) + f;

Put ! after a binding name when that variable, parameter, global, or field must be reassigned:

Int count! = 0;
count = count + 1;

The same rule applies to fixed arrays:

Int[3] values! = [1, 2, 3];
values[0] = 10;

Imported public declarations are accessed through the module namespace:

import "math.jiang";
Int value = math.add(1, 2);

If a name cannot be found, check whether it needs the module prefix or an explicit public declaration in the imported file.