@@ -202,7 +202,7 @@ impl<'a> ResolvedName<'a> {
202202 AnyEntKind :: Library
203203 | AnyEntKind :: Attribute ( _)
204204 | AnyEntKind :: ElementDeclaration ( _)
205- | AnyEntKind :: Concurrent ( _ )
205+ | AnyEntKind :: Concurrent ( .. )
206206 | AnyEntKind :: Sequential ( _)
207207 | AnyEntKind :: LoopParameter ( _) => {
208208 return Err ( (
@@ -258,7 +258,7 @@ impl<'a> ResolvedName<'a> {
258258 | AnyEntKind :: View ( _)
259259 | AnyEntKind :: InterfaceFile ( _)
260260 | AnyEntKind :: Component ( _)
261- | AnyEntKind :: Concurrent ( _ )
261+ | AnyEntKind :: Concurrent ( .. )
262262 | AnyEntKind :: Sequential ( _)
263263 | AnyEntKind :: LoopParameter ( _)
264264 | AnyEntKind :: PhysicalLiteral ( _) => ResolvedName :: Final ( ent) ,
@@ -1273,8 +1273,40 @@ impl<'a> AnalyzeContext<'a, '_> {
12731273 } ) ;
12741274 }
12751275 SplitName :: External ( ename) => {
1276- let ExternalName { subtype, class, .. } = ename;
1276+ let ExternalName {
1277+ subtype,
1278+ class,
1279+ path,
1280+ ..
1281+ } = ename;
12771282 let subtype = self . resolve_subtype_indication ( scope, subtype, diagnostics) ?;
1283+ match self . resolve_external_path ( scope, path, diagnostics) ? {
1284+ Some ( ResolvedName :: ObjectName ( obj) ) => {
1285+ if !self . can_be_target_type ( obj. type_mark ( ) , subtype. base ( ) ) {
1286+ diagnostics. push ( Diagnostic :: type_mismatch (
1287+ & path. pos ( self . ctx ) ,
1288+ & obj. describe_type ( ) ,
1289+ subtype. type_mark ( ) ,
1290+ ) )
1291+ }
1292+ if * class != obj. base . class ( ) . into ( ) {
1293+ diagnostics. push ( Diagnostic :: new (
1294+ path. pos ( self . ctx ) ,
1295+ format ! ( "class {} does not match {}" , * class, obj. base. class( ) ) ,
1296+ ErrorCode :: MismatchedObjectClass ,
1297+ ) )
1298+ }
1299+ }
1300+ None => {
1301+ // ignore; we do not analyze this yet
1302+ }
1303+ _ => {
1304+ diagnostics. push ( Diagnostic :: mismatched_kinds (
1305+ path. pos ( self . ctx ) ,
1306+ "External path must point to a constant, variable or signal" ,
1307+ ) ) ;
1308+ }
1309+ }
12781310 return Ok ( ResolvedName :: ObjectName ( ObjectName {
12791311 base : ObjectBase :: ExternalName ( * class) ,
12801312 type_mark : Some ( subtype. type_mark ( ) . to_owned ( ) ) ,
@@ -1583,6 +1615,24 @@ impl<'a> AnalyzeContext<'a, '_> {
15831615 Ok ( resolved)
15841616 }
15851617
1618+ // Currently, only resolves Package name
1619+ fn resolve_external_path (
1620+ & self ,
1621+ scope : & Scope < ' a > ,
1622+ path : & mut WithTokenSpan < ExternalPath > ,
1623+ diagnostics : & mut dyn DiagnosticHandler ,
1624+ ) -> EvalResult < Option < ResolvedName < ' a > > > {
1625+ match & mut path. item {
1626+ ExternalPath :: Package ( pkg) => Ok ( Some ( self . name_resolve (
1627+ scope,
1628+ pkg. span ,
1629+ & mut pkg. item ,
1630+ diagnostics,
1631+ ) ?) ) ,
1632+ _ => Ok ( None ) ,
1633+ }
1634+ }
1635+
15861636 // Helper function:
15871637 // Resolve a name that must be some kind of object selection, index or slice
15881638 // Such names occur as assignment targets and aliases
@@ -2251,7 +2301,7 @@ constant c0 : rec_t := (others => 0);
22512301" ,
22522302 ) ;
22532303
2254- assert_matches ! ( test. name_resolve( & test. snippet( "c0.field" ) , None , & mut NoDiagnostics ) ,
2304+ assert_matches ! ( test. name_resolve( & test. snippet( "c0.field" ) , None , & mut NoDiagnostics ) ,
22552305 Ok ( ResolvedName :: ObjectName ( oname) ) if oname. type_mark( ) == test. lookup_type( "natural" ) ) ;
22562306 }
22572307
@@ -2493,7 +2543,7 @@ type enum2_t is (alpha, beta);
24932543 test. declarative_part (
24942544 "
24952545type ptr_t is access integer_vector;
2496- variable vptr : ptr_t;
2546+ variable vptr : ptr_t;
24972547" ,
24982548 ) ;
24992549 let code = test. snippet ( "vptr(0 to 1)" ) ;
@@ -2509,7 +2559,7 @@ variable vptr : ptr_t;
25092559 test. declarative_part (
25102560 "
25112561type ptr_t is access integer_vector;
2512- variable vptr : ptr_t;
2562+ variable vptr : ptr_t;
25132563" ,
25142564 ) ;
25152565 let code = test. snippet ( "vptr(0)" ) ;
@@ -2637,7 +2687,7 @@ variable c0 : arr_t;
26372687 let test = TestSetup :: new ( ) ;
26382688 test. declarative_part (
26392689 "
2640- type arr_t is array (integer range 0 to 3) of integer;
2690+ type arr_t is array (integer range 0 to 3) of integer;
26412691 " ,
26422692 ) ;
26432693 let code = test. snippet ( "arr_t'left" ) ;
@@ -2654,7 +2704,7 @@ type arr_t is array (integer range 0 to 3) of integer;
26542704 let test = TestSetup :: new ( ) ;
26552705 test. declarative_part (
26562706 "
2657- type arr_t is array (integer range 0 to 3, character range 'a' to 'c') of integer;
2707+ type arr_t is array (integer range 0 to 3, character range 'a' to 'c') of integer;
26582708 " ,
26592709 ) ;
26602710 let code = test. snippet ( "arr_t'left(1)" ) ;
@@ -2710,7 +2760,7 @@ type arr_t is array (integer range 0 to 3, character range 'a' to 'c') of intege
27102760
27112761 test. declarative_part (
27122762 "
2713- type arr_t is array (integer range 0 to 3) of integer;
2763+ type arr_t is array (integer range 0 to 3) of integer;
27142764 " ,
27152765 ) ;
27162766
@@ -2729,7 +2779,7 @@ type arr_t is array (integer range 0 to 3) of integer;
27292779
27302780 test. declarative_part (
27312781 "
2732- type arr_t is array (integer range 0 to 3) of integer;
2782+ type arr_t is array (integer range 0 to 3) of integer;
27332783constant c0 : arr_t := (others => 0);
27342784 " ,
27352785 ) ;
@@ -2749,7 +2799,7 @@ constant c0 : arr_t := (others => 0);
27492799
27502800 test. declarative_part (
27512801 "
2752- type arr_t is array (integer range 0 to 3) of integer;
2802+ type arr_t is array (integer range 0 to 3) of integer;
27532803constant c0 : arr_t := (others => 0);
27542804 " ,
27552805 ) ;
@@ -2954,7 +3004,7 @@ variable thevar : integer;
29543004 let test = TestSetup :: new ( ) ;
29553005 test. declarative_part (
29563006 "
2957- signal thesig : integer;
3007+ signal thesig : integer;
29583008 " ,
29593009 ) ;
29603010
@@ -3100,7 +3150,7 @@ variable thevar : integer;
31003150 let test = TestSetup :: new ( ) ;
31013151 test. declarative_part (
31023152 "
3103- signal thesig : integer;
3153+ signal thesig : integer;
31043154 " ,
31053155 ) ;
31063156
0 commit comments