gleam
gleam copied to clipboard
Implement `let assert as "msg"` syntax
This is a draft of https://github.com/gleam-lang/gleam/issues/3216
Design
- I went with option
3.
from https://github.com/gleam-lang/gleam/issues/3216#issue-2326145589 since option2.
means something different and option1.
was very confusing,let assert as msg
is similar totodo as msg
andpanic as msg
- I remove
AssignmentKind
enum and replaced it withAssertAssignment
struct which contains both location and optional message ofassert
- In
let assert as MSG
ourMSG
can only be a unit expression: basically a name orString
- I added a inference of
MSG
to only beString
and nothing else
Further steps
I understand that this feature was not fully discussed and not fully specified. So, please: feel free to close this PR if you don't want this.
I did it just for fun :)
Impressions
I really had fun working on this!
The compiler is very simple and is pleasant to work with. Tests are really intuitive with the help of insta
.
Thanks a lot for writting Gleam, it is so refreshing and cool!