File 7551-Eliminate-crash-for-nested-guards-in-record-initiali.patch of Package erlang
From 1b23ddb92aede36726b7715b0041e0bc96065467 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org>
Date: Tue, 27 Feb 2024 13:31:19 +0100
Subject: [PATCH] Eliminate crash for nested guards in record initialization
Also fix other bugs in the `erl_expand_records` pass hidden behind the
original bug.
Closes #8190
---
lib/stdlib/src/erl_expand_records.erl | 26 +++++---
lib/stdlib/src/erl_lint.erl | 9 +--
lib/stdlib/test/erl_expand_records_SUITE.erl | 65 ++++++++++++++++----
3 files changed, 73 insertions(+), 27 deletions(-)
diff --git a/lib/stdlib/src/erl_lint.erl b/lib/stdlib/src/erl_lint.erl
index 5123a4941a..d7dfd57c63 100644
--- a/lib/stdlib/src/erl_lint.erl
+++ b/lib/stdlib/src/erl_lint.erl
@@ -2385,13 +2385,9 @@ is_guard_test(Expression, Forms, IsOverridden) ->
%% processing the forms until we'll know that the record
%% definitions are truly needed.
F = fun() ->
- St = foldl(fun({attribute, _, record, _}=Attr0, St0) ->
- Attr = set_file(Attr0, "none"),
- attribute_state(Attr, St0);
- (_, St0) ->
- St0
- end, start(), Forms),
- St#lint.records
+ lists:foldl(fun({attribute, A, record, {Name, Fs}}, Acc) -> Acc#{Name => {A, Fs}};
+ (_, Acc) -> Acc
+ end, #{}, Forms)
end,
is_guard_test2(NoFileExpression, {F,IsOverridden}).
--
2.35.3