Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:23
erlang
1378-syntax-tools-Fix-location-info-of-reverted...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 1378-syntax-tools-Fix-location-info-of-reverted-lists.patch of Package erlang
From 4f2b41386ce5105c576eb727c68923c400a3691c Mon Sep 17 00:00:00 2001 From: Max Nordlund kivra <max.nordlund@kivra.com> Date: Tue, 13 Jun 2023 17:23:36 +0200 Subject: [PATCH 2/2] syntax tools: Fix location info of reverted lists The hidden `nil` node that is generated takes it's location from the last element of the list, instead of the list node itself, because that generally represents the start of the list. Similarly, the `cons` nodes are given the location of each element. However, care must be taken to preserve the other annotations in `pos`, which is really an `erl_anno` annotation. --- lib/syntax_tools/src/erl_syntax.erl | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/lib/syntax_tools/src/erl_syntax.erl b/lib/syntax_tools/src/erl_syntax.erl index f3e8a106ea..4797aa229e 100644 --- a/lib/syntax_tools/src/erl_syntax.erl +++ b/lib/syntax_tools/src/erl_syntax.erl @@ -2456,17 +2456,23 @@ list(Elements, Tail) when Elements =/= [] -> revert_list(Node) -> Pos = get_pos(Node), - P = list_prefix(Node), - S = case list_suffix(Node) of + Prefix = list_prefix(Node), + Suffix = case list_suffix(Node) of none -> - revert_nil(set_pos(nil(), Pos)); - S1 -> - S1 + LastPos = get_pos(lists:last(Prefix)), + LastLocation = case erl_anno:end_location(LastPos) of + undefined -> erl_anno:location(LastPos); + Location -> Location + end, + revert_nil(set_pos(nil(), erl_anno:set_location(LastLocation, Pos))); + Suffix1 -> + Suffix1 end, - lists:foldr(fun (X, A) -> - {cons, Pos, X, A} - end, - S, P). + lists:foldr(fun (Head, Tail) -> + HeadPos = get_pos(Head), + HeadLocation = erl_anno:location(HeadPos), + {cons, erl_anno:set_location(HeadLocation, Pos), Head, Tail} + end, Suffix, Prefix). %% ===================================================================== %% @doc Creates an abstract empty list. The result represents -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor