gccrs icon indicating copy to clipboard operation
gccrs copied to clipboard

nr2.0: Run a final `TopLevel` pass after desugaring

Open powerboat9 opened this issue 7 months ago • 9 comments

powerboat9 avatar May 20 '25 16:05 powerboat9

I don't know if this is the best way to go about this, it's definitely hacky. maybe we could do all the desugars as part of the fixed point and mark the visitor as dirty when we find something to desugar

CohenArthur avatar May 23 '25 14:05 CohenArthur

I don't know if this is the best way to go about this, it's definitely hacky. maybe we could do all the desugars as part of the fixed point and mark the visitor as dirty when we find something to desugar

It looks like doing exactly that would screw up recursion_limit tracking -- I've reworked the patch to put desugaring + the final TopLevel pass in the fixed point loop though, which seems a bit less hacky.

powerboat9 avatar May 24 '25 18:05 powerboat9

I don't know if this is the best way to go about this, it's definitely hacky. maybe we could do all the desugars as part of the fixed point and mark the visitor as dirty when we find something to desugar

It looks like doing exactly that would screw up recursion_limit tracking -- I've reworked the patch to put desugaring + the final TopLevel pass in the fixed point loop though, which seems a bit less hacky.

It looks like this doesn't work, as the desugaring doesn't seem to handle partially complete early resolution well. I have moved the desugaring and last TopLevel pass to the expansion function, though.

powerboat9 avatar May 28 '25 01:05 powerboat9

@CohenArthur @P-E-P

powerboat9 avatar May 31 '25 22:05 powerboat9

It looks like doing exactly that would screw up recursion_limit tracking

how do you mean? desugaring shouldn't count for the expansion limit, as we control the expansion (as opposed to a user-defined macro).

CohenArthur avatar Jun 09 '25 10:06 CohenArthur

It looks like doing exactly that would screw up recursion_limit tracking

how do you mean? desugaring shouldn't count for the expansion limit, as we control the expansion (as opposed to a user-defined macro).

The fixed point loop would either have to skip desugaring if we hit the expansion limit or run an extra iteration past the expansion limit.

powerboat9 avatar Jun 09 '25 22:06 powerboat9

I think this is not really an issue, if we hit the expansion limit we'll have an error anyway and will stop the pipeline. so the desugaring does not matter. I think the resulting code would be more correct

CohenArthur avatar Jun 11 '25 13:06 CohenArthur

I think this is not really an issue, if we hit the expansion limit we'll have an error anyway and will stop the pipeline. so the desugaring does not matter. I think the resulting code would be more correct

I'm having trouble writing code that both includes desugaring in the main loop and that I can verify doesn't introduce an off-by-one error to cfg.recursion_limit. I've pushed what I have so far -- it looks correct, but I'm not sure its better than what I had before.

powerboat9 avatar Jun 14 '25 02:06 powerboat9

@P-E-P this changeset?

powerboat9 avatar Jun 16 '25 14:06 powerboat9