vnmakarov / mir

A lightweight JIT compiler based on MIR (Medium Internal Representation) and C11 JIT compiler and interpreter based on MIR
MIT License
2.26k stars 145 forks source link

Removing `MIR_NO_RETURN` in `MIR_error_func_t`? #220

Open eliphatfs opened 2 years ago

eliphatfs commented 2 years ago

For my own use case, I want to catch the errors, print them to the user, and tell the user to fix somewhere in the input (interactively) instead of terminating the process at this point. Another consideration is that contexts should be independent. Errors in one context should not crash others. The attribute hints the compiler that the function never returns, and the PC runs out of bounds causing problems with some platforms/compilers (OS X 11.1, specifically). So I suggest removing this attribute in MIR_error_func_t. Yet I realize that perhaps some code may break due to the previous assumptions that calling error func ends the program. Then what's the suggested method for implementing the error catching behavior?

vnmakarov commented 2 years ago

Sorry for the delay with the answer.

I think some errors will be fatal in any way. Others can be recoverable. I'll investigate this more and inform you what can be done. The recovery might be done with setjmp/longjmp as it is already done for textual MIR parsing.