fix issues with parse.cm and tokenize.cm

This commit is contained in:
2026-02-09 17:43:44 -06:00
parent 68e2395b92
commit d5209e1d59
5 changed files with 201 additions and 57 deletions

View File

@@ -6283,8 +6283,8 @@ static JSValue js_cell_number (JSContext *ctx, JSValue this_val, int argc, JSVal
return val;
}
/* Handle string */
if (tag == JS_TAG_STRING || tag == JS_TAG_STRING_IMM) {
/* Handle string (immediate ASCII or heap JSText) */
if (JS_IsText (val)) {
const char *str = JS_ToCString (ctx, val);
if (!str) return JS_EXCEPTION;
@@ -6925,7 +6925,7 @@ JSValue js_cell_character (JSContext *ctx, JSValue this_val, int argc, JSValue *
int tag = JS_VALUE_GET_TAG (arg);
/* Handle string - return first character */
if (tag == JS_TAG_STRING || tag == JS_TAG_STRING_IMM) {
if (JS_IsText (arg)) {
if (js_string_value_len (arg) == 0) return JS_NewString (ctx, "");
return js_sub_string_val (ctx, arg, 0, 1);
}
@@ -6978,7 +6978,7 @@ static JSValue js_cell_text (JSContext *ctx, JSValue this_val, int argc, JSValue
int tag = JS_VALUE_GET_TAG (arg);
/* Handle string / rope */
if (tag == JS_TAG_STRING || tag == JS_TAG_STRING_IMM) {
if (JS_IsText (arg)) {
JSValue str = JS_ToString (ctx, arg); /* owned + flattens rope */
if (JS_IsException (str)) return JS_EXCEPTION;