Skip to content

Commit

Permalink
tests: OTP-27 compatible
Browse files Browse the repository at this point in the history
Summary:
- The type `file:fd()` has changed between OTP 26 and OTP 27 - erlang/otp@218ecbe#diff-7f2ad64a34b87080776f94ed42c8f0de5232c9e0d2db74c8e5e48fa2bf4963cb, which now results into different error messages on different OTP versions
- massaging the tests to not use the type `file:fd()` directly, - this relies a bit on how much eqwalizer unfolds when reporting a subtype error, but this is the best we can do right now to preserve the tests and to run them the same way both on OTP 26 and OTP 27

Reviewed By: michalmuskala

Differential Revision: D59757111

fbshipit-source-id: 70ac1be599ee21e824618833ab883c7f25563bf0
  • Loading branch information
ilya-klyuchnikov authored and facebook-github-bot committed Jul 15, 2024
1 parent ffad3c7 commit cd5e3b6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2214,14 +2214,12 @@ error: incompatible_types
│ │
│ Device.
Expression has type: file:io_device()
Context expected type: file:fd()
Context expected type: #file_descriptor{}

See https://fb.me/eqwalizer_errors#incompatible_types

file:io_device() is not compatible with file:fd()
because
pid() | file:fd() is not compatible with file:fd()
file:io_device() is not compatible with #file_descriptor{}
because
pid() | file:fd() is not compatible with #file_descriptor{}
because
Expand All @@ -2235,14 +2233,12 @@ error: incompatible_types
│ │
│ Device.
Expression has type: file:io_device()
Context expected type: file:fd()
Context expected type: #file_descriptor{}

See https://fb.me/eqwalizer_errors#incompatible_types

file:io_device() is not compatible with file:fd()
because
pid() | file:fd() is not compatible with file:fd()
file:io_device() is not compatible with #file_descriptor{}
because
pid() | file:fd() is not compatible with #file_descriptor{}
because
Expand Down
8 changes: 4 additions & 4 deletions test_projects/eqwalizer_tests/check/src/custom.erl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

-import(maps, [get/2, get/3]).
-compile([export_all, nowarn_export_all]).

-include_lib("kernel/include/file.hrl").
-record(foo, {
a :: ok | error,
b :: number(),
Expand Down Expand Up @@ -2158,21 +2158,21 @@ file_open1() ->
file:open("/file", [read]),
Device.

-spec file_open2() -> file:fd().
-spec file_open2() -> #file_descriptor{}.
file_open2() ->
{ok, Device} =
file:open("/file", [read, raw]),
Device.

-spec file_open3_neg
([file:mode()]) -> file:fd().
([file:mode()]) -> #file_descriptor{}.
file_open3_neg(Modes) ->
{ok, Device} =
file:open("/file", Modes),
Device.

-spec file_open5_neg
(file:mode()) -> file:fd().
(file:mode()) -> #file_descriptor{}.
file_open5_neg(Mode) ->
{ok, Device} =
file:open("/file", [Mode]),
Expand Down

0 comments on commit cd5e3b6

Please sign in to comment.