shithub: femtolisp

Download patch

ref: fe8b88cfc681d085c706f4364fd19b295ae7444b
parent: a0707331b8b358023e63c3123e3abe49de450dc4
author: Jeff Bezanson <jeff.bezanson@gmail.com>
date: Sat Mar 30 20:20:54 EDT 2013

fix bug printing custom cvalue types that lack print methods

--- a/cvalues.c
+++ b/cvalues.c
@@ -768,7 +768,6 @@
         return T_FLOAT;
     else if (type == doublesym)
         return T_DOUBLE;
-    assert(0);
     return N_NUMTYPES;
 }
 
--- a/print.c
+++ b/print.c
@@ -700,11 +700,17 @@
     else if (issymbol(type)) {
         // handle other integer prims. we know it's smaller than uint64
         // at this point, so int64 is big enough to capture everything.
-        int64_t i64 = conv_to_int64(data, sym_to_numtype(type));
-        if (weak || print_princ)
-            HPOS += ios_printf(f, "%lld", i64);
-        else
-            HPOS += ios_printf(f, "#%s(%lld)", symbol_name(type), i64);
+        numerictype_t nt = sym_to_numtype(type);
+        if (nt == N_NUMTYPES) {
+            HPOS += ios_printf(f, "#<%s>", symbol_name(type));
+        }
+        else {
+            int64_t i64 = conv_to_int64(data, sym_to_numtype(type));
+            if (weak || print_princ)
+                HPOS += ios_printf(f, "%lld", i64);
+            else
+                HPOS += ios_printf(f, "#%s(%lld)", symbol_name(type), i64);
+        }
     }
     else if (iscons(type)) {
         if (car_(type) == arraysym) {