gleam icon indicating copy to clipboard operation
gleam copied to clipboard

Implement `let assert as "msg"` syntax

Open sobolevn opened this issue 6 months ago • 0 comments

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 option 2. means something different and option 1. was very confusing, let assert as msg is similar to todo as msg and panic as msg
  • I remove AssignmentKind enum and replaced it with AssertAssignment struct which contains both location and optional message of assert
  • In let assert as MSG our MSG can only be a unit expression: basically a name or String
  • I added a inference of MSG to only be String 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!

sobolevn avatar Aug 01 '24 14:08 sobolevn