`Export.Parse` accepts a re-bound expr id and a 2nd JSON object on one line (lean4lean `--import` uses it)
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 66/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- backend
Hướng nghiên cứu
Start with Export/Parse.lean and compare it with the core copy at src/LeanExport/Parse.lean, focusing on the duplicate expression ID and end-of-input checks described in the issue. Reproduce both malformed inputs using the provided scripts and verify that parsing rejects them; the issue’s done criteria are that neither malformed file is accepted.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
The parser in Export/Parse.lean (master df81913) accepts two kinds of malformed files that the copy in core (src/LeanExport/Parse.lean) rejects:
- an expr id bound twice (core:
Expr index N bound twice) - two JSON objects on one line; the 2nd is silently dropped (core:
Invalid JSON: ... expected end of input)
lean4lean --import reads exports with this parser (its lake-manifest pins lean4export df81913), so it accepts both files. For (2) the dropped object can be a theorem that is then never checked.
Repro
-- Two.lean
def two : Nat := 2
theorem two_eq : two = 2 := rfl
lean Two.lean -o Two.olean
LEAN_PATH=$(lean --print-libdir):. leanexport Two -- two_eq > two.ndjson
python3 dupid.py two.ndjson > dup-id.ndjson
python3 twoobj.py two.ndjson > two-objects.ndjson
dupid.py:
import json, sys
# bind the id of the literal `2` a 2nd time, to 3
L = open(sys.argv[1]).read().splitlines()
i = next(i for i, l in enumerate(L) if '"natVal":"2"' in l)
k = json.loads(L[i])["ie"]
L.insert(i + 1, json.dumps({"ie": k, "natVal": "3"}))
print("\n".join(L))
twoobj.py (the 2nd object is a theorem bad whose value is its own type):
import json, sys
# append a 2nd, ill-typed theorem `bad` to the line of `theorem two_eq`
L = open(sys.argv[1]).read().splitlines()
mx = max(json.loads(l).get("in", 0) for l in L)
for i, l in enumerate(L):
o = json.loads(l)
if "thm" in o:
b = dict(o["thm"]); b["name"] = mx + 1; b["all"] = [mx + 1]
b["value"] = b["type"] # a type used as its own proof
L[i] = l + json.dumps({"thm": b})
L.insert(i, json.dumps({"in": mx + 1, "str": {"pre": 0, "str": "bad"}}))
break
print("\n".join(L))
Result (nightly-2026-11-26 bundled checkers)
| file | leanchecker | paranoid | lean4lean | nanoda | con-leche | con-ron |
|---|---|---|---|---|---|---|
| dup-id | reject | reject | accept | decline | malformed (exit 3) | malformed (exit 3) |
| two-objects | reject | reject | accept | reject | malformed (exit 3) | malformed (exit 3) |
lean4lean prints checked 8 declarations for both. v4.36.0 gives the same, except that v4.36.0 con-leche/con-ron also accept dup-id.
Impact
leanexport doesn't write such files, and --paranoid still rejects (leanchecker). But anything that trusts Export.Parse alone can be fed a file whose content isn't what got checked. Porting the bound twice checks and the end-of-input check from core would fix both.
- Ngôn ngữ chính
- Lean
- Star
- 52
- Fork
- 30
- 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 leanprover/lean4export
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
leanprover/lean4export#40 · 6 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 8/100
leanprover/lean4export#62 · 2 bình luận ·
-
Exported binder names and binder info depend on what else is exportedCó thể đã có người làm @JoAdo07 đã nhận 31 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 76/100
leanprover/lean4export#58 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
leanprover/lean4export#48 · 1 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
leanprover/lean4export#8 · 2 bình luận ·
Tất cả issue của leanprover/lean4export
Issue tương tự
-
Thai project names become 'project', 'project-2'… (slug keeps ASCII only)Có thể đã có người làm @mastel2 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
storytold/craft-anything#2538 ·
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 70/100
compiler-explorer/compiler-explorer#9738 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
openfoodfacts/openfoodfacts-python#573 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Rasterio reads over HTTPS do not send the Earthdata token and return 500 "HTTP response code: 404"Đang mởcredentials rasterio
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
developmentseed/titiler-cmr#359 ·
Maintainer thường phản hồi trong vòng 1 ngày