From 6c430707925a0d66d42bc93bc839c10455200d68 Mon Sep 17 00:00:00 2001 From: rzvxa Date: Tue, 16 Jul 2024 18:44:18 +0330 Subject: [PATCH] test: add assertion for non ast visitable(which is wrong!) --- tasks/ast_codegen/src/schema.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tasks/ast_codegen/src/schema.rs b/tasks/ast_codegen/src/schema.rs index a4ff8d2a554a57..9054a7c7e02376 100644 --- a/tasks/ast_codegen/src/schema.rs +++ b/tasks/ast_codegen/src/schema.rs @@ -154,9 +154,15 @@ impl RType { } pub fn set_visitable(&mut self, value: bool) -> Result<()> { + macro_rules! assign { + ($it:ident) => {{ + debug_assert!($it.meta.ast, "only ast types can be visitable!"); + $it.meta.visitable = value; + }}; + } match self { - RType::Enum(it) => it.meta.visitable = value, - RType::Struct(it) => it.meta.visitable = value, + RType::Enum(it) => assign!(it), + RType::Struct(it) => assign!(it), _ => return Err("Unsupported type!".to_string()), } Ok(())