Skip to content

Commit 717cab5

Browse files
committed
CLJS-1225: Variadic function with same name as parent function gives runtime error in advanced compile mode.
For optimized invokes where we rename the fn disable shadowing as shadowing has *already* been applied. Add test.
1 parent 5612bf6 commit 717cab5

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/clj/cljs/compiler.cljc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,9 @@
785785
(-> info
786786
(assoc :name (symbol (str (munge info) ".cljs$core$IFn$_invoke$arity$variadic")))
787787
;; bypass local fn-self-name munging, we're emitting direct
788-
(update-in [:info] dissoc :fn-self-name))))
788+
;; shadowing already applied
789+
(update-in [:info]
790+
#(-> % (dissoc :shadow) (dissoc :fn-self-name))))))
789791
{:max-fixed-arity mfa}]
790792

791793
;; direct dispatch to specific arity case
@@ -797,7 +799,9 @@
797799
(-> info
798800
(assoc :name (symbol (str (munge info) ".cljs$core$IFn$_invoke$arity$" arity)))
799801
;; bypass local fn-self-name munging, we're emitting direct
800-
(update-in [:info] dissoc :fn-self-name)))) nil]
802+
;; shadowing already applied
803+
(update-in [:info]
804+
#(-> % (dissoc :shadow) (dissoc :fn-self-name)))))) nil]
801805
[f nil]))))
802806
[f nil])]
803807
(emit-wrap env

test/cljs/cljs/core_test.cljs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2786,7 +2786,7 @@
27862786
(is (= (.getBasis TypeBasis) '[a b]))
27872787
(is (= (.getBasis RecordBasis) '[c d e])))
27882788

2789-
(deftest test-1212
2789+
(deftest test-cljs-1212
27902790
(is (= (set {:a 0 :b 0 :c 0 :d 0 :e 0 :f 0 :g 0 :h 0 :i 0})
27912791
#{[:a 0] [:b 0] [:c 0] [:d 0] [:e 0] [:f 0] [:g 0] [:h 0] [:i 0]})))
27922792

@@ -2807,6 +2807,13 @@
28072807
(is (not= tl (tagged-literal 'x "z")))
28082808
(is (= (hash tl) (hash (tagged-literal 'x "y"))))))
28092809

2810+
(defn- incme []
2811+
(let [incme (fn [a queue & args] (inc a))]
2812+
(incme 1 [1] :color "#fff")))
2813+
2814+
(deftest test-cljs-1225
2815+
(is (= (incme) 2)))
2816+
28102817
(comment
28112818
;; ObjMap
28122819
;; (let [ks (map (partial str "foo") (range 500))

0 commit comments

Comments
 (0)