From a265854c0b515f4415ec5c6d1d04c02c4769488a Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Thu, 25 Jul 2024 19:35:46 -0500 Subject: [PATCH] make symbol and value macros error when undefined --- src/kiss/Macros.hx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/kiss/Macros.hx b/src/kiss/Macros.hx index 059821a..33e5f4d 100644 --- a/src/kiss/Macros.hx +++ b/src/kiss/Macros.hx @@ -275,13 +275,23 @@ class Macros { k.doc("#value", 1, 1, '(#value "")'); macros["#value"] = (wholeExp:ReaderExp, args:Array, k:KissState) -> { var b = wholeExp.expBuilder(); - b.str(Context.definedValue(compileTimeResolveToString("The only argument to (#value...)", "a compiler flag's name", args[0], k))); + var key = compileTimeResolveToString("The only argument to (#value...)", "a compiler flag's name", args[0], k); + var value = Context.definedValue(key); + if (value == null) { + throw KissError.fromExp(wholeExp, 'Compiler value "$key" is not defined'); + } + b.str(value); }; k.doc("#symbol", 1, 1, '(#symbol "")'); macros["#symbol"] = (wholeExp:ReaderExp, args:Array, k:KissState) -> { var b = wholeExp.expBuilder(); - b.symbol(Context.definedValue(compileTimeResolveToString("The only argument to (#symbol...)", "a compiler flag's name", args[0], k))); + var key = compileTimeResolveToString("The only argument to (#value...)", "a compiler flag's name", args[0], k); + var value = Context.definedValue(key); + if (value == null) { + throw KissError.fromExp(wholeExp, 'Compiler value $key is not defined'); + } + b.symbol(value); }; k.doc("or", 1, null, "(or )");