Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:24
erlang
0550-dialyzer-Correct-interpretation-of-none.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0550-dialyzer-Correct-interpretation-of-none.patch of Package erlang
From 982de2929cf347739917532c764d13e133736927 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org> Date: Thu, 6 Oct 2022 07:10:55 +0200 Subject: [PATCH] dialyzer: Correct interpretation of [none()] Given the following module: -module(list_none). -export([new/0]). -spec new() -> list(none()). new() -> []. dialyzer emits the following warning: list_none.erl:4:2: Invalid type specification for function list_none:new/0. The success typing is () -> [] No warning is expected, since `list(Type)` means a list containing zero or more elements. Even if `Type` is impossible, the empty list is still possible. Therefore, the success typing and the spec are consistent with each other. Closes #6333 --- lib/dialyzer/src/erl_types.erl | 4 +--- lib/dialyzer/test/small_SUITE_data/results/stack | 0 .../test/small_SUITE_data/src/list_none.erl | 5 +++++ lib/dialyzer/test/small_SUITE_data/src/stack.erl | 15 +++++++++++++++ 4 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 lib/dialyzer/test/small_SUITE_data/results/stack create mode 100644 lib/dialyzer/test/small_SUITE_data/src/list_none.erl create mode 100644 lib/dialyzer/test/small_SUITE_data/src/stack.erl diff --git a/lib/dialyzer/src/erl_types.erl b/lib/dialyzer/src/erl_types.erl index 9abd967cd1..83b12b3041 100644 --- a/lib/dialyzer/src/erl_types.erl +++ b/lib/dialyzer/src/erl_types.erl @@ -1468,10 +1468,8 @@ t_list() -> -spec t_list(erl_type()) -> erl_type(). -t_list(?none) -> ?none; -t_list(?unit) -> ?none; t_list(Contents) -> - ?list(Contents, ?nil, ?unknown_qual). + t_sup(t_nonempty_list(Contents), t_nil()). -spec t_list_elements(erl_type()) -> erl_type(). diff --git a/lib/dialyzer/test/small_SUITE_data/results/stack b/lib/dialyzer/test/small_SUITE_data/results/stack new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lib/dialyzer/test/small_SUITE_data/src/list_none.erl b/lib/dialyzer/test/small_SUITE_data/src/list_none.erl new file mode 100644 index 0000000000..7fb40133e7 --- /dev/null +++ b/lib/dialyzer/test/small_SUITE_data/src/list_none.erl @@ -0,0 +1,5 @@ +-module(list_none). +-export([new/0]). + +-spec new() -> list(none()). +new() -> []. diff --git a/lib/dialyzer/test/small_SUITE_data/src/stack.erl b/lib/dialyzer/test/small_SUITE_data/src/stack.erl new file mode 100644 index 0000000000..080ce7e3b9 --- /dev/null +++ b/lib/dialyzer/test/small_SUITE_data/src/stack.erl @@ -0,0 +1,15 @@ +-module(stack). + +-export([new/0, push/2, pop/1]). +-export_type([stack/1]). + +-opaque stack(A) :: [A]. + +-spec new() -> stack(none()). +new() -> []. + +-spec push(stack(A), A) -> stack(A). +push(T, H) -> [H | T]. + +-spec pop(stack(A)) -> {A, stack(A)}. +pop([H | T]) -> {H, T}. -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor