Use a runtime check for Macro.classify_atom/1
#294
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We ran into an issue in Lexical reported here: lexical-lsp/lexical#805
Lexical is packaged by precompiling everything, usually on the lowest supported version of Elixir/OTP, and then injecting those compiled modules when launching the runtime node where user project code runs. This means that compile-time version checks could lead to an unexpected code branch at runtime, as the runtime might be a later version.
I think this would usually be okay, since compile-time version checks are usually there to use new APIs and fall back to ones that would still work, but in this case, a private API (
Code.Identifier.classify
) was being used that no longer exists in 1.14+.I know this code-path is performance-sensitive, but a quick Benchee shows that
function_exported?/3
is a small fraction of the cost ofVersion.match?/2
:I've confirmed locally that this change addresses the issue linked above.