fix(#42):--smells crash on Erlang source files - #43
Open
rriley-quorum wants to merge 2 commits into
Open
Conversation
Erlang-sourced function_def nodes never got a :module in their metadata, unlike Elixir-sourced ones. Effects.infer_local_effects grouped by module and crashed on Module.split(nil) as soon as any .erl file was in scope. Fixes elixir-vibe#42.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
mix reach.check --smellscrashed on any project with a.erlfile (#42). This PR closes #42.Root cause: the Erlang frontend never set
:moduleon function metadata, unlike the Elixir frontend.Effects.infer_local_effectsgroups functions by module and crashed onModule.split(nil)as soon as it hit an Erlang-sourced function.The issue suggested two fixes: (a) populate
:modulein the Erlang frontend, or (b) make the crashing call site tolerate a missing:module. We went with (a) because the codebase already relies on everyfunction_defnode carrying a real module identity in many places (call graph, dead code, effects inference, etc.) —lib/reach/frontend/beam.exalready does this same thing for compiled BEAM files. Patching just the one call site would leave that same gap open for the ~150 other places that assume a real module, so it would likely just crash again somewhere else.Changes:
lib/reach/frontend/erlang.ex: read the-module(name).attribute and stamp it onto eachfunction_defnode.lib/reach/effects.ex:short_module_alias/1also crashed on plain Erlang atoms (noElixir.prefix); it now leaves those alone.Test plan
function_defnodes carry:module.erlfile and confirmedmix reach.check --smellsnow runs cleanlymix test(1235 tests, 0 failures)