Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distinguish "will throw" from "may throw" #309

Closed
jtrakk opened this issue Dec 27, 2021 · 1 comment
Closed

Distinguish "will throw" from "may throw" #309

jtrakk opened this issue Dec 27, 2021 · 1 comment

Comments

@jtrakk
Copy link

jtrakk commented Dec 27, 2021

f1(x) = error("hello")
f2(x) = f1(x)
@report_call mode=:sound f2(:a)

says "may throw" but in fact it will throw. If error is the only possible outcome, I should not try to run the code, especially if it will take a long time to execute. The report could distinguish this case when it is sure of the result.

@jakobnissen
Copy link
Contributor

I think it already does this, and it's just a matter of phrasing in the message:

julia> f(x) = x ? error() : x
f (generic function with 1 method)

julia> g(x) = error()
g (generic function with 1 method)

julia> @report_call f(true)
No errors !

julia> @report_call g(true)
═════ 1 possible error found ═════
┌ @ REPL[9]:1 Main.error()
│┌ @ error.jl:40 error()
││ may throw: Base.throw(Base.ErrorException(Base.getfield(Main.Base::Module, :string::Symbol)::typeof(string)()::String)::ErrorException)
│└───────────────

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants