make: fix catch of undefined plain symbol
authorJoel Martin <github@martintribe.org>
Wed, 31 Jul 2019 05:06:37 +0000 (00:06 -0500)
committerJoel Martin <github@martintribe.org>
Wed, 31 Jul 2019 17:17:17 +0000 (12:17 -0500)
The _error function was returning an empty string which meant that in
the try*/catch* implementation, the lack of result was preventing
foreach from being used as a "let" form and because of that it was
skipping the catch* handling path.

make/types.mk
tests/step9_try.mal

index 43016e5..7424cf7 100644 (file)
@@ -68,11 +68,6 @@ __var_print = $(foreach v,$(1),\
 _visualize_memory = $(foreach var,$(sort $(foreach vv,$(filter $(__obj_magic)_%,$(.VARIABLES)),$(call __var_name,$(vv)))),$(call __var_print,$(__obj_magic)_$(var)))
 
 
-# Errors/Exceptions
-__ERROR :=
-_error = $(eval __ERROR := $(call _string,$(1)))
-
-
 # Constant atomic values
 __undefined = $(__obj_magic)_undf_0
 __nil = $(__obj_magic)__nil_0
@@ -80,6 +75,11 @@ __true = $(__obj_magic)_true_0
 __false = $(__obj_magic)_fals_0
 
 
+# Errors/Exceptions
+__ERROR :=
+_error = $(eval __ERROR := $(call _string,$(1)))$(__nil)
+
+
 # General functions
 
 # Return the type of the object (or "make" if it's not a object
index d231b7f..8c07588 100644 (file)
 (try* 123 (catch* e 456))
 ;=>123
 
+(try* abc (catch* exc (prn "exc is:" exc)))
+;/"exc is:" "'abc' not found"
+;=>nil
+
 (try* (abc 1 2) (catch* exc (prn "exc is:" exc)))
 ;/"exc is:" "'abc' not found"
 ;=>nil