Skip to content

Commit

Permalink
# This is a combination of 2 commits.
Browse files Browse the repository at this point in the history
# This is the 1st commit message:

Add documentation for `Macro.prewalk/2` (elixir-lang#10951)


# This is the commit message #2:

Bump OTP version and fix CI on Windows (elixir-lang#10952)
  • Loading branch information
iaguirre88 authored and eksperimental committed Apr 25, 2021
1 parent ae4d482 commit bb8c0f0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
otp_release: ['OTP-23.0', 'OTP-22.3', 'OTP-22.0']
otp_release: ['OTP-23.3', 'OTP-23.0', 'OTP-22.3', 'OTP-22.0']
development: [false]
include:
- otp_release: master
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
name: Windows, OTP-${{ matrix.otp_release }}, Windows Server 2019
strategy:
matrix:
otp_release: ['22.0']
otp_release: ['22.3']
runs-on: windows-2019
steps:
- name: Configure Git
Expand All @@ -84,7 +84,9 @@ jobs:
- name: Erlang test suite
run: make --keep-going test_erlang
- name: Elixir test suite
run: make --keep-going test_elixir
run: |
del c:/Windows/System32/drivers/etc/hosts
make --keep-going test_elixir
check_posix_compliant:
name: Check POSIX-compliant
Expand Down
17 changes: 17 additions & 0 deletions lib/elixir/lib/macro.ex
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,23 @@ defmodule Macro do

@doc """
Performs a depth-first, pre-order traversal of quoted expressions.
Returns a new ast where each node is the result of invoking `fun` on each
corresponding node of `ast`.
## Examples
iex> ast = quote do: 5 + 3 * 7
iex> new_ast = Macro.prewalk(ast, fn
...> {:+, meta, children} -> {:*, meta, children}
...> {:*, meta, children} -> {:+, meta, children}
...> other -> other
...> end)
iex> Code.eval_quoted(ast)
{26, []}
iex> Code.eval_quoted(new_ast)
{50, []}
"""
@spec prewalk(t, (t -> t)) :: t
def prewalk(ast, fun) when is_function(fun, 1) do
Expand Down

0 comments on commit bb8c0f0

Please sign in to comment.