@@ -63,17 +63,21 @@ pub fn compile(
63
63
match mode {
64
64
Mode :: Exec => {
65
65
let ast = parser:: parse_program ( source) ?;
66
- compile_program ( ast, source_path, optimize)
66
+ compile_program ( ast, source_path. clone ( ) , optimize)
67
67
}
68
68
Mode :: Eval => {
69
69
let statement = parser:: parse_statement ( source) ?;
70
- compile_statement_eval ( statement, source_path, optimize)
70
+ compile_statement_eval ( statement, source_path. clone ( ) , optimize)
71
71
}
72
72
Mode :: Single => {
73
73
let ast = parser:: parse_program ( source) ?;
74
- compile_program_single ( ast, source_path, optimize)
74
+ compile_program_single ( ast, source_path. clone ( ) , optimize)
75
75
}
76
76
}
77
+ . map_err ( |mut err| {
78
+ err. update_source_path ( & source_path) ;
79
+ err
80
+ } )
77
81
}
78
82
79
83
/// A helper function for the shared code of the different compile functions
@@ -258,6 +262,7 @@ impl<O: OutputStream> Compiler<O> {
258
262
statement : None ,
259
263
error : CompileErrorType :: ExpectExpr ,
260
264
location : statement. location . clone ( ) ,
265
+ source_path : None ,
261
266
} ) ;
262
267
}
263
268
}
@@ -537,6 +542,7 @@ impl<O: OutputStream> Compiler<O> {
537
542
statement : None ,
538
543
error : CompileErrorType :: InvalidBreak ,
539
544
location : statement. location . clone ( ) ,
545
+ source_path : None ,
540
546
} ) ;
541
547
}
542
548
self . emit ( Instruction :: Break ) ;
@@ -547,6 +553,7 @@ impl<O: OutputStream> Compiler<O> {
547
553
statement : None ,
548
554
error : CompileErrorType :: InvalidContinue ,
549
555
location : statement. location . clone ( ) ,
556
+ source_path : None ,
550
557
} ) ;
551
558
}
552
559
self . emit ( Instruction :: Continue ) ;
@@ -557,6 +564,7 @@ impl<O: OutputStream> Compiler<O> {
557
564
statement : None ,
558
565
error : CompileErrorType :: InvalidReturn ,
559
566
location : statement. location . clone ( ) ,
567
+ source_path : None ,
560
568
} ) ;
561
569
}
562
570
match value {
@@ -635,6 +643,7 @@ impl<O: OutputStream> Compiler<O> {
635
643
statement : None ,
636
644
error : CompileErrorType :: Delete ( expression. name ( ) ) ,
637
645
location : self . current_source_location . clone ( ) ,
646
+ source_path : None ,
638
647
} ) ;
639
648
}
640
649
}
@@ -1339,6 +1348,7 @@ impl<O: OutputStream> Compiler<O> {
1339
1348
statement : None ,
1340
1349
error : CompileErrorType :: StarArgs ,
1341
1350
location : self . current_source_location . clone ( ) ,
1351
+ source_path : None ,
1342
1352
} ) ;
1343
1353
} else {
1344
1354
seen_star = true ;
@@ -1369,6 +1379,7 @@ impl<O: OutputStream> Compiler<O> {
1369
1379
statement : None ,
1370
1380
error : CompileErrorType :: Assign ( target. name ( ) ) ,
1371
1381
location : self . current_source_location . clone ( ) ,
1382
+ source_path : None ,
1372
1383
} ) ;
1373
1384
}
1374
1385
}
@@ -1654,6 +1665,7 @@ impl<O: OutputStream> Compiler<O> {
1654
1665
statement : Option :: None ,
1655
1666
error : CompileErrorType :: InvalidYield ,
1656
1667
location : self . current_source_location . clone ( ) ,
1668
+ source_path : Option :: None ,
1657
1669
} ) ;
1658
1670
}
1659
1671
self . mark_generator ( ) ;
@@ -1751,6 +1763,7 @@ impl<O: OutputStream> Compiler<O> {
1751
1763
"Invalid starred expression" ,
1752
1764
) ) ,
1753
1765
location : self . current_source_location . clone ( ) ,
1766
+ source_path : Option :: None ,
1754
1767
} ) ;
1755
1768
}
1756
1769
IfExpression { test, body, orelse } => {
0 commit comments