$ check
= 0
15 definitions, 0 programs
$ fmt
= 0
lang/test/tree_semi/lib.g
$ fmt lang/test/tree_semi/lib.g
= 0
-- Semicolons (docs/lang.md 2): the end of a line is one after a token
-- that can end a statement, one may be written, and one may be left out
-- before a "}". Every form here renders without one.

type Unit = rec;

-- an explicit one, and a comment beside it
type Pair = rec a int, b int

-- A ";" written after every statement, and after the block.
fn explicit x int -> int = {
  let y = x + 1
  y
}

-- None before the "}".
fn before x int -> int = {
  let y = x + 1
  y
}

-- A line that ends in an operator goes on.
fn lines x int -> int = {
  let y = x + 1
  y
}

-- break, continue and return end their lines.
fn ends x int -> int = {
  var n = 0
  loop {
    n = n + 1
    if n == x then break
    if n < x then continue
    return n
  }
  n
}

fn arms o opt int -> int = match o {
  Some v => v
  None => 0
}

-- A construction over lines: a "," after each field, the last too.
fn cons x int -> Pair = Pair { a = x, b = x }

-- An else on the line of the "}" before it.
fn other x int -> int = if x == 0 then { 1 } else { 2 }

-- One function four ways (docs/lang.md 2, "Semicolons"): each renders as
-- the first.
fn one n int = {
  var left = n
  while left != 0 {
    print left "\n"
    left = left - 1
  }
}

fn two n int = {
  var left = n
  while left != 0 {
    print left "\n"
    left = left - 1
  }
}

fn three n int = {
  var left = n
  while left != 0 {
    print left "\n"
    left = left - 1
  }
}

fn four n int = {
  var left = n
  while left != 0 {
    print left "\n"
    left = left - 1
  }
}

-- A comment after the last token of a line, and the end of the text
-- with no line end before it.
-- beside
fn noted -> int = 1

fn last = { }
