risor
risor copied to clipboard
Potential expression issue
Hey @myzie
I've recently been evaluating risor for a project and was surprised by this being allowed:
a := 123
a a a a // returns 123
and
fn := func() {}
a := 123
fn{}a{}fn{}true
I understand that this is because each of these are individual expressions, and they're not invalid, but it can account for some weird errors if you're not too familiar with the language. For example, I mistakening thought that to create a map, I needed to use the syntax map{a: 123}
. But map
is a built-in.
m := map{a: 123}
m["a"]
Rather than a parser or compile error, you get a runtime error of type error: object is not a container (got builtin)
which is a little confusing.
Do you suspect this could be improved? Should this be a parser/compile error? Thank you!