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

Improve error message for invalid target in attribute #4369

Merged
merged 5 commits into from
Mar 19, 2025

Conversation

AlecGhost
Copy link
Contributor

Resolves Issue #4362.

  • Return UnknownTarget error in case the target name is neither javascript nor erlang
  • Return new ExpectedTargetName error in case the target is missing
  • Hand down the location of the parenthesis for the error span
  • Add snapshot tests for the new error messages

Copy link
Member

@lpil lpil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!! Would you mind updating the changelog also? 🙏

let (start, t, end) = match self.next_tok() {
Some(t) => t,
None => {
return parse_error(ParseErrorType::UnexpectedEof, SrcSpan { start: 0, end: 0 });
}
};
let location = SrcSpan::new(start, end);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only build this when it is needed please 🙏

CHANGELOG.md Outdated
@@ -222,6 +222,10 @@
- Fixed a bug where variant inference wouldn't work on `let assert` assignments.
([Giacomo Cavalieri](https://github.com/giacomocavalieri))

- Fixed a bug where the error message for an unknown or missing target name
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't a bug!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would you classify it? It seems like undesired behaviour to me.
Should I move it to the compiler section instead?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an improvement to compiler error messages, there was nothing not-working previously so it's not a bug fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, thanks a lot for reviewing everything so quickly and in-depth.

Copy link
Member

@lpil lpil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@lpil lpil merged commit 046df5e into gleam-lang:main Mar 19, 2025
12 checks passed
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.

2 participants