Skip to content

Commit

Permalink
Merge pull request #9276 from bjorng/bjorn/stdlib/epp-stringify/GH-9173
Browse files Browse the repository at this point in the history
…/OTP-19421

epp: Correct stringification of non-latin1 atoms
  • Loading branch information
bjorng authored Jan 10, 2025
2 parents 4856f40 + d927158 commit 9c918d8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/stdlib/src/epp.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2172,6 +2172,8 @@ token_src({char,_,C}) ->
io_lib:write_char(C);
token_src({string, _, X}) ->
io_lib:write_string(X);
token_src({atom, _, X}) ->
io_lib:write_atom(X);
token_src({_, _, X}) ->
io_lib:format("~w", [X]).

Expand Down
19 changes: 17 additions & 2 deletions lib/stdlib/test/epp_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
test_if/1,source_name/1,otp_16978/1,otp_16824/1,scan_file/1,file_macro/1,
deterministic_include/1, nondeterministic_include/1,
gh_8268/1,
moduledoc_include/1
moduledoc_include/1,
stringify/1
]).

-export([epp_parse_erl_form/2]).
Expand Down Expand Up @@ -78,7 +79,8 @@ all() ->
otp_14285, test_if, source_name, otp_16978, otp_16824, scan_file, file_macro,
deterministic_include, nondeterministic_include,
gh_8268,
moduledoc_include].
moduledoc_include,
stringify].

groups() ->
[{upcase_mac, [], [upcase_mac_1, upcase_mac_2]},
Expand Down Expand Up @@ -2121,6 +2123,19 @@ gh_8268(Config) ->
[] = run(Config, Ts),
ok.

stringify(Config) ->
Ts = [{stringify_1,
~"""
-define(S(S), ??S).
t() ->
~S('атом') = ?S('атом'),
~S("атом") = ?S("атом"),
ok.
""",
[],
ok}],
[] = run(Config, Ts),
ok.

%% Start location is 1.
check(Config, Tests) ->
Expand Down

0 comments on commit 9c918d8

Please sign in to comment.