Skip to content

Commit 5ff421c

Browse files
committed
Disable inference as part of v1.19 release
1 parent 4425d68 commit 5ff421c

File tree

5 files changed

+1
-244
lines changed

5 files changed

+1
-244
lines changed

lib/elixir/lib/module/types.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ defmodule Module.Types do
419419
local_handler: handler,
420420
# Control if variable refinement is enabled.
421421
# It is disabled only on dynamic dispatches.
422-
refine_vars: true
422+
refine_vars: false
423423
}
424424
end
425425

lib/elixir/test/elixir/module/types/expr_test.exs

Lines changed: 0 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,6 @@ defmodule Module.Types.ExprTest do
4343
assert typecheck!([x], [:ok | x]) == dynamic(non_empty_list(term(), term()))
4444
end
4545

46-
test "inference" do
47-
assert typecheck!(
48-
[x, y, z],
49-
(
50-
List.to_integer([x, y | z])
51-
{x, y, z}
52-
)
53-
) == dynamic(tuple([integer(), integer(), list(integer())]))
54-
end
55-
5646
test "hd" do
5747
assert typecheck!([x = [123, :foo]], hd(x)) == dynamic(union(atom([:foo]), integer()))
5848
assert typecheck!([x = [123 | :foo]], hd(x)) == dynamic(integer())
@@ -127,16 +117,6 @@ defmodule Module.Types.ExprTest do
127117
end
128118

129119
describe "funs" do
130-
test "infers calls" do
131-
assert typecheck!(
132-
[x],
133-
(
134-
x.(1, 2)
135-
x
136-
)
137-
) == dynamic(fun(2))
138-
end
139-
140120
test "infers functions" do
141121
assert typecheck!(& &1) == fun([dynamic()], dynamic())
142122
assert typecheck!(fn -> :ok end) == fun([], atom([:ok]))
@@ -263,53 +243,6 @@ defmodule Module.Types.ExprTest do
263243
assert typecheck!([%x{}], x.foo_bar()) == dynamic()
264244
end
265245

266-
test "infers atoms" do
267-
assert typecheck!(
268-
[x],
269-
(
270-
x.foo_bar()
271-
x
272-
)
273-
) == dynamic(atom())
274-
275-
assert typecheck!(
276-
[x],
277-
(
278-
x.foo_bar(123)
279-
x
280-
)
281-
) == dynamic(atom())
282-
283-
assert typecheck!(
284-
[x],
285-
(
286-
&x.foo_bar/1
287-
x
288-
)
289-
) == dynamic(atom())
290-
end
291-
292-
test "infers maps" do
293-
assert typecheck!(
294-
[x],
295-
(
296-
:foo = x.foo_bar
297-
123 = x.baz_bat
298-
x
299-
)
300-
) == dynamic(open_map(foo_bar: atom([:foo]), baz_bat: integer()))
301-
end
302-
303-
test "infers args" do
304-
assert typecheck!(
305-
[x, y],
306-
(
307-
z = Integer.to_string(x + y)
308-
{x, y, z}
309-
)
310-
) == dynamic(tuple([integer(), integer(), binary()]))
311-
end
312-
313246
test "undefined function warnings" do
314247
assert typewarn!(URI.unknown("foo")) ==
315248
{dynamic(), "URI.unknown/1 is undefined or private"}
@@ -535,16 +468,6 @@ defmodule Module.Types.ExprTest do
535468
end
536469

537470
describe "binaries" do
538-
test "inference" do
539-
assert typecheck!(
540-
[x, y],
541-
(
542-
<<x::float-size(y)>>
543-
{x, y}
544-
)
545-
) == dynamic(tuple([union(float(), integer()), integer()]))
546-
end
547-
548471
test "warnings" do
549472
assert typeerror!([<<x::binary-size(2)>>], <<x::float>>) ==
550473
~l"""
@@ -644,16 +567,6 @@ defmodule Module.Types.ExprTest do
644567
assert typecheck!([x], {:ok, x}) == dynamic(tuple([atom([:ok]), term()]))
645568
end
646569

647-
test "inference" do
648-
assert typecheck!(
649-
[x, y],
650-
(
651-
{:ok, :error} = {x, y}
652-
{x, y}
653-
)
654-
) == dynamic(tuple([atom([:ok]), atom([:error])]))
655-
end
656-
657570
test "elem/2" do
658571
assert typecheck!(elem({:ok, 123}, 0)) == atom([:ok])
659572
assert typecheck!(elem({:ok, 123}, 1)) == integer()
@@ -1458,16 +1371,6 @@ defmodule Module.Types.ExprTest do
14581371
) == dynamic(atom([:ok, :error, :timeout]))
14591372
end
14601373

1461-
test "infers type for timeout" do
1462-
assert typecheck!(
1463-
[x],
1464-
receive do
1465-
after
1466-
x -> x
1467-
end
1468-
) == dynamic(union(integer(), atom([:infinity])))
1469-
end
1470-
14711374
test "resets branches" do
14721375
assert typecheck!(
14731376
[x, timeout = :infinity],
@@ -1854,16 +1757,6 @@ defmodule Module.Types.ExprTest do
18541757
"""
18551758
end
18561759

1857-
test "infers binary generators" do
1858-
assert typecheck!(
1859-
[x],
1860-
(
1861-
for <<_ <- x>>, do: :ok
1862-
x
1863-
)
1864-
) == dynamic(binary())
1865-
end
1866-
18671760
test ":into" do
18681761
assert typecheck!([binary], for(<<x <- binary>>, do: x)) == list(integer())
18691762
assert typecheck!([binary], for(<<x <- binary>>, do: x, into: [])) == list(integer())
@@ -1901,20 +1794,6 @@ defmodule Module.Types.ExprTest do
19011794
end
19021795
) == union(atom([:ok]), union(integer(), float()))
19031796
end
1904-
1905-
test ":reduce inference" do
1906-
assert typecheck!(
1907-
[list, x],
1908-
(
1909-
123 =
1910-
for _ <- list, reduce: x do
1911-
x -> x
1912-
end
1913-
1914-
x
1915-
)
1916-
) == dynamic(integer())
1917-
end
19181797
end
19191798

19201799
describe "info" do

lib/elixir/test/elixir/module/types/infer_test.exs

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,6 @@ defmodule Module.Types.InferTest do
5151
assert types[{:fun4, 4}] == {:infer, nil, [{args, atom([:ok])}]}
5252
end
5353

54-
test "infer types from expressions", config do
55-
types =
56-
infer config do
57-
def fun(x) do
58-
x.foo + x.bar
59-
end
60-
end
61-
62-
number = union(integer(), float())
63-
64-
assert types[{:fun, 1}] ==
65-
{:infer, nil, [{[dynamic(open_map(foo: number, bar: number))], dynamic(number)}]}
66-
end
67-
6854
test "infer with Elixir built-in", config do
6955
types =
7056
infer config do
@@ -95,33 +81,6 @@ defmodule Module.Types.InferTest do
9581
]}
9682
end
9783

98-
test "infers return types from private functions", config do
99-
types =
100-
infer config do
101-
def pub(x), do: priv(x)
102-
defp priv(:ok), do: :ok
103-
defp priv(:error), do: :error
104-
end
105-
106-
assert types[{:pub, 1}] ==
107-
{:infer, nil, [{[dynamic(atom([:ok, :error]))], dynamic(atom([:ok, :error]))}]}
108-
109-
assert types[{:priv, 1}] == nil
110-
end
111-
112-
test "infers return types from super functions", config do
113-
types =
114-
infer config do
115-
def pub(:ok), do: :ok
116-
def pub(:error), do: :error
117-
defoverridable pub: 1
118-
def pub(x), do: super(x)
119-
end
120-
121-
assert types[{:pub, 1}] ==
122-
{:infer, nil, [{[dynamic(atom([:ok, :error]))], dynamic(atom([:ok, :error]))}]}
123-
end
124-
12584
test "infers return types even with loops", config do
12685
types =
12786
infer config do

lib/elixir/test/elixir/module/types/integration_test.exs

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -85,77 +85,6 @@ defmodule Module.Types.IntegrationTest do
8585
]
8686
end
8787

88-
test "writes exports with inferred map types" do
89-
files = %{
90-
"a.ex" => """
91-
defmodule A do
92-
defstruct [:x, :y, :z]
93-
94-
def struct_create_with_atom_keys(x) do
95-
infer(y = %A{x: x})
96-
{x, y}
97-
end
98-
99-
def map_create_with_atom_keys(x) do
100-
infer(%{__struct__: A, x: x, y: nil, z: nil})
101-
x
102-
end
103-
104-
def map_update_with_atom_keys(x) do
105-
infer(%{x | y: nil})
106-
x
107-
end
108-
109-
def map_update_with_unknown_keys(x, y) do
110-
infer(%{x | y => 123})
111-
x
112-
end
113-
114-
defp infer(%A{x: <<_::binary>>, y: nil}) do
115-
:ok
116-
end
117-
end
118-
"""
119-
}
120-
121-
modules = compile_modules(files)
122-
exports = read_chunk(modules[A]).exports |> Map.new()
123-
124-
return = fn name, arity ->
125-
pair = {name, arity}
126-
%{^pair => %{sig: {:infer, nil, [{_, return}]}}} = exports
127-
return
128-
end
129-
130-
assert return.(:struct_create_with_atom_keys, 1) ==
131-
dynamic(
132-
tuple([
133-
binary(),
134-
closed_map(
135-
__struct__: atom([A]),
136-
x: binary(),
137-
y: atom([nil]),
138-
z: atom([nil])
139-
)
140-
])
141-
)
142-
143-
assert return.(:map_create_with_atom_keys, 1) == dynamic(binary())
144-
145-
assert return.(:map_update_with_atom_keys, 1) ==
146-
dynamic(
147-
closed_map(
148-
__struct__: atom([A]),
149-
x: binary(),
150-
y: term(),
151-
z: term()
152-
)
153-
)
154-
155-
assert return.(:map_update_with_unknown_keys, 2) ==
156-
dynamic(open_map())
157-
end
158-
15988
test "writes exports with inferred function types" do
16089
files = %{
16190
"a.ex" => """

lib/elixir/test/elixir/module/types/pattern_test.exs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,6 @@ defmodule Module.Types.PatternTest do
106106
) == uri_type
107107
end
108108

109-
test "refines types" do
110-
assert typecheck!(
111-
[x, foo = :foo, bar = 123],
112-
(
113-
{^foo, ^bar} = x
114-
x
115-
)
116-
) == dynamic(tuple([atom([:foo]), integer()]))
117-
end
118-
119109
test "reports incompatible types" do
120110
assert typeerror!([x = {:ok, _}], [_ | _] = x) == ~l"""
121111
the following pattern will never match:

0 commit comments

Comments
 (0)