Confusing "variable not in scope" error
LightAndLight opened this issue · comments
path : String
path = "example.com"
main : IO ()
main = println "https://$path?key=value"
Output:
$ ipso test.ipso
test.ipso:5:26: error: variable not in scope
|
5 | main = println "https://$path?key=value"
| ^
I felt confused when debugging a similar error. I looked at Ipso's error message, and thought to myself, "Why? path
is in scope." After a few minutes, I realised I had forgotten that Ipso allows ?
and !
in variable names, so the error was telling me that the variable path?key
was not in scope, which is true. To fix the error, I need to write "https://${path}?key=value"
so that the ?
is treated literally.
If the caret in the error message was actually a span then I would have noticed this instantly:
$ ipso test.ipso
test.ipso:5:26: error: variable not in scope
|
5 | main = println "https://$path?key=value"
| ^~~~~~~~