An assignment used as an expression, such as `(x = 7);` or `const y = (x = 7)`, is extracted as an equality test, so a false `ensures` can verify
Maintainer thường phản hồi trong vòng 1 ngày
@namin đang làm issue này rồi.
Từ ngày 23/11/2026.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- Nửa 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ệ
- typescript
- Lĩnh vực
- compilers
Hướng nghiên cứu
Start in tools/src/extract.ts: the op === "=" branch in extractExpr (around line 516) emits a binop that later becomes ==, and desugarStmtExpr (around line 1350) does not unwrap a ParenthesizedExpression before checking for an assignment. Done means (x = 7); and const y = (x = 7); lower to an assignment or a source-positioned error, and the parenWholeAssign example no longer verifies. Note that pull request #363 is already open against this issue.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
When a JavaScript assignment appears in expression position, extract turns it into the IR's equality operator. (x = 7); and const y = (x = 7); therefore emit x == 7, the assignment disappears, and a false ensures verifies.
Reproduced on upstream main at 2ccd0a5 (0.6.11) with Dafny 4.11.0.
Reproduction
export function parenWholeAssign(p: number): number {
//@ ensures p === 0 ==> \result === 0
let x = p;
(x = 7);
return x;
}
parenWholeAssign(0) returns 7 in JavaScript. lsc gen --backend=dafny emits:
method parenWholeAssign(p: int) returns (res: int)
ensures ((p == 0) ==> (res == 0))
{
var x := p;
var _ := (x == 7);
return x;
}
and dafny verify reports 1 verified, 0 errors.
The same happens with an assignment in an initializer:
export function assignInInit(p: number): number {
//@ ensures p === 0 ==> \result === 0
let x = p;
const y = (x = 7);
return x;
}
emits var y := (x == 7); and verifies (1 verified, 0 errors), while JavaScript returns 7.
if ((x = 7) > 0) emits if ((x == 7) > 0), which Dafny rejects as a type error, so that form fails loudly.
Expected
A parenthesized assignment statement such as (x = 7); should be lowered the same way as x = 7;. An assignment anywhere else inside an expression should either be supported or be rejected with a source-positioned error. It should never become an equality test.
Likely cause
In tools/src/extract.ts:
extractExprhandlesop === "="by returning{ kind: "binop", op: "=", ... }(around line 516, commented "extract as binop for now"). Later passes treat binop"="as equality, which the Dafny emitter prints as==.desugarStmtExpr(line 1350) checksNode.isBinaryExpression(expr)without unwrapping aParenthesizedExpression, so(x = 7);falls through to an expression statement and reaches the branch above. Theforincrementor path also callsdesugarStmtExpr.
Related
- #355: a parenthesized assignment target,
(x) = 7, in the same function. That one fails to parse in Dafny. Both need parentheses unwrapped indesugarStmtExpr.
- Ngôn ngữ chính
- TypeScript
- Star
- 113
- Fork
- 13
- Merge trung bình
- 12 giờ 22 phút
- Pull request đã merge (30 ngày)
- 64
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 midspiral/LemmaScript
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 62/100
midspiral/LemmaScript#354 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Narrowing substitution skips lambda bodies and loop `decreases`/`done_with` clauses, leaving the unnarrowed variable in the outputCó thể đã có người làm @robertpenner đã nhận 2 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
midspiral/LemmaScript#353 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`??` or `?.` on a value whose type is not optional crashes `lsc gen` with "reached transform"Đang mở
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 66/100
midspiral/LemmaScript#352 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
midspiral/LemmaScript#350 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 12/100
midspiral/LemmaScript#349 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của midspiral/LemmaScript
Issue tương tự
-
Y2025: QBI forms print a negative taxable income; Form 8995-A lines 14b/14c check the wrong columnĐang mở
Độ 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 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
readest/readest#7903 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
type: documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Oddmash/oddmash-ui#72 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug good first issue priority: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
TMHSDigital/steam-mcp#106 ·
-
bug priority:p3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
LCNINE/almondyoung-server#1562 ·
Maintainer thường phản hồi trong vòng 1 ngày