-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Closed
Description
Environment
Erlang/OTP 24 [erts-12.1.4] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]
Elixir 1.13.0-rc.1 (0974e90) (compiled with Erlang/OTP 22
Current behavior
iex(2)> URI.parse("http://")
%URI{
authority: "",
fragment: nil,
host: "",
path: nil, # it's nil
port: 80,
query: nil,
scheme: "http",
userinfo: nil
}
however:
iex(6)> t URI
@opaque authority()
@type t() :: %URI{
authority: authority(),
fragment: nil | binary(),
host: nil | binary(),
path: binary(), # it can't be nil
port: nil | :inet.port_number(),
query: nil | binary(),
scheme: nil | binary(),
userinfo: nil | binary()
}
In my 1.12 code I had a nil
check for path
, since it can be nil
. When updating, Dialyzer complained that this check can never succeed -- and according to the type spec that's true:
dummy.ex:2:guard_fail
The guard clause:
when _ :: binary() === nil
can never succeed.
However, removing it of course will cause issues down the line.
Expected behavior
I don't really have a desired behaviour. The angle I'm coming from is that URI.parse
was only mentioned as a soft-deprecation, so I expected that my existing code keeps working, including type-checks. So simply updating the changelog would be fine by me. I guess removing the type-spec from URI.parse
also works.
related: #11363
Metadata
Metadata
Assignees
Labels
No labels