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

Fix: const_eval bugs #4761

Merged
merged 15 commits into from
Jul 10, 2023
Merged

Fix: const_eval bugs #4761

merged 15 commits into from
Jul 10, 2023

Conversation

xunilrj
Copy link
Contributor

@xunilrj xunilrj commented Jul 6, 2023

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

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

@xunilrj xunilrj changed the title Fix: s Fix: const_eval bugs Jul 6, 2023
@xunilrj xunilrj self-assigned this Jul 7, 2023
@xunilrj xunilrj marked this pull request as ready for review July 7, 2023 13:04
@xunilrj xunilrj requested a review from a team July 7, 2023 13:05
@anton-trunov
Copy link
Contributor

It would be great to have failing end-to-end tests with e.g. return and state-modifying operators somewhere in this directory: https://github.com/FuelLabs/sway/tree/master/test/src/e2e_vm_tests/test_programs/should_fail

@xunilrj
Copy link
Contributor Author

xunilrj commented Jul 7, 2023

It would be great to have failing end-to-end tests with e.g. return and state-modifying operators somewhere in this directory: https://github.com/FuelLabs/sway/tree/master/test/src/e2e_vm_tests/test_programs/should_fail

Done.

@xunilrj xunilrj requested a review from anton-trunov July 7, 2023 19:49
@xunilrj xunilrj requested a review from IGI-111 July 10, 2023 07:38
@IGI-111 IGI-111 merged commit 2c6d410 into master Jul 10, 2023
@IGI-111 IGI-111 deleted the xunilrj/fix-const-eval-bugs branch July 10, 2023 10:57
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

Successfully merging this pull request may close these issues.

3 participants