diff --git a/src/object.c b/src/object.c index 128194d..c8cc3be 100644 --- a/src/object.c +++ b/src/object.c @@ -122,6 +122,7 @@ static const char* errorText[] = { "NULL_MAP_ARGS", "LAMBDA_ARGS_NOT_LIST", "DID_NOT_FIND_SYMBOL", + "BAD_SYMBOL", "BAD_TYPE", "BAD_PARAMS", "BAD_NUMBER", diff --git a/src/object.h b/src/object.h index 5b6a744..45e21da 100644 --- a/src/object.h +++ b/src/object.h @@ -22,7 +22,13 @@ #ifdef RELEASE #define assert(...) do { } while (0) #else -#define assert(...) do {if (!(__VA_ARGS__)) {eprintf("\nassertion '" # __VA_ARGS__ "' at %s:%d failed!\nBailing!\n", __FILE__, __LINE__); int* X = NULL; unused int Y = *X;}} while (0) +#define assert(...) do { \ + if (!(__VA_ARGS__)) { \ + eprintf("\nassertion '" # __VA_ARGS__ "' at %s:%d failed!\nBailing!\n", __FILE__, __LINE__); \ + int* X = NULL; \ + unused int Y = *X; \ + }\ +} while (0) #endif #define MAX_TOK_CNT 2048 @@ -94,6 +100,7 @@ enum errorCode { NULL_MAP_ARGS, LAMBDA_ARGS_NOT_LIST, DID_NOT_FIND_SYMBOL, + BAD_SYMBOL, BAD_TYPE, BAD_PARAMS, BAD_NUMBER, diff --git a/src/pebblisp.c b/src/pebblisp.c index 10ec35a..267900c 100644 --- a/src/pebblisp.c +++ b/src/pebblisp.c @@ -54,14 +54,16 @@ Object listDef(Object* nameList, Object* valueList, struct Environment* env) * @param env The environment to add the new definition to * @return The symbol(s) defined */ -Object def(Object* params, unused int length, struct Environment* env) +Object def(Object* params, int length, struct Environment* env) { - if (isStringy(params[0])) { - return singleDef(params[0].string, ¶ms[1], env); - } + if (length == 2) { + if (isStringy(params[0])) { + return singleDef(params[0].string, ¶ms[1], env); + } - if (length == 2 && isListy(params[0]) && isListy(params[1])) { - return listDef(¶ms[0], ¶ms[1], env); + if (isListy(params[0]) && isListy(params[1])) { + return listDef(¶ms[0], ¶ms[1], env); + } } throw(BAD_TYPE, "Poorly constructed (def)");