Skip to content

Diagnostics

Jiang diagnostics are being improved as the Stage1 compiler grows. 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 suffixes are layered. Write optional and mutable markers in their canonical order:

Int?! value;

Avoid duplicate flags in the same layer:

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;

Mutability is part of the type. A binding must be mutable before it can be reassigned:

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

For arrays, the element layer and outer array layer are separate:

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.