ethereum / fe

Emerging smart contract language for the Ethereum blockchain.
https://fe-lang.org
Other
1.6k stars 179 forks source link

v2: enum record variant support; one-liner record def #916

Closed sbillig closed 12 months ago

sbillig commented 1 year ago

v2 parser and HIR now allow record-type enum variants.

Struct (and record enum variant) fields must now be separated by a comma (newlines are allowed but not required). This allows a struct with multiple fields to be defined on a single line, eg struct S { x: u8, y: u8 }.

Nit-picky feedback welcome.

sbillig commented 12 months ago

@Y-Nak I added the enum record variant fields to the scope graph, in the way that we decided wasn't very elegant 🙃. This seemed nicer than adding a lookup from ScopeId(u32) to ScopeKind

sbillig commented 12 months ago

Great!

I feel comma should be required for an enum definition as well if it is required for a struct definition. I want to hear your opinion.

I agree; I'll make this change separately.