Visitar URL original
CLJ-2959 · clojure/clojure@7d888da · GitHub
Skip to content

Commit 7d888da

Browse files
JarrodCTaylorpuredanger
authored andcommitted
CLJ-2959
* Add `hashCode()` to `Compiler$LocalBinding` returning `name.hashCode()` * Add CLJ-2959 test compiling the same closure three times and asserting identical field order Signed-off-by: Alex Miller <alex.miller@cognitect.com>
1 parent 98d735f commit 7d888da

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

‎src/jvm/clojure/lang/Compiler.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6579,6 +6579,10 @@ public Class getJavaClass() {
65796579
public Class getPrimitiveType(){
65806580
return maybePrimitiveType(init);
65816581
}
6582+
6583+
public int hashCode() {
6584+
return name.hashCode();
6585+
}
65826586
}
65836587

65846588
public static class LocalBindingExpr implements Expr, MaybePrimitiveExpr, AssignableExpr{

‎test/clojure/test_clojure/compilation.clj‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,3 +451,12 @@
451451
(meta ^:foo (reify clojure.lang.ILookup)) #{:foo}
452452
(meta (macroexpand-1 '(reify clojure.lang.ILookup))) #{:line :column}
453453
(meta (macroexpand-1 '^:foo (reify clojure.lang.ILookup))) #{:line :column :foo})))
454+
455+
(deftest CLJ-2959
456+
(testing "CLJ-2959 Closed over fields are emitted deterministically"
457+
(let [field-order (fn []
458+
(map #(.getName %)
459+
(.getDeclaredFields
460+
(class (eval '(let [a 0 b 1 c 2 d 3 e 4 f 5 g 6 h 7]
461+
(fn [] [a b c d e f g h])))))))]
462+
(is (= (field-order) (field-order) (field-order))))))

0 commit comments

Comments
 (0)