@@ -997,8 +997,23 @@ impl TaskEvaluator {
997
997
let decl_ty = decl. ty ( ) ;
998
998
let ty = crate :: convert_ast_type_v1 ( state. document , & decl_ty) ?;
999
999
1000
- let ( value, span) = match inputs. get ( name. text ( ) ) {
1001
- Some ( input) => ( input. clone ( ) , name. span ( ) ) ,
1000
+ let value = match inputs. get ( name. text ( ) ) {
1001
+ Some ( input) => {
1002
+ let mut value = input. coerce ( & ty) . map_err ( |e| {
1003
+ runtime_type_mismatch ( e, & ty, name. span ( ) , & input. ty ( ) , name. span ( ) )
1004
+ } ) ?;
1005
+
1006
+ // Add the input to the inputs collection
1007
+ // Only performed for inputs given to the task as they may contain host paths
1008
+ if state. guest_roots . is_none ( ) {
1009
+ self . add_input ( & name, & ty, & mut value, state) . await ?;
1010
+ } else {
1011
+ self . add_guest_path_input ( & name, & ty, & mut value, state)
1012
+ . await ?;
1013
+ }
1014
+
1015
+ value
1016
+ }
1002
1017
None => match decl. expr ( ) {
1003
1018
Some ( expr) => {
1004
1019
debug ! (
@@ -1015,28 +1030,20 @@ impl TaskEvaluator {
1015
1030
ROOT_SCOPE_INDEX ,
1016
1031
) ) ;
1017
1032
let value = evaluator. evaluate_expr ( & expr) . await ?;
1018
- ( value, expr. span ( ) )
1033
+
1034
+ // Note: a backend input is *not* added to the state because any literal or
1035
+ // reference to another input will already be a guest path
1036
+ value. coerce ( & ty) . map_err ( |e| {
1037
+ runtime_type_mismatch ( e, & ty, name. span ( ) , & value. ty ( ) , expr. span ( ) )
1038
+ } ) ?
1019
1039
}
1020
1040
_ => {
1021
1041
assert ! ( ty. is_optional( ) , "type should be optional" ) ;
1022
- ( Value :: new_none ( ty. clone ( ) ) , name . span ( ) )
1042
+ Value :: new_none ( ty. clone ( ) )
1023
1043
}
1024
1044
} ,
1025
1045
} ;
1026
1046
1027
- let mut value = value
1028
- . coerce ( & ty)
1029
- . map_err ( |e| runtime_type_mismatch ( e, & ty, name. span ( ) , & value. ty ( ) , span) ) ?;
1030
-
1031
- // If the backend does not run tasks in a container, add the input without guest
1032
- // path
1033
- if state. guest_roots . is_none ( ) {
1034
- self . add_input ( & name, & ty, & mut value, state) . await ?;
1035
- } else {
1036
- self . add_guest_path_input ( & name, & ty, & mut value, state)
1037
- . await ?;
1038
- }
1039
-
1040
1047
// Insert the name into the scope
1041
1048
state. scopes [ ROOT_SCOPE_INDEX . 0 ] . insert ( name. text ( ) , value. clone ( ) ) ;
1042
1049
@@ -1524,7 +1531,7 @@ impl TaskEvaluator {
1524
1531
1525
1532
// Download any necessary files
1526
1533
for ( idx, input) in state. inputs . as_slice_mut ( ) . iter_mut ( ) . enumerate ( ) {
1527
- if input. location ( ) . is_some ( ) {
1534
+ if input. local_path ( ) . is_some ( ) {
1528
1535
continue ;
1529
1536
}
1530
1537
@@ -1559,7 +1566,7 @@ impl TaskEvaluator {
1559
1566
1560
1567
if enabled ! ( Level :: DEBUG ) {
1561
1568
for input in state. inputs . as_slice ( ) {
1562
- match ( input. location ( ) , input. guest_path ( ) ) {
1569
+ match ( input. local_path ( ) , input. guest_path ( ) ) {
1563
1570
( None , None ) => { }
1564
1571
( None , Some ( guest_path) ) => {
1565
1572
debug ! (
@@ -1570,25 +1577,25 @@ impl TaskEvaluator {
1570
1577
path = input. path( ) . display( ) ,
1571
1578
) ;
1572
1579
}
1573
- ( Some ( location ) , None ) => {
1580
+ ( Some ( local_path ) , None ) => {
1574
1581
debug ! (
1575
1582
task_id,
1576
1583
task_name = state. task. name( ) ,
1577
1584
document = state. document. uri( ) . as_str( ) ,
1578
- "task input `{path}` downloaded to `{location }`" ,
1585
+ "task input `{path}` downloaded to `{local_path }`" ,
1579
1586
path = input. path( ) . display( ) ,
1580
- location = location . display( )
1587
+ local_path = local_path . display( )
1581
1588
) ;
1582
1589
}
1583
- ( Some ( location ) , Some ( guest_path) ) => {
1590
+ ( Some ( local_path ) , Some ( guest_path) ) => {
1584
1591
debug ! (
1585
1592
task_id,
1586
1593
task_name = state. task. name( ) ,
1587
1594
document = state. document. uri( ) . as_str( ) ,
1588
- "task input `{path}` downloaded to `{location }` and mapped to \
1595
+ "task input `{path}` downloaded to `{local_path }` and mapped to \
1589
1596
`{guest_path}`",
1590
1597
path = input. path( ) . display( ) ,
1591
- location = location . display( ) ,
1598
+ local_path = local_path . display( ) ,
1592
1599
) ;
1593
1600
}
1594
1601
}
0 commit comments