File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -1599,6 +1599,20 @@ x (not (contains? ret :info)))
15991599 else-tag #{else-tag})]
16001600 (into then-tag else-tag))))))))
16011601
1602+ (defn infer-try
1603+ [env ast]
1604+ (let [body-tag (infer-tag env (:body ast))
1605+ catch-tag (infer-tag env (:catch ast))]
1606+ (cond
1607+ #?(:clj (= body-tag impl/IGNORE_SYM)
1608+ :cljs (symbol-identical? body-tag impl/IGNORE_SYM))
1609+ catch-tag
1610+ #?(:clj (= catch-tag impl/IGNORE_SYM)
1611+ :cljs (symbol-identical? catch-tag impl/IGNORE_SYM))
1612+ body-tag
1613+ :else
1614+ (add-types body-tag catch-tag))))
1615+
16021616(defn js-var? [ast]
16031617 (= :js-var (:op ast)))
16041618
@@ -1638,7 +1652,7 @@ x (not (contains? ret :info)))
16381652 :throw impl/IGNORE_SYM
16391653 :let (infer-tag env (:body ast))
16401654 :loop (infer-tag env (:body ast))
1641- :try (infer-tag env ( :body ast) )
1655+ :try (infer-try env ast)
16421656 :do (infer-tag env (:ret ast))
16431657 :fn-method (infer-tag env (:body ast))
16441658 :def (infer-tag env (:init ast))
Original file line number Diff line number Diff line change 15621562 (is (= 1 (count @ws)))
15631563 (is (string/starts-with? (first @ws) " Wrong number of args (2) passed to Foo" ))))
15641564
1565+ (deftest test-cljs-3473
1566+ (let [ws (atom [])]
1567+ (ana/with-warning-handlers [(collecting-warning-handler ws)]
1568+ (analyze (ana/empty-env )
1569+ '(+ 1 2 (try (throw (throw 2 )) (catch :default _ 1 )))))
1570+ (is (empty? @ws))
1571+ (ana/with-warning-handlers [(collecting-warning-handler ws)]
1572+ (analyze (ana/empty-env )
1573+ '(+ 1 2 (try (throw (throw 2 )) (catch :default _ " 1" )))))
1574+ (is (string/starts-with? (first @ws) " cljs.core/+, all arguments must be numbers, got [number string] instead" ))))
1575+
15651576(deftest test-cljs-3401
15661577 (is (not= (ana/gen-constant-id '_PLUS_)
15671578 (ana/gen-constant-id '+)))
You can’t perform that action at this time.
0 commit comments