@@ -35,7 +35,8 @@ pub(crate) struct ResolvedFormal<'a> {
3535 /// port map(to_slv(foo) => sig)
3636 is_converted : bool ,
3737
38- /// The type of the potentially partial or converted formal
38+ /// The type of the potentially partial or converted formal.
39+ /// `None`, if the formal does not have to a type (e.g., packages or subprograms).
3940 type_mark : Option < TypeEnt < ' a > > ,
4041}
4142
@@ -50,7 +51,7 @@ impl<'a> ResolvedFormal<'a> {
5051 }
5152 }
5253
53- fn convert ( & self , into_type : TypeEnt < ' a > ) -> Self {
54+ fn convert ( self , into_type : TypeEnt < ' a > ) -> Self {
5455 Self {
5556 idx : self . idx ,
5657 iface : self . iface ,
@@ -83,14 +84,13 @@ impl<'a> ResolvedFormal<'a> {
8384 }
8485
8586 pub fn require_type_mark ( & self ) -> Result < TypeEnt < ' a > , Diagnostic > {
86- match self . type_mark {
87- None => Err ( Diagnostic :: invalid_formal (
87+ self . type_mark . ok_or_else ( || {
88+ Diagnostic :: invalid_formal (
8889 self . iface
8990 . decl_pos ( )
90- . expect ( "Interface ent must have a declaration position" ) ,
91- ) ) ,
92- Some ( type_mark) => Ok ( type_mark) ,
93- }
91+ . expect ( "InterfaceEnt must have a declaration position" ) ,
92+ )
93+ } )
9494 }
9595}
9696
@@ -378,7 +378,8 @@ impl<'a> AnalyzeContext<'a, '_> {
378378 /// that are present at the call / instantiation site).
379379 /// The result is a vector of tuples where the first refers to the token span
380380 /// of the actual and the second to the resolved formal.
381- /// If there is an extraneous argument, the resolved formal will be `None`.
381+ /// If there is are extraneous arguments, the resolved formals at that position
382+ /// will be `None`.
382383 pub fn combine_formal_with_actuals < ' e > (
383384 & self ,
384385 formal_region : & FormalRegion < ' a > ,
@@ -499,11 +500,11 @@ impl<'a> AnalyzeContext<'a, '_> {
499500 self . check_missing_and_duplicates ( error_pos, resolved_pairs, formal_region, diagnostics)
500501 }
501502
502- /// Checks associations irrelevant of the actual kind (i.e., can analyzes generic maps,
503+ /// Checks associations irrelevant of the actual kind (i.e., can analyze generic maps,
503504 /// port maps and subprogram calls).
504505 ///
505506 /// * `error_pos` Position of the instance or call site
506- /// * `formal_region` The formals, i.e., the declared elements
507+ /// * `formal_region` The formals ( i.e., the declared elements)
507508 /// * `mapping` Maps generic types to their actual values. This is a mutable reference so that
508509 /// generic maps can populate the content appropriately while port maps and parameters will
509510 /// only read from it.
@@ -531,7 +532,7 @@ impl<'a> AnalyzeContext<'a, '_> {
531532 continue ;
532533 } ;
533534 if formal_region. typ == InterfaceType :: Parameter {
534- self . check_parameter_interface (
535+ self . check_interface_mode_mismatch (
535536 resolved_formal,
536537 expr,
537538 scope,
@@ -684,9 +685,11 @@ impl<'a> AnalyzeContext<'a, '_> {
684685 Ok ( ( ) )
685686 }
686687
687- // LRM 4.2.2.1: In a subprogram, the interface mode must match the mode of the actual designator
688- // when the interface mode is signal, variable or file. Furthermore, they must be a single name.
689- fn check_parameter_interface (
688+ /// From LRM 4.2.2.1:
689+ /// In a subprogram, the interface mode must match the mode of the actual designator
690+ /// when the interface mode is signal, variable or file.
691+ /// Furthermore, they must be a single name.
692+ fn check_interface_mode_mismatch (
690693 & self ,
691694 resolved_formal : & ResolvedFormal < ' a > ,
692695 expr : & mut Expression ,
@@ -718,7 +721,6 @@ impl<'a> AnalyzeContext<'a, '_> {
718721 ) ;
719722 }
720723 }
721- ObjectClass :: Constant => { }
722724 ObjectClass :: Variable | ObjectClass :: SharedVariable => {
723725 let Some ( name) =
724726 as_fatal ( self . expression_as_name ( expr, scope, actual_pos, diagnostics) ) ?
@@ -741,6 +743,7 @@ impl<'a> AnalyzeContext<'a, '_> {
741743 ) ;
742744 }
743745 }
746+ ObjectClass :: Constant => { }
744747 } ,
745748 InterfaceEnt :: File ( _) => {
746749 let Some ( name) =
0 commit comments