Skip to content

Cryptic type violation on Elixir 1.20 in older StreamData prop-based test #15065

@sabiwara

Description

@sabiwara

In Elixir 1.20.0-rc.1.

Feel free to close since it seems fixed on the latest StreamData (1.1.3+), but reporting just in case it is the symptom of an error message that could be improved.

Reproduction as a standalone script:

Mix.install([stream_data: "1.1.2"])
ExUnit.start()

defmodule ReproTest do
  use ExUnit.Case, async: true
  use ExUnitProperties

  property "causes a type violation" do
    check all(
            int1 <- positive_integer(),
            int2 <- positive_integer(),
            sum = int1 + int2
          ) do
      assert sum > int1
      assert sum > int2
    end
  end
end
 warning: this clause in cond will always match:

        sum = int1 + int2

    since it has type:

        dynamic(float() or integer())

    where "int1" was given the type:

        # type: dynamic(float() or integer())
        # from: scripts/stream_data_check_all.exs:12:24
        int1 + int2

    where "int2" was given the type:

        # type: dynamic(float() or integer())
        # from: scripts/stream_data_check_all.exs:12:24
        int1 + int2

    where "sum" was given the type:

        # type: dynamic(float() or integer())
        # from: scripts/stream_data_check_all.exs:12:17
        sum = int1 + int2

    typing violation found at:
12 │             sum = int1 + int2~~~~~~~~~~~~~~~~~
    │
    └─ scripts/stream_data_check_all.exs:12: ReproTest."property causes a type violation"/1

I can understand why a number would always match in a cond if that's the code being generated, but reporting a "typing violation" in the sum feels really confusing here.

Will try to come up with a minimal repro if I can.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions