Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix instantiation of a module containing USE. #191

Merged
merged 1 commit into from
Jan 4, 2025
Merged

Conversation

kape1395
Copy link
Collaborator

@kape1395 kape1395 commented Jan 2, 2025

It was failing before with tlapm ending abnormally with Failure("unknown bound variable").

This fixes a case mentioned in #151 (comment)

It was failing before with `tlapm ending abnormally with Failure("unknown bound variable")`.

Signed-off-by: Karolis Petrauskas <[email protected]>
@muenchnerkindl
Copy link
Contributor

I am afraid I know nothing about this part of the code, and I'd prefer if @damiendoligez or @johnyf could have a look.

@johnyf
Copy link
Contributor

johnyf commented Jan 4, 2025

The change looks good to me, based on Module.Elab.normalize, which appends the hypotheses of the module-scope USE statement to the context via let cx = Deque.append_list cx (hyps_of_modunit mu) in which is used in the case of Mutate statements. In Module.T.hyps_of_modunit the case of USE statements returns the USE facts, with indices shifted depending on the fact's position.

The cause of the error appears to be that the context used during the module traversal did not have the USE facts, so the indexing of Op within OpAll would not point to where Op is defined. The error message "unknown bound variable" appears to originate from Expr.T.get_val_from_id, which is used to retrieve hypotheses from the context, based on their index. By adding let cx = update_cx cx mu in to the Mutate case, the USE facts are appended to the traversal's context, so that the occurrence Op in \A x : Op(x) will resolve to where Op is defined, which is before the USE statement.

@kape1395 kape1395 merged commit 9df048d into main Jan 4, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants