Skip to content

fix(#42):--smells crash on Erlang source files - #43

Open
rriley-quorum wants to merge 2 commits into
elixir-vibe:masterfrom
rriley-quorum:fix/erl-crash
Open

fix(#42):--smells crash on Erlang source files#43
rriley-quorum wants to merge 2 commits into
elixir-vibe:masterfrom
rriley-quorum:fix/erl-crash

Conversation

@rriley-quorum

@rriley-quorum rriley-quorum commented Aug 24, 2026

Copy link
Copy Markdown

Summary

mix reach.check --smells crashed on any project with a .erl file (#42). This PR closes #42.

Root cause: the Erlang frontend never set :module on function metadata, unlike the Elixir frontend. Effects.infer_local_effects groups functions by module and crashed on Module.split(nil) as soon as it hit an Erlang-sourced function.

The issue suggested two fixes: (a) populate :module in the Erlang frontend, or (b) make the crashing call site tolerate a missing :module. We went with (a) because the codebase already relies on every function_def node carrying a real module identity in many places (call graph, dead code, effects inference, etc.) — lib/reach/frontend/beam.ex already 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 each function_def node.
  • lib/reach/effects.ex: short_module_alias/1 also crashed on plain Erlang atoms (no Elixir. prefix); it now leaves those alone.

Test plan

  • Added tests confirming Erlang function_def nodes carry :module
  • Added a regression test reproducing the effects.ex crash
  • Reproduced the original crash with a minimal Mix project containing a .erl file and confirmed mix reach.check --smells now runs cleanly
  • Full suite passes: mix test (1235 tests, 0 failures)

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.
@rriley-quorum rriley-quorum changed the title Fix --smells crash on Erlang source files fix:--smells crash on Erlang source files Aug 24, 2026
@rriley-quorum rriley-quorum changed the title fix:--smells crash on Erlang source files fix(#42):--smells crash on Erlang source files Aug 24, 2026
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.

--smells crashes with KeyError: key :module not found on any Erlang (.erl) source file in scope

1 participant