flux-rs / flux

Refinement Types for Rust
MIT License
658 stars 21 forks source link

Shorthand constructor initialization #893

Closed vrindisbacher closed 3 days ago

vrindisbacher commented 4 days ago

Right now, the constructor syntax is a bit redundant. e.g. this annotation:

#[flux::sig(fn(r: S[@old]) -> S[S { x: 1, ..old }])]

Could be a bit simpler:

#[flux::sig(fn(r: S[@old]) -> S[{ x: 1, ..old }])]

i.e. we should be able to infer that the constructor has sort S because of the signature. I don't think this is too hard to implement. We should add an additional case for parsing constructors that omits the surface::PathExpr and change the surface + fhir structures to an Option.

This should leave us with two places where we need to handle not having a path for the constructor: