@@ -1522,7 +1522,11 @@ find_imported(char_u *name, size_t len, cctx_T *cctx)
15221522 * Generate an instruction to load script-local variable "name".
15231523 */
15241524 static int
1525- compile_load_scriptvar (cctx_T * cctx , char_u * name )
1525+ compile_load_scriptvar (
1526+ cctx_T * cctx ,
1527+ char_u * name , // variable NUL terminated
1528+ char_u * start , // start of variable
1529+ char_u * * end ) // end of variable
15261530{
15271531 scriptitem_T * si = SCRIPT_ITEM (current_sctx .sc_sid );
15281532 int idx = get_script_item_idx (current_sctx .sc_sid , name , FALSE);
@@ -1546,11 +1550,40 @@ compile_load_scriptvar(cctx_T *cctx, char_u *name)
15461550 import = find_imported (name , 0 , cctx );
15471551 if (import != NULL )
15481552 {
1549- // TODO: check this is a variable, not a function
1550- generate_VIM9SCRIPT (cctx , ISN_LOADSCRIPT ,
1551- import -> imp_sid ,
1552- import -> imp_var_vals_idx ,
1553- import -> imp_type );
1553+ if (import -> imp_all )
1554+ {
1555+ char_u * p = skipwhite (* end );
1556+ int name_len ;
1557+ ufunc_T * ufunc ;
1558+ type_T * type ;
1559+
1560+ // Used "import * as Name", need to lookup the member.
1561+ if (* p != '.' )
1562+ {
1563+ semsg (_ ("E1060: expected dot after name: %s" ), start );
1564+ return FAIL ;
1565+ }
1566+ ++ p ;
1567+
1568+ idx = find_exported (import -> imp_sid , & p , & name_len , & ufunc , & type );
1569+ // TODO: what if it is a function?
1570+ if (idx < 0 )
1571+ return FAIL ;
1572+ * end = p ;
1573+
1574+ generate_VIM9SCRIPT (cctx , ISN_LOADSCRIPT ,
1575+ import -> imp_sid ,
1576+ idx ,
1577+ type );
1578+ }
1579+ else
1580+ {
1581+ // TODO: check this is a variable, not a function
1582+ generate_VIM9SCRIPT (cctx , ISN_LOADSCRIPT ,
1583+ import -> imp_sid ,
1584+ import -> imp_var_vals_idx ,
1585+ import -> imp_type );
1586+ }
15541587 return OK ;
15551588 }
15561589
@@ -1564,10 +1597,11 @@ compile_load_scriptvar(cctx_T *cctx, char_u *name)
15641597 * When "error" is FALSE do not give an error when not found.
15651598 */
15661599 static int
1567- compile_load (char_u * * arg , char_u * end , cctx_T * cctx , int error )
1600+ compile_load (char_u * * arg , char_u * end_arg , cctx_T * cctx , int error )
15681601{
15691602 type_T * type ;
15701603 char_u * name ;
1604+ char_u * end = end_arg ;
15711605 int res = FAIL ;
15721606
15731607 if (* (* arg + 1 ) == ':' )
@@ -1589,7 +1623,7 @@ compile_load(char_u **arg, char_u *end, cctx_T *cctx, int error)
15891623 }
15901624 else if (* * arg == 's' )
15911625 {
1592- res = compile_load_scriptvar (cctx , name );
1626+ res = compile_load_scriptvar (cctx , name , NULL , NULL );
15931627 }
15941628 else
15951629 {
@@ -1645,7 +1679,7 @@ compile_load(char_u **arg, char_u *end, cctx_T *cctx, int error)
16451679 else if (SCRIPT_ITEM (current_sctx .sc_sid )-> sn_version
16461680 == SCRIPT_VERSION_VIM9 )
16471681 // in Vim9 script "var" can be script-local.
1648- res = compile_load_scriptvar (cctx , name );
1682+ res = compile_load_scriptvar (cctx , name , * arg , & end );
16491683 }
16501684 }
16511685 if (gen_load )
@@ -3412,7 +3446,7 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
34123446 generate_LOAD (cctx , ISN_LOADG , 0 , name + 2 , type );
34133447 break ;
34143448 case dest_script :
3415- compile_load_scriptvar (cctx , name + (name [1 ] == ':' ? 2 : 0 ));
3449+ compile_load_scriptvar (cctx , name + (name [1 ] == ':' ? 2 : 0 ), NULL , NULL );
34163450 break ;
34173451 case dest_env :
34183452 // Include $ in the name here
0 commit comments