From 5e03be17ade373b26453a00781feb1f951214e9b Mon Sep 17 00:00:00 2001 From: Michael Schimmel Date: Thu, 19 Feb 2026 14:05:32 +0100 Subject: [PATCH] Fix: Use NOP instead of void in unless macro The `unless` macro's expansion was updated to use `...` (NOP) instead of `void`. This change also involved removing the `void` keyword from the parser, as it is no longer used. --- examples/macro_unless.myc | 4 ++-- src/ast/compiler/macros.rs | 4 ++-- src/ast/parser.rs | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/examples/macro_unless.myc b/examples/macro_unless.myc index f591a88..dcd7f78 100644 --- a/examples/macro_unless.myc +++ b/examples/macro_unless.myc @@ -1,8 +1,8 @@ -;; Benchmark: 100ns +;; Benchmark: 100ns ;; Classic "unless" macro example ;; Demonstrates simple template substitution. ;; Output: 42 (do - (macro unless [c b] `(if ~c void ~b)) + (macro unless [c b] `(if ~c ... ~b)) (unless false 42)) diff --git a/src/ast/compiler/macros.rs b/src/ast/compiler/macros.rs index 66510d7..9f93dc8 100644 --- a/src/ast/compiler/macros.rs +++ b/src/ast/compiler/macros.rs @@ -481,7 +481,7 @@ mod tests { fn test_macro_expansion_unless() { let source = " (do - (macro unless [c b] `(if ~c void ~b)) + (macro unless [c b] `(if ~c ... ~b)) (unless false 42)) "; let mut parser = Parser::new(source).unwrap(); @@ -496,7 +496,7 @@ mod tests { if let UntypedKind::Identifier(sym) = &cond.kind { assert_eq!(sym.name.as_ref(), "false"); } else { panic!("Expected identifier 'false', got {:?}", cond.kind); } - assert!(matches!(then_br.kind, UntypedKind::Constant(Value::Void))); + assert!(matches!(then_br.kind, UntypedKind::Nop)); if let Some(eb) = else_br { if let UntypedKind::Constant(Value::Int(n)) = &eb.kind { assert_eq!(*n, 42); diff --git a/src/ast/parser.rs b/src/ast/parser.rs index 7fa1ffc..30bae36 100644 --- a/src/ast/parser.rs +++ b/src/ast/parser.rs @@ -92,7 +92,6 @@ impl<'a> Parser<'a> { TokenKind::Identifier(id) => { match id.as_ref() { "..." => UntypedKind::Nop, - "void" => UntypedKind::Constant(Value::Void), _ => UntypedKind::Identifier(id.into()), } }