-
-
Save FROGGS/6dde2440e37351c834fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/core/coerce.c b/src/core/coerce.c | |
index c74fd67..b3e121d 100644 | |
--- a/src/core/coerce.c | |
+++ b/src/core/coerce.c | |
@@ -71,9 +71,16 @@ void MVM_coerce_istrue(MVMThreadContext *tc, MVMObject *obj, MVMRegister *res_re | |
case MVM_BOOL_MODE_UNBOX_NUM: | |
result = !IS_CONCRETE(obj) || REPR(obj)->box_funcs.get_num(tc, STABLE(obj), obj, OBJECT_BODY(obj)) == 0.0 ? 0 : 1; | |
break; | |
- case MVM_BOOL_MODE_UNBOX_STR_NOT_EMPTY: | |
- result = !IS_CONCRETE(obj) || MVM_string_graphs(tc, REPR(obj)->box_funcs.get_str(tc, STABLE(obj), obj, OBJECT_BODY(obj))) == 0 ? 0 : 1; | |
+ case MVM_BOOL_MODE_UNBOX_STR_NOT_EMPTY: { | |
+ MVMString *str; | |
+ if (!IS_CONCRETE(obj)) { | |
+ result = 0; | |
+ break; | |
+ } | |
+ str = REPR(obj)->box_funcs.get_str(tc, STABLE(obj), obj, OBJECT_BODY(obj)); | |
+ result = MVM_coerce_istrue_s(tc, str); | |
break; | |
+ } | |
case MVM_BOOL_MODE_UNBOX_STR_NOT_EMPTY_OR_ZERO: { | |
MVMString *str; | |
if (!IS_CONCRETE(obj)) { | |
@@ -81,7 +88,10 @@ void MVM_coerce_istrue(MVMThreadContext *tc, MVMObject *obj, MVMRegister *res_re | |
break; | |
} | |
str = REPR(obj)->box_funcs.get_str(tc, STABLE(obj), obj, OBJECT_BODY(obj)); | |
- result = MVM_coerce_istrue_s(tc, str); | |
+ result = str == NULL || | |
+ !IS_CONCRETE(str) || | |
+ (MVM_string_graphs(tc, str) == 1 && MVM_string_get_grapheme_at_nocheck(tc, str, 0) == 48) | |
+ ? 0 : 1; | |
break; | |
} | |
case MVM_BOOL_MODE_NOT_TYPE_OBJECT: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment