mirror of
https://github.com/Dummi26/mers.git
synced 2025-03-10 05:43:53 +01:00
fix empty ranges not being empty
This commit is contained in:
parent
d6ccbb7d54
commit
b53c245776
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "mers"
|
||||
version = "0.9.14"
|
||||
version = "0.9.16"
|
||||
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.15"
|
||||
mers_lib = "0.9.16"
|
||||
# mers_lib = { path = "../mers_lib" }
|
||||
clap = { version = "4.3.19", features = ["derive"] }
|
||||
colored = { version = "2.1.0", optional = true }
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "mers_lib"
|
||||
version = "0.9.15"
|
||||
version = "0.9.16"
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
description = "library to use the mers language in other projects"
|
||||
|
@ -721,7 +721,11 @@ impl MersType for RangeT {
|
||||
write!(f, "Range<{}..{}>", self.0, self.1)
|
||||
}
|
||||
fn iterable(&self) -> Option<Type> {
|
||||
Some(Type::new(IntT(self.0, self.0.max(self.1))))
|
||||
Some(if self.is_empty() {
|
||||
Type::empty()
|
||||
} else {
|
||||
Type::new(IntT(self.0, self.1))
|
||||
})
|
||||
}
|
||||
fn is_same_type_as(&self, other: &dyn MersType) -> bool {
|
||||
other
|
||||
@ -761,7 +765,7 @@ struct RangeInt(isize, isize, bool);
|
||||
impl Iterator for RangeInt {
|
||||
type Item = isize;
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
if !self.2 {
|
||||
if !self.2 && self.0 <= self.1 {
|
||||
let o = self.0;
|
||||
if self.0 < self.1 {
|
||||
self.0 += 1;
|
||||
|
Loading…
Reference in New Issue
Block a user