Skip to content

Commit

Permalink
Do not memoize Name.name_designated_type_env
Browse files Browse the repository at this point in the history
  • Loading branch information
thvnx committed Jun 26, 2024
1 parent 68bb683 commit 1b2434d
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ada/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -16158,7 +16158,11 @@ def is_static_subtype():
"""
return Entity.name_designated_type.is_static_decl

@langkit_property(memoized=True)
# ATTENTION: As for Name.use_package_name_designated_env this property must
# not be memoized because of an unsoundness issue between infinite
# recursion guards in lexical envs and memoized properties. See
# libadalang#1307.
@langkit_property(memoized=False)
def name_designated_type_env():
return Entity.name_designated_type._.primitives_env

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
procedure Test is
generic package GP is
generic function GF return Boolean;
private
-- The following use clause was known to raise an infinite recursion in
-- Name.name_designated_type_env because of an unsoundness issue between
-- infinite recursion guards in lexical envs and memoized properties.

use type Integer;
end GP;

package body GP is
function GF return Boolean is (True);
end GP;

package P is new GP;
function F is new P.GF;
pragma Test_Statement;
begin
null;
end Test;
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Analyzing test.adb
##################

Resolving xrefs for node <GenericSubpInstantiation ["F"] test.adb:17:4-17:27>
*****************************************************************************

Expr: <DottedName test.adb:17:22-17:26>
references: <| DefiningName "GF" test.adb:3:24-3:26 [test.adb:16:4] |>
type: None
expected type: None
Expr: <Id "P" test.adb:17:22-17:23>
references: <DefiningName "P" test.adb:16:12-16:13>
type: None
expected type: None
Expr: <Id "GF" test.adb:17:24-17:26>
references: <| DefiningName "GF" test.adb:3:24-3:26 [test.adb:16:4] |>
type: None
expected type: None
Traversing generic node <| GenericSubpDecl ["GF"] test.adb:3:7-3:42 [test.adb:16:4, test.adb:17:4] |>
*****************************************************************************************************

Resolving xrefs for node <| SubpSpec test.adb:3:15-3:41 [test.adb:16:4, test.adb:17:4] |>
*****************************************************************************************

Expr: <| Id "Boolean" test.adb:3:34-3:41 [test.adb:16:4, test.adb:17:4] |>
references: <DefiningName "Boolean" __standard:3:8-3:15>
type: None
expected type: None

Traversing generic node <| ExprFunction ["GF"] test.adb:13:7-13:44 [test.adb:16:4, test.adb:17:4] |>
****************************************************************************************************

Resolving xrefs for node <| SubpSpec test.adb:13:7-13:33 [test.adb:16:4, test.adb:17:4] |>
******************************************************************************************

Expr: <| Id "Boolean" test.adb:13:26-13:33 [test.adb:16:4, test.adb:17:4] |>
references: <DefiningName "Boolean" __standard:3:8-3:15>
type: None
expected type: None



Done.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
driver: name-resolution
input_sources: [test.adb]
traverse_generics: true

0 comments on commit 1b2434d

Please sign in to comment.