Skip to content

fix state in local bind#47

Merged
Octachron merged 1 commit intoOctachron:masterfrom
art-w:diff0
May 4, 2026
Merged

fix state in local bind#47
Octachron merged 1 commit intoOctachron:masterfrom
art-w:diff0

Conversation

@art-w
Copy link
Copy Markdown
Contributor

@art-w art-w commented May 4, 2026

Thank you for this amazing project!

I ran into a tiny glitch when playing around, with a spurious "non-resolvable module Y" on the second instance of a let module M = Y in ... even though the first use of Y resolved correctly. This PR adds a test to document the issue, and the second commit is an attempt to fix it (I think the bug is just a one-character typo, but note that I don't understand the code enough to be sure).

Comment thread lib/zipper_fold.ml Outdated
body
>>= fun body ->
let state = State.restart state diff in
let state = State.restart state diff0 in
Copy link
Copy Markdown
Owner

@Octachron Octachron May 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be more symmetrical, I would propose to remove this line,
Indeed, in this case we are restarting from the <?> hole after succeeding at resolving it in

let module M = <?> in <body>
<rest>

Thus once we have resolved the body in the extended environment state', we should go back to the starting environment from the <?> hole when resolving <rest>.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ha! thanks I've updated :)

@Octachron
Copy link
Copy Markdown
Owner

Similarly, for the test I think I will add the single file version

module R = struct end
module M = struct let x = 0 end
let () = let module Z = R in ()
let () = let module Z = R in M.x

where the issue can be detected by the tests/step_by_step resolver (but not the ordinary solver which cannot fail on a local module resolution).

@art-w
Copy link
Copy Markdown
Contributor Author

art-w commented May 4, 2026

Thanks for the quick review! I was a bit fixated on the module aliases and didn't notice it was unrelated here... Anyway I've applied your feedback verbatim (but feel free to close that PR if you have your own fix :) )

@Octachron Octachron merged commit 68ff962 into Octachron:master May 4, 2026
8 checks passed
@Octachron
Copy link
Copy Markdown
Owner

Merged, thanks for the report and the fix !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants