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 cd61d8b commit 1b662eb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
7 changes: 4 additions & 3 deletions eqwalizer/test_projects/check/src/custom.erl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +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,
Expand Down Expand Up @@ -2158,21 +2159,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
19 changes: 8 additions & 11 deletions eqwalizer/test_projects/check/src/custom.erl.check
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +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, | |
Expand Down Expand Up @@ -2888,41 +2889,37 @@ file_open1() -> | OK |
file:open("/file", [read]), | |
Device. | |
| |
-spec file_open2() -> file:fd(). | |
-spec file_open2() -> #file_descriptor{}. | |
file_open2() -> | OK |
{ok, Device} = | |
file:open("/file", [read, raw]), | |
Device. | |
| |
-spec file_open3_neg | |
([file:mode()]) -> file:fd(). | |
([file:mode()]) -> #file_descriptor{}. | |
file_open3_neg(Modes) -> | ERROR |
{ok, Device} = | |
file:open("/file", Modes), | |
Device. | | Device.
| | Expression has type: file:io_device()
| | Context expected type: file:fd()
| | Context expected type: #file_descriptor{}
| |
| | 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
| | pid() is not compatible with #file_descriptor{}
| |
-spec file_open5_neg | |
(file:mode()) -> file:fd(). | |
(file:mode()) -> #file_descriptor{}. | |
file_open5_neg(Mode) -> | ERROR |
{ok, Device} = | |
file:open("/file", [Mode]), | |
Device. | | Device.
| | Expression has type: file:io_device()
| | Context expected type: file:fd()
| | Context expected type: #file_descriptor{}
| |
| | 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

0 comments on commit 1b662eb

Please sign in to comment.