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

Show hint to import unqualified types/values #4297

Open
GearsDatapacks opened this issue Mar 3, 2025 · 8 comments · May be fixed by #4304
Open

Show hint to import unqualified types/values #4297

GearsDatapacks opened this issue Mar 3, 2025 · 8 comments · May be fixed by #4304
Labels
help wanted Contributions encouraged priority:medium

Comments

@GearsDatapacks
Copy link
Member

For example:

import gleam/dict

type Grid(a) {
  Grid(Dict(#(Int, Int), a))
}

This is an error, since Dict is not imported. However, gleam/dict is. So we could either give a hint to import it unqualified: gleam/dict.{type Dict}, or (probably preferably), qualify it: dict.Dict(...)
We could either just check for this in imported modules, or all importable modules.

@lpil
Copy link
Member

lpil commented Mar 3, 2025

Good idea! Perhaps we could look for a type constructor with the appropriate arity, favouring imported modules over unimported ones?

@lpil lpil added help wanted Contributions encouraged priority:medium labels Mar 3, 2025
@mine-tech-oficial
Copy link

I've been meaning to try and tackle this and, just so that its clear, I just need to add the hint to the error output for now, or should I implement a code action too?

@mine-tech-oficial
Copy link

Also, should I hint to qualify it or import unqualified?

@mine-tech-oficial mine-tech-oficial linked a pull request Mar 5, 2025 that will close this issue
4 tasks
@GearsDatapacks
Copy link
Member Author

Probably hint to qualify it. No code action needed for now, although if you want to integrate the code action, feel free

@mine-tech-oficial
Copy link

mine-tech-oficial commented Mar 5, 2025

Just when I publish a draft to import unqualified (as I suppose that is the programmer's original intention) 😄

@GearsDatapacks
Copy link
Member Author

That's fine. I don't have a strong opinion either way

@mine-tech-oficial
Copy link

When you say value, do you mean a public constant, function and/or type constructor?

@GearsDatapacks
Copy link
Member Author

Yep

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Contributions encouraged priority:medium
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants