Skip to content

Commit

Permalink
bugfix return
Browse files Browse the repository at this point in the history
  • Loading branch information
nbittich committed Sep 22, 2023
1 parent 50d0d70 commit 9b1df8f
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 20 deletions.
39 changes: 25 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ nu-ansi-term = "0.49.0"
rustyline = "12.0.0"
rustyline-derive = "0.9.0"
serde = { version = "1.0.188", features = ['serde_derive', 'rc'] }
serde_json = "1.0.105"
serde_json = "1.0.107"
slab_tree = "0.3.2"
strum = { version = "0.25.0", features = ["derive"] }
ctrlc = "3.4.0"
ctrlc = "3.4.1"
[dependencies.env_logger]
default-features = false
version = "0.10.0"
[dependencies.regex]
version = "1.9.4"
version = "1.9.5"
default-features = false
# regex currently requires the standard library, you must re-enable it.
features = ["std"]
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM rust:1.72-bullseye as builder
FROM rust:1.72.1-bullseye as builder

WORKDIR /app

Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "stable"
host = "1.72.0"
host = "1.72.1"
targets = ["x86_64-unknown-linux-musl"]
2 changes: 1 addition & 1 deletion src/adana_script/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ fn parse_break(s: &str) -> Res<Value> {
map(tag_no_space(BREAK), |_| Value::Break)(s)
}
fn parse_early_return(s: &str) -> Res<Value> {
map(preceded(tag_no_space(RETURN), opt(parse_value)), |v| {
map(preceded(tag_no_space(RETURN), opt(parse_expression)), |v| {
Value::EarlyReturn(Box::new(v))
})(s)
}
Expand Down
15 changes: 15 additions & 0 deletions src/adana_script/tests/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -631,3 +631,18 @@ fn bug_javascript_meme() {
// *mathematically*
assert_eq!(Primitive::Bool(false), compute("3>2>1<3", &mut ctx).unwrap());
}

#[test]
fn recur_early_return() {
let mut ctx = BTreeMap::new();
let script = r#"
fact = (n) => {
if(n>=1) {
return n * fact(n-1)
}
return 1
}
fact(6)
"#;
assert_eq!(Primitive::Int(720i128), compute(script, &mut ctx).unwrap());
}

0 comments on commit 9b1df8f

Please sign in to comment.