Produce better errors when attempting to index values using square brackets #581
Replies: 3 comments
-
(actually, perhaps it's because lists can't be indexed with square brackets like most languages? in which case, maybe this should be special cased to throw an error, since it's a common expectation that a user coming to the language might have) |
Beta Was this translation helpful? Give feedback.
-
Indeed, there's nothing wrong with the formater here so-to-speak; the code is just invalid to begin with because there's no array-indexing on Aiken. Honestly, this is a bit tricky to handle any better because |
Beta Was this translation helpful? Give feedback.
-
I'm not in favor of this at all. It's highly unusual for a linked list style list. I believe this kind of syntax implies semantics that are very misleading about what happens at runtime. Although sometimes "familiar" to people from other languages is definitely a good argument, I do not believe this is a situation where that applies. Most languages have arrays so having that syntax makes sense, Aiken lists are not array's at all. That being said we could allow this syntax for ByteArray because they do have a direct indexing operation in the virtual machine. |
Beta Was this translation helpful? Give feedback.
-
What Git revision are you using?
aiken v1.0.7-alpha unknown
What operating system are you using, and which version?
NixOS
Describe what the problem is?
Aiken fmt is forcing a newline be introduced in the code below, which produces invalid code.
The above snippet gets transformed to
Which doesn't compile
What should be the expected behavior?
It should keep the
[idx]
on the same line.Beta Was this translation helpful? Give feedback.
All reactions