Skip to content

Commit

Permalink
Fix: const_eval bugs (#4761)
Browse files Browse the repository at this point in the history
## Description

This PR is necessary for #4708

It fixes some problems with `const_eval`, most importantly:

1 - It differentiates when an eval cannot be used inside const (there is
a new error for that), and when expressions/statements just do not
produce any value;
2 - It always cleans up `eval_codeblock` (it never shortcircuit with
`?`);

Another advantage of the explicit error is the exact span of the
"offending" expression, which we can use in the future for better error
messages.

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.

---------

Co-authored-by: Anton Trunov <[email protected]>
  • Loading branch information
xunilrj and anton-trunov authored Jul 10, 2023
1 parent 8491be8 commit 2c6d410
Show file tree
Hide file tree
Showing 7 changed files with 434 additions and 98 deletions.
6 changes: 4 additions & 2 deletions sway-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ derivative = "2.2.0"
dirs = "3.0"
either = "1.6"
ethabi = { package = "fuel-ethabi", version = "18.0.0" }
etk-asm = { package = "fuel-etk-asm", version = "0.3.1-dev", features = ["backtraces"] }
etk-asm = { package = "fuel-etk-asm", version = "0.3.1-dev", features = [
"backtraces",
] }
etk-dasm = { package = "fuel-etk-dasm", version = "0.3.1-dev" }
etk-ops = { package = "fuel-etk-ops", version = "0.3.1-dev" }
fuel-abi-types = "0.1"
fuel-abi-types = "0.1"
fuel-vm = { workspace = true, features = ["serde"] }
hashbrown = "0.13.1"
hex = { version = "0.4", optional = true }
Expand Down
Loading

0 comments on commit 2c6d410

Please sign in to comment.