-
Notifications
You must be signed in to change notification settings - Fork 463
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
Clean up Super_error #6199
Clean up Super_error #6199
Conversation
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.
Just one final thing to check, then ready to go.
jscomp/ml/typemod.ml
Outdated
| Repeated_name(kind, name, repeated_loc) -> | ||
let start_line = repeated_loc.loc_start.pos_lnum in | ||
let start_col = repeated_loc.loc_start.pos_cnum - repeated_loc.loc_start.pos_bol in | ||
let end_col = repeated_loc.loc_end.pos_cnum - repeated_loc.loc_end.pos_bol in |
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.
Is there some logic already to do this? The ocaml and vscode loc info's are different (zero-based vs one-based) so it's a bit tricky and best to keep all in the same place.
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.
Look for the part that says: "we've found a bug for you".
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 have added wider task: #6202
This PR fits well in that.
jscomp/ml/typemod.ml
Outdated
let start_line = repeated_loc.loc_start.pos_lnum in | ||
let start_col = repeated_loc.loc_start.pos_cnum - repeated_loc.loc_start.pos_bol in | ||
let end_col = repeated_loc.loc_end.pos_cnum - repeated_loc.loc_end.pos_bol in | ||
let (_, start_line, start_char) = Location.get_pos_info repeated_loc.loc_start in |
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.
Would you check that these correspond to the locations printed normally (whether starting from 0 or 1) for other error messages?
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 locations are not quite right I think.
jscomp/build_tests/super_errors/expected/repeated_def_types.res.expected
Show resolved
Hide resolved
[1;31m3[0m [2m│[0m type [1;31ma[0m | ||
4 [2m│[0m | ||
|
||
Multiple definition of the type name a at line 1, characters 5-6. |
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 this should say 1:6 for consistency.
I think this is using ocaml locations, from Location.
.
Instead it should be using super-errors locations. The super-error location treatment is use to output 3:6
above.
I think the printing here should use that location logic.
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.
Now I get it about error handling including super_error.
I'm going to fix this with super_error then will take care of #6202
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.
Looks like this test output has non changed yet?
ppf | ||
(fun ppf () -> | ||
fprintf ppf | ||
"@[This expression's type contains type variables that can't be generalized:@,@{<error>%a@}@]" |
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 ounit test seemed to need to pass "can't be generalized," but the test case was written as "cannot be generalized." So, when it was moved to typemod.ml as is, it failed the test, and that's why it was moved to typemod.ml as "cannot be generalized."
When testing "This expression's type contains," it passes, so I think there is no problem.
Two of the ounit tests did not pass, and there seems to be a problem with the existing tests or I did not understand them well. So, I rewrote the tests, and I would like to request a review. @cristianoc |
If the output of the tests changed slightly, you can update the expected result of tests. See Is this correct, that there was just a small difference in what has been printed? If so, it seems better to just update the expected result instead of changing the tests. If I misunderstood: what tests were not working and why? |
Two Ounit_cmd_tests tests cannot pass:
|
OK to move these to super-error tests? So we can check that they're working. |
Cleaning up the Super_error doesn't make changes of test result in fixtures |
Yes thanks I have understood now. That's why I'm asking to move those tests out of ounit. |
Got it, done 10ac8c0 |
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 looks great.
Left a tiny comment.
Anything else to do? Looks like this can be merged.
@@ -276,14 +276,14 @@ let rec y = A y;; | |||
OUnit.assert_bool __LOC__ | |||
(Ext_string.contain_substring should_err.stderr "contravariant") | |||
end; | |||
__LOC__ >:: begin fun _ -> |
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.
Would you delete instead of commenting out?
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.
@@ -294,10 +292,6 @@ let buckle_script_flags : (string * Bsc_args.spec * string) array = | |||
|
|||
(******************************************************************************) | |||
|
|||
|
|||
"-bs-super-errors", unit_lazy Super_main.setup, |
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.
Perhaps mention this as breaking change in the changelog.
I don't think there's any use for calling bsc
directly, but just to be on the safe side.
Isn't there also something in bsconfig
? Perhaps one could deprecate or remove that too.
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 can add it to the changelog as a breaking change, but how do I deprecate it when I've already removed the super_error? There is a way to make it deprecated?
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 is low risk. Remove is OK. No need to deprecate.
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.
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 have nothing left for this PR now. |
Fix #6202
Fix #5695
This PR enhances the error message for duplicate type definitions in ReScript by including the location of the previously declared definition. This improvement aims to provide better context for developers, making it easier to identify and resolve type conflicts in their code.This PR incorporates the Super_error module into the regular modules and cleans up the Super_error module. It also includes adding location information of the already defined declaration in the error message for duplicated type definitions.
In this change, replace the
SetString ref
data structure with(string, Warnings.loc) Hashtbl.t
for better handling of location information.