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: treat pretty-printed names as strings #2652

Merged
merged 1 commit into from
Oct 11, 2023
Merged

Conversation

Vtec234
Copy link
Member

@Vtec234 Vtec234 commented Oct 10, 2023

I initially expected Names to always faithfully represent internal data, in particular that a name with macro scopes would have a form such as `foo._@.Module._hyg.1, and that tombstones would only appear in types that represent pretty-printed output such as as String or Format. However, that is not what happens. We have sanitizeNames which rewrites the userName field of local hypotheses to be Name.str .anonymous "blah✝".

Then in the server code, we put these into names : Array Name. This works fine for displaying in the infoview, but if we try to deserialize an InteractiveHypothesisBundle inside an RPC method for widget purposes, the FromJson Name instance blows up in String.toName.

I think my preferred solution is to, rather than 'fix' String.toName to accept these names with tombstones, stop pretending that they are actual Names and re-type InteractiveHypothesisBundle.names : Array String. This should be a backwards-compatible change w.r.t. infoview code as the JSON representation is a string in either case. It is not backwards compatible w.r.t. meta code that uses this field.

See also Zulip discussion.

I initially expected `Name`s to always faithfully represent internal data, in particular that a name with macro scopes would have a form such as  ```foo._@.Module._hyg.1``, and that tombstones would only appear in types that represent pretty-printed output such as as `String` or `Format`. However, that is not what happens. We have `sanitizeNames` which rewrites the `userName` field of local hypotheses to be `Name.str .anonymous "blah✝"`.

Then in the server code, we put these into `names : Array Name`e. This works fine for displaying in the infoview, but if we try to deserialize an `InteractiveHypothesisBundle` inside an RPC method for widget purposes, the `FromJson Name` instance blows up in `String.toName`.

I think my preferred solution is to, rather than 'fix' `String.toName` to accept these names with tombstones, stop pretending that they are actual `Name`s and re-type `InteractiveHypothesisBundle.names : Array String`. This should be a backwards-compatible change w.r.t. infoview code as the JSON representation is a string in either case. It is not backwards compatible w.r.t. meta code that uses this field.
@Vtec234
Copy link
Member Author

Vtec234 commented Oct 11, 2023

awaiting-review

@github-actions github-actions bot added awaiting-review Waiting for someone to review the PR toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN labels Oct 11, 2023
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Oct 11, 2023
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added the builds-mathlib CI has verified that Mathlib builds against this PR label Oct 11, 2023
@leanprover-community-mathlib4-bot
Copy link
Collaborator

@Kha Kha merged commit 856a9b5 into leanprover:master Oct 11, 2023
17 checks passed
@Vtec234 Vtec234 deleted the hyp-names branch October 11, 2023 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-review Waiting for someone to review the PR builds-mathlib CI has verified that Mathlib builds against this PR toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants