From e34d841f9ae660b6f73ed60697774deeaed6fd81 Mon Sep 17 00:00:00 2001 From: Mark <> Date: Thu, 7 Nov 2024 23:00:08 +0100 Subject: [PATCH] fix initializing object from not working --- mers/Cargo.toml | 4 ++-- mers_lib/Cargo.toml | 2 +- mers_lib/src/program/run/object.rs | 4 ++++ merslsp/Cargo.toml | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/mers/Cargo.toml b/mers/Cargo.toml index a1305ca..ea49e58 100644 --- a/mers/Cargo.toml +++ b/mers/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mers" -version = "0.9.17" +version = "0.9.18" 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.17" +mers_lib = "0.9.18" # 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 cc35bc6..6b0992e 100755 --- a/mers_lib/Cargo.toml +++ b/mers_lib/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mers_lib" -version = "0.9.17" +version = "0.9.18" 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/run/object.rs b/mers_lib/src/program/run/object.rs index 3852ced..b7ca930 100644 --- a/mers_lib/src/program/run/object.rs +++ b/mers_lib/src/program/run/object.rs @@ -18,7 +18,9 @@ impl MersStatement for Object { info: &mut super::CheckInfo, init_to: Option<&Type>, ) -> Result { + let mut init_to_is_empty_type = false; 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 mut init_fields = HashMap::new(); for t in init_to.types.iter() { @@ -67,6 +69,8 @@ impl MersStatement for Object { if let Some(f) = &mut init_fields { Some(if let Some(s) = f.remove(field) { s + } else if init_to_is_empty_type { + Type::empty() } else { return Err(CheckError::new().msg(vec![ ("can't init an ".to_owned(), None), diff --git a/merslsp/Cargo.toml b/merslsp/Cargo.toml index a87522f..63bfd3c 100644 --- a/merslsp/Cargo.toml +++ b/merslsp/Cargo.toml @@ -4,7 +4,7 @@ version = "0.9.15" edition = "2021" [dependencies] -mers_lib = "0.9.14" +mers_lib = "0.9.18" lspower = "1.5.0" tokio = { version = "1.36.0", features = ["full"] } line-span = "0.1.5"