F# emits catch/rethrow for exception type tests #3297
Labels
Area-Debug
stepping, debug points, stacks and more
Feature Improvement
Ready
Theme-Simple-F#
A cross-community initiative called "Simple F#", keeping people in the sweet spot of the language.
Milestone
When the F# compiler translates a try-with block, by default it seems to generate IL that catches Object and then rethrows the exception if it doesn't match any of the patterns. (Here's the relevant source code.) This has the unpleasant effect that when the Visual Studio debugger reports a user-unhandled exception, it reports it at an unrelated enclosing catch block instead of where it was originally thrown. This was previously reported on Stack Overflow.
Repro steps
Run the following code under the debugger:
Expected behavior
The exception popup appears on the "failwith" call.
Actual behavior
The exception popup appears on the "with" block, even though it doesn't catch this type of exception.
Known workarounds
In the project properties, "Build" tab, "Other flags", add
--generate-filter-blocks
.Related information
The text was updated successfully, but these errors were encountered: