roc-lang / roc

A fast, friendly, functional language.
https://roc-lang.org
Universal Permissive License v1.0
3.86k stars 284 forks source link

Make nicer error message when `todo!` is hit #6812

Open Anton-4 opened 2 weeks ago

Anton-4 commented 2 weeks ago
thread 'main' panicked at crates/compiler/gen_dev/src/generic64/aarch64.rs:1861:13:
not yet implemented: immediate subtractions with values greater than 12bits

Is not the best looking error message, we should see if we can easily modify the output used by the todo macro or create our own todo macro with a nicely formatted and nicely worded error message.

Recommended experience: Novice at Rust

NoodleSamaChan commented 2 weeks ago

Hello there!

Would it be quite alright if I worked on this issue ?

Cheers!

Anton-4 commented 2 weeks ago

Hi @NoodleSamaChan, thanks for helping out! I've assigned you to the issue :)

NoodleSamaChan commented 1 week ago

Thanks so much, apologies for the late answer, I have a follow up question if that's alright to be sure I understand exactly what is expected : )

Would you have an example of what a better looking message would look like for you for instance? And do you expect a panic or an error to be returned ideally?

Cheers!

Anton-4 commented 6 days ago

Would you have an example of what a better looking message would look like for you for instance?

I would go with something like this:

<red>Error<\red>: Unimplemented feature

    Immediate subtractions with values exceeding 12 bits are not yet supported.

    Tip: You probably hit this in the repl. You should be able to build/run this code using a roc file, e.g.: `roc myFile.roc`.

    Issue: <https://github.com/roc-lang/roc/issues/ISSUE_NR>

Instead of the todo macro we should probably use a normal function e.g.: roc_todo(description: &str, tip: Option<&str>, issue_link: Url). It should call eprintln followed by process::exit(1);.

And do you expect a panic or an error to be returned ideally?

We can start with the function I suggested, later we want this to return an error but I think passing the error through the whole compiler would require too much work for a first PR.

Down the road we should also do a CI check that fails if there are any todo! in the code, and it should recommend using the roc_todo function instead.