Skip to content

Commit 14629b6

Browse files
waserver: number, integer, float fixes
Summary: - the next version of eqwalizer (D108936049) distinguishes `integer()` and `float()` (`number() :: integer() | float()`), - because we previously did not have such distinction during type-checking, many specs/types did not pay much attention to proper numeric types - this diff contains type and spec fixes (with minimal code changes - fixing guards in a few obvious places) that remove type errors related to `integer()` and `float()` being different types. - it reduces the number of type error (wrt new eqwalizer) ~800 -> ~100. Reviewed By: michalmuskala Differential Revision: D109170364 fbshipit-source-id: a2577db6dccb72eaf228372fb1fe264a5b39add0
1 parent 1adbd35 commit 14629b6

11 files changed

Lines changed: 36 additions & 36 deletions

apps/edb/src/edb_dap.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ decode_frames(Data, Messages) ->
158158
%%% Basic Types (used by requests and responses)
159159
%%%---------------------------------------------------------------------------------
160160

161-
-type thread_id() :: number().
161+
-type thread_id() :: integer().
162162

163163
%%% https://microsoft.github.io/debug-adapter-protocol/specification#Types_Source
164164
-type source() :: #{

apps/edb/src/edb_dap_request_disconnect.erl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ handle(State, Args) ->
106106
none
107107
| #{
108108
node := node(),
109-
process_id := number(),
110-
shell_process_id => number(),
109+
process_id := integer(),
110+
shell_process_id => integer(),
111111
port => port() | none
112112
}.
113113

@@ -195,15 +195,15 @@ kill_node(Node) ->
195195
ok.
196196

197197
-spec kill_os_process(ProcessId, force | dont_force) -> ok when
198-
ProcessId :: number().
198+
ProcessId :: integer().
199199
kill_os_process(ProcessId, ForceOrNot) ->
200200
case os:type() of
201201
{unix, _} -> kill_unix_process(ProcessId, ForceOrNot);
202202
{win32, _} -> kill_win_process(ProcessId, ForceOrNot)
203203
end.
204204

205205
-spec kill_unix_process(ProcessId, ForceOrNot) -> ok when
206-
ProcessId :: number(),
206+
ProcessId :: integer(),
207207
ForceOrNot :: force | dont_force.
208208
kill_unix_process(ProcessId, force) ->
209209
os:cmd("kill -9 " ++ integer_to_list(ProcessId)),
@@ -213,7 +213,7 @@ kill_unix_process(ProcessId, dont_force) ->
213213
ok.
214214

215215
-spec kill_win_process(ProcessId, ForceOrNot) -> ok when
216-
ProcessId :: number(),
216+
ProcessId :: integer(),
217217
ForceOrNot :: force | dont_force.
218218
kill_win_process(ProcessId, force) ->
219219
os:cmd("taskkill /F /PID " ++ integer_to_list(ProcessId)),

apps/edb/src/edb_dap_request_evaluate.erl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,19 @@ evaluate requests: https://microsoft.github.io/debug-adapter-protocol/specificat
4040

4141
% Evaluate the expression in the scope of this stack frame. If not specified,
4242
% the expression is evaluated in the global scope.
43-
frameId => number(),
43+
frameId => integer(),
4444

4545
% The contextual line where the expression should be evaluated. In the
4646
% 'hover' context, this should be set to the start of the expression being
4747
% hovered.
48-
line => number(),
48+
line => integer(),
4949

5050
% The contextual column where the expression should be evaluated. This may be
5151
% provided if `line` is also provided.
5252
%
5353
% It is measured in UTF-16 code units and the client capability
5454
% `columnsStartAt1` determines whether it is 0- or 1-based.
55-
column => number(),
55+
column => integer(),
5656

5757
% The contextual source in which the `line` is found. This must be provided
5858
% if `line` is provided.
@@ -95,19 +95,19 @@ evaluate requests: https://microsoft.github.io/debug-adapter-protocol/specificat
9595
% children can be retrieved by passing `variablesReference` to the
9696
% `variables` request as long as execution remains suspended. See 'Lifetime
9797
% of Object References' in the Overview section for details.
98-
variablesReference := number(),
98+
variablesReference := integer(),
9999

100100
% The number of named child variables.
101101
% The client can use this information to present the variables in a paged
102102
% UI and fetch them in chunks.
103103
% The value should be less than or equal to 2147483647 (2^31-1).
104-
namedVariables => number(),
104+
namedVariables => integer(),
105105

106106
% The number of indexed child variables.
107107
% The client can use this information to present the variables in a paged
108108
% UI and fetch them in chunks.
109109
% The value should be less than or equal to 2147483647 (2^31-1).
110-
indexedVariables => number(),
110+
indexedVariables => integer(),
111111

112112
% A memory reference to a location appropriate for this result.
113113
% For pointer type eval results, this is generally a reference to the
@@ -124,7 +124,7 @@ evaluate requests: https://microsoft.github.io/debug-adapter-protocol/specificat
124124
%
125125
% This reference shares the same lifetime as the `variablesReference`. See
126126
% 'Lifetime of Object References' in the Overview section for details.
127-
valueLocationReference => number()
127+
valueLocationReference => integer()
128128
}.
129129

130130
-export_type([arguments/0, response_body/0]).

apps/edb/src/edb_dap_request_scopes.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ scopes requests: https://microsoft.github.io/debug-adapter-protocol/specificatio
3838
-type arguments() :: #{
3939
% Retrieve the scopes for the stack frame identified by `frameId`. The
4040
% `frameId` must have been obtained in the current suspended state.
41-
frameId := number()
41+
frameId := integer()
4242
}.
4343

4444
-type response_body() ::
@@ -65,7 +65,7 @@ scopes requests: https://microsoft.github.io/debug-adapter-protocol/specificatio
6565
% The variables of this scope can be retrieved by passing the value of
6666
% `variablesReference` to the `variables` request as long as execution
6767
% remains suspended.
68-
variablesReference := number(),
68+
variablesReference := integer(),
6969
% The number of named variables in this scope.
7070
% The client can use this information to present the variables in a paged UI
7171
% and fetch them in chunks.

apps/edb/src/edb_dap_request_set_breakpoints.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,12 @@ setBreakpoints requests: https://microsoft.github.io/debug-adapter-protocol/spec
112112
%%% https://microsoft.github.io/debug-adapter-protocol/specification#Types_SourceBreakpoint
113113
-type sourceBreakpoint() :: #{
114114
%% The source line of the breakpoint or logpoint.
115-
line := number(),
115+
line := integer(),
116116

117117
%% Start position within source line of the breakpoint or logpoint. It is
118118
%% measured in UTF-16 code units and the client capability `columnsStartAt1`
119119
%% determines whether it is 0- or 1-based.
120-
column => number(),
120+
column => integer(),
121121

122122
%% The expression for conditional breakpoints.
123123
%% It is only honored by a debug adapter if the corresponding capability

apps/edb/src/edb_dap_request_stack_trace.erl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,25 +88,25 @@ stackTrace requests: https://microsoft.github.io/debug-adapter-protocol/specific
8888
% An identifier for the stack frame. It must be unique across all threads.
8989
% This id can be used to retrieve the scopes of the frame with the `scopes`
9090
% request or to restart the execution of a stack frame.
91-
id := number(),
91+
id := integer(),
9292
% The name of the stack frame, typically a method name.
9393
name := binary(),
9494
% The source of the frame.
9595
source => edb_dap:source(),
9696
% The line within the source of the frame. If the source attribute is missing
9797
% or doesn't exist, `line` is 0 and should be ignored by the client.
98-
line := number(),
98+
line := integer(),
9999
% Start position of the range covered by the stack frame. It is measured in
100100
% UTF-16 code units and the client capability `columnsStartAt1` determines
101101
% whether it is 0- or 1-based. If attribute `source` is missing or doesn't
102102
% exist, `column` is 0 and should be ignored by the client.
103-
column := number(),
103+
column := integer(),
104104
% The end line of the range covered by the stack frame.
105-
endLine => number(),
105+
endLine => integer(),
106106
% End position of the range covered by the stack frame. It is measured in
107107
% UTF-16 code units and the client capability `columnsStartAt1` determines
108108
% whether it is 0- or 1-based.
109-
endColumn => number(),
109+
endColumn => integer(),
110110
% Indicates whether this frame can be restarted with the `restartFrame`
111111
% request. Clients should only use this if the debug adapter supports the
112112
% `restart` request and the corresponding capability `supportsRestartFrame`

apps/edb/src/edb_dap_request_variables.erl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ variables requests: https://microsoft.github.io/debug-adapter-protocol/specifica
3737
%% Types
3838
%% ------------------------------------------------------------------
3939

40-
-type variables_reference() :: number().
40+
-type variables_reference() :: integer().
4141

4242
%%% https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Variables
4343
-type arguments() :: #{
@@ -51,12 +51,12 @@ variables requests: https://microsoft.github.io/debug-adapter-protocol/specifica
5151
% The index of the first variable to return; if omitted children start at 0.
5252
% The attribute is only honored by a debug adapter if the corresponding
5353
% capability `supportsVariablePaging` is true.
54-
start => number(),
54+
start => integer(),
5555
% The number of variables to return. If count is missing or 0, all variables
5656
% are returned.
5757
% The attribute is only honored by a debug adapter if the corresponding
5858
% capability `supportsVariablePaging` is true.
59-
count => number(),
59+
count => integer(),
6060
% Specifies details on how to format the Variable values.
6161
% The attribute is only honored by a debug adapter if the corresponding
6262
% capability `supportsValueFormattingOptions` is true.

apps/edb/src/edb_dap_server.erl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ For details see https://microsoft.github.io/debug-adapter-protocol/specification
5151
-type attach_type() ::
5252
#{
5353
request := attach,
54-
process_id := number()
54+
process_id := integer()
5555
}
5656
| #{
5757
request := launch,
58-
process_id := number(),
59-
shell_process_id => number()
58+
process_id := integer(),
59+
shell_process_id => integer()
6060
}.
6161

6262
-type state() ::
@@ -74,7 +74,7 @@ For details see https://microsoft.github.io/debug-adapter-protocol/specification
7474
state := launching,
7575
client_info := client_info(),
7676
port := port() | none,
77-
shell_process_id => number(),
77+
shell_process_id => integer(),
7878
reverse_attach_ref := reference(),
7979
cwd := binary(),
8080
subscription := edb:event_subscription()

apps/edb/test/edb_dap_evaluate_SUITE.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ test_evaluate_without_frame_id(Config) ->
380380

381381
-spec evaluate_expression(Client, FrameId, Expression, Context) -> Result when
382382
Client :: edb_dap_test_support:client(),
383-
FrameId :: number(),
383+
FrameId :: integer(),
384384
Expression :: binary(),
385385
Context :: atom(),
386386
Result :: #{success := boolean(), body := edb_dap_request_evaluate:response_body()}.

apps/edb/test/edb_dap_scopes_SUITE.erl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ inspect(Inspector, Module, Fun, Args) ->
831831
% -----------------------------------------------------------------------------
832832
-spec get_variables_page(Client, VarRef, Window) -> [edb_dap_request_variables:variable()] when
833833
Client :: edb_dap_test_support:client(),
834-
VarRef :: number(),
834+
VarRef :: integer(),
835835
Window :: #{start => non_neg_integer(), count => non_neg_integer()}.
836836
get_variables_page(Client, VarRef, Window) ->
837837
Args0 = #{variablesReference => VarRef},
@@ -858,15 +858,15 @@ get_variables_page(Client, VarRef, Window) ->
858858

859859
-spec assertEvaluateNameIsCorrect(Client, FrameId, edb_dap_request_variables:variable(), binary()) -> ok when
860860
Client :: edb_dap_test_support:client(),
861-
FrameId :: number().
861+
FrameId :: integer().
862862
assertEvaluateNameIsCorrect(Client, FrameId, EvalName, Expected) ->
863863
assertEvaluateNameIsCorrect(Client, FrameId, EvalName, Expected, fun(X) -> X end).
864864

865865
-spec assertEvaluateNameIsCorrect(Client, FrameId, edb_dap_request_variables:variable(), binary(), Comparator) ->
866866
ok
867867
when
868868
Client :: edb_dap_test_support:client(),
869-
FrameId :: number(),
869+
FrameId :: integer(),
870870
Comparator :: fun((binary()) -> binary() | dynamic()).
871871
assertEvaluateNameIsCorrect(Client, FrameId, #{evaluateName := EvalName}, Expected, Comparator) ->
872872
Response = edb_dap_test_client:evaluate(Client, #{
@@ -881,7 +881,7 @@ assertEvaluateNameIsCorrect(Client, FrameId, #{evaluateName := EvalName}, Expect
881881

882882
-spec get_process_vars(Client, FrameId) -> #{binary() => edb_dap_request_variables:variable()} when
883883
Client :: edb_dap_test_support:client(),
884-
FrameId :: number().
884+
FrameId :: integer().
885885
get_process_vars(Client, FrameId) ->
886886
Scopes = edb_dap_test_support:get_scopes(Client, FrameId),
887887
ProcessScopeVarsRef = maps:get(variablesReference, maps:get(~"Process", Scopes)),

0 commit comments

Comments
 (0)