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

Erase global_ by moving the modality to a [@globalized] attribute #93

Merged
merged 2 commits into from
Jan 14, 2025

Conversation

dvulakh
Copy link

@dvulakh dvulakh commented Dec 2, 2024

Erasing modalities can cause ppxs that inspect them to fail. Consider:

open! Core

module A = struct
  type t = int
end

module B = struct
  type t =
    { global_ a : A.t
    ; b : string
    }
  [@@deriving globalize]
end

As written, this code compiles. If global_ is completely erased, ppx_globalize generates code that references A.globalize (which does not exist). So we wish to tell ppx_globalize not to "re-globalize" a when deriving B.globalize without leaving the global_ modality in the record.

ppx_globalize already recognizes the [@globalized] attribute for this purpose, so for now we rewrite global_ modalities to the [@globalized] attribute when erasing extensions. Eventually, we will want to come up with a more general approach that all modes and ppxs can share and recognize.

@dvulakh dvulakh requested a review from ccasin December 2, 2024 20:41
@dvulakh dvulakh force-pushed the dvulakh.fix-global_-erasing branch from f8d2925 to b0e7f36 Compare January 14, 2025 16:30
Copy link

@ccasin ccasin left a comment

Choose a reason for hiding this comment

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

LGTM (except CI is failing for a reason that looks unrelated to this PR)

lib/Normalize_std_ast.ml Outdated Show resolved Hide resolved
Signed-off-by: David Vulakh <[email protected]>
@dvulakh dvulakh merged commit 35aaa33 into jane Jan 14, 2025
3 of 4 checks passed
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