regexp literal after for/if/while header causes SyntaxError in js_parse_skip_parens_token
维护者通常 5 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- c, javascript
- 领域
- compilers
调研方向
Start by reading js_parse_skip_parens_token(), is_regexp_allowed(), and js_parse_regexp() in the parser; the issue identifies these as the paths involved in the incorrect lookahead and pending exception. Reproduce with the supplied snippets and trace how parsing handles / after each listed header. Done means all snippets parse and the IIFE leaves no pending syntax error.
由索引模型根据 Issue 内容生成。
描述
var f1 = (fn = function(e){ for (var r in e) /data-/gi.test(r); var s = "#"; }) => fn;
var f2 = (fn = function(){ for (var x in {a:1}) /[)]/.test(x); }) => fn;
var f3 = (fn = function(){ if (1) /[)]/.test(")"); }) => fn;
var f4 = (fn = function(){ while (0) /[)]/.test(")"); }) => fn;
var f5 = (fn = function(){ with ({}) /[)]/.test(")"); }) => fn;
var f6 = (fn = async function(){ for await (var x of [1]) /[)]/.test(")"); }) => fn;
All the valid snippets above fail to parse with SyntaxError: expecting ';'. In addition, for an IIFE like:
(function(e){ for (var r in e) /data-/gi.test(r); var s = "#"; })({a:1});
JS_Eval() succeeds, but JS_GetException(ctx) still returns a pending SyntaxError: unexpected end of regexp.
The root cause is that is_regexp_allowed(')') always returns FALSE inside js_parse_skip_parens_token(). However, after the closing ) of a for (...), for await (...), if (...), while (...), or with (...) header, a statement follows and / starts a regexp literal rather than division. Treating / as division breaks paren matching during lookahead and also leaves an uncleared exception in rt->current_exception when js_parse_regexp() fails. Could you help look into fixing this?
- 主要语言
- C
- 星标
- 11.1k
- 派生
- 1.2k
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
bellard/quickjs 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 75/100
维护者通常 5 天内回复
-
RegExp: patterns with more than 255 capture groups fail with "too many captures"可能已有人在做 @andreasrosdal 于 3 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 25/100
维护者通常 5 天内回复
-
(comment on #611) `function g(a, d = (a = 10)) { return a; }` returns the argument instead of 10未关闭
难度 4/5 3-5 天 新手友好度 30/100
维护者通常 5 天内回复
-
难度 4/5 3-5 天 新手友好度 30/100
维护者通常 5 天内回复
-
难度 5/5 一周以上 新手友好度 35/100
维护者通常 5 天内回复
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 85/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
FujiNetWIFI/fujinet-firmware#2518 ·
维护者通常 1 天内回复
-
category:port-update
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 2 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 72/100
lauppv/cyberstars#610 ·
维护者通常 1 天内回复
-
documentation good first issue help wanted
难度 2/5 1-3 小时 新手友好度 72/100