-
Notifications
You must be signed in to change notification settings - Fork 38
Open
Description
I wrote codes with the maybe feature like this:
-module(test_eqwalizer).
-feature(maybe_expr, enable).
-export([main/1]).
-spec main(Args :: list(binary())) -> {ok, binary()} | {error, any()}.
main(Args) ->
maybe
true ?= (length(Args) =/= 0) orelse {error, empty_args},
true ?= is_binary(lists:last(Args)) orelse {error, badargs},
{ok, <<"ok">>}
end.I suppose the type spec is correct. However, the eqwalizer reports the error incompatible_types.
The entire output is as below:
error: incompatible_types
┌─ src/test_eqwalizer.erl:11:17
│
11 │ true ?= (length(Args) =/= 0) orelse {error, empty_args},
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
│ │
│ _ orelse _.
Expression has type: 'true' | {'error', 'empty_args'}
Context expected type: {'ok', binary()} | {'error', term()}
See https://fb.me/eqwalizer_errors#incompatible_types
│
'true' | {'error', 'empty_args'} is not compatible with {'ok', binary()} | {'error', term()}
because
'true' is not compatible with {'ok', binary()} | {'error', term()}
because
'true' is not compatible with {'ok', binary()}
error: incompatible_types
┌─ src/test_eqwalizer.erl:12:17
│
12 │ true ?= is_binary(lists:last(Args)) orelse {error, badargs},
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
│ │
│ _ orelse _.
Expression has type: 'true' | {'error', 'badargs'}
Context expected type: {'ok', binary()} | {'error', term()}
See https://fb.me/eqwalizer_errors#incompatible_types
│
'true' | {'error', 'badargs'} is not compatible with {'ok', binary()} | {'error', term()}
because
'true' is not compatible with {'ok', binary()} | {'error', term()}
because
'true' is not compatible with {'ok', binary()}
2 ERRORS
Could you please give me an explanation ?
Metadata
Metadata
Assignees
Labels
No labels