Skip to content

Fix IEx.Helpers.r/1 fails reload modules defined in same file#15627

Merged
josevalim merged 1 commit into
elixir-lang:mainfrom
AlexGx:ag-iex_r-fix
Jul 17, 2026
Merged

Fix IEx.Helpers.r/1 fails reload modules defined in same file#15627
josevalim merged 1 commit into
elixir-lang:mainfrom
AlexGx:ag-iex_r-fix

Conversation

@AlexGx

@AlexGx AlexGx commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Two modules defined in one file:

defmodule Foo do
    def hello, do: :foo
end

defmodule Bar do
    def hello, do: :bar
end

Trying to reload after compilation:

iex> r([Bar, Foo])

    ...
    
    error: cannot define module Foo because it is currently being defined in /tmp/reload.ex:1
    │
  1 │ defmodule Foo do
    │ ^^^^^^^^^^^^^^^^
    │
    └─ /tmp/reload.ex:1: Foo (module)


= Compilation error in file /tmp/reload.ex ==
** (CompileError) /tmp/reload.ex: cannot compile module Foo (errors have been logged)
    (stdlib 8.0.2) lists.erl:2465: :lists.foldl/3
    (elixir 1.21.0-dev) lib/kernel/parallel_compiler.ex:549: anonymous fn/5 in Kernel.ParallelCompiler.spawn_workers/8
** (MatchError) no match of right hand side value:

Expected: {:reloaded, [Bar, Foo]}

Changes:

  • add elixir sources dedup
  • tests

@josevalim
josevalim merged commit dae2bcb into elixir-lang:main Jul 17, 2026
15 checks passed
@josevalim

Copy link
Copy Markdown
Member

💚 💙 💜 💛 ❤️

@AlexGx
AlexGx deleted the ag-iex_r-fix branch July 17, 2026 14:23
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.

2 participants