Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return the position of runtime failure #542

Open
irevoire opened this issue Aug 18, 2024 · 3 comments
Open

Return the position of runtime failure #542

irevoire opened this issue Aug 18, 2024 · 3 comments

Comments

@irevoire
Copy link
Contributor

irevoire commented Aug 18, 2024

Currently, numbat doesn't return anything except the error message when encountering a runtime error:

% numbat -e "12 / 0"
error: runtime error
 = Division by zero

Interpreter stopped

Ideally, it should return the line that caused the error (at least the line number and column).

Currently, this is not possible because once we generate the bytecode, we lose all information about the code source.
It seems like, in the industry, the way to make that work is to generate a second vector the sizes of the instructions that link to spans.
So while executing instructions we don't lose time with this information, but in case of an error we can find back what caused the issue.

I’m not an expert, if anyone know a better way to do it feel free to jump in!

@sharkdp
Copy link
Owner

sharkdp commented Aug 29, 2024

It seems like, in the industry, the way to make that work is to generate a second vector the sizes of the instructions that link to spans.

I don't know where I read about this, but that's also what I heard. It sounds very reasonable. And maybe not too hard.

@sharkdp
Copy link
Owner

sharkdp commented Aug 29, 2024

Or... maybe not so easy after all. Wouldn't that require stack traces as well?

fn f(x) = 1 / x

# 100 lines later

f(0)

The division by zero happens in an instruction that belongs to the code of f. But what would be more useful for the user would be to see the call site (one level up in the call stack) and it's corresponding span.

@irevoire
Copy link
Contributor Author

Yeah, we definitely need the stack trace as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants