don't explode on bad repr print?
This commit is contained in:
parent
cc236b8da3
commit
76b0b50154
2
value.c
2
value.c
@ -59,10 +59,12 @@ void krk_printValue(FILE * f, KrkValue printable) {
|
||||
if (type->_tostr) {
|
||||
krk_push(printable);
|
||||
printable = krk_callSimple(OBJECT_VAL(type->_tostr), 1, 0);
|
||||
if (!IS_STRING(printable)) return;
|
||||
fprintf(f, "%s", AS_CSTRING(printable));
|
||||
} else if (type->_reprer) {
|
||||
krk_push(printable);
|
||||
printable = krk_callSimple(OBJECT_VAL(type->_reprer), 1, 0);
|
||||
if (!IS_STRING(printable)) return;
|
||||
fprintf(f, "%s", AS_CSTRING(printable));
|
||||
} else {
|
||||
fprintf(f, "%s", krk_typeName(printable));
|
||||
|
2
vm.c
2
vm.c
@ -1470,7 +1470,7 @@ static KrkValue _char_to_int(int argc, KrkValue argv[]) {
|
||||
}
|
||||
|
||||
/* TODO unicode strings? Interpret as UTF-8 and return codepoint? */
|
||||
return INTEGER_VAL(AS_CSTRING(argv[0])[0]);
|
||||
return INTEGER_VAL(((unsigned char)AS_CSTRING(argv[0])[0]));
|
||||
}
|
||||
|
||||
static KrkValue _print(int argc, KrkValue argv[], int hasKw) {
|
||||
|
Loading…
Reference in New Issue
Block a user