tokiwa-software / fuzion

The Fuzion Language Implementation
https://fuzion-lang.dev
GNU General Public License v3.0
47 stars 11 forks source link

It might be nice to switch these over to a panic effect with a severe-compiler-bug-found panic handler. #3586

Open michaellilltokiwa opened 2 months ago

michaellilltokiwa commented 2 months ago

Some of these use panic, others call to the fuzion.std.panic intrinsic. I tried to switch the latter over to use panic a while ago, but @fridis did not want like this because that meant any calls to these features showed up as using the panic effect with fz -effects. It might be nice to switch these over to a panic effect with a severe-compiler-bug-found panic handler. Then we could have a message like:

error 1: option.val called on nil
[stack trace]

You either turned off safety or you discovered a severe compiler bug!
This code should be unreachable.

(could even switch the message to show "turned off safety" only when !safety).

Originally posted by @maxteufel in https://github.com/tokiwa-software/fuzion/pull/3564#pullrequestreview-2246990282

fridis commented 2 months ago

With anything as simple as setting an option -safety=off, I would prefer not to create a message stating that there is a compiler bug. This is just asking for trouble.

Showing panic when using -effects is not nice (and happens currently anyways due to panic being used in

$MODULE/effect.fz:143:5:
    instate R e code (panic "unexpected abort in {effect.this.type}")

for a mutate effect where this panic should be unreachable. We have to do both, improve the DFA to not show panic in dead code and use fuzion.std.panic where this is not possible.