File 0651-epp-Fix-use-of-maybe-in-macro-argument.patch of Package erlang
From d988c3171512407b29e51b93eb111615d352481c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org>
Date: Fri, 15 Mar 2024 13:47:32 +0100
Subject: [PATCH] epp: Fix use of `maybe` in macro argument
Closes #8268
---
lib/stdlib/src/epp.erl | 2 ++
lib/stdlib/test/epp_SUITE.erl | 26 ++++++++++++++++++++++++--
2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/lib/stdlib/src/epp.erl b/lib/stdlib/src/epp.erl
index bdb0bc64a2..358e0cf6c7 100644
--- a/lib/stdlib/src/epp.erl
+++ b/lib/stdlib/src/epp.erl
@@ -1774,6 +1774,8 @@ macro_arg([{'fun',Lc}|[{'(',_}|_]=Toks], E, Arg) ->
macro_arg(Toks, ['end'|E], [{'fun',Lc}|Arg]);
macro_arg([{'fun',_}=Fun,{var,_,_}=Name|[{'(',_}|_]=Toks], E, Arg) ->
macro_arg(Toks, ['end'|E], [Name,Fun|Arg]);
+macro_arg([{'maybe',Lb}|Toks], E, Arg) ->
+ macro_arg(Toks, ['end'|E], [{'maybe',Lb}|Arg]);
macro_arg([{'receive',Lr}|Toks], E, Arg) ->
macro_arg(Toks, ['end'|E], [{'receive',Lr}|Arg]);
macro_arg([{'try',Lr}|Toks], E, Arg) ->
diff --git a/lib/stdlib/test/epp_SUITE.erl b/lib/stdlib/test/epp_SUITE.erl
index c62f6fa3c1..aec5bcdaef 100644
--- a/lib/stdlib/test/epp_SUITE.erl
+++ b/lib/stdlib/test/epp_SUITE.erl
@@ -30,7 +30,9 @@
otp_11728/1, encoding/1, extends/1, function_macro/1,
test_error/1, test_warning/1, otp_14285/1,
test_if/1,source_name/1,otp_16978/1,otp_16824/1,scan_file/1,file_macro/1,
- deterministic_include/1, nondeterministic_include/1]).
+ deterministic_include/1, nondeterministic_include/1,
+ gh_8268/1
+ ]).
-export([epp_parse_erl_form/2]).
@@ -73,7 +75,8 @@ all() ->
otp_8665, otp_8911, otp_10302, otp_10820, otp_11728,
encoding, extends, function_macro, test_error, test_warning,
otp_14285, test_if, source_name, otp_16978, otp_16824, scan_file, file_macro,
- deterministic_include, nondeterministic_include].
+ deterministic_include, nondeterministic_include,
+ gh_8268].
groups() ->
[{upcase_mac, [], [upcase_mac_1, upcase_mac_2]},
@@ -2054,6 +2057,25 @@ otp_16824(Config) when is_list(Config) ->
[] = compile(Config, Cs),
ok.
+gh_8268(Config) ->
+ Ts = [{circular_1,
+ <<"-define(LOG(Tag, Code), io:format(\"~s\", [Tag]), Code).
+ more_work() -> ok.
+ some_work() -> ok.
+ t() ->
+ ?LOG(work,
+ begin
+ maybe
+ ok ?= some_work()
+ end,
+ more_work()
+ end).
+ ">>,
+ [{feature,maybe_expr,enable}],
+ ok}],
+ [] = run(Config, Ts),
+ ok.
+
%% Start location is 1.
check(Config, Tests) ->
eval_tests(Config, fun check_test/3, Tests).
--
2.35.3