Skip to content

Commit

Permalink
Merge branch 'topic/1390' into 'master'
Browse files Browse the repository at this point in the history
Do not fail with an exception when stub is missing.

See merge request eng/libadalang/libadalang!1662
  • Loading branch information
Roldak committed Jun 4, 2024
2 parents 142a740 + afc90a6 commit 8c080f4
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 7 deletions.
14 changes: 7 additions & 7 deletions ada/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -23495,7 +23495,7 @@ class PackageBody(Body):
# Since the reference to the package decl is non transitive, we still
# want to reference the envs that are "used" there.
reference(Self.cast(AdaNode).singleton,
through=T.PackageBody.package_decl_uses_clauses_envs,
through=T.PackageBody.package_decl_use_clauses_envs,
cond=Not(Self.is_compilation_unit_root) | Self.is_subunit)
)

Expand All @@ -23511,17 +23511,17 @@ class PackageBody(Body):
declarative_parts = Property(Entity.decls.singleton)

@langkit_property()
def package_decl_uses_clauses_envs():
def package_decl_use_clauses_envs():
"""
Return the environments for the use clauses of the package decl of this
body. Used because they need to be explicitly referenced.
"""
pd = Var(imprecise_fallback.bind(
return imprecise_fallback.bind(
False, Entity.decl_part.cast_or_raise(T.BasePackageDecl)
))

return Array([pd.public_part.use_clauses_envs,
pd.private_part._.use_clauses_envs]).env_group()
).then(lambda pd: Array([
pd.public_part.use_clauses_envs,
pd.private_part._.use_clauses_envs
]).env_group())


class TaskBody(Body):
Expand Down
7 changes: 7 additions & 0 deletions testsuite/tests/name_resolution/invalid_subunit/pkg-inner.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
separate (Pkg)
package body Inner is
procedure Not_Used is null;
begin
I := 1;
pragma Test_Statement;
end Inner;
6 changes: 6 additions & 0 deletions testsuite/tests/name_resolution/invalid_subunit/pkg.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package body Pkg is
-- package body Inner is separate;
-- We explicitly make the code illegal by commenting out the stub.
-- Libadalang should be able to handle this gracefully without property
-- errors.
end Pkg;
7 changes: 7 additions & 0 deletions testsuite/tests/name_resolution/invalid_subunit/pkg.ads
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package Pkg is
package Inner is
procedure Not_Used;

I : Integer;
end Inner;
end Pkg;
17 changes: 17 additions & 0 deletions testsuite/tests/name_resolution/invalid_subunit/test.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Analyzing pkg-inner.adb
#######################

Resolving xrefs for node <AssignStmt pkg-inner.adb:5:4-5:11>
************************************************************

Expr: <Id "I" pkg-inner.adb:5:4-5:5>
references: <DefiningName "I" pkg.ads:5:7-5:8>
type: <ConcreteTypeDecl ["Integer"] __standard:4:3-4:54>
expected type: None
Expr: <Int pkg-inner.adb:5:9-5:10>
references: None
type: <ConcreteTypeDecl ["Universal_Int_Type_"] __standard:116:3-116:45>
expected type: <ConcreteTypeDecl ["Integer"] __standard:4:3-4:54>


Done.
2 changes: 2 additions & 0 deletions testsuite/tests/name_resolution/invalid_subunit/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
driver: name-resolution
input_sources: [pkg-inner.adb]

0 comments on commit 8c080f4

Please sign in to comment.