wcmu_rejection/
wcmu_rejection.rs1use keleusma::compiler::compile;
9use keleusma::lexer::tokenize;
10use keleusma::parser::parse;
11use keleusma::vm::{Vm, VmError};
12
13const SCRIPT: &str = "
14loop main(input: i64) -> i64 {
15 let doubled = input * 2;
16 let _ignored = yield doubled;
17 doubled
18}
19";
20
21fn main() {
22 let tokens = tokenize(SCRIPT).expect("lex error");
23 let program = parse(&tokens).expect("parse error");
24 let module = compile(&program).expect("compile error");
25
26 let arena = keleusma::Arena::with_capacity(16);
29 match Vm::new(module, &arena) {
30 Ok(_) => unreachable!("expected verification to fail"),
31 Err(VmError::VerifyError(msg)) => {
32 println!("verification rejected the module:");
33 println!(" {}", msg);
34 }
35 Err(other) => panic!("expected VerifyError, got {:?}", other),
36 }
37
38 println!();
39 println!("the host can either pre-size the arena via keleusma::Arena::with_capacity");
40 println!("or compute the required capacity from the module via auto_arena_capacity_for");
41}