Skip to content

Commit

Permalink
Merge branch 'topic/949' into 'master'
Browse files Browse the repository at this point in the history
nameres: fix record assoc expression matching type predicate

Closes #949

See merge request eng/libadalang/libadalang!1287
  • Loading branch information
thvnx committed Apr 13, 2023
2 parents 5dd6369 + 68e2690 commit 55a1ecf
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ada/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -15453,7 +15453,7 @@ def record_assoc_equation():
match.formal.formal_decl.type_expression.designated_type
),
match.actual.assoc.expr.sub_equation,
match.actual.assoc.expr.matches_expected_type,
match.actual.assoc.expr.matches_expected_assign_type,
match.actual.name.then(
lambda n: Bind(n.ref_var, match.formal.formal_decl),
LogicTrue()
Expand Down
23 changes: 23 additions & 0 deletions testsuite/tests/name_resolution/anonymous_type_match/test.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
procedure Test is
type Obj is tagged null record;

type T is record
Class : access Obj'Class;
end record;

type Obj2 is new Obj with record
I : Integer;
end record;

procedure P (Prm : access Obj2);

procedure P (Prm : access Obj2) is
E : T := T'(Class => Prm);
pragma Test_Statement;
begin
null;
end P;

begin
null;
end Test;
32 changes: 32 additions & 0 deletions testsuite/tests/name_resolution/anonymous_type_match/test.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Analyzing test.adb
##################

Resolving xrefs for node <ObjectDecl ["E"] test.adb:15:8-15:34>
***************************************************************

Expr: <Id "T" test.adb:15:12-15:13>
references: <DefiningName "T" test.adb:4:9-4:10>
type: None
expected type: None
Expr: <QualExpr test.adb:15:17-15:33>
references: <DefiningName "T" test.adb:4:9-4:10>
type: <ConcreteTypeDecl ["T"] test.adb:4:4-6:15>
expected type: <ConcreteTypeDecl ["T"] test.adb:4:4-6:15>
Expr: <Id "T" test.adb:15:17-15:18>
references: <DefiningName "T" test.adb:4:9-4:10>
type: None
expected type: None
Expr: <Aggregate test.adb:15:19-15:33>
type: <ConcreteTypeDecl ["T"] test.adb:4:4-6:15>
expected type: <ConcreteTypeDecl ["T"] test.adb:4:4-6:15>
Expr: <Id "Class" test.adb:15:20-15:25>
references: <DefiningName "Class" test.adb:5:7-5:12>
type: None
expected type: None
Expr: <Id "Prm" test.adb:15:29-15:32>
references: <DefiningName "Prm" test.adb:14:17-14:20>
type: <AnonymousTypeDecl ["None"] test.adb:14:23-14:34>
expected type: <AnonymousTypeDecl ["None"] test.adb:5:15-5:31>


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

0 comments on commit 55a1ecf

Please sign in to comment.