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

Refactor error_emitted pattern #4885

Closed
IGI-111 opened this issue Jul 29, 2023 · 0 comments · Fixed by #4895
Closed

Refactor error_emitted pattern #4885

IGI-111 opened this issue Jul 29, 2023 · 0 comments · Fixed by #4895
Assignees
Labels
code quality compiler General compiler. Should eventually become more specific as the issue is triaged

Comments

@IGI-111
Copy link
Contributor

IGI-111 commented Jul 29, 2023

As part of #4878 we introduced an imperative error handling pattern where calls to Handler::emit_err would get fed into a error_emitted: Option<ErrorEmitted> variable to detect error emission within a function's context.

We should develop a facility within/associated with the Handler type to refactor that pattern into something more cleaner and more readable.

@IGI-111 IGI-111 added compiler General compiler. Should eventually become more specific as the issue is triaged code quality labels Jul 29, 2023
IGI-111 added a commit that referenced this issue Aug 1, 2023
This changes addresses the issues introduced in #4878

The `error_emitted` pattern is replaced by a scoping method on `Handler`
that collects errors within a closure and will error out if new erros are
introduced.

All instances of introducing `ErrorEmitted` as a literal value have
now been replaced by passing arround the receipt of the error emission
through the error representing values. Some types from the AST had to
be moved to `sway-types` to avoid circular dependencies introduced by
this change.

This also repairs some of the discrepancies to emitted warnings
introduced in #4878, as well as rename some of the `Handler` methods.

Fixes #4885
Fixes #4886
IGI-111 added a commit that referenced this issue Aug 1, 2023
This changes addresses the issues introduced in #4878

The `error_emitted` pattern is replaced by a scoping method on `Handler`
that collects errors within a closure and will error out if new erros are
introduced.

All instances of introducing `ErrorEmitted` as a literal value have
now been replaced by passing arround the receipt of the error emission
through the error representing values. Some types from the AST had to
be moved to `sway-types` to avoid circular dependencies introduced by
this change.

This also repairs some of the discrepancies to emitted warnings
introduced in #4878, as well as rename some of the `Handler` methods.

Fixes #4885
Fixes #4886
IGI-111 added a commit that referenced this issue Aug 1, 2023
This changes addresses the issues introduced in #4878

The `error_emitted` pattern is replaced by a scoping method on `Handler`
that collects errors within a closure and will error out if new erros are
introduced.

All instances of introducing `ErrorEmitted` as a literal value have
now been replaced by passing arround the receipt of the error emission
through the error representing values. Some types from the AST had to
be moved to `sway-types` to avoid circular dependencies introduced by
this change.

This also repairs some of the discrepancies to emitted warnings
introduced in #4878, as well as rename some of the `Handler` methods.

Fixes #4885
Fixes #4886
IGI-111 added a commit that referenced this issue Aug 1, 2023
This changes addresses the issues introduced in #4878

The `error_emitted` pattern is replaced by a scoping method on `Handler`
that collects errors within a closure and will error out if new erros are
introduced.

All instances of introducing `ErrorEmitted` as a literal value have
now been replaced by passing arround the receipt of the error emission
through the error representing values. Some types from the AST had to
be moved to `sway-types` to avoid circular dependencies introduced by
this change.

This also repairs some of the discrepancies to emitted warnings
introduced in #4878, as well as rename some of the `Handler` methods.

Fixes #4885
Fixes #4886
IGI-111 added a commit that referenced this issue Aug 1, 2023
## Description
This changes addresses the issues introduced in #4878

The `error_emitted` pattern is replaced by a scoping method on `Handler`
that collects errors within a closure and will error out if new erros
are introduced.

All instances of introducing `ErrorEmitted` as a literal value have now
been replaced by passing arround the receipt of the error emission
through the error representing values. Some types from the AST had to be
moved to `sway-types` to avoid circular dependencies introduced by this
change.

This also repairs some of the discrepancies to emitted warnings
introduced in #4878, as well as rename some of the `Handler` methods.

Fixes #4885
Fixes #4886

## 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.
@IGI-111 IGI-111 self-assigned this Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code quality compiler General compiler. Should eventually become more specific as the issue is triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant