-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Add detailed diagnostics for Rust-style enums #7047
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
base: master
Are you sure you want to change the base?
Conversation
Thanks for the contribution! Before we can merge this, we need @kfastov to sign the Fuel Labs Contributor License Agreement. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs more polish (since the point here is to have as helpful errors as possible) but you're on the right track I think.
@IGI-111 @ironcev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, very clean and well documented implementation! Thanks for taking this over @kfastov!
Just one small detail to change.
@IGI-111 Hi, sorry for bothering you, should I do something else for this PR to be reviewed? |
Description
Adds detailed error messages when detected Rust-style enums
close #5403
Changes:
sway-parse/src/item/mod.rs
to detect Rust-like tuple (Variant(T)
), unit (Variant
), and struct (Variant { field: T }
) syntax, generating errors.ParseErrorKind::MissingColonInEnumTypeField
insway-error/src/parser_error.rs
to storevariant_name
and optionaltuple_contents
span for diagnostic purposes.sway-error/src/error.rs
to output error messages and syntax suggestions (e.g.,Did you mean 'Variant: (T)'?
) for incorrect enum definitions.enum_rust_like
test (main.sw
andtest.toml
) with new test cases for these syntax errors and adjusted expectations for the new diagnostic output.All error messages match the spec defined in the issue description.
Checklist
Breaking*
orNew Feature
labels where relevant.