Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ TODO.

* Type inference of patterns (typing inference of guards will be part of an upcoming release)

* [Support for tuples and lists as composite types](https://elixir-lang.org/blog/2024/08/28/typing-lists-and-tuples/) as well as type checking of their basic operations

* Type checking of all language constructs, except `for`, `with`, and closures
* Type checking of all language constructs, including local and remote calls, except `for`, `with`, and closures

* Type checking of all `Kernel` and conversion functions inlined by the compiler

* Detection of clauses and patterns that never match
* [Support for tuples and lists as composite types](https://elixir-lang.org/blog/2024/08/28/typing-lists-and-tuples/) as well as type checking of their basic operations

* Detection of clauses and patterns that will never match from `case`, `cond`, and `=`

* Detection of unused clauses from private functions

## ExUnit improvements

Expand Down
11 changes: 2 additions & 9 deletions lib/elixir/lib/calendar/time.ex
Original file line number Diff line number Diff line change
Expand Up @@ -797,15 +797,8 @@ defmodule Time do
@doc since: "1.5.0"
@spec convert!(Calendar.time(), Calendar.calendar()) :: t
def convert!(time, calendar) do
case convert(time, calendar) do
{:ok, value} ->
value

{:error, reason} ->
raise ArgumentError,
"cannot convert #{inspect(time)} to target calendar #{inspect(calendar)}, " <>
"reason: #{inspect(reason)}"
end
{:ok, value} = convert(time, calendar)
value
end

@doc """
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/lib/code.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1649,7 +1649,7 @@ defmodule Code do

* `:infer_signatures` (since v1.18.0) - when `false`, it disables module-local
signature inference used when type checking remote calls to the compiled
module. Type checking will be executed regardless of this value of this option.
module. Type checking will be executed regardless of the value of this option.
Defaults to `true`.

`mix test` automatically disables this option via the `:test_elixirc_options`
Expand Down
6 changes: 3 additions & 3 deletions lib/elixir/lib/kernel.ex
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ defmodule Kernel do
@compile {:inline, bootstrapped?: 1}
case :code.ensure_loaded(Kernel) do
{:module, _} ->
defp bootstrapped?(_), do: true
defp bootstrapped?(module), do: is_atom(module)

{:error, _} ->
defp bootstrapped?(module), do: :code.ensure_loaded(module) == {:module, module}
Expand Down Expand Up @@ -3646,7 +3646,7 @@ defmodule Kernel do
:ok

true ->
pos = :elixir_locals.cache_env(__CALLER__)
pos = :elixir_module.cache_env(__CALLER__)
%{line: line, file: file, module: module} = __CALLER__

quote do
Expand Down Expand Up @@ -5323,7 +5323,7 @@ defmodule Kernel do
key
end

pos = :elixir_locals.cache_env(env)
pos = :elixir_module.cache_env(env)

quote do
:elixir_def.store_definition(unquote(kind), unquote(store), unquote(pos))
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/lib/kernel/cli.ex
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ defmodule Kernel.CLI do
end

@elixir_internals [:elixir, :elixir_aliases, :elixir_expand, :elixir_compiler, :elixir_module] ++
[:elixir_clauses, :elixir_lexical, :elixir_def, :elixir_map, :elixir_locals] ++
[:elixir_clauses, :elixir_lexical, :elixir_def, :elixir_map] ++
[:elixir_erl, :elixir_erl_clauses, :elixir_erl_compiler, :elixir_erl_pass] ++
[Kernel.ErrorHandler, Module.ParallelChecker]

Expand Down
10 changes: 5 additions & 5 deletions lib/elixir/lib/kernel/typespec.ex
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ defmodule Kernel.Typespec do
case type_to_signature(expr) do
{name, arity} = signature when signature in @reserved_signatures ->
compile_error(
:elixir_locals.get_cached_env(pos),
:elixir_module.get_cached_env(pos),
"type #{name}/#{arity} is a reserved type and it cannot be defined"
)

Expand Down Expand Up @@ -247,7 +247,7 @@ defmodule Kernel.Typespec do

defp collect_defined_type_pairs(type_typespecs) do
fun = fn {_kind, expr, pos}, type_pairs ->
%{file: file, line: line} = env = :elixir_locals.get_cached_env(pos)
%{file: file, line: line} = env = :elixir_module.get_cached_env(pos)

case type_to_signature(expr) do
{name, arity} = type_pair ->
Expand Down Expand Up @@ -292,7 +292,7 @@ defmodule Kernel.Typespec do

defp translate_type({kind, {:"::", _, [{name, meta, args}, definition]}, pos}, state)
when is_list(meta) do
caller = :elixir_locals.get_cached_env(pos)
caller = :elixir_module.get_cached_env(pos)
state = clean_local_state(state)

args =
Expand Down Expand Up @@ -349,12 +349,12 @@ defmodule Kernel.Typespec do
defp underspecified?(_kind, _arity, _spec), do: false

defp translate_spec({kind, {:when, _meta, [spec, guard]}, pos}, state) do
caller = :elixir_locals.get_cached_env(pos)
caller = :elixir_module.get_cached_env(pos)
translate_spec(kind, spec, guard, caller, state)
end

defp translate_spec({kind, spec, pos}, state) do
caller = :elixir_locals.get_cached_env(pos)
caller = :elixir_module.get_cached_env(pos)
translate_spec(kind, spec, [], caller, state)
end

Expand Down
13 changes: 2 additions & 11 deletions lib/elixir/lib/module.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1415,15 +1415,7 @@ defmodule Module do
def delete_definition(module, {name, arity})
when is_atom(module) and is_atom(name) and is_integer(arity) do
assert_not_readonly!(__ENV__.function, module)

case :elixir_def.take_definition(module, {name, arity}) do
false ->
false

_ ->
:elixir_locals.yank({name, arity}, module)
true
end
:elixir_def.take_definition(module, {name, arity}) != false
end

@doc """
Expand Down Expand Up @@ -1452,8 +1444,7 @@ defmodule Module do
"overridable because it was not defined"

clause ->
neighbours = :elixir_locals.yank(tuple, module)
:elixir_overridable.record_overridable(module, tuple, clause, neighbours)
:elixir_overridable.record_overridable(module, tuple, clause)
end

other ->
Expand Down
Loading
Loading