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.
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 Suffixes
Section titled “Type Suffixes”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 nameInt?! 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”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;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.