Skip to content

Commit 08b559f

Browse files
committed
Pass the caller module to unique_var to avoid confusion
1 parent 1cadeff commit 08b559f

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

lib/elixir/lib/macro.ex

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -508,13 +508,11 @@ defmodule Macro do
508508
Generates AST nodes for a given number of required argument
509509
variables using `Macro.unique_var/2`.
510510
511+
The second argument is generally the macro caller's module.
512+
511513
## Examples
512514
513-
iex> [var1, var2] = Macro.generate_unique_arguments(2, __MODULE__)
514-
iex> {:arg1, [counter: c1], __MODULE__} = var1
515-
iex> {:arg2, [counter: c2], __MODULE__} = var2
516-
iex> is_integer(c1) and is_integer(c2)
517-
true
515+
[var1, var2] = Macro.generate_unique_arguments(2, __CALLER__.module)
518516
519517
"""
520518
@doc since: "1.11.3"
@@ -570,11 +568,11 @@ defmodule Macro do
570568
generate another variable, with its own unique counter.
571569
See `var/2` for an alternative.
572570
571+
The second argument is generally the macro caller's module.
572+
573573
## Examples
574574
575-
iex> {:foo, [counter: c], __MODULE__} = Macro.unique_var(:foo, __MODULE__)
576-
iex> is_integer(c)
577-
true
575+
var = Macro.unique_var(:foo, __CALLER__.module)
578576
579577
"""
580578
@doc since: "1.11.3"

0 commit comments

Comments
 (0)