XSharp TRY without CATCH
Posted: Mon Aug 03, 2020 6:32 am
Hi,
When adding a TRY block to the code, if you skip the CATCH and FINALLY sections, the XSharp compiler will not generate an error. Moreover, if you examine the compiled code using ILSpy, you can see that the compiler itself has added the missing empty CATCH block. This can lead to subtle errors when the programmer forgot to implement the CATCH block, but the TRY block has a THROW operator. As a result, a possible error caught in THROW goes silently into an invisible CATCH. And as a result, such an invisible error can live undetected for a long time. For example, in C # in such a situation, the compiler generates the error "Expected catch of finally."
Perhaps the XSharp team specifically implemented this behavior? Therefore, I did not describe it in Tickets on GitHub, but brought it here to the forum for discussion. It seems to me that the compiler should react to the situation described above with an error. This is meant only for the TRY block, not for the BEGIN SEQUENCE block (which works in XSharp as in VO, and even better).
Best regards,
Leonid
When adding a TRY block to the code, if you skip the CATCH and FINALLY sections, the XSharp compiler will not generate an error. Moreover, if you examine the compiled code using ILSpy, you can see that the compiler itself has added the missing empty CATCH block. This can lead to subtle errors when the programmer forgot to implement the CATCH block, but the TRY block has a THROW operator. As a result, a possible error caught in THROW goes silently into an invisible CATCH. And as a result, such an invisible error can live undetected for a long time. For example, in C # in such a situation, the compiler generates the error "Expected catch of finally."
Perhaps the XSharp team specifically implemented this behavior? Therefore, I did not describe it in Tickets on GitHub, but brought it here to the forum for discussion. It seems to me that the compiler should react to the situation described above with an error. This is meant only for the TRY block, not for the BEGIN SEQUENCE block (which works in XSharp as in VO, and even better).
Best regards,
Leonid