(comment on #611) `function g(a, d = (a = 10)) { return a; }` returns the argument instead of 10
Maintainer thường phản hồi trong vòng 5 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 30/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- c, javascript
- Lĩnh vực
- compilers
Hướng nghiên cứu
Repro is ./qjs t.js with the g/k/f snippets; run it first to confirm 1 [1,10] and 1. The relevant path is FunctionDeclarationInstantiation: fd->has_parameter_expressions, the argument-scope copy through OP_get_arg and OP_scope_put_var_init, and body lookup via find_var/find_arg falling back to fd->args. Done when g(1) and f(1) print 10 and 5 and existing tests still pass.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
One more from the same run, on master e585640 (2026-11-10) and release 2026-06-04 (./qjs t.js).
3. Parameter assignment in a default initializer (or parameter-scope closure) is not visible in the function body.
function g(a, d = (a = 10)) { return a; }
function k(a, c = () => a, d = (a = 10)) { return [a, c()]; }
console.log(g(1), JSON.stringify(k(1)));
// expected: 10 [10,10]
./qjs t.js prints 1 [1,10]. Because the body has no var a, the parameter list and body share one binding for a (FunctionDeclarationInstantiation steps 27-28), so the assignment a = 10 during d's initializer must be visible in the body. The same happens when a closure created in the parameter list assigns to a later:
function f(a, set = () => { a = 5; }) { set(); return a; }
console.log(f(1)); // expected: 5
./qjs t.js prints 1. When fd->has_parameter_expressions is true, QuickJS copies each plain parameter into a separate JS_VAR_DEF_LET variable in the argument scope (OP_get_arg + OP_scope_put_var_init) so expressions and closures in the parameter list read/write that lexical variable, while the body resolves a to the original fd->args slot via find_var (find_arg) unless a body var shadows it.
Credit: https://ucsbplse.github.io/
- Ngôn ngữ chính
- C
- Star
- 11.1k
- Fork
- 1.2k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của bellard/quickjs
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 5 ngày
-
RegExp: patterns with more than 255 capture groups fail with "too many captures"Có thể đã có người làm @andreasrosdal đã nhận 3 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
bellard/quickjs#624 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 5 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
bellard/quickjs#620 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 5 ngày
-
Account for Map/Set retained strings in JS_ComputeMemoryUsage, or document partial accountingĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 30/100
Maintainer thường phản hồi trong vòng 5 ngày
-
`{ ..."ab" }` is `{}`; a throw in a `for await` body does not wait for the iterator's return()Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
bellard/quickjs#611 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 5 ngày
Tất cả issue của bellard/quickjs
Issue tương tự
-
Fix a typo in H5Centry.cĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
FujiNetWIFI/fujinet-firmware#2518 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[mimalloc] update to 3.7.1Đang mởcategory:port-update
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 2 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
lauppv/cyberstars#610 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100