-
Notifications
You must be signed in to change notification settings - Fork 471
More error messages #7522
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
Merged
Merged
More error messages #7522
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
1637911
refactor
zth 96ed8a3
explicit error for while condition
zth b80fea5
explicit for loop condition
zth 6e5d149
assert condition
zth 9cd6bfd
refactor
zth 01288d3
fix
zth 374d563
try tracking record field type checking
zth ab01839
iron out a few more error messages
zth 9411f97
track optional function arguments
zth 3e8a1f7
format
zth bb358ae
cleanup
zth 28a3d38
PR comments
zth 0ca45e7
update test output
zth 33c4c2e
change wording a bit
zth c29fc23
change wording
zth f2d3278
changelog
zth 1171e16
explicit error message for optional component props, since they have …
zth 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
track optional function arguments
- Loading branch information
commit 9411f977b6c4c62d38c469da78336af11e558b39
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
18 changes: 18 additions & 0 deletions
18
tests/build_tests/super_errors/expected/optional_fn_argument_pass_option.res.expected
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
[1;31mWe've found a bug for you![0m | ||
[36m/.../fixtures/optional_fn_argument_pass_option.res[0m:[2m5:18[0m | ||
|
||
3 [2m│[0m let t = Some(1) | ||
4 [2m│[0m | ||
[1;31m5[0m [2m│[0m let f = optFn(~x=[1;31mt[0m) | ||
6 [2m│[0m | ||
|
||
This has type: [1;31moption<int>[0m | ||
But this optional function argument is expecting: [1;33mint[0m | ||
|
||
You're passing an optional value into an optional function argument. | ||
Optional function arguments expect you to pass the concrete value, not an option, when passed directly. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if this wording is easy to understand. Maybe we can omit the "when passed directly"? |
||
|
||
Possible solutions: | ||
- Unwrap the option and pass a concrete value directly | ||
- If you really do want to pass the optional value, prepend the value with [1;33m?[0m to show you want to pass the option, like: [1;33m?t[0m |
5 changes: 5 additions & 0 deletions
5
tests/build_tests/super_errors/fixtures/optional_fn_argument_pass_option.res
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
let optFn = (~x: option<int>=?) => x | ||
|
||
let t = Some(1) | ||
|
||
let f = optFn(~x=t) |
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.
Uh oh!
There was an error while loading. Please reload this page.