writeonce/compiler/test/golden/ast/body-statements.wo
shoney.arickathil 76f72e85c4 feat(compiler): nullable types (?T) support
- ast.ml: Added Nullable variant to field_ty; param.ty/method_sig.ret/method_decl.ret now use field_ty
- parser.ml: Parse ? prefix for field types, return types, parameters
- dump.ml: Render ?T in --dump-ast output
- types.ml: New typechecker (Task 6) with nullable field-kind derivation (WO_K_NULLABLE=6)
- dune: Added types module
- Added golden test fixtures for nullable types and statement/expression parser
- Added implementation plan doc
2026-08-10 08:39:29 +02:00

34 lines
697 B
Text

class Calc {
items: multi Item
fn run(mut total: Int, step: Int) -> Int {
let base: Int = 10
let label = "sum"
total = total + base * 2 - 1
let neg = -total
if total > 100 {
label = label .. "-big"
} else if total > 50 {
label = label .. "-mid"
} else {
label = label .. "-small"
}
while total > 0 {
total = total - step
}
for item in self.items {
item.touch()
total = total + item.count
}
if neg > 0 {
return
}
let first = self.items[0]
let cache = PriceCache { entries: total, note: label }
return latest(self.items).amount
}
}
fn add(a: Int, b: Int) -> Int {
return a + b
}