diff --git a/cozo-core/src/parse/imperative.rs b/cozo-core/src/parse/imperative.rs index a0140698..282a3328 100644 --- a/cozo-core/src/parse/imperative.rs +++ b/cozo-core/src/parse/imperative.rs @@ -111,7 +111,7 @@ fn parse_imperative_stmt( let condition = inner.next().unwrap(); let cond = match condition.as_rule() { Rule::underscore_ident => Left(SmartString::from(condition.as_str())), - Rule::query_script_inner => { + Rule::imperative_clause => { let mut src = condition.into_inner(); let prog = parse_query( src.next().unwrap().into_inner(), diff --git a/cozo-core/src/runtime/tests.rs b/cozo-core/src/runtime/tests.rs index d7b42bc3..b8e6d420 100644 --- a/cozo-core/src/runtime/tests.rs +++ b/cozo-core/src/runtime/tests.rs @@ -1361,3 +1361,21 @@ fn param_shorthand() { let res = db.run_default(r"?[x, y, z] := *x {x, y, z}"); assert_eq!(res.unwrap().into_json()["rows"], json!([[1, 2, 3]])); } + +#[test] +fn crashy_imperative() { + let db = DbInstance::default(); + db.run_default( + r" + {:create _test {a}} + + %loop + %if { len[count(x)] := *_test[x]; ?[x] := len[z], x = z >= 10 } + %then %return _test + %end + { ?[a] := a = rand_uuid_v1(); :put _test {a} } + %end + ", + ) + .unwrap(); +}