diff --git a/mers/Cargo.toml b/mers/Cargo.toml index 7d9b65f..a1305ca 100644 --- a/mers/Cargo.toml +++ b/mers/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mers" -version = "0.9.16" +version = "0.9.17" edition = "2021" license = "MIT OR Apache-2.0" description = "dynamically typed but type-checked programming language" @@ -15,7 +15,7 @@ default = ["colored-output"] colored-output = ["mers_lib/ecolor-term", "mers_lib/pretty-print", "dep:colored"] [dependencies] -mers_lib = "0.9.16" +mers_lib = "0.9.17" # mers_lib = { path = "../mers_lib" } clap = { version = "4.3.19", features = ["derive"] } colored = { version = "2.1.0", optional = true } diff --git a/mers_lib/Cargo.toml b/mers_lib/Cargo.toml index 25d821a..cc35bc6 100755 --- a/mers_lib/Cargo.toml +++ b/mers_lib/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mers_lib" -version = "0.9.16" +version = "0.9.17" edition = "2021" license = "MIT OR Apache-2.0" description = "library to use the mers language in other projects" diff --git a/mers_lib/src/program/configs/with_iters.rs b/mers_lib/src/program/configs/with_iters.rs index bb9f657..fbd4e8a 100755 --- a/mers_lib/src/program/configs/with_iters.rs +++ b/mers_lib/src/program/configs/with_iters.rs @@ -51,11 +51,14 @@ impl Config { if a.0.len() == 2 { let mut min = None; let mut max = None; - for v in a.0[0].types.iter().chain(a.0[1].types.iter()) { + for v in &a.0[0].types { let v = v.as_any().downcast_ref::().ok_or_else(|| CheckError::from(format!("expected int as first argument, but got {}", v.with_info(i))))?; if min.is_none_or(|min| min > v.0) { min = Some(v.0); } + } + for v in &a.0[1].types { + let v = v.as_any().downcast_ref::().ok_or_else(|| CheckError::from(format!("expected int as second argument, but got {}", v.with_info(i))))?; if max.is_none_or(|max| max < v.1) { max = Some(v.1); } @@ -84,11 +87,14 @@ impl Config { if a.0.len() == 2 { let mut min = None; let mut max = None; - for v in a.0[0].types.iter().chain(a.0[1].types.iter()) { + for v in &a.0[0].types { let v = v.as_any().downcast_ref::().ok_or_else(|| CheckError::from(format!("expected int as first argument, but got {}", v.with_info(i))))?; if min.is_none_or(|min| min > v.0) { min = Some(v.0); } + } + for v in &a.0[1].types { + let v = v.as_any().downcast_ref::().ok_or_else(|| CheckError::from(format!("expected int as second argument, but got {}", v.with_info(i))))?; if max.is_none_or(|max| max < v.1) { max = Some(v.1); } @@ -97,7 +103,7 @@ impl Config { if let Some(max) = max.checked_sub(1) { o.add(Arc::new(RangeT(min, max))); } else { - o.add(Arc::new(RangeT(min.saturating_add(1), max))); + o.add(Arc::new(RangeT(if min == isize::MIN { min + 1 } else { min }, isize::MIN))); } } } else {