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
error: Unknown variable
┌─ /src/main.gleam:4:7
│
4 │ let X = 2
│ ^
The name `X` is not in scope here.
error: Unknown variable
┌─ /src/main.gleam:5:12
│
5 │ io.debug(X)
│ ^
The name `X` is not in scope here.
Maybe this error message could be improved so that it's clear that here the user tried to pattern match on a constructor which does not exsits.
Danielle — 11:09
Yeah that is a slightly confusing error message to me
lpil — 11:09
What you’ve written is valid Gleam
You’re pattern matching on a custom type constructor called X, but no such constructor is in scope
We couldn’t change the error message for this niche situation without making the error message for common situation worse
Danielle — 11:11
does it saying error: Unknown variable make the most sense considering it's a pattern match?
lpil — 11:12
Unknown constructor might be clearer
Unknown value?
bouzlibop — 11:14
"You’re pattern matching on a custom type constructor called X" would be a super helpful error message 🙂
lpil — 11:14
Could you make an issue with the above conversation please
bouzlibop — 11:14
Sure 👍
lpil — 11:17
Thank you
The text was updated successfully, but these errors were encountered:
I suggest splitting between "no parameters case" and then "1+ parameters case".
For "1+ parameters", the current error message ("unknown variable") is sufficient. Notably, with some parameters written out, the user is probably trying to destructure, and has a constructor in mind.
For "no parameters", I am unsure of where destructuring to a parameter-less constructor would be useful. There's no variables to bind to. If someone has a useful example please share. This case deserves more attention.
Currently:
let X(text) = func() // error: Unknown variable, The name `X` is not in scope here.
let Y = func() // error: Unknown variable, The name `Y` is not in scope here.
Proposed:
let X(text) = func() // keep the same
let Y = func() // add -> "Hint: Variable names are typically lowercase, unless they reference a type."
Also possible: Change from "unknown variable" to "unknown constructor" for both cases.
Context
When trying to run following:
in the playground
One gets:
Maybe this error message could be improved so that it's clear that here the user tried to pattern match on a constructor which does not exsits.
Notes
This issue was discussed on the Discord server:
The text was updated successfully, but these errors were encountered: