These are the programs in spec/examples/. Each cell shows the result the reference checker gives for it. Edit any program and press Run, or Ctrl+Enter, to check your version. In a code cell, Tab inserts four spaces; press Escape and then Tab to leave the cell.
Accepted programs (54)
Each of these is accepted: it parses, type-checks, and every example and check inside it holds.
spec/examples/01_counter.rce
Expected: accepted
intent"a counter that never goes negative"exampleInc, Inc, Dec -> 1exampleDec -> refused: UnderflowstateCounter
n: u64 = 0eventInceventDecerrorUnderflowstepCounteronInc -> n + 1stepCounteronDec -> try n.checked_sub(1) elseUnderflow
spec/examples/02_hello_main.rce
Expected: accepted
module hello
fn main()
emit"hello, world"
spec/examples/03_fib_loop.rce
Expected: accepted
intent"the n-th Fibonacci number, computed in linear time"check fib(0) == 0check fib(10) == 55fn fib(n: u32) -> u64var a: u64 = 0var b: u64 = 1for _ in0..n
let t = a + b
a = b
b = t
return a
spec/examples/04_bank_account.rce
Expected: accepted
module bank
intent"a bank account that refuses overdrafts"exampleDeposit(amount: 50), Withdraw(amount: 20) -> 30exampleWithdraw(amount: 1) -> refused: InsufficientstateAccount
balance: i64 = 0eventDeposit(amount: i64)
eventWithdraw(amount: i64)
errorInsufficient(need: i64)
structWithdrawn
amount: i64stepAccountonDeposit(amount: a) if a > 0 -> balance + a
stepAccountonDeposit(amount: _) -> balance
stepAccountonWithdraw(amount: a)
if a > balance
failInsufficient(need: a - balance)
balance -= a
emitWithdrawn(amount: a)
spec/examples/05_kind_match.rce
Expected: accepted
kindShapeCircle(r: f64)
Rect(w: f64, h: f64)
Emptyfn area(s: &Shape) -> f64match s
Circle(r: r) -> 3.141592653589793 * r * r
Rect(w: w, h: h) -> w * h
Empty -> 0.0
spec/examples/06_option.rce
Expected: accepted
fn first_even(xs: &[i64]) -> i64?
for x in xs
if x % 2 == 0return some(x)
returnnonefn or_zero(v: i64?) -> i64match v
some(x) -> x
none -> 0
fn max_of[T: Ord](xs: &[T]) -> T?
var best: T? = nonefor x in xs
match best
none -> best = some(copy(x))
some(b) if x > b -> best = some(copy(x))
_ -> passreturn best
traitDescribefn describe(&self) -> textimplforall[T: Describe] DescribeforList[T]
fn describe(&self) -> text = ", ".join([x.describe() for x inself])
spec/examples/10_comptime.rce
Expected: accepted
constN: usize = 64constTABLE: [u32; 256] = comptime crc_table()
comptimefn crc_table() -> [u32; 256]
var t = [0; 256]
for i in0..256var c: u32 = i asu32for _ in0..8
c = if c & 1 == 1then0xEDB88320 ^ (c >> 1) else c >> 1
t[i] = c
return t
fn zeros[comptime n: usize]() -> [u8; n]
return [0; n]
spec/examples/11_arena.rce
Expected: accepted
fn word_lengths(s: &text) -> List[u32]
var out: List[u32] = []
witharena scratch
let ws: List[text] @scratch = s.words()
for w in ws
out.append(w.len() asu32)
return out
spec/examples/12_borrow.rce
Expected: accepted
fn push_all(dst: &mutList[i64], src: &[i64])
for x in src
dst.append(x)
fn demo() -> usizevar a: List[i64] = [1, 2, 3]
let b: List[i64] = [4, 5]
push_all(&mut a, &b)
return a.len()
spec/examples/13_spawn_chan.rce
Expected: accepted
fn producer(out: chani64, n: i64)
for i in0..n
out <- i
out.close()
fn main()
let c = chan[i64](8)
spawn producer(c, 100)
var total = 0loopmatch <- c
some(v) -> total += v
none -> breakemit total
spec/examples/14_select.rce
Expected: accepted
fn merge(a: chantext, b: chantext, out: chantext)
loopbound1000selectrecv some(x) from a -> out <- x
recv some(y) from b -> out <- y
recvnonefrom a -> breakafter10 -> emit"idle"
spec/examples/15_actor.rce
Expected: accepted
eventGet(reply: chani64)
eventAdd(k: i64)
actorTally
total: i64 = 0onAdd(k: k) -> total + k
onGet(reply: r)
r <- total
spec/examples/16_multi_region.rce
Expected: accepted
stateCart
items: List[text] = []
stateStats
adds: u64 = 0
removes: u64 = 0eventAddItem(name: text)
eventRemoveItem(name: text)
eventResetstepCartonAddItem(name: n) -> items.with(n)
stepStatsonAddItem(name: _)
adds += 1stepCartonRemoveItem(name: n)
items = [copy(i) for i in items if i != n]
stepStatsonRemoveItem(name: _)
removes += 1stepCartonReset -> []
spec/examples/17_traffic_light.rce
Expected: accepted
intent"a traffic light that cycles on each tick"exampleTick, Tick -> light == YellowkindLightRedGreenYellowstateSignal
light: Light = RedeventTickstepSignalonTickmatch light
Red -> light = GreenGreen -> light = YellowYellow -> light = Red
spec/examples/18_while_bound.rce
Expected: accepted
errorDivergedfn collatz_steps(n: u64) -> u64 ! Divergedvar x = n
var k: u64 = 0while x != 1bound10_000
x = if x % 2 == 0then x / 2else3 * x + 1
k += 1return k
spec/examples/19_floats.rce
Expected: accepted
errorEmptyfn mean(xs: &[f64]) -> f64 ! Emptyif xs.len() == 0failEmptyvar s = 0.0for x in xs
s += x
return s / xs.len() asf64constAVOGADRO: f64 = 6.02214076e23constEPS = 1e-9
spec/examples/20_strings.rce
Expected: accepted
fn shout(s: &text) -> text = s.strip().upper() + "!"fn is_palindrome(s: &text) -> boollet t = [c for c in s.lower().chars() if c.isalpha()]
return t == t.reverse()
fn escapes() -> text = "tab\t newline\n quote\" snow \u{2603}"
spec/examples/21_maps.rce
Expected: accepted
fn freq(words: &[text]) -> Map[text, u32]
var m: Map[text, u32] = {}
for w in words
m[w] = (m.get(w) catch0) + 1return m
fn table() -> Map[text, i64] = {"a": 1, "b": 2,}
spec/examples/22_tuples.rce
Expected: accepted
errorDivByZerofn divmod(a: i64, b: i64) -> (i64, i64) ! DivByZeroif b == 0failDivByZeroreturn (a / b, a % b)
fn use_it() -> i64let (q, r) = divmod(17, 5) catch (0, 0)
let pair = (q, r)
return pair.0 + pair.1
fn popcount(x: u64) -> u32var v = x
var c: u32 = 0while v != 0bound64
v &= v - 1
c += 1return c
fn mix(a: u32, b: u32) -> u32 = (a << 5 | a >> 27) ^ ~b & 0xFF
intent"a door that locks only when closed""the door starts closed and unlocked"exampleOpen, Close, Lock -> locked
exampleOpen, Lock -> refused: DoorOpenstateDoor
open: bool = false
locked: bool = falseeventOpeneventCloseeventLockeventUnlockerrorDoorOpenerrorLockedstepDooronOpenif locked
failLockedstepDooronOpen
open = truestepDooronClose
open = falsestepDooronLockif open
failDoorOpenstepDooronLock
locked = truestepDooronUnlock
locked = false
fn long_call() -> i64let xs = [
1, 2, 3,
4, 5, 6,
]
let total = xs.fold(
0,
fn(a: i64, b: i64) => a + b,
)
return total # comments are allowed here
spec/examples/37_actor_spawn.rce
Expected: accepted
eventPing(n: u64, reply: chanu64)
actorEcho
seen: u64 = 0onPing(n: n, reply: r)
seen += 1
r <- n
fn main()
let e = Echo()
let r = chan[u64](1)
e <- Ping(n: 7, reply: r)
emit <- r
# Structural recursion: each self-call takes a field of a constructor the# function matched, so the depth is bounded by the size of the value.kindTreeLeaf(v: i64)
Node(l: Box[Tree], r: Box[Tree])
fn tree_sum(t: &Tree) -> i64match t
Leaf(v: v) -> return v
Node(l: l, r: r) -> return tree_sum(l) + tree_sum(r)
fn sample_sum() -> i64let t = Node(l: Box(Leaf(v: 2)), r: Box(Node(l: Box(Leaf(v: 3)), r: Box(Leaf(v: 4)))))
return tree_sum(&t)
check sample_sum() == 9
spec/examples/40_extern.rce
Expected: accepted
# A foreign function: C ABI, scalar results, borrowed buffers only.# Only main and task functions may call it; its results enter the log.extern"C"fn crc32(data: &[u8], seed: u32) -> u32fn main()
let bytes: List[u8] = [1, 2, 3]
emit crc32(&bytes, 0)
spec/examples/41_arena_bound_wrapping.rce
Expected: accepted
# An arena with a fixed capacity, and explicit wrapping arithmetic for hashing.fn fnv1a(s: &text) -> u32var h: u32 = 2166136261witharena scratch bound4096let cs: List[text] @scratch = s.chars()
for c in cs
h = (h ^ (c.len() asu32)).wrapping_mul(16777619)
return h
check (250asu8).wrapping_add(10) == 4check (250asu8).saturating_add(10) == 255
spec/examples/42_f32.rce
Expected: accepted
# f32 arithmetic: computed in f64 and rounded once, so every target agrees bit for bit.fn axpy(a: f32, x: f32, y: f32) -> f32return a * x + y
check axpy(2.0asf32, 0.1asf32, 1.0asf32) == 1.2asf32check (0.1asf32) asf64 != 0.1check (16777217asf32) asi64 == 16777216
# A device region holds fixed-size values only and performs no effects.fn dot4(a: [f32; 4], b: [f32; 4]) -> f32var acc: f32 = 0asf32withdevice gpu bound4096let p: [f32; 4] = a * b
for x in p
acc = acc + x
return acc
check dot4([1.0asf32, 2.0asf32, 3.0asf32, 4.0asf32], [1.0asf32, 1.0asf32, 1.0asf32, 1.0asf32]) == 10.0asf32
spec/examples/45_byte_text.rce
Expected: accepted
# Text is indexed and measured in UTF-8 bytes.fn first_byte(s: &text) -> u8return s[0]
check"héllo".len() == 6constA: text = "A"check first_byte(&A) == 65check"héllo"[1] == 195check"héllo"[0:1] == "h"check"héllo"[1:3] == "é"
spec/examples/46_u64.rce
Expected: accepted
# Full-range u64 arithmetic, checked against [0, 2^64).constBIG: u64 = 18446744073709551615fn half(x: u64) -> u64return x / 2check half(BIG) == 9223372036854775807checkBIG - 1 == 18446744073709551614check (BIG / 3) * 3 == BIGcheckBIG.checked_add(1).isnone()
# `lalr` is an ordinary name (it was wrongly reserved before 0.5).const lalr: u64 = 1checkBIG - lalr + lalr == BIG
spec/examples/47_select_fair.rce
Expected: accepted
# Two producers on one select: the rotation guarantees neither is starved.fn fan_in(a: chanu64, b: chanu64, out: chanu64)
loopbound1000selectrecv some(x) from a -> out <- x
recv some(y) from b -> out <- y
recvnonefrom a -> break
spec/examples/48_linear_handle.rce
Expected: accepted
# A linear handle must be consumed exactly once on every path.linearstructFile
fd: i32extern"C"fn c_open(path: &text) -> Fileextern"C"fn c_close(f: File) -> i32extern"C"fn c_write(f: File, n: u32) -> Filefn main()
let p = "log.txt"let f = c_open(&p)
let g = c_write(f, 3)
if g.fd < 0let _ = c_close(g)
elselet r = c_close(g)
emit r
spec/examples/49_loop_limit.rce
Expected: accepted
# A program can raise or lower the default loop limit.constLOOP_LIMIT: u64 = 5000000fn count(n: u64) -> u64var k: u64 = 0while k < n
k += 1return k
check count(2000000) == 2000000
spec/examples/50_iterators.rce
Expected: accepted
# Iterators: push-model generators, bounded by the loop limit.fn evens(n: u64) -> iteru64var i: u64 = 0while i < n
yield i * 2
i += 1fn naturals() -> iteru64var i: u64 = 0loopyield i
i += 1fn first_over(t: u64) -> u64for x in naturals()
if x > t
return x
return0fn total(n: u64) -> u64var s: u64 = 0for x in evens(n)
s += x
return s
check total(4) == 12check evens(3).collect() == [0, 2, 4]
check first_over(100) == 101
spec/examples/51_refined_input.rce
Expected: accepted
module refined
intent"input validation is a declared predicate: an event whose payload is outside its refined type is refused, state unchanged"exampleSetVolume(pct: 40) -> level == 40exampleRename(name: "ok") -> name == "ok"exampleCode(pin: "0042"), Code(pin: "9999") -> accepted == 2exampleSetVolume(pct: 40), Rename(name: "ok") -> level == 40typePct = u8whereself <= 100typeName = textwhereself.len() >= 1andself.len() <= 2typePin = textwhereself.isdigit() andself.len() == 4stateVolume
level: Pct = 0stateCodes
accepted: u32 = 0stateProfile
name: text = "-"eventSetVolume(pct: Pct)
eventRename(name: Name)
eventCode(pin: Pin)
stepVolumeonSetVolume(pct: p) -> p
stepCodesonCode(pin: _) -> accepted + 1stepProfileonRename(name: n) -> n
spec/examples/52_context_text.rce
Expected: accepted
# rce-version: 0.8module page
intent"untrusted text reaches HTML and SQL only through the context's encoder (5.16): markup and query syntax come from program literals"exampleComment(body: "<script>x</script>") -> html.raw() == "<p><script>x</script></p>"exampleComment(body: "O'Brien") -> query.raw() == "SELECT id FROM users WHERE name = 'O''Brien'"exampleComment(body: "a b&c") -> link.raw() == "/search?q=a%20b%26c"statePage
html: Text[Html] = Html.lit("<p></p>")
query: Text[Sql] = Sql.lit("")
link: Text[Url] = Url.lit("/")
eventComment(body: text)
stepPageonComment(body: b)
html = Html.lit("<p>") + Html.encode(b) + Html.lit("</p>")
query = Sql.lit("SELECT id FROM users WHERE name = ") + Sql.encode(b)
link = Url.lit("/search?q=") + Url.encode(b)
emit html
spec/examples/53_capability.rce
Expected: accepted
# rce-version: 0.8module admin
intent"authority is a value (5.16): a Guarded field is written only by a step whose event carries the capability"exampleSetLimit(admin: (), limit: 50) -> limit == 50exampleSetLimit(admin: (), limit: 50), Spend(amount: 20) -> spent == 20exampleSpend(amount: 5) -> limit == 100structRootstatePolicy
limit: Guarded[u32, Root] = 100stateLedger
spent: u32 = 0eventSetLimit(admin: Cap[Root], limit: u32)
eventSpend(amount: u32)
stepPolicyonSetLimit(admin: _, limit: n) -> n
stepLedgeronSpend(amount: a) -> spent + a
spec/examples/54_secret.rce
Expected: accepted
# rce-version: 0.8module login
intent"secrets are opaque (5.16): no literal can make one, no output can carry one, equality is the one release"exampleEnroll(pw: "s3cret"), Login(pw: "s3cret") -> ok == 1exampleEnroll(pw: "s3cret"), Login(pw: "guess") -> failed == 1stateVault
stored: Secret[text]? = none
ok: u32 = 0
failed: u32 = 0eventEnroll(pw: Secret[text])
eventLogin(pw: Secret[text])
stepVaultonEnroll(pw: p)
stored = some(p)
stepVaultonLogin(pw: p)
if stored == some(p)
ok += 1else
failed += 1
spec/examples/55_rcedb.rce
Expected: accepted
module rcedb
intent"a keyed store written in RCE over the host's durable append (Appendix E.8): puts are state writes, a bound Synced event moves the durable mark, scans are in canonical key order"examplePut(key: "b", val: "2"), Put(key: "a", val: "1"), Synced(upto: 1) -> durable == 1examplePut(key: "k", val: "v"), Delete(key: "k") -> rows.len() == 0exampleDelete(key: "x") -> refused: MissingstateDb
rows: Map[text, text] = {}
writes: u64 = 0
durable: u64 = 0eventPut(key: text, val: text)
eventDelete(key: text)
eventSynced(upto: u64)
eventScan(start: text)
errorMissing(key: text)
structRow
key: text
val: textstepDbonPut(key: k, val: v)
rows[k] = v
writes += 1stepDbonDelete(key: k)
ifnot rows.contains(k)
failMissing(key: k)
rows.remove(k)
writes += 1stepDbonSynced(upto: n)
if n > durable
durable = n
stepDbonScan(start: f)
var ks = rows.keys()
ks.sort()
for k in ks
if k >= f
let v = rows.get(k) catch""emitRow(key: k.tostr(), val: v)
Syntax rejects (12)
Each of these is not in the language of the grammar and is refused before type checking.
spec/examples/reject/assign_in_expr.rce
Expected: refused at the parse stage by W-SYN-1: line 1: W-SYN-1 expected `)` (found `=`)
fn f() -> i64 = (x = 1)
spec/examples/reject/bad_dedent.rce
Expected: refused at the parse stage by W-LEX-2: line 3: W-LEX-2 inconsistent dedent
fn f() -> i64let x = 1return x
spec/examples/reject/chained_compare.rce
Expected: refused at the parse stage by W-SYN-1: line 1: W-SYN-1 expected end of line (found `<`)
fn f(a: i64) -> bool = 0 < a < 10
spec/examples/reject/class_keyword.rce
Expected: refused at the parse stage by W-SYN-1: line 1: W-SYN-1 expected a declaration (found `class`)
class Foo
x: i64
spec/examples/reject/if_expr_no_else.rce
Expected: refused at the parse stage by W-SYN-1: line 1: W-SYN-1 expected `else` (found end of line)
fn f(a: bool) -> i64 = if a then1
spec/examples/reject/kind_empty.rce
Expected: refused at the parse stage by W-SYN-1: line 2: W-SYN-1 expected indented block (found `fn`)
kindKfn f() -> i64 = 1
spec/examples/reject/missing_arrow_example.rce
Expected: refused at the parse stage by W-SYN-1: line 2: W-SYN-1 expected `->` (found integer `1`)
intent"x"exampleInc1
spec/examples/reject/state_no_fields.rce
Expected: refused at the parse stage by W-SYN-1: line 2: W-SYN-1 expected indented block (found `event`)
stateSeventE
spec/examples/reject/step_no_on.rce
Expected: refused at the parse stage by W-SYN-1: line 4: W-SYN-1 expected `on` (found `E`)
stateS
n: i64 = 0eventEstepSE -> n
spec/examples/reject/tab_indent.rce
Expected: refused at the parse stage by W-LEX-1: line 2: W-LEX-1 tab character
fn f() -> i64return1
spec/examples/reject/try_in_then.rce
Expected: refused at the parse stage by W-SYN-1: line 1: W-SYN-1 expected an expression (found `try`)
fn f(a: bool) -> i64 = if a thentry g() else0
spec/examples/reject/unterminated_string.rce
Expected: refused at the parse stage by W-SYN-1: line 1: W-SYN-1 unterminated string
fn f() -> text = "abc
Ill-typed programs (48)
Each of these parses but breaks a typing, ownership or well-formedness rule.
spec/examples/ill_typed/arena_escape.rce
Expected: refused at the check stage by W-REG-1: line 5: W-REG-1 a value in arena `a` escapes into `out`
fn f(s: &text) -> List[text]
var out: List[text] = []
witharena a
let ws: List[text] @a = s.words()
out = ws
return out
spec/examples/ill_typed/assign_let.rce
Expected: refused at the check stage: line 3: W-PLACE `x` is not mutable (declare it with var)
fn f() -> i64let x = 1
x = 2return x
spec/examples/ill_typed/borrow_escape.rce
Expected: refused at the check stage by W-OWN-3: line 1: W-OWN-3 a returned borrow must derive from a borrowed parameter (R-RET)
Expected: refused at the check stage by W-FFI-1: line 1: W-FFI-1 foreign parameter type List[u8] is not bool, an integer, f64, &text, &[scalar] or &mut [scalar]
Expected: refused at the check stage by W-MATCH-1: line 6: W-MATCH-1 match is not exhaustive: missing Green
kindLightRedGreenfn f(l: Light) -> u8match l
Red -> return1
spec/examples/ill_typed/orphan_impl.rce
Expected: refused at the check stage by W-TRAIT-2: line 1: W-TRAIT-2 orphan impl: neither the trait nor the type is declared in this module
implEqforList[i64]
fn eq(&self) -> bool = true
spec/examples/ill_typed/pure_send.rce
Expected: refused at the check stage by W-EFF-1: line 2: W-EFF-1 emit in a pure function
fn f(x: i64) -> i64emit x
return x
spec/examples/ill_typed/rec_not_structural.rce
Expected: refused at the check stage by W-REC-1: line 4: W-REC-1 recursion through countdown has no decreasing measure (6.7): no layers of summed measures, each kept by every call not yet done and shrunk by at least one, leave the remaining calls without a cycle, and a cycle of its calls passes through no function declared with `bound`
Expected: refused at the check stage by W-REC-1: line 8: W-REC-1 recursion through loop_forever has no decreasing measure (6.7): no layers of summed measures, each kept by every call not yet done and shrunk by at least one, leave the remaining calls without a cycle, and a cycle of its calls passes through no function declared with `bound`
Expected: refused at the check stage by W-REC-1: line 1: W-REC-1 recursion through f, g has no decreasing measure (6.7): no layers of summed measures, each kept by every call not yet done and shrunk by at least one, leave the remaining calls without a cycle, and a cycle of its calls passes through no function declared with `bound`
Expected: refused at the check stage by W-TY-1: line 2: W-TY-1 expected u64, found text
fn f(a: chanu64)
selectrecv some(x) from a -> passafter"soon" -> pass
spec/examples/ill_typed/simd_len.rce
Expected: refused at the check stage by W-SIMD-1: line 2: W-SIMD-1 lane-wise `+` needs two arrays of one fixed length, found [i32; 3] and [i32; 4]
fn f(a: [i32; 3], b: [i32; 4]) -> [i32; 3]
return a + b
spec/examples/ill_typed/simd_text.rce
Expected: refused at the check stage by W-SIMD-1: line 2: W-SIMD-1 lane-wise `*` needs numeric lanes, found text
fn f(a: [text; 2], b: [text; 2]) -> [text; 2]
return a * b
spec/examples/ill_typed/spawn_borrow.rce
Expected: refused at the check stage by W-SPAWN-1: line 7: W-SPAWN-1 spawned tasks cannot receive borrows
fn worker(c: chani64, xs: &List[i64])
c <- 1fn main()
let c = chan[i64](1)
let xs: List[i64] = [1]
spawn worker(c, &xs)
spec/examples/ill_typed/state_no_init.rce
Expected: refused at the check stage by W-STATE-2: line 2: W-STATE-2 field `n` needs a comptime initial value
stateS
n: u64eventEstepSonE -> n
spec/examples/ill_typed/text_index_char.rce
Expected: refused at the check stage by W-TY-1: line 2: W-TY-1 cannot compare u8 with text
fn f(s: &text) -> boolreturn s[0] == "a"
spec/examples/ill_typed/u64_mixed.rce
Expected: refused at the check stage by W-TY-1: line 2: W-TY-1 `+` on u64 and i64: no implicit conversion
fn f(a: u64, b: i64) -> u64return a + b
spec/examples/ill_typed/unchecked_union.rce
Expected: refused at the check stage by W-TY-1: line 6: W-TY-1 expected i64, found i64 ! E
errorEfn g() -> i64 ! EfailEfn f() -> i64 = g()
spec/examples/ill_typed/unhandled_event.rce
Expected: refused at the check stage by W-STEP-2: line 5: W-STEP-2 event `Dec` is handled by no step or actor: δ would not be total
stateCounter
n: u64 = 0eventInceventDecstepCounteronInc -> n + 1
spec/examples/ill_typed/unknown_name.rce
Expected: refused at the check stage by W-NAME-1: line 1: W-NAME-1 unknown name `y`
fn f() -> i64 = y + 1
spec/examples/ill_typed/unreachable_step.rce
Expected: refused at the check stage by W-STEP-4: line 7: W-STEP-4 unreachable: the unguarded step at line 6 already handles S on E
stateS
n: u64 = 0eventEstepSonE -> n + 1stepSonE -> n + 2
spec/examples/ill_typed/unsafe_name.rce
Expected: refused at the check stage by W-SAFE-1: line 2: W-SAFE-1 `unsafe` is refused
fn f() -> i64let unsafe = 1return unsafe
spec/examples/ill_typed/use_after_move.rce
Expected: refused at the check stage by W-OWN-1: line 5: W-OWN-1 `s` is used after it was moved
fn take(s: text) -> u64 = s.len() asu64fn twice(s: text) -> u64let a = take(s)
return a + take(s)
spec/examples/ill_typed/yield_outside.rce
Expected: refused at the check stage by W-ITER-1: line 2: W-ITER-1 yield outside an iterator function
fn f() -> u64yield1return0
Inadmissible programs (16)
Each of these type-checks but fails the admission gate: an example, a check, a comptime block or a constant does not hold when evaluated.
spec/examples/inadmissible/arena_size_limit.rce
Expected: refused at the admit stage by W-INT-1: line 8: W-INT-1 check: trap: size limit
fn build(n: u64) -> u64var k: u64 = 0witharena a bound16let xs: List[u64] @a = [n, n, n, n, n, n, n, n, n, n]
k = xs.len() asu64return k
check build(12345) == 10
spec/examples/inadmissible/bslice_boundary.rce
Expected: refused at the admit stage by W-INT-1: line 1: W-INT-1 check: trap: not a char boundary
check"héllo"[0:2] == "h"
spec/examples/inadmissible/comptime_check.rce
Expected: refused at the admit stage by W-CT-1: line 3: W-CT-1 comptime block in `f`: trap: check failed
Built from spec commit 49fa9af. Code cells run the reference checker rce-check, written in Rust and compiled to WebAssembly, inside your browser; nothing is sent to a server. Read-aloud uses the Kokoro-82M model (Apache-2.0), served from this site and run in your browser.