File 4991-Always-consider-maybe-and-else-as-keywords-in-epp_do.patch of Package erlang
From c1d9b83bef7adab962c27f9ee657825399e9ba15 Mon Sep 17 00:00:00 2001
From: Roberto Aloi <robertoaloi@fb.com>
Date: Fri, 19 May 2023 14:07:41 +0200
Subject: [PATCH] Always consider 'maybe' and 'else' as keywords in epp_dodger
---
lib/edoc/test/edoc_SUITE.erl | 12 +++++++++++-
lib/syntax_tools/src/epp_dodger.erl | 11 +++++++++--
2 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/lib/edoc/test/edoc_SUITE.erl b/lib/edoc/test/edoc_SUITE.erl
index d09e9a2ecb..5fb81f74bd 100644
--- a/lib/edoc/test/edoc_SUITE.erl
+++ b/lib/edoc/test/edoc_SUITE.erl
@@ -25,7 +25,7 @@
%% Test cases
-export([app/1,appup/1,build_std/1,build_map_module/1,otp_12008/1,
build_app/1, otp_14285/1, infer_module_app_test/1,
- module_with_feature/1]).
+ module_with_feature/1, module_with_maybe/1]).
suite() -> [{ct_hooks,[ts_install_cth]}].
@@ -170,3 +170,13 @@ module_with_feature(Config) ->
PreprocessOpts = [{preprocess, true}, {dir, PrivDir}],
ok = edoc:files([Source], PreprocessOpts),
ok.
+
+module_with_maybe(Config) ->
+ DataDir = ?config(data_dir, Config),
+ PrivDir = ?config(priv_dir, Config),
+ Source = filename:join(DataDir, "module_with_maybe.erl"),
+ DodgerOpts = [{dir, PrivDir}],
+ ok = edoc:files([Source], DodgerOpts),
+ PreprocessOpts = [{preprocess, true}, {dir, PrivDir}],
+ ok = edoc:files([Source], PreprocessOpts),
+ ok.
diff --git a/lib/syntax_tools/src/epp_dodger.erl b/lib/syntax_tools/src/epp_dodger.erl
index 40f67b5660..a5f579705a 100644
--- a/lib/syntax_tools/src/epp_dodger.erl
+++ b/lib/syntax_tools/src/epp_dodger.erl
@@ -434,8 +434,7 @@ parse_form(Dev, L0, Parser, Options) ->
%% This has the *potential* to read options for enabling/disabling
%% features for the parsing of the file.
{ok, {_Ftrs, ResWordFun}} =
- erl_features:keyword_fun(Options,
- fun erl_scan:f_reserved_word/1),
+ erl_features:keyword_fun(Options, fun reserved_word/1),
case io:scan_erl_form(Dev, "", L0, [{reserved_word_fun,ResWordFun}]) of
{ok, Ts, L1} ->
@@ -932,3 +931,11 @@ errormsg(String) ->
%% =====================================================================
+
+%% See #7266: The dodger currently does not process feature attributes
+%% correctly, so temporarily consider the `else` and `maybe` atoms
+%% always as keywords
+-spec reserved_word(Atom :: atom()) -> boolean().
+reserved_word('else') -> true;
+reserved_word('maybe') -> true;
+reserved_word(Atom) -> erl_scan:f_reserved_word(Atom).
--
2.35.3