-
-
Notifications
You must be signed in to change notification settings - Fork 783
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
Suggest wrapping value in Ok
or Error
if it makes sense
#3663
Open
giacomocavalieri
wants to merge
12
commits into
gleam-lang:main
Choose a base branch
from
giacomocavalieri:suggest-result-wrapping
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
0b87be8
wip suggest wrapping result to fit into result
giacomocavalieri 6c6ddbc
Improve hint reporting for case branches
giacomocavalieri 17b631e
comments
giacomocavalieri 2515b93
clippy
giacomocavalieri 63f8df4
one more test
giacomocavalieri 2d7a67d
changelog
giacomocavalieri c7d0471
more tests!
giacomocavalieri 377eb28
add equality for types
giacomocavalieri dfa7d2e
replace collapse_link with same_as
giacomocavalieri a4ffae2
remove unused function
giacomocavalieri ca39d1e
address review comments
giacomocavalieri b07330c
remove hint from case expressions
giacomocavalieri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This error is wrong!
Ok([first, ..rest] -> first)
would not be valid.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.
The message is referring to the
first
bit but the way the two overlapping spans are rendered it's not very clear; do you think we should stop highlighting the entire case branch in this case? However that would mean that the error message is not very precise now:And it would be more confusing when the part on the right of
->
is on its own line as the clause would not be displayed in the error!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.
I think we should continue to highlight the entire cause as the source of the type error, but a label about wrapping an expression should only point to the code that is to be wrapped.
If this is a lot of work then another option could be to not have this suggestion for case clauses.
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.
The tricky thing is it is already pointing to just the code that needs to be wrapped but the way the library renders it it's not immediately obvious. If the then clause were not on the same line what you'd see is this:
But when the two are on the same line the two look like this
The way it gets rendered is not the best, maybe I could try and remove it for branches when the then clause is on the same line or for case matches entirely
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.
Ah, I see, that is annoying. Sounds good to me- changing printing sounds like it would be irritating.