You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add imported module variables suggestions for unknown variables.
When a variable is not in the current scope, an `Error::UnknownVariable`
is triggered. However the only suggestions were for variables in the
scope with a similar name computed by the "did you mean" algorithm. With
this commit, we also suggest public variables / identifiers (such as
constants, functions or type variant constructor) in imported modules
with the same name.
For example with the following code:
```gleam
import gleam/io
pub fn main() -> Nil {
println("Hello, World!")
}
```
The suggestions are:
```
┌─ /path/to/project/src/project.gleam:4:3
│
4 │ println("Hello, World!")
│ ^^^^^^^
The name `println` is not in scope here.
Consider using one of these variables:
io.println
```
However because we are only checking the name of the variable, we could
have wrong suggestions, as in this case:
```gleam
import gleam/float
import gleam/int
pub fn main() -> Nil {
to_string(3)
}
```
Here, it is clear that we want suggestions on a function named
`to_string` and accepting one parameter of type `Int`, but this is not
the case:
```
┌─ /path/to/project/src/project.gleam:5:3
│
5 │ to_string(3)
│ ^^^^^^^^^
The name `to_string` is not in scope here.
Consider using one of these implementations:
float.to_string
int.to_string
```
0 commit comments