Stream: contributing

Topic: desugar bang help


view this post on Zulip Luke Boswell (Mar 19 2024 at 05:13):

I've been working on the desguaring for ! in the desugar-bang branch.

I'm currently having some trouble working with the Defs in crates/compiler/parse/src/ast.rs. Specifically to implement the algorithm the way I want, I need to be able to remove a definition from the Defs, from the start or from within the middle of the vec. Hence I've added the remove_value_def helper. To get the index I wrote the search_suffixed_defs which finds the first value def that I am interested in.

But I'm really unsure about how to work with the pub tags: std::vec::Vec<EitherIndex<TypeDef<'a>, ValueDef<'a>>> part. It probably doesn't help I'm also just fumbling my way through rust at the same time so I am not sure where I'm going wrong.

I started off by just working with the value_defs vec but then realised that I probably need to also work with the type_defs and the other parts of the Defs struct if I am removing things. I know there is an issue here because I get "panicked at 'index out of bounds: the len is 1 but the index is 1'" errors.

It may not be helpful, but here is my plan to desugar Defs worked out manually

view this post on Zulip Luke Boswell (Mar 19 2024 at 08:29):

I think I know what the issue with my logic is. Using Vec::remove shifts the remaining values left, so the remaining indexes will now be all off by 1.


Last updated: Jul 06 2025 at 12:14 UTC