Skip to content

Commit

Permalink
Slightly improve Macro.generate_arguments/2 (elixir-lang#8842)
Browse files Browse the repository at this point in the history
I added a bodyless clause so that arguments are clearly named in the 
documentation. I also added a is_atom/1 guard to the first function 
clause so that we consistently check that the context is an atom.
  • Loading branch information
whatyouhide committed Mar 1, 2019
1 parent 9e387ce commit 0558e7c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/elixir/lib/macro.ex
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,11 @@ defmodule Macro do
"""
@doc since: "1.5.0"
@spec generate_arguments(0, term) :: []
@spec generate_arguments(0, context :: atom) :: []
@spec generate_arguments(pos_integer, context) :: [{atom, [], context}, ...] when context: atom
def generate_arguments(0, _), do: []
def generate_arguments(amount, context)

def generate_arguments(0, context) when is_atom(context), do: []

def generate_arguments(amount, context)
when is_integer(amount) and amount > 0 and is_atom(context) do
Expand Down

0 comments on commit 0558e7c

Please sign in to comment.