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.
Missing Semicolons
Section titled “Missing Semicolons”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 Layer Order
Section titled “Type Layer Order”Type suffixes are layered. Write optional and mutable markers in their canonical order:
Int?! value;Avoid duplicate flags in the same layer:
Int?? value; // invalidInt!! value; // invalidNumeric Conversions
Section titled “Numeric Conversions”Jiang does not implicitly promote already-typed numeric values:
Int two = 2;Float f = 0.5;Float result = two + f; // invalidUse an explicit target type:
Float result = Float(two) + f;Mutability
Section titled “Mutability”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;Imports
Section titled “Imports”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.