Skip to content

1.9 Type checking examples not working in iex #14571

@sross

Description

@sross

Elixir and Erlang/OTP versions

Erlang/OTP 28 [erts-16.0] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns]

Elixir 1.19.0-rc.0 (2a9a4f2) (compiled with Erlang/OTP 28)

Installed via mise

Operating system

Linux - Ubuntu 25.04

Current behavior

Running an example type checking samples from the 1.9 Changelog in a new iex session provides no type checking information.

iex(1)> defmodule Example do
def my_code(first..last//step = range) do
"hello #{range}"
end
end
warning: variable "first" is unused (if the variable is not meant to be used, prefix it with an underscore)
└─ iex:2: Example.my_code/1

warning: variable "last" is unused (if the variable is not meant to be used, prefix it with an underscore)
└─ iex:2: Example.my_code/1

warning: variable "step" is unused (if the variable is not meant to be used, prefix it with an underscore)
└─ iex:2: Example.my_code/1

{ :module, Example, ....}
iex(2)>

Expected behavior

Type checking information is emitted as per the documentation.

Note: Invoking Mix.install [] prior to the examples fixes the issue.

iex(1)> Mix.install []
:ok
iex(2)> defmodule Example do
def my_code(first..last//step = range) do
"hello #{range}"
end
end
warning: variable "first" is unused (if the variable is not meant to be used, prefix it with an underscore)
└─ iex:3: Example.my_code/1

warning: variable "last" is unused (if the variable is not meant to be used, prefix it with an underscore)
└─ iex:3: Example.my_code/1

warning: variable "step" is unused (if the variable is not meant to be used, prefix it with an underscore)
└─ iex:3: Example.my_code/1

warning: incompatible value given to string interpolation:

range

it has type:

dynamic(%Range{})

but expected a type that implements the String.Chars protocol, it must be one of:

dynamic(
  %Date{} or %DateTime{} or %Hex.Solver.Assignment{} or %Hex.Solver.Constraints.Range{} or
    %Hex.Solver.Constraints.Union{} or %Hex.Solver.Incompatibility{} or %Hex.Solver.PackageRange{} or
    %Hex.Solver.Term{} or %NaiveDateTime{} or %Time{} or %URI{} or %Version{} or
    %Version.Requirement{}
) or %Hex.Solver.Constraints.Empty{} or atom() or binary() or empty_list() or float() or integer() or
  non_empty_list(term(), term())

where "range" was given the type:

# type: dynamic(%Range{})
# from: iex:3
first..last//step = range

hint: string interpolation uses the String.Chars protocol to convert a data structure into a string. Either convert the data type into a string upfront or implement the protocol accordingly

└─ iex:4: Example.my_code/1

{:module, Example, ...}

Activity

changed the title [-]Type checking examples not working in iex[/-] [+]1.9 Type checking examples not working in iex[/+] on Jun 11, 2025
josevalim

josevalim commented on Jun 11, 2025

@josevalim
Member

Anything related to protocols will require protocol consolidation, and therefore won't work in IEx, it requires a proper compilation. I will add a note to the changelog, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

        Participants

        @josevalim@sross

        Issue actions

          1.9 Type checking examples not working in iex · Issue #14571 · elixir-lang/elixir