@@ -198,25 +198,35 @@ impl<'a> AnalyzeContext<'a> {
198198 NamedEntityKind :: Overloaded ,
199199 diagnostics,
200200 ) ;
201- let mut spec_region = self . analyze_subprogram_declaration (
202- region,
201+ let mut subpgm_region = region. nested ( ) ;
202+
203+ self . analyze_subprogram_declaration (
204+ & mut subpgm_region,
203205 & mut body. specification ,
204206 diagnostics,
205207 ) ?;
206208 self . analyze_declarative_part (
207- & mut spec_region ,
209+ & mut subpgm_region ,
208210 & mut body. declarations ,
209211 diagnostics,
210212 ) ?;
211- self . analyze_sequential_part ( & mut spec_region, & mut body. statements , diagnostics) ?;
213+ subpgm_region. close ( diagnostics) ;
214+ self . analyze_sequential_part (
215+ & mut subpgm_region,
216+ & mut body. statements ,
217+ diagnostics,
218+ ) ?;
212219 }
213220 Declaration :: SubprogramDeclaration ( ref mut subdecl) => {
214221 region. add (
215222 subdecl. designator ( ) ,
216223 NamedEntityKind :: Overloaded ,
217224 diagnostics,
218225 ) ;
219- self . analyze_subprogram_declaration ( region, subdecl, diagnostics) ?;
226+
227+ let mut subpgm_region = region. nested ( ) ;
228+ self . analyze_subprogram_declaration ( & mut subpgm_region, subdecl, diagnostics) ?;
229+ subpgm_region. close ( diagnostics) ;
220230 }
221231
222232 Declaration :: Use ( ref mut use_clause) => {
@@ -334,7 +344,13 @@ impl<'a> AnalyzeContext<'a> {
334344 NamedEntityKind :: Overloaded ,
335345 diagnostics,
336346 ) ;
337- self . analyze_subprogram_declaration ( & region, subprogram, diagnostics) ?;
347+ let mut subpgm_region = region. nested ( ) ;
348+ self . analyze_subprogram_declaration (
349+ & mut subpgm_region,
350+ subprogram,
351+ diagnostics,
352+ ) ?;
353+ subpgm_region. close ( diagnostics) ;
338354 }
339355 }
340356 }
@@ -535,7 +551,9 @@ impl<'a> AnalyzeContext<'a> {
535551 region. add ( ident, NamedEntityKind :: InterfaceType , diagnostics) ;
536552 }
537553 InterfaceDeclaration :: Subprogram ( ref mut subpgm, ..) => {
538- self . analyze_subprogram_declaration ( region, subpgm, diagnostics) ?;
554+ let mut subpgm_region = region. nested ( ) ;
555+ self . analyze_subprogram_declaration ( & mut subpgm_region, subpgm, diagnostics) ?;
556+ subpgm_region. close ( diagnostics) ;
539557 region. add (
540558 subpgm. designator ( ) ,
541559 NamedEntityKind :: Overloaded ,
@@ -660,31 +678,24 @@ impl<'a> AnalyzeContext<'a> {
660678 Ok ( ( ) )
661679 }
662680
663- fn analyze_subprogram_declaration < ' r > (
681+ fn analyze_subprogram_declaration (
664682 & self ,
665- parent : & ' r Region < ' _ > ,
683+ region : & mut Region < ' _ > ,
666684 subprogram : & mut SubprogramDeclaration ,
667685 diagnostics : & mut dyn DiagnosticHandler ,
668- ) -> FatalResult < Region < ' r > > {
669- let mut region = parent. nested ( ) ;
670-
686+ ) -> FatalNullResult {
671687 match subprogram {
672688 SubprogramDeclaration :: Function ( fun) => {
673- self . analyze_interface_list ( & mut region, & mut fun. parameter_list , diagnostics) ?;
674- if let Err ( err) = self . resolve_type_mark ( & parent , & mut fun. return_type ) {
689+ self . analyze_interface_list ( region, & mut fun. parameter_list , diagnostics) ?;
690+ if let Err ( err) = self . resolve_type_mark ( region , & mut fun. return_type ) {
675691 err. add_to ( diagnostics) ?
676692 }
677693 }
678694 SubprogramDeclaration :: Procedure ( procedure) => {
679- self . analyze_interface_list (
680- & mut region,
681- & mut procedure. parameter_list ,
682- diagnostics,
683- ) ?;
695+ self . analyze_interface_list ( region, & mut procedure. parameter_list , diagnostics) ?;
684696 }
685697 }
686- region. close ( diagnostics) ;
687- Ok ( region)
698+ Ok ( ( ) )
688699 }
689700}
690701
0 commit comments