changeset 162:f6c1d15232ee

eval: Remove unreachable code
author Lewin Bormann <lbo@spheniscida.de>
date Tue, 03 Sep 2019 17:16:05 +0200
parents 72a52494df50
children 2448ebe4a586
files src/eval.c src/eval_test.c
diffstat 2 files changed, 3 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/eval.c	Tue Sep 03 17:00:26 2019 +0200
+++ b/src/eval.c	Tue Sep 03 17:16:05 2019 +0200
@@ -128,20 +128,9 @@
                         }
                         return result;
                     } else if (val->typ == YVALUE_EXPR) {
-                        // resolve as normal below; this seems to be a "data
-                        // list".
-                    } else {
-                        yexpr_t exc = yexpr_new();
-                        ystr_t msg = ystr_new(NULL);
-                        ystr_build(&msg, "possibly undefined function: ");
-                        ystr_t dbg = yref_debug(&first->value.ref);
-                        ystr_append(&msg, &dbg);
-                        ystr_destroy(&dbg);
-                        yexpr_set_exception(&exc, msg);
-                        return exc;
-                        assert(val->typ == YVALUE_FUNC ||
-                               val->typ == YVALUE_EXPR);
+                        assert(val->typ == YVALUE_FUNC /* yeval() should have returned a copy of the expression if first element was a reference to an expression */);
                     }
+                    assert(false /* yeval() on a reference should have prevented any other case */);
                 }
                 yexpr_destroy(&ref);
             }
--- a/src/eval_test.c	Tue Sep 03 17:00:26 2019 +0200
+++ b/src/eval_test.c	Tue Sep 03 17:16:05 2019 +0200
@@ -113,6 +113,7 @@
 
     ystr_t input = ystr_new(
             "(defn f (a) (+ a 1))"
+            "(let x 4)"
             "(f g)");
 
     yexpr_t program = yexpr_new();