File 0124-Fixes-analysing-a-wild-attribute-to-return-Info.patch of Package erlang

From 34b0649c744c93e9f143c3c7ec14276a57ff3d06 Mon Sep 17 00:00:00 2001
From: Harry Lawrence <hello@hazbo.co.uk>
Date: Wed, 8 Dec 2021 19:49:49 +0000
Subject: [PATCH] Fixes analysing a wild attribute to return Info

As per issue #4671:

erl_syntax_lib:analyze_attribute({attribute,17,mark,mark_1}).

returns {mark, {mark, mark_1}} due to the attribute being wrapped on
line 1320:

{A, analyze_attribute(A, Node)}

when what would be expected as per the documentation is:

{mark, mark1}

Returning *just* the Info from {_, Info} = analyze_wild_attribute(Node)
within analyze_attribute/2, this double wrapping does not occur, fixing
the original issue.
---
 lib/syntax_tools/src/erl_syntax_lib.erl | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/syntax_tools/src/erl_syntax_lib.erl b/lib/syntax_tools/src/erl_syntax_lib.erl
index 6185007235..6ca224ea8e 100644
--- a/lib/syntax_tools/src/erl_syntax_lib.erl
+++ b/lib/syntax_tools/src/erl_syntax_lib.erl
@@ -1106,7 +1106,7 @@ collect_attribute(file, _, Info) ->
     Info;
 collect_attribute(record, {R, L}, Info) ->
     finfo_add_record(R, L, Info);
-collect_attribute(_, {N, V}, Info) ->
+collect_attribute(N, V, Info) ->
     finfo_add_attribute(N, V, Info).
 
 %% Abstract datatype for collecting module information.
@@ -1335,7 +1335,8 @@ analyze_attribute(record, Node) ->
     analyze_record_attribute(Node);
 analyze_attribute(_, Node) ->
     %% A "wild" attribute (such as e.g. a `compile' directive).
-    analyze_wild_attribute(Node).
+    {_, Info} = analyze_wild_attribute(Node),
+    Info.
 
 
 %% =====================================================================
-- 
2.31.1

openSUSE Build Service is sponsored by