-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
try without catch should not catch #27554
Comments
IIUC correctly, wrapping a block in |
Yes, that is what I am saying.
Could do:
So just plain making it a syntax error would be reasonable |
Yes, I think we can disallow it. |
FWIW, I like the |
julia> @eval macro $(:try)(ex)
quote
try $(esc(ex))
catch
end
end
end
@try (macro with 1 method)
julia> @try error("BOO") |
This is a breaking change,
but I feel like I should point it out now while 0.7 is still alpha,
as there is a chance it can be fixed before 1.0
Right now: if you have a
try
block that has neither acatch
nor afinally
,it is the same as a
try
block with acatch
.But if you have a
try
block without acatch
and with afinally
it does not catch anything.My gut tells me that without a
catch
nothing should becaught
.and also that adding an empty finally block should never change behaviour.
Right now the tryblock comes in 4 forms:
try-catch-finally:
Catches (what I expected)
try-catch
Catches (what I expected)
try-finally
Does Not Catch (what I expected)
try
Catches (Not what I expected)
This caught me off-guard today,
because I had some code that I had added a
catch
block to, for debugging purposes.I was using it as a big of a hack dump out some extra state to the screen so I could find what was wrong with my code.
When I was done debugging, I commented out the catch block,
because I didn't want to catch things anymore.
Many weeks later (today) I come back to the code, and I do something kinda silly for other debugging reasons (printing an undefined variable)
and I am sitting here wondering first "Why am i not getting the expected output", and then once I found my mistake "Why is my program not erroring out?"
The text was updated successfully, but these errors were encountered: