radon-project / radon

The Radon Programming Language
https://radon-project.github.io
GNU General Public License v3.0
23 stars 2 forks source link

Make `raise` statements show the correct function name #138

Closed angelcaru closed 4 months ago

angelcaru commented 4 months ago

Closes #137

Almas-Ali commented 4 months ago

This should also accept just function name. Ex. raise somefile.TypeError without ().

Almas-Ali commented 4 months ago

It would be nice to get like this:

Radiation (most recent call last):
  File ./test_lib.rn, line 3
TypeError

raise rlib.TypeError
      ^^^^^^^^^^^^^^

if called rlib.TypeError this only. no arguments and no default will be executed while no ().

angelcaru commented 4 months ago

What, like this?

TypeError = "type error"
raise TypeError

instead of

fun TypeError() {
    return "type error"
}
raise TypeError
Almas-Ali commented 4 months ago

What, like this?

TypeError = "type error"
raise TypeError

instead of

fun TypeError() {
    return "type error"
}
raise TypeError
Radiation (most recent call last):
  File ./test_lib.rn, line 6, in <program>
RuntimeError: Illegal operation for ("type error", "type error")

raise TypeError
      ^^^^^^^^^
angelcaru commented 4 months ago

OK, now I'm even more confused

angelcaru commented 4 months ago

So if the function returns null don't print a message? So

fun TypeError() {
    return "type error"
}
raise TypeError

would give TypeError: type error, while

fun TypeError() {} # implicitly returns null
raise TypeError

would give TypeError?

Almas-Ali commented 4 months ago

When it is not defined yet, it raise errors 2 times. It could be for the super() call on error file.

Radiation (most recent call last):
  File ./test_lib.rn, line 3, in <program>
Radiation (most recent call last):
  File ./test_lib.rn, line 3
RuntimeError: Attribute 'rrError' does not exist

raise rlib.rrError()
      ^^^^^^^^^^^^

raise rlib.rrError()
      ^^^^^^^^^^^^
Almas-Ali commented 4 months ago

Some times it leaves closing parent on error.

Screenshot_2024-05-26_16-55-02

angelcaru commented 4 months ago

? Can't reproduce

Almas-Ali commented 4 months ago

? Can't reproduce

What do you mean?

angelcaru commented 4 months ago

What is even the issue?

Almas-Ali commented 4 months ago

What is even the issue?

Check the last error message on the screenshot.

angelcaru commented 4 months ago

It looks fine to me...

Almas-Ali commented 4 months ago

It missed the closing parenthesis.

angelcaru commented 4 months ago

That's such a minor thing though. It doesn't really matter

Almas-Ali commented 4 months ago

That's such a minor thing though. It doesn't really matter

Well you are right. But this looks weird to me.

angelcaru commented 4 months ago

We have all sorts of similar issues with error reporting. I don't see a reason why this one specifically needs to block the PR. For instance:

Almas-Ali commented 4 months ago

We have all sorts of similar issues with error reporting. I don't see a reason why this one specifically needs to block the PR. For instance:

I am not blocking the PR here. Just wanted to share my opinion on this related topic.

In this case we need to identify this issue with more various perspective and create a new issue linking all found bugs on radiation traceback formatting to fix it.