Ada: Fix assertion failure on nested formal packages with box notation
Corrects an assertion failure in Ada package instantiation that occurred when nested formal packages were involved.
The Ada compiler previously encountered an assertion failure when instantiating generics within nested formal packages. This was due to the compiler attempting to use discarded transient package information. This change ensures that instantiations are not registered if they reside within the local package of a formal one, resolving the assertion.
In Details
In Ada's semantic analysis, this change addresses an issue where the compiler incorrectly attempted to instantiate a generic body for an instantiation found in a transient package that had already been discarded. The fix modifies Analyze_Package_Instantiation and Need_Subprogram_Instance_Body to prevent registering the body instantiation if it's part of a formal package's local scope, thereby avoiding the assertion failure.
- generic
- In Ada, a generic is a template that can be used to create other program units (like packages or procedures) that operate on different types or values. It's similar to templates in C++ or generics in Java.
- package
- An Ada package is a program unit that encapsulates related declarations, such as types, variables, and subprograms. It provides a way to group and hide implementation details.
- formal package
- In Ada, a formal package is a parameter to a generic package. It acts as a placeholder for a specific package that will be provided when the generic package is instantiated.
- box notation
- In Ada, box notation (e.g., '<>') is used to denote an uninitialized or default value for a type, often employed in generic package specifications.