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]
|
[package]
|
||||||
name = "mers"
|
name = "mers"
|
||||||
version = "0.9.14"
|
version = "0.9.16"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
description = "dynamically typed but type-checked programming language"
|
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"]
|
colored-output = ["mers_lib/ecolor-term", "mers_lib/pretty-print", "dep:colored"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
mers_lib = "0.9.15"
|
mers_lib = "0.9.16"
|
||||||
# mers_lib = { path = "../mers_lib" }
|
# mers_lib = { path = "../mers_lib" }
|
||||||
clap = { version = "4.3.19", features = ["derive"] }
|
clap = { version = "4.3.19", features = ["derive"] }
|
||||||
colored = { version = "2.1.0", optional = true }
|
colored = { version = "2.1.0", optional = true }
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "mers_lib"
|
name = "mers_lib"
|
||||||
version = "0.9.15"
|
version = "0.9.16"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
description = "library to use the mers language in other projects"
|
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)
|
write!(f, "Range<{}..{}>", self.0, self.1)
|
||||||
}
|
}
|
||||||
fn iterable(&self) -> Option<Type> {
|
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 {
|
fn is_same_type_as(&self, other: &dyn MersType) -> bool {
|
||||||
other
|
other
|
||||||
@ -761,7 +765,7 @@ struct RangeInt(isize, isize, bool);
|
|||||||
impl Iterator for RangeInt {
|
impl Iterator for RangeInt {
|
||||||
type Item = isize;
|
type Item = isize;
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
if !self.2 {
|
if !self.2 && self.0 <= self.1 {
|
||||||
let o = self.0;
|
let o = self.0;
|
||||||
if self.0 < self.1 {
|
if self.0 < self.1 {
|
||||||
self.0 += 1;
|
self.0 += 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user