Skip to content

Recompile regexes when escaped from module attributes #14381

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

Merged
merged 5 commits into from
Mar 30, 2025

Conversation

josevalim
Copy link
Member

@josevalim josevalim commented Mar 30, 2025

Elixir has historically relied on a behaviour that, when regexes were compiled, its native parts were compiled to a binary. Erlang/OTP 28 changes this and emits a reference, which means they can no longer be inlined at compile-time. In other words, you can no longer define a regex in a module body and store it in a module attribute or escape it inside a function.

In order to avoid breakage, we are adding a special case to module attributes that recompiles injected regexes, however, we are also attaching a deprecation to it. We could theoretically fix this generally by introducing some sort of Macro.Escape protocol, which we could be used by projects like Explorer and similar, but I think keeping a distinction between those would be important. For example, similar issues would happen when transferring those data types between nodes.

This patch should be backported to v1.18 however, when backporting, I would remove the deprecation notice.

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.

1 participant