Add missing BAD_SYMBOL error
This commit is contained in:
parent
a145b436c9
commit
9b6b80f204
|
@ -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",
|
||||
|
|
|
@ -22,7 +22,13 @@
|
|||
#ifdef RELEASE
|
||||
#define assert(...) do { } while (0)
|
||||
#else
|
||||
#define assert(...) do {if (!(__VA_ARGS__)) {eprintf("\n[31;1massertion '" # __VA_ARGS__ "' at %s:%d failed!\nBailing![0m\n", __FILE__, __LINE__); int* X = NULL; unused int Y = *X;}} while (0)
|
||||
#define assert(...) do { \
|
||||
if (!(__VA_ARGS__)) { \
|
||||
eprintf("\n[31;1massertion '" # __VA_ARGS__ "' at %s:%d failed!\nBailing![0m\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,
|
||||
|
|
|
@ -54,15 +54,17 @@ 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 (length == 2) {
|
||||
if (isStringy(params[0])) {
|
||||
return singleDef(params[0].string, ¶ms[1], env);
|
||||
}
|
||||
|
||||
if (length == 2 && isListy(params[0]) && isListy(params[1])) {
|
||||
if (isListy(params[0]) && isListy(params[1])) {
|
||||
return listDef(¶ms[0], ¶ms[1], env);
|
||||
}
|
||||
}
|
||||
|
||||
throw(BAD_TYPE, "Poorly constructed (def)");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue