-
-
Notifications
You must be signed in to change notification settings - Fork 774
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 import error suggestions #3553
base: main
Are you sure you want to change the base?
Conversation
compiler-core/src/parse/snapshots/gleam_core__parse__tests__import_dotted_name.snap
Show resolved
Hide resolved
Ok, I failed to make suggestions shorter 🙈 They are now longer. Changes:
#[test]
fn import_value_as_submodule3() {
// Two possible suggestions: `import one/wobble` or `import one.{wibble}`
// One via hint, one via `did_you_mean`.
assert_with_module_error!(
("one", "pub fn wibble() {}"),
("one/wobble", ""),
"import one/wibble"
);
} We should suggest both:
Because it is not clear what was meant. Now we do both suggestions.
Sadly, we cannot apply suggestions from #3553 (comment) which are great, because of syntax error limitations :( Please, take a look! |
.../src/type_/tests/snapshots/gleam_core__type___tests__imports__import_value_as_submodule.snap
Show resolved
Hide resolved
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'm finding it confusing the way that 2 different suggestions are presenting in 2 different ways now. I think it should only present 1 suggestion and it should always be presented in the same way.
I was not expecting this. | ||
|
||
This syntax for import is not correct. Probably, you meant: | ||
- `import gleam/io` to import module `io` from package `gleam` |
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.
gleam
isn't a package, this would be to import the module gleam/io
name: EcoString, | ||
name_parts: (EcoString, EcoString), | ||
importable_modules: Vec<EcoString>, | ||
}, |
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.
Merge this into the existing unknown module error please
UnknownModuleWithRichSuggestions { | ||
location: SrcSpan, | ||
name: EcoString, | ||
name_parts: (EcoString, EcoString), |
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.
What are name parts?
No module has been found with the name `this_is_a_very_long_name_for_a_module_even_hard_to_read/this_is_a_very_long_submodule_name`. | ||
Hint: Did you mean `import | ||
this_is_a_very_long_name_for_a_module_even_hard_to_read. | ||
{this_is_a_very_long_submodule_name}`? |
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 isn't the correct formatting. Wrapping shouldn't be applied to code.
Hello! Are you still working on this one? Thanks |
Sorry, no :( |
This is the first PR in the series.
This case is not covered yet:
It requires a bit tricky logic to get right, so I decided to split it out.
Better wordings are more than welcome! 👍