diff --git a/ada/ast.py b/ada/ast.py index 93a7a5a61..9c8239374 100644 --- a/ada/ast.py +++ b/ada/ast.py @@ -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 diff --git a/testsuite/tests/name_resolution/use_clause_in_instantiation/test.adb b/testsuite/tests/name_resolution/use_clause_in_instantiation/test.adb new file mode 100644 index 000000000..20d2ed3cf --- /dev/null +++ b/testsuite/tests/name_resolution/use_clause_in_instantiation/test.adb @@ -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; diff --git a/testsuite/tests/name_resolution/use_clause_in_instantiation/test.out b/testsuite/tests/name_resolution/use_clause_in_instantiation/test.out new file mode 100644 index 000000000..102024ee2 --- /dev/null +++ b/testsuite/tests/name_resolution/use_clause_in_instantiation/test.out @@ -0,0 +1,43 @@ +Analyzing test.adb +################## + +Resolving xrefs for node +***************************************************************************** + +Expr: + references: <| DefiningName "GF" test.adb:3:24-3:26 [test.adb:16:4] |> + type: None + expected type: None +Expr: + references: + type: None + expected type: None +Expr: + 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: + 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: + type: None + expected type: None + + + +Done. diff --git a/testsuite/tests/name_resolution/use_clause_in_instantiation/test.yaml b/testsuite/tests/name_resolution/use_clause_in_instantiation/test.yaml new file mode 100644 index 000000000..6c2fc1a63 --- /dev/null +++ b/testsuite/tests/name_resolution/use_clause_in_instantiation/test.yaml @@ -0,0 +1,3 @@ +driver: name-resolution +input_sources: [test.adb] +traverse_generics: true