Skip to content

Commit

Permalink
Fix specific_type in case of discrete base subtype
Browse files Browse the repository at this point in the history
  • Loading branch information
raph-amiard committed Apr 7, 2023
1 parent 9079ee6 commit 8b6ce16
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ada/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -6132,7 +6132,12 @@ def specific_type():
# Recurse on the class-wide type because it could be a subtype
# renaming a class-wide type itself.
lambda cw=T.ClasswideTypeDecl: cw.type_decl.specific_type,
lambda bt=T.BaseSubtypeDecl: bt.base_subtype.specific_type,
lambda bt=T.BaseSubtypeDecl: Let(
lambda bt=bt.base_subtype:
# Check if the base subtype is Self, to not do an infinite
# recursion.
If(bt == Entity, Entity, bt.specific_type)
),
lambda _: Entity
)

Expand Down
6 changes: 6 additions & 0 deletions testsuite/tests/properties/specific_type/test.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
procedure Test is
subtype P is Integer'Base;
--% node.f_subtype.p_designated_type_decl.p_specific_type
begin
null;
end Test;
5 changes: 5 additions & 0 deletions testsuite/tests/properties/specific_type/test.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Working on node <SubtypeDecl ["P"] test.adb:2:4-2:30>
=====================================================

Eval 'node.f_subtype.p_designated_type_decl.p_specific_type'
Result: <DiscreteBaseSubtypeDecl ["Integer"] __standard:4:3-4:54>
2 changes: 2 additions & 0 deletions testsuite/tests/properties/specific_type/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
driver: inline-playground
input_sources: [test.adb]

0 comments on commit 8b6ce16

Please sign in to comment.