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

Comptime assertion failures should show the full backtrace #5828

Closed
asterite opened this issue Aug 26, 2024 · 0 comments · Fixed by #5842
Closed

Comptime assertion failures should show the full backtrace #5828

asterite opened this issue Aug 26, 2024 · 0 comments · Fixed by #5842
Assignees
Labels
enhancement New feature or request

Comments

@asterite
Copy link
Collaborator

Problem

When an assertion fails during comptime code evaluation, the error only shows the line that failed the assertion. That sometimes makes it impossible to understand the real cause of the assertion failure. In particular, Option::unwrap always fails the same way:

error: Assertion failed
   ┌─ std/option.nr:33:16
   │
33 │         assert(self._is_some);
   │                -------------

Happy Case

The full trace is shown.

Workaround

None

Workaround Description

No response

Additional Context

No response

Project Impact

None

Blocker Context

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

@asterite asterite added the enhancement New feature or request label Aug 26, 2024
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Aug 26, 2024
@asterite asterite self-assigned this Aug 27, 2024
github-merge-queue bot pushed a commit that referenced this issue Aug 28, 2024
# Description

## Problem

Part of #5668

## Summary

Also allows `quote { ... }.as_expr()` to work with statements and
L-values. Then adds an example that injects a `_context: Context`
parameter to functions annotated with `#[aztec]`, and to calls inside
those functions (any call for now). Also adds an incomplete `Expr::map`
to help doing this.

Oh, and allows unquoting `Value::Expr`, which wasn't possible before.

## Additional Context

A lot is remaining, but I thought this was a good cutting point. Next I
might work on #5828 because debugging comptime code without it is
tricky.

I didn't add docs for `Expr::map` yet as it's still not fully
functional. I'll add them once it works for in all cases.

## Documentation

Check one:
- [ ] No documentation needed.
- [ ] Documentation included in this PR.
- [x] **[For Experimental Features]** Documentation to be submitted in a
separate PR.

# PR Checklist

- [x] I have tested the changes locally.
- [x] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
github-merge-queue bot pushed a commit that referenced this issue Aug 29, 2024
# Description

## Problem

Resolves #5828

## Summary

`CustomDiagnostic` didn't have a `call_stack` property because so far
this wasn't needed. I only added it for `FailingConstraint`, which is,
_I think_, the only case where a backtrace might be needed. In all other
cases (for example "wrong number of arguments" it might be clear why
it's failing without needing a backtrace).

Here's an example output:

```
error: Assertion failed
   ┌─ std/option.nr:33:16
   │
33 │         assert(self._is_some);
   │                -------------
   │
   ┌─ src/main.nr:8:9
   │
 8 │         foo();
   │         -----
   │
   ┌─ src/other.nr:2:5
   │
 2 │     bar();
   │     -----
   ·
 7 │     let _ = expr.as_integer().unwrap();
   │             --------------------------
   │

Aborting due to 1 previous error
```

## Additional Context

None.

## Documentation

Check one:
- [x] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[For Experimental Features]** Documentation to be submitted in a
separate PR.

# PR Checklist

- [x] I have tested the changes locally.
- [x] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants
@asterite and others