clojure.core.async/alts!! annotation does not account for returning nil values


  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
  • Environment:
    clojure.core.typed 0.2.13


The current annotation for clojure.core.async/alts can be seen here:

I believe it needs to be updated to account for returning a nil value if the channel is closed, or if the operation is a put, given the doc for alts!/alts!!:

([ports & {:as opts}])
Completes at most one of several channel operations. Must be called
inside a (go ...) block. ports is a vector of channel endpoints, which
can be either a channel to take from or a vector of
[channel-to-put-to val-to-put], in any combination. Takes will be
made as if by <!, and puts will be made as if by >!. Unless
the :priority option is true, if more than one port operation is
ready a non-deterministic choice will be made. If no operation is
ready and a :default value is supplied, [default-val :default] will
be returned, otherwise alts! will park until the first operation to
become ready completes. Returns [val port] of the completed
operation, where val is the value taken for takes, and nil for puts.

opts are passed as :key val ... Supported options:

:default val - the value to use if none of the operations are immediately ready
:priority true - (default nil) when true, the operations will be tried in order.

Note: there is no guarantee that the port exps or val exprs will be
used, nor in what order should they be, so they should not be
depended upon for side effects.

So presumably the annotation should be something more like this:


Vote (0)
Watch (0)


  • Created: