File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -183,9 +183,8 @@ pub(crate) fn annotate_input(
183183 let annotated_code = if let Some ( breakpoints) = breakpoints {
184184 let parse = aether_parser:: parse ( code, Default :: default ( ) ) ;
185185 if let Some ( err) = parse. error ( ) {
186- return Err ( anyhow ! (
187- "Unexpected parse error in `annotate_input()`: {err}"
188- ) ) ;
186+ // Shouldn't happen since we're only operating on code that was parsed by R
187+ return Err ( anyhow ! ( "Parse error in `annotate_input()`: {err}" ) ) ;
189188 }
190189
191190 let root = parse. tree ( ) ;
@@ -246,7 +245,13 @@ pub(crate) fn annotate_source(
246245 let wrapped = format ! ( "{{\n {code}\n }}" ) ;
247246 let line_index = LineIndex :: new ( & wrapped) ;
248247
249- let root = aether_parser:: parse ( & wrapped, Default :: default ( ) ) . tree ( ) ;
248+ let parse = aether_parser:: parse ( & wrapped, Default :: default ( ) ) ;
249+ if let Some ( err) = parse. error ( ) {
250+ // Shouldn't happen since we're only operating on code that was parsed by R
251+ return Err ( anyhow ! ( "Parse error in `annotate_input()`: {err}" ) ) ;
252+ }
253+
254+ let root = parse. tree ( ) ;
250255
251256 // `line_offset` = -1 because:
252257 // - Wrapped line 0 is `{`
Original file line number Diff line number Diff line change @@ -354,9 +354,18 @@ impl PendingInputs {
354354 breakpoints : Option < & mut [ Breakpoint ] > ,
355355 ) -> anyhow:: Result < ParseResult < PendingInputs > > {
356356 let input = if let Some ( location) = location {
357- let annotated_code = annotate_input ( code, location, breakpoints) ?;
358- log:: trace!( "Annotated code: \n ```\n {annotated_code}\n ```" ) ;
359- harp:: ParseInput :: SrcFile ( & SrcFile :: new_virtual_empty_filename ( annotated_code. into ( ) ) )
357+ match annotate_input ( code, location, breakpoints) {
358+ Ok ( annotated_code) => {
359+ log:: trace!( "Annotated code: \n ```\n {annotated_code}\n ```" ) ;
360+ harp:: ParseInput :: SrcFile ( & SrcFile :: new_virtual_empty_filename (
361+ annotated_code. into ( ) ,
362+ ) )
363+ } ,
364+ Err ( err) => {
365+ log:: warn!( "{err:?}" ) ;
366+ harp:: ParseInput :: Text ( code)
367+ } ,
368+ }
360369 } else if harp:: get_option_bool ( "keep.source" ) {
361370 harp:: ParseInput :: SrcFile ( & SrcFile :: new_virtual_empty_filename ( code. into ( ) ) )
362371 } else {
You can’t perform that action at this time.
0 commit comments