sci
sci copied to clipboard
Improve error message when recurring from try
0.7.4 Windows
With 0.7.4 I get
----- Error --------------------------------------------------------------------
Type: clojure.lang.ExceptionInfo
Message: Can only recur from tail position
Location: d:\Users\Steffen\bin\browsers.clj:14:11
Phase: analysis
----- Context ------------------------------------------------------------------
10: (println "trying" (str/join " " cmd))
11: (println (apply shell/sh (browser url))))
12: (catch java.io.IOException exc
13: (if (seq browsers)
14: (recur browsers)))
^--- Can only recur from tail position
15: (catch Exception exc (println exc)))))
executing
(let [browsers [#(identity ["C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" %])
#(identity ["C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe" %])
#(identity ["start" (str "microsoft-edge:" %)])
#(identity ["C:\\Windows\\System32\\cmd.exe" "/c" "start" "shell:AppsFolder\\Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge" %])
#(identity ["C:\\Program Files\\Internet Explorer\\iexplore.exe" %])]
url (first *command-line-args*)]
(loop [[browser & browsers] browsers]
(try
(let [cmd (browser url)]
(println "trying" (str/join " " cmd))
(println (apply shell/sh (browser url))))
(catch java.io.IOException exc
(if (seq browsers)
(recur browsers)))
(catch Exception exc (println exc)))))
This worked previously and I'd think the recur actually is in tail position - I am not sure about the try, though.
@MrGung The error message could be improved but the official Clojure would say: cannot recur across try.
Oh my. Still - that changed between 0.7.3 and 0.7.4.
I'll fix my code...
@MrGung It was accidentally supported since there was no check here, but it wasn't intentionally supported.