fix initializing object from <unreachable> not working

This commit is contained in:
Mark 2024-11-07 23:00:08 +01:00
parent 6630542644
commit e34d841f9a
4 changed files with 8 additions and 4 deletions

View File

@ -1,6 +1,6 @@
[package] [package]
name = "mers" name = "mers"
version = "0.9.17" version = "0.9.18"
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.17" mers_lib = "0.9.18"
# 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 }

View File

@ -1,6 +1,6 @@
[package] [package]
name = "mers_lib" name = "mers_lib"
version = "0.9.17" version = "0.9.18"
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"

View File

@ -18,7 +18,9 @@ impl MersStatement for Object {
info: &mut super::CheckInfo, info: &mut super::CheckInfo,
init_to: Option<&Type>, init_to: Option<&Type>,
) -> Result<data::Type, super::CheckError> { ) -> Result<data::Type, super::CheckError> {
let mut init_to_is_empty_type = false;
let mut init_fields = if let Some(init_to) = init_to { let mut init_fields = if let Some(init_to) = init_to {
init_to_is_empty_type = init_to.types.is_empty();
let print_is_part_of = init_to.types.len() > 1; let print_is_part_of = init_to.types.len() > 1;
let mut init_fields = HashMap::new(); let mut init_fields = HashMap::new();
for t in init_to.types.iter() { for t in init_to.types.iter() {
@ -67,6 +69,8 @@ impl MersStatement for Object {
if let Some(f) = &mut init_fields { if let Some(f) = &mut init_fields {
Some(if let Some(s) = f.remove(field) { Some(if let Some(s) = f.remove(field) {
s s
} else if init_to_is_empty_type {
Type::empty()
} else { } else {
return Err(CheckError::new().msg(vec![ return Err(CheckError::new().msg(vec![
("can't init an ".to_owned(), None), ("can't init an ".to_owned(), None),

View File

@ -4,7 +4,7 @@ version = "0.9.15"
edition = "2021" edition = "2021"
[dependencies] [dependencies]
mers_lib = "0.9.14" mers_lib = "0.9.18"
lspower = "1.5.0" lspower = "1.5.0"
tokio = { version = "1.36.0", features = ["full"] } tokio = { version = "1.36.0", features = ["full"] }
line-span = "0.1.5" line-span = "0.1.5"