Elixir: Typing for System.cmd is in complete

Created on 21 Jul 2017  路  1Comment  路  Source: elixir-lang/elixir

There is a mismatch between the typespec and the actual implementation of System.cmd/2.

Environment

  • Elixir & Erlang versions (elixir --version):
    Erlang/OTP 19 [erts-8.1] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]
    Elixir 1.4.0

  • Operating system:
    macOS 10.12.5

Current behavior

Calling System.cmd with a charlist argument compiles and runs successfully, but fails dialyzer typechecks, because the typespec doesn't include charlist options. The current typesped is: @spec cmd(binary, [binary], Keyword.t).

eg

System.cmd("ls", ['-la'])

Expected behavior

I think the typespec should be changed to @spec cmd(binary, [binary | charlist], Keyword.t) .

Or

The implementation should not accept charlists.

Elixir Bug Starter

Most helpful comment

The implementation should not accept charlists. A PR that adds a binary check would be appreciated.

>All comments

The implementation should not accept charlists. A PR that adds a binary check would be appreciated.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

p-adams picture p-adams  路  36Comments

pragdave picture pragdave  路  61Comments

conradwt picture conradwt  路  34Comments

pragdave picture pragdave  路  28Comments

josevalim picture josevalim  路  27Comments