diff --git a/src/ast/compiler/macros.rs b/src/ast/compiler/macros.rs index 594713a..66510d7 100644 --- a/src/ast/compiler/macros.rs +++ b/src/ast/compiler/macros.rs @@ -493,9 +493,9 @@ mod tests { if let UntypedKind::Block { exprs } = &expanded.kind { if let UntypedKind::Expansion { call: _, expanded: result } = &exprs[1].kind { if let UntypedKind::If { cond, then_br, else_br } = &result.kind { - if let UntypedKind::Constant(Value::Bool(b)) = &cond.kind { - assert_eq!(*b, false); - } else { panic!("Expected false, got {:?}", cond.kind); } + 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))); if let Some(eb) = else_br { if let UntypedKind::Constant(Value::Int(n)) = &eb.kind { diff --git a/src/ast/parser.rs b/src/ast/parser.rs index 176a316..7fa1ffc 100644 --- a/src/ast/parser.rs +++ b/src/ast/parser.rs @@ -92,8 +92,6 @@ impl<'a> Parser<'a> { TokenKind::Identifier(id) => { match id.as_ref() { "..." => UntypedKind::Nop, - "true" => UntypedKind::Constant(Value::Bool(true)), - "false" => UntypedKind::Constant(Value::Bool(false)), "void" => UntypedKind::Constant(Value::Void), _ => UntypedKind::Identifier(id.into()), } diff --git a/src/ast/rtl/core.rs b/src/ast/rtl/core.rs index 99c8681..6722d83 100644 --- a/src/ast/rtl/core.rs +++ b/src/ast/rtl/core.rs @@ -16,6 +16,8 @@ fn register_constants(env: &Environment) { // We register NaN as a value, not a function. env.register_constant("NaN", StaticType::Float, Value::Float(f64::NAN)); + env.register_constant("true", StaticType::Bool, Value::Bool(true)); + env.register_constant("false", StaticType::Bool, Value::Bool(false)); } fn register_arithmetic(env: &Environment) {