This almost certainly a wacky idea, but thought I would share it anyway.
I was looking at code similar to the below and had a thought; I wondered if you should be able to add a type annotation when deconstructing values... maybe it would make sense to have an anonymous annotation like below?
expect
first : { foo : U32 } # annotation for ident `first`
first = { foo: 12 }
: {bar : U32, baz : Dec } # annotation for anonymous struct?
{bar, baz} = {bar: 24, baz: 36.0 }
first.foo == 12 && bar == 24 && baz == 36.0
It looks a bit strange, and you could just assign it to an identifier if you wanted an annotation. But I guess this could reduce visual clutter without the additional identifier.
Interesting, although I wonder if it would still be valuable once you have "type on hover" support in an editor.
I was thinking the primary benefit for an annotation is to help the compiler help you, so if the types are not what is expected then you get a more accurate error.
Type on hover sounds great though
You can already do this, right? I checked and you can't
bar : U32
baz : Dec
{ bar, baz } = { bar: 24, baz: 36.0 }
Or can type hints only go on the line directly before something is defined?
If you can do that, it might make sense to be able to put those type hints on one line somehow, like this?
bar : U32, baz : Dec
{ bar, baz } = { bar: 24, baz: 36.0 }
Or even this:
{ bar, baz } : { bar : U32, baz : Dec }
{ bar, baz } = { bar: 24, baz: 36.0 }
I'm surprised that last one doesn't work already, I just assumed it would :shrug:
That last one looks nice I think. Hadn't thought of that.
Last updated: Jun 16 2026 at 16:19 UTC