namespace; include rt; // a tour of the compiler's optimization hints. the program is valid and runs; // the hints only show up in the editor (or the lsp cli), never in a normal build. // each function below triggers one of them. void sink(.d p) { rt.free(p); return; } // a variable that is written and never read fn dead() { let unused = 5; return 1; } // never reassigned, so it could be a const fn constant() { let width = 40; return width + 2; } // multiplying by a power of two is a shift fn shifty(n) { return n * 8; } // a number with no name fn magic(n) { return n + 1234; } // new inside a loop allocates every pass fn looping() { let i = 0; while (i < 3) { let buf = rt.new(10); buf[0] = i; sink(buf); i++; } return i; } // a small buffer that never leaves the function can live on the stack fn scratch() { let buf = rt.new(8); buf[0] = 7; return buf[0]; } // a consuming call takes the object after its allocation void handoff() { let tmp = rt.new(4); sink(tmp); return; } void main() { rt.put_n(dead() + constant() + shifty(2) + magic(0) + looping() + scratch()); handoff(); rt.put_c(10); return; }