Skip to content

Commit 10ea380

Browse files
committed
Clarify infer signatures as of now
1 parent d403bb9 commit 10ea380

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/elixir/lib/code.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1578,7 +1578,7 @@ defmodule Code do
15781578
## Examples
15791579
15801580
Code.compiler_options(infer_signatures: false)
1581-
#=> %{infer_signatures: true}
1581+
#=> %{infer_signatures: [:elixir]}
15821582
15831583
"""
15841584
@spec compiler_options(Enumerable.t({atom, term})) :: %{optional(atom) => term}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ Inferring type signatures comes with a series of trade-offs:
142142

143143
* Cascading errors - when a user accidentally makes type errors or the code has conflicting assumptions, type inference may lead to less clear error messages as the type system tries to reconcile diverging type assumptions across code paths.
144144

145-
On the other hand, type inference offers the benefit of enabling type checking for functions and codebases without requiring the user to add type annotations. To balance these trade-offs, Elixir has a two-steps system, where we first perform inference of functions without type signatures, and then we type check all modules. The inference considers all calls to the same module and any dependency, but assumes calls to modules within the same project to return `dynamic()`, reducing cyclic dependencies and the need for recompilations.
145+
On the other hand, type inference offers the benefit of enabling type checking for functions and codebases without requiring the user to add type annotations. To balance these trade-offs, Elixir has a two-steps system, where we first perform inference of functions without type signatures, and then we type check all modules. The inference considers all calls within the same module and to Elixir standard library. All other calls are assumed to return `dynamic()`, including calls to modules within the same project as to reduce cyclic dependencies and the need for recompilations. Future Elixir versions will include your project dependencies as part of the inferred modules.
146146

147147
Type inference in Elixir is best-effort: it doesn't guarantee it will find all possible type incompatibilities, only that it may find bugs where all combinations of a type _will_ fail, even in the absence of explicit type annotations. It is meant to be an efficient routine that brings developers some benefits of static typing without requiring any effort from them.
148148

0 commit comments

Comments
 (0)