Skip to content

Commit aae39c8

Browse files
committed
Fix warnings
1 parent 8a2c815 commit aae39c8

5 files changed

Lines changed: 10 additions & 15 deletions

File tree

lib/elixir/pages/references/gradual-set-theoretic-types.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,9 @@ In the long term, Elixir developers who want static typing guarantees must expli
241241

242242
Our goal with type inference is to avoid false positives: we will only emit typing violations if the code always fails. However, in some situations, Elixir may, on purpose, define a more strict type during inference, as to encourage certain idioms or to help spot bugs. Those cases are documented below.
243243

244-
* Struct update syntax: when using the struct update syntax, `%User{user | name: "John Doe"}`, `user` must be guaranteed statically to be always be a `User` struct
244+
* Struct update syntax: when using the struct update syntax, `%User{user | name: "John Doe"}`, `user` must be guaranteed statically to be always be a `User` struct
245245

246-
* Single-clause anonymous functions: Elixir always considers the code inside anonynous functions to be executed. For example, in the snippet below
246+
* Single-clause anonymous functions: Elixir always considers the code inside anonynous functions to be executed. For example, in the snippet below, even though the code will only fail at runtime if the anonymous function is later executed, Elixir will treat it as if the function is always executed. If the function has multiple clauses, then Elixir doesn't know which clause will be executed, and makes no assumption.
247247

248248
```elixir
249249
def example(x) do
@@ -252,8 +252,6 @@ Our goal with type inference is to avoid false positives: we will only emit typi
252252
end
253253
```
254254

255-
even though the code will only fail at runtime if the anonymous function is executed, Elixir will treat it as if the function is always executed. If the function has multiple clauses, then Elixir doesn't know which clause will be executed, and makes no assumption.
256-
257255
## Roadmap
258256

259257
At this moment, Elixir implements type inference of all language constructs. The goal is to assess performance and collect feedback on the quality of error messages, before introducing user facing types.

lib/elixir/src/elixir_fn.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ escape({'&', Meta, [Pos]}, E, Dict) when is_integer(Pos), Pos > 0 ->
155155
{Var, Dict};
156156
error ->
157157
Next = elixir_module:next_counter(?key(E, module)),
158-
Var = {capture, [{counter, Next}, {capture, Pos} | Meta], nil},
158+
Var = {'_&', [{counter, Next}, {capture, Pos} | Meta], ?MODULE},
159159
{Var, orddict:store(Pos, Var, Dict)}
160160
end;
161161
escape({'&', Meta, [Pos]}, E, _Dict) when is_integer(Pos) ->

lib/elixir/test/elixir/kernel/expansion_test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,8 +1217,8 @@ defmodule Kernel.ExpansionTest do
12171217
[
12181218
{:->, [line: 1],
12191219
[
1220-
[{:capture, [capture: 1, line: 1], nil}],
1221-
{:capture, [capture: 1, line: 1], nil}
1220+
[{:"_&", [capture: 1, line: 1], :elixir_fn}],
1221+
{:"_&", [capture: 1, line: 1], :elixir_fn}
12221222
]}
12231223
]}
12241224
end

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,12 +1318,6 @@ defmodule Module.Types.ExprTest do
13181318
13191319
dynamic()
13201320
1321-
where "capture" was given the type:
1322-
1323-
# type: dynamic()
1324-
# from: types_test.ex:LINE
1325-
&1
1326-
13271321
instead of using &1, you must define an anonymous function, define a variable and pattern match on "%Date{}"
13281322
"""
13291323

lib/ex_unit/test/ex_unit/formatter_test.exs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,13 +593,16 @@ defmodule ExUnit.FormatterTest do
593593
end
594594

595595
test "inspect failure" do
596-
failure = [{:error, catch_assertion(assert :will_fail == struct!(BadInspect)), []}]
596+
failure = [
597+
{:error, catch_assertion(assert Process.get(:unused, :will_fail) == struct!(BadInspect)),
598+
[]}
599+
]
597600

598601
assert format_test_failure(test(), failure, 1, 80, &formatter/2) =~ ~s'''
599602
1) world (Hello)
600603
test/ex_unit/formatter_test.exs:1
601604
Assertion with == failed
602-
code: assert :will_fail == struct!(BadInspect)
605+
code: assert Process.get(:unused, :will_fail) == struct!(BadInspect)
603606
left: :will_fail
604607
right: #Inspect.Error<
605608
got FunctionClauseError with message:

0 commit comments

Comments
 (0)