File tree Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -91,18 +91,17 @@ impl fmt::Display for CompileError {
91
91
CompileErrorType :: InvalidYield => "'yield' outside function" . to_string ( ) ,
92
92
} ;
93
93
94
- if self . statement . is_some ( ) && self . location . column ( ) > 0 {
95
- // visualize the error, when location and statement are provided
96
- write ! (
97
- f,
98
- "\n {}\n {}" ,
99
- self . statement. clone( ) . unwrap( ) ,
100
- self . location. visualize( & error_desc)
101
- )
102
- } else {
103
- // print line number
104
- write ! ( f, "{} at {}" , error_desc, self . location)
94
+ if let Some ( statement) = & self . statement {
95
+ if self . location . column ( ) > 0 {
96
+ if let Some ( line) = statement. lines ( ) . nth ( self . location . row ( ) - 1 ) {
97
+ // visualize the error, when location and statement are provided
98
+ return write ! ( f, "\n {}\n {}" , line, self . location. visualize( & error_desc) ) ;
99
+ }
100
+ }
105
101
}
102
+
103
+ // print line number
104
+ write ! ( f, "{} at {}" , error_desc, self . location)
106
105
}
107
106
}
108
107
You can’t perform that action at this time.
0 commit comments