MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

add error handling for empty parenthesis

+8 -1
+8 -1
src/ant.c
··· 8245 8245 8246 8246 char err_buf[64]; 8247 8247 size_t tok_len = js->tlen > 20 ? 20 : js->tlen; 8248 - snprintf(err_buf, sizeof(err_buf), "Unexpected token '%.*s'", (int)tok_len, &js->code[js->toff]); 8248 + if (tok_len == 0) snprintf(err_buf, sizeof(err_buf), "Unexpected token 'EOF'"); else { 8249 + snprintf(err_buf, sizeof(err_buf), "Unexpected token '%.*s'", (int)tok_len, &js->code[js->toff]); 8250 + } 8249 8251 return js_mkerr_typed(js, JS_ERR_SYNTAX, err_buf); 8250 8252 } 8251 8253 } ··· 8392 8394 8393 8395 return js_arrow_func(js, paren_start, paren_end, false); 8394 8396 } else { 8397 + if (next(js) == TOK_RPAREN) { 8398 + js->parse_depth--; 8399 + return js_mkerr_typed(js, JS_ERR_SYNTAX, "Parenthesized expression cannot be empty"); 8400 + } 8401 + 8395 8402 jsval_t v = js_expr(js); 8396 8403 if (is_err(v)) { js->parse_depth--; return v; } 8397 8404