Have `?` fall back to stringObj.

Note that ->forward is not used once an Object is in the environment.
This commit is contained in:
Sage Vaillancourt 2022-04-07 23:56:03 -04:00
parent 03d3247be3
commit a2b0e0813b
2 changed files with 12 additions and 1 deletions

View File

@ -410,6 +410,14 @@ Object help(Object* params, int length, struct Environment* env)
return text; return text;
} }
} }
Object* object = fetch(symbol, env);
if (object) {
size_t len;
char* string = stringObj(object, &len);
Object text = stringFromSlice(string, len);
free(string);
return text;
}
return nullTerminated("Help not found!"); return nullTerminated("Help not found!");
} }

View File

@ -106,7 +106,10 @@ struct Object {
#endif #endif
}; };
union {
Object* forward; Object* forward;
char* docString;
};
}; };
struct StructDef { struct StructDef {