Skip to content

Supervisor.which_children has incorrect @spec #11005

@boydm

Description

@boydm

Current behavior

The documentation indicates that which_children returns a list of modules. This is confirmed in the code. It returns a list of modules.

The @spec for the function indicates it returns a single module or :dynamic.

Thus, the following code matches and works at runtime, but produces a dialyzer error.

[{_, pid, :supervisor, [DynamicSupervisor]}] = Supervisor.which_children(supervisor_pid)

Expected behavior

The @spec for which_children should be:

which_children(supervisor()) :: [
  {term() | :undefined, child() | :restarting, :worker | :supervisor,
   [module()] | :dynamic}
]

The change is that the module() toward the end is in a list.

Note: the :dynamic might need to be in the list too. Not sure without digging in deeper.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions