Repository navigation
Conversation
`start_type + end_type < 2*IS_STRING` is not right, in this test case the types are start_type==5 (IS_DOUBLE), end_type==7 (IS_ARRAY). The IS_ARRAY type is a sentinel to disambiguate single-byte strings. The path must be taken when one of the types is not a string nor a single-byte string. Therefore, use < IS_STRING with an OR condition.
| if (start_type >= IS_STRING || end_type >= IS_STRING) { | ||
| /* If one of the inputs is NOT a string */ | ||
| if (UNEXPECTED(start_type + end_type < 2*IS_STRING)) { | ||
| /* If one of the inputs is NOT a string nor single-byte string */ |
There was a problem hiding this comment.
Gina, please double-check my edit to this comment :-)
There was a problem hiding this comment.
This took a hot minute, but I think this is correct, yes.
As the initial logic was that one of the inputs is a valid string (be single byte or not) and the other one is either an int or float. Thus it "wouldn't" be more than 2*IS_STRING in my head.
Girgias
left a comment
There was a problem hiding this comment.
Don't know why I didn't do this in the first place. Was probably trying to be smart.
| if (start_type >= IS_STRING || end_type >= IS_STRING) { | ||
| /* If one of the inputs is NOT a string */ | ||
| if (UNEXPECTED(start_type + end_type < 2*IS_STRING)) { | ||
| /* If one of the inputs is NOT a string nor single-byte string */ |
There was a problem hiding this comment.
This took a hot minute, but I think this is correct, yes.
As the initial logic was that one of the inputs is a valid string (be single byte or not) and the other one is either an int or float. Thus it "wouldn't" be more than 2*IS_STRING in my head.
start_type + end_type < 2*IS_STRINGis not right, in this test case the types are start_type==5 (IS_DOUBLE), end_type==7 (IS_ARRAY). The IS_ARRAY type is a sentinel to disambiguate single-byte strings. The path must be taken when one of the types is not a string nor a single-byte string. Therefore, use < IS_STRING with an OR condition.