zetzit / zz

πŸΊπŸ™ ZetZ a zymbolic verifier and tranzpiler to bare metal C
MIT License
1.6k stars 52 forks source link

Field Init Shorthand (like rust) #65

Closed jwerle closed 4 years ago

jwerle commented 4 years ago

Hi @aep,

I hope you are doing well. I am curious for your thoughts about supporting field init shorthand parameters, much like Rust [1] for ZZ.

[1]: https://doc.rust-lang.org/book/ch05-01-defining-structs.html#using-the-field-init-shorthand-when-variables-and-fields-have-the-same-name

aep commented 4 years ago

Yes this is fairly easy to implement. All it needs is zz.pest to parse it as short hand, then in parser.rs duplicate the field name.

There are no additional checks required because abs will catch if the field name is actually not in scope.