Skip to content

docs: assert_raise example is a compiler warning in Elixir 1.18 #14111

Closed
@nathany-copia

Description

@nathany-copia

Elixir and Erlang/OTP versions

Erlang/OTP 27 [erts-15.2] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1] [jit] [dtrace]

Elixir 1.18.0 (compiled with Erlang/OTP 27)

Operating system

macOS 15.2

Current behavior

The documentation for assert_raise suggests using 1 + "test" to get an Arithmetic Error.
https://hexdocs.pm/ex_unit/ExUnit.Assertions.html#assert_raise/2

assert_raise ArithmeticError, fn ->
  1 + "test"
end

Expected behavior

While an Arithmetic Error is still the case at runtime, Elixir 1.18 provides a compiler warning for code like this, so maybe it's no longer the best example?

The RuntimeError provided is a better example. Should the ArithmeticError example be removed?
https://github.com/elixir-lang/elixir/blob/main/lib/ex_unit/lib/ex_unit/assertions.ex#L788

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions