We're updating the issue view to help you get more done. 

Instrumented self-calling multi-arity fn throws maximum call stack exceeded with optimizations advanced

Description

Multi-arity function cannot be instrumented and then run with optimizations advanced.

The self-call from arity-0 to another one is giving problems.
The self-call from another arity to arity-0 is also giving problems.

Repro:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 (ns repro (:require [clojure.spec.alpha :as s] [clojure.spec.test.alpha :as stest])) (defn foo ([] (foo 0)) ([a] (foo a 1)) ([a b] [a b])) (s/fdef foo :args (s/cat :a (s/? number?) :b (s/? number?))) (defn -main [& args] (stest/instrument) (foo 1) (println "(foo 1) worked") (foo 1 2) (println "(foo 1 2) worked") (foo) (println "(foo) worked")) (set! *main-cli-fn* -main)

Compile, run and output with advanced:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 clj -Srepro -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.439"} org.clojure/test.check {:mvn/version "RELEASE"}}}' -m cljs.main -t nodejs -O advanced -co '{:pseudo-names true :pretty-print true}' -c repro node out/main.js (foo 1) worked (foo 1 2) worked /private/tmp/repro/out/main.js:2477 function $cljs$core$seq$$($coll$jscomp$37$$) { ^ RangeError: Maximum call stack size exceeded at $cljs$core$seq$$ (/private/tmp/repro/out/main.js:2477:26) at $cljs$core$apply_to$$ (/private/tmp/repro/out/main.js:4916:26) at $cljs$core$apply$cljs$0core$0IFn$0_invoke$0arity$02$$ (/private/tmp/repro/out/main.js:5147:38) at Function.$cljs$core$IFn$_invoke$arity$0$ (/private/tmp/repro/out/main.js:19504:16) at $cljs$core$apply_to$$ (/private/tmp/repro/out/main.js:4918:78) at $cljs$core$apply$cljs$0core$0IFn$0_invoke$0arity$02$$ (/private/tmp/repro/out/main.js:5147:38) at Function.$cljs$core$IFn$_invoke$arity$0$ (/private/tmp/repro/out/main.js:19504:16) at $cljs$core$apply_to$$ (/private/tmp/repro/out/main.js:4918:78) at $cljs$core$apply$cljs$0core$0IFn$0_invoke$0arity$02$$ (/private/tmp/repro/out/main.js:5147:38) at Function.$cljs$core$IFn$_invoke$arity$0$ (/private/tmp/repro/out/main.js:19504:16)

Environment

None

Status

Assignee

David Nolen

Reporter

Michiel Borkent

Labels

Approval

Accepted

Patch

Code and Test

Priority

Blocker