lambdaisland / lambdaisland/deep-diff2
Prettyprinted diff mangled when using advanced compilation in cljs
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Clojure
- Star
- 326
- Fork
- 18
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
Thanks for the awesome tool! We are currently using it in an internal web-based integration testing tool. It's working great right up until trying to display a pretty printed version of diffs.
It seems the pretty printer messes up the diff when compiled with advanced optimizations.
Here is a shell session demonstrating the problem:
❯ tree
.
├── deps.edn
└── src
└── ddiff_bug
└── core.cljs
3 directories, 2 files
❯ bat deps.edn
1 {:paths ["src"]
2 :deps { org.clojure/clojurescript {:mvn/version "1.11.132"}
3 lambdaisland/deep-diff2 {:mvn/version "2.11.216"}}}
❯ bat src/ddiff_bug/core.cljs
1 (ns ddiff-bug.core
2 (:require [lambdaisland.deep-diff2 :as ddiff]))
3
4
5 (enable-console-print!)
6
7 (defn diff-view
8 [a b]
9 (let [diff (ddiff/diff a b)
10 diffstr (with-out-str (ddiff/pretty-print diff))]
11 (println "\nDocument A")
12 (println a)
13 (println "\nDocument B")
14 (println b)
15 (println "\nDiff")
16 (println diff)
17 (println "\nPretty printed diff")
18 (println diffstr)))
19
20 (defn -main
21 [& args]
22 (diff-view {"Hi" {:foo 424128, :bar 22140, :baz 243000}}
23 {"Ho" {:foo 424128, :bar 22140, :baz 243000}}))
24
25
26 (-main)
27
❯ clj -M --main cljs.main --target node --output-to main-dev.js --optimizations none --compile ddiff-bug.core
❯ clj -M --main cljs.main --target node --output-to main-prod.js --optimizations advanced --compile ddiff-bug.core
❯ node main-dev.js
Document A
{Hi {:foo 424128, :bar 22140, :baz 243000}}
Document B
{Ho {:foo 424128, :bar 22140, :baz 243000}}
Diff
{#lambdaisland.deep-diff2.diff-impl.Deletion{:- Hi} {:foo 424128, :bar 22140, :baz 243000}, #lambdaisland.deep-diff2.diff-impl.Insertion{:+ Ho} {:foo 424128, :bar 22140, :baz 243000}}
Pretty printed diff
{+"Ho" {:bar 22140, :baz 243000, :foo 424128}, -"Hi" {:bar 22140, :baz 243000, :foo 424128}}
❯ node main-prod.js
Document A
{Hi {:foo 424128, :bar 22140, :baz 243000}}
Document B
{Ho {:foo 424128, :bar 22140, :baz 243000}}
Diff
{#lambdaisland.deep-diff2.diff-impl.Deletion{:- Hi} {:foo 424128, :bar 22140, :baz 243000}, #lambdaisland.deep-diff2.diff-impl.Insertion{:+ Ho} {:foo 424128, :bar 22140, :baz 243000}}
Pretty printed diff
{#Xo {:+ "Ho"} {:bar 22140, :baz 243000, :foo 424128},
#Wo {:- "Hi"} {:bar 22140, :baz 243000, :foo 424128}}
It seems minimized names (as seen in the Xo and Wo tags here) are confusing the printer. The two tags seen here are minimized versions of $lambdaisland$deep_diff2$diff_impl$Insertion$$ and $lambdaisland$deep_diff2$diff_impl$Deletion$$
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
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.
Hướng nghiên cứu
Bắt đầu với src/ddiff_bug/core.cljs và deps.edn, sau đó tái hiện sự khác biệt bằng cách chạy hai lệnh cljs.main với --optimizations none và advanced. Truy vết điểm vào ddiff/pretty-print và so sánh đầu ra thu được. Hoàn tất khi bản build advanced in ra các thẻ chèn và xóa dễ đọc giống như bản build không tối ưu hóa.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- clojure
- Lĩnh vực
- tooling
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100