diff --git a/examples/record_to_tuple.myc b/examples/record_to_tuple.myc deleted file mode 100644 index ad5325c..0000000 --- a/examples/record_to_tuple.myc +++ /dev/null @@ -1,12 +0,0 @@ -;; Record to Tuple Mapping Test -;; Output: 30 -;; Benchmark: 727ns -;; Benchmark-Repeat: 2764 -(do - (def rec {:x 10 :y 20}) - - ;; Map record to tuple pattern - (def add-tuple (fn [[a b]] (+ a b))) - - (add-tuple rec) -) diff --git a/examples/record_unpack.myc b/examples/record_unpack.myc deleted file mode 100644 index f1d99ef..0000000 --- a/examples/record_unpack.myc +++ /dev/null @@ -1,11 +0,0 @@ -;; Benchmark: Record Destructuring Performance -;; This test calls a function that destructures a record -;; Current implementation is now zero-allocation for destructuring. -;; Output: 3 -;; Benchmark: 129ns -;; Benchmark-Repeat: 15432 - -(do - (def process (fn [[x y]] (+ x y))) - (process {:a 1 :b 2}) -) diff --git a/src/ast/compiler/type_checker.rs b/src/ast/compiler/type_checker.rs index 7d3ad96..875a308 100644 --- a/src/ast/compiler/type_checker.rs +++ b/src/ast/compiler/type_checker.rs @@ -627,15 +627,6 @@ mod tests { assert_eq!(get_ret_type(&result.unwrap()), StaticType::Int); } - #[test] - fn test_destructuring_record_args() { - let env = crate::ast::environment::Environment::new(); - // ((fn [[x y]] (+ x y)) {:a 5 :b 7}) -> 12 - let result = env.compile("((fn [[x y]] (+ x y)) {:a 5 :b 7})"); - assert!(result.is_ok()); - assert_eq!(get_ret_type(&result.unwrap()), StaticType::Int); - } - fn get_ret_type(node: &TypedNode) -> StaticType { if let StaticType::Function(sig) = &node.ty { sig.ret.clone() diff --git a/src/ast/types.rs b/src/ast/types.rs index 0695d22..32fc9fd 100644 --- a/src/ast/types.rs +++ b/src/ast/types.rs @@ -299,16 +299,6 @@ impl StaticType { .zip(other_elements.iter()) .all(|(e, o)| e.is_assignable_from(o)) } - // Record to Tuple (Destructuring by values) - (StaticType::Tuple(elements), StaticType::Record(fields)) => { - if elements.len() != fields.len() { - return false; - } - elements - .iter() - .zip(fields.iter().map(|(_, ty)| ty)) - .all(|(e, o)| e.is_assignable_from(o)) - } // A Matrix is a Vector (of Vectors/Matrices) (StaticType::Vector(inner, len), StaticType::Matrix(m_inner, shape)) => { if shape.is_empty() || shape[0] != *len { @@ -367,11 +357,10 @@ impl Value { } } - /// Returns the underlying values as a slice if this is a Tuple or Record. + /// Returns the underlying values as a slice if this is a Tuple. pub fn as_slice(&self) -> Option<&[Value]> { match self { Value::Tuple(v) => Some(v), - Value::Record(r) => Some(&r.values), _ => None, } } diff --git a/src/integration_test.rs b/src/integration_test.rs index 8418b1d..953c006 100644 --- a/src/integration_test.rs +++ b/src/integration_test.rs @@ -301,16 +301,6 @@ mod tests { "Nested tuple should be folded to 30. Dump:\n{}", dump_tuple ); - - // 2. Record-to-Tuple - let source_record = "((fn [[x y]] (+ x y)) {:a 5 :b 7})"; - assert_eq!(format!("{}", env.run_script(source_record).unwrap()), "12"); - let dump_record = env.dump_ast(source_record).unwrap(); - assert!( - dump_record.contains("Constant: 12"), - "Record-to-Tuple destructuring should be folded to 12. Dump:\n{}", - dump_record - ); } #[test]