gleam
gleam copied to clipboard
Improve error message if importing type using the value import syntax
Give a hint to say that you probably meant the type as the value does not exist
For example, if you have a module named wibble
, that defines a type named One
but no value called One
and you write this code
import wibble.{One}
the resulting error message should suggest import wibble.{type One}
I am interested in this issue and would like to know more.
Firstly I would like to understand the issue better, does it mean that in cases such as:
import gleam/io
fn say_hello(name: Str) {
io.println(name)
}
pub fn main() {
let name = "Gleam"
say_hello(name)
}
The compiler instead of saying "Did you mean Int?" should say "Str doesn't exist"?
Also in this example I find it strange that when I compile I get:
error: Unknown type
┌─ /home/user/glem_proj/src/mod_dep.gleam:3:20
│
3 │ fn say_hello(name: Str) {
│ ^^^ Did you mean `Int`?
The type `Str` is not defined or imported in this module.
When it would have been more appropriate to say: "Did you mean String?"
Ah! I've updating the issue with more detail. Thank you