Skip to content

Bug with nested letrecs? #84

@gmorpheme

Description

@gmorpheme

I think there may be a bug in the handling of nested recursive bindings with embeds... i.e. nested letrecs as in the test I've added here:

curvelogic@39d7c56

(I may be misunderstanding or there may be a way to combine Nest<> or something else to fix this but I'm not seeing it at present.)

When opening the pattern, state depth is not incremented when entering the second scope's pattern so bound variables which actually identify the nested letrec are being looked up in the outer letrec. (Which fails in the test above because there are fewer bindings in the outer letrec than the index of the binding being sought.)

Culprit seems to be a missing .incr() on line 142 of scope.rs. Depth is incremented for unsafe_body but not for unsafe_pattern. I'm not clear in my head yet whether the obvious change of adding the .incr() for the pattern too (like this) is safe or correct but it doesn't seem to break any tests at least.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions