Skip to content

Commit 9b22b6d

Browse files
author
José Valim
committed
Ensure local is disabled on module definitions
1 parent 2a69400 commit 9b22b6d

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

lib/elixir/include/elixir.hrl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
-define(line(Opts), elixir_utils:get_line(Opts)).
1010

1111
-record(elixir_scope, {
12-
context=nil, %% can be assign, guards or nil
12+
context=nil, %% can be match, guards or nil
1313
extra=nil, %% extra information about the context, like fn_match and do_match
1414
noname=false, %% when true, don't add new names (used by try)
1515
super=false, %% when true, it means super was invoked
@@ -32,7 +32,7 @@
3232
file=(<<"nofile">>), %% the current filename
3333
line=1, %% the current line
3434
function=nil, %% the current function
35-
context=nil, %% can be assign, guards or nil
35+
context=nil, %% can be match_vars, guards or nil
3636
requires=[], %% a set with modules required
3737
aliases=[], %% an orddict with aliases by new -> old names
3838
functions=[], %% a list with functions imported from module

lib/elixir/src/elixir_module.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ compile(Module, Block, Vars, #elixir_env{line=Line} = Env) when is_atom(Module)
2424
%% we get rid of the lexical tracker information as, at this
2525
%% point, the lexical tracker process is long gone.
2626
LexEnv = case Env#elixir_env.function of
27-
nil -> Env#elixir_env{module=Module};
28-
_ -> Env#elixir_env{lexical_tracker=nil, function=nil, module=Module}
27+
nil -> Env#elixir_env{module=Module, local=nil};
28+
_ -> Env#elixir_env{lexical_tracker=nil, function=nil, module=Module, local=nil}
2929
end,
3030

3131
case LexEnv#elixir_env.lexical_tracker of

lib/iex/test/iex/interaction_test.exs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,19 @@ defmodule IEx.InteractionTest do
6666
assert "** (RuntimeError) undefined function: many/3" <> _ = capture_iex("many(:ok, 22, \"hi\")")
6767
end
6868

69+
test "module definition" do
70+
input = """
71+
defmodule Sample do
72+
def foo, do: bar
73+
def bar, do: 13
74+
end && Sample.foo
75+
"""
76+
assert capture_iex(input) =~ "13"
77+
after
78+
:code.purge(Sample)
79+
:code.delete(Sample)
80+
end
81+
6982
## .iex file loading
7083

7184
test "no .iex" do

0 commit comments

Comments
 (0)