-
Notifications
You must be signed in to change notification settings - Fork 220
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
VB -> C#: Exit Try is converted to break - this causes problems when a loop is inside a try-catch block #779
Comments
Thanks for the report. It's closely related to #690. I like the suggestion of just outputting an error initially so at least it's obvious. I'll try to post some hints on where to make this change when I have chance to look, but it's probably a method called something like VisitExitStatemement |
Yes, it is possible to automatically convert it, but it gets rather complicated and the resulting code is going to look a bit different from the source. I'll try to take a look when I have time at the VisitExitStatement. |
In terms of a logically identical conversion, one option is a bunch of booleans and if statements (annoying for very nested code). Other options (I might edit these slightly if I come back to them and notice further issues): Break from loopdo
{
try
{
//...
break;
//...
}
catch
{
//...
}
} while (false) This would need a special case of #690 (treat the try block as an enclosing breakable block) if the "try" contains other Return from local functiontry
{
void InnerTry()
{
//...
return;
//...
}
InnerTry();
} catch
{
//...
} This would need a special case of #690 (pull |
In df6354b I turned this into a compilation error so that it at least can't surprise anyone |
VB.Net input code
Erroneous output
Expected output
Details
This is mainly a problem when inside a loop since the break, instead of causing a compile error, causes the code to behave differently. I may be able to contribute a fix, but I have no experience with the code base. Also, thanks for a wonderful program!
The text was updated successfully, but these errors were encountered: