Skip to content

Commit e7ec9a0

Browse files
authored
prune_metadata keeps delimiters (#13911)
1 parent f99c856 commit e7ec9a0

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

lib/elixir/lib/macro.ex

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -776,23 +776,23 @@ defmodule Macro do
776776
777777
## Options
778778
779-
* `:unquote` - when true, this function leaves `unquote/1` and
779+
* `:unquote` - when `true`, this function leaves `unquote/1` and
780780
`unquote_splicing/1` expressions unescaped, effectively unquoting
781781
the contents on escape. This option is useful only when escaping
782-
ASTs which may have quoted fragments in them. Defaults to false.
782+
ASTs which may have quoted fragments in them. Defaults to `false`.
783783
784-
* `:prune_metadata` - when true, removes metadata from escaped AST
784+
* `:prune_metadata` - when `true`, removes most metadata from escaped AST
785785
nodes. Note this option changes the semantics of escaped code and
786-
it should only be used when escaping ASTs. Defaults to false.
786+
it should only be used when escaping ASTs. Defaults to `false`.
787787
788-
As an example, `ExUnit` stores the AST of every assertion, so when
789-
an assertion fails we can show code snippets to users. Without this
790-
option, each time the test module is compiled, we get a different
791-
MD5 of the module bytecode, because the AST contains metadata,
788+
As an example for `:prune_metadata`, `ExUnit` stores the AST of every
789+
assertion, so when an assertion fails we can show code snippets to users.
790+
Without this option, each time the test module is compiled, we would get a
791+
different MD5 of the module bytecode, because the AST contains metadata,
792792
such as counters, specific to the compilation environment. By pruning
793793
the metadata, we ensure that the module is deterministic and reduce
794794
the amount of data `ExUnit` needs to keep around. Only the minimal
795-
amount of metadata is kept, such as `:line` and `:no_parens`.
795+
amount of metadata is kept, such as `:line`, `:no_parens` and `:delimiter`.
796796
797797
## Comparison to `quote/2`
798798

lib/elixir/src/elixir_quote.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ escape(Expr, Op, Unquote) ->
140140
}).
141141

142142
do_escape({Left, Meta, Right}, #elixir_quote{op=prune_metadata} = Q) when is_list(Meta) ->
143-
TM = [{K, V} || {K, V} <- Meta, (K == no_parens) orelse (K == line)],
143+
TM = [{K, V} || {K, V} <- Meta, (K == no_parens) orelse (K == line) orelse (K == delimiter)],
144144
TL = do_quote(Left, Q),
145145
TR = do_quote(Right, Q),
146146
{'{}', [], [TL, TM, TR]};

lib/ex_unit/test/ex_unit/doc_test_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ defmodule ExUnit.DocTestTest do
983983
8) doctest module ExUnit.DocTestTest.PatternMatching (8) (ExUnit.DocTestTest.PatternMatchingRunner)
984984
test/ex_unit/doc_test_test.exs:#{doctest_line}
985985
match (=) failed
986-
code: %{year: 2001, day: 1} = ~D"2000-01-01"
986+
code: %{year: 2001, day: 1} = ~D[2000-01-01]
987987
left: %{year: 2001, day: 1}
988988
right: ~D[2000-01-01]
989989
stacktrace:

0 commit comments

Comments
 (0)