File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed
lib/elixir/test/elixir/module/types Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -148,6 +148,21 @@ defmodule Module.Types.ExprTest do
148148
149149 assert typewarn! ( try ( do: :ok , after: URI . unknown ( "foo" ) ) ) ==
150150 { dynamic ( ) , "URI.unknown/1 is undefined or private" }
151+
152+ # Check it also emits over a union
153+ assert typewarn! (
154+ [ x = Atom , y = GenServer , z ] ,
155+ (
156+ mod =
157+ cond do
158+ z -> x
159+ true -> y
160+ end
161+
162+ mod . to_string ( :atom )
163+ )
164+ ) ==
165+ { union ( dynamic ( ) , binary ( ) ) , "GenServer.to_string/1 is undefined or private" }
151166 end
152167
153168 test "calling a nullary function on non atoms" do
@@ -180,6 +195,34 @@ defmodule Module.Types.ExprTest do
180195 # from: types_test.ex:LINE-1
181196 <<x::integer>>
182197 """
198+
199+ assert typeerror! (
200+ [ << x :: integer >> , y = Atom , z ] ,
201+ (
202+ mod =
203+ cond do
204+ z -> x
205+ true -> y
206+ end
207+
208+ mod . to_string ( :atom )
209+ )
210+ ) ==
211+ ~l"""
212+ expected a module (an atom) when invoking to_string/1 in expression:
213+
214+ mod.to_string(:atom)
215+
216+ where "mod" was given the type:
217+
218+ # type: dynamic(Atom or integer()) or integer()
219+ # from: types_test.ex:LINE-9
220+ mod =
221+ cond do
222+ z -> x
223+ true -> y
224+ end
225+ """
183226 end
184227
185228 test "capture a function with non atoms" do
You can’t perform that action at this time.
0 commit comments