@@ -202,7 +202,7 @@ impl<'a> ResolvedName<'a> {
202
202
AnyEntKind :: Library
203
203
| AnyEntKind :: Attribute ( _)
204
204
| AnyEntKind :: ElementDeclaration ( _)
205
- | AnyEntKind :: Concurrent ( _ )
205
+ | AnyEntKind :: Concurrent ( .. )
206
206
| AnyEntKind :: Sequential ( _)
207
207
| AnyEntKind :: LoopParameter ( _) => {
208
208
return Err ( (
@@ -258,7 +258,7 @@ impl<'a> ResolvedName<'a> {
258
258
| AnyEntKind :: View ( _)
259
259
| AnyEntKind :: InterfaceFile ( _)
260
260
| AnyEntKind :: Component ( _)
261
- | AnyEntKind :: Concurrent ( _ )
261
+ | AnyEntKind :: Concurrent ( .. )
262
262
| AnyEntKind :: Sequential ( _)
263
263
| AnyEntKind :: LoopParameter ( _)
264
264
| AnyEntKind :: PhysicalLiteral ( _) => ResolvedName :: Final ( ent) ,
@@ -1273,8 +1273,40 @@ impl<'a> AnalyzeContext<'a, '_> {
1273
1273
} ) ;
1274
1274
}
1275
1275
SplitName :: External ( ename) => {
1276
- let ExternalName { subtype, class, .. } = ename;
1276
+ let ExternalName {
1277
+ subtype,
1278
+ class,
1279
+ path,
1280
+ ..
1281
+ } = ename;
1277
1282
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
+ }
1278
1310
return Ok ( ResolvedName :: ObjectName ( ObjectName {
1279
1311
base : ObjectBase :: ExternalName ( * class) ,
1280
1312
type_mark : Some ( subtype. type_mark ( ) . to_owned ( ) ) ,
@@ -1583,6 +1615,24 @@ impl<'a> AnalyzeContext<'a, '_> {
1583
1615
Ok ( resolved)
1584
1616
}
1585
1617
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
+
1586
1636
// Helper function:
1587
1637
// Resolve a name that must be some kind of object selection, index or slice
1588
1638
// Such names occur as assignment targets and aliases
@@ -2251,7 +2301,7 @@ constant c0 : rec_t := (others => 0);
2251
2301
" ,
2252
2302
) ;
2253
2303
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 ) ,
2255
2305
Ok ( ResolvedName :: ObjectName ( oname) ) if oname. type_mark( ) == test. lookup_type( "natural" ) ) ;
2256
2306
}
2257
2307
@@ -2493,7 +2543,7 @@ type enum2_t is (alpha, beta);
2493
2543
test. declarative_part (
2494
2544
"
2495
2545
type ptr_t is access integer_vector;
2496
- variable vptr : ptr_t;
2546
+ variable vptr : ptr_t;
2497
2547
" ,
2498
2548
) ;
2499
2549
let code = test. snippet ( "vptr(0 to 1)" ) ;
@@ -2509,7 +2559,7 @@ variable vptr : ptr_t;
2509
2559
test. declarative_part (
2510
2560
"
2511
2561
type ptr_t is access integer_vector;
2512
- variable vptr : ptr_t;
2562
+ variable vptr : ptr_t;
2513
2563
" ,
2514
2564
) ;
2515
2565
let code = test. snippet ( "vptr(0)" ) ;
@@ -2637,7 +2687,7 @@ variable c0 : arr_t;
2637
2687
let test = TestSetup :: new ( ) ;
2638
2688
test. declarative_part (
2639
2689
"
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;
2641
2691
" ,
2642
2692
) ;
2643
2693
let code = test. snippet ( "arr_t'left" ) ;
@@ -2654,7 +2704,7 @@ type arr_t is array (integer range 0 to 3) of integer;
2654
2704
let test = TestSetup :: new ( ) ;
2655
2705
test. declarative_part (
2656
2706
"
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;
2658
2708
" ,
2659
2709
) ;
2660
2710
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
2710
2760
2711
2761
test. declarative_part (
2712
2762
"
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;
2714
2764
" ,
2715
2765
) ;
2716
2766
@@ -2729,7 +2779,7 @@ type arr_t is array (integer range 0 to 3) of integer;
2729
2779
2730
2780
test. declarative_part (
2731
2781
"
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;
2733
2783
constant c0 : arr_t := (others => 0);
2734
2784
" ,
2735
2785
) ;
@@ -2749,7 +2799,7 @@ constant c0 : arr_t := (others => 0);
2749
2799
2750
2800
test. declarative_part (
2751
2801
"
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;
2753
2803
constant c0 : arr_t := (others => 0);
2754
2804
" ,
2755
2805
) ;
@@ -2954,7 +3004,7 @@ variable thevar : integer;
2954
3004
let test = TestSetup :: new ( ) ;
2955
3005
test. declarative_part (
2956
3006
"
2957
- signal thesig : integer;
3007
+ signal thesig : integer;
2958
3008
" ,
2959
3009
) ;
2960
3010
@@ -3100,7 +3150,7 @@ variable thevar : integer;
3100
3150
let test = TestSetup :: new ( ) ;
3101
3151
test. declarative_part (
3102
3152
"
3103
- signal thesig : integer;
3153
+ signal thesig : integer;
3104
3154
" ,
3105
3155
) ;
3106
3156
0 commit comments