You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fansi.Str(_) allows one to pass in an ErrorMode controlling whether an exception is thrown. But this call here defaults to throwing an exception. One can also sanitize the input before it is sent to fansi.Str(_), but that is not done either. There do not appear to be hooks to allow you to do either of these things if so desired, but I'm virtually ignorant of this codebase so I wouldn't know.
The reason this behavior is bad is that mdoc processing of scala worksheets explodes if the output of some line of code contains content that would cause fansi.Str(_) to explode, with no straightforward way to avoid this behavior. I'm seeing this frequently in my current project:
java.lang.IllegalArgumentException: Unknown ansi-escape at index XXX inside string cannot be parsed into an fansi.Str
at fansi.ErrorMode$Throw$.handle(Fansi.scala:419)
at fansi.ErrorMode$Throw$.handle(Fansi.scala:407)
at fansi.Str$.apply(Fansi.scala:272)
at pprint.Renderer.$anonfun$rec$32(Renderer.scala:147)
at scala.collection.Iterator$$anon$9.next(Iterator.scala:575)
at scala.collection.Iterator$$anon$6.hasNext(Iterator.scala:471)
at pprint.Truncated.hasNext(Truncated.scala:80)
at scala.collection.Iterator$$anon$6.hasNext(Iterator.scala:470)
at pprint.Truncated.hasNext(Truncated.scala:80)
at scala.collection.Iterator$$anon$9.hasNext(Iterator.scala:574)
at scala.collection.Iterator$$anon$6.hasNext(Iterator.scala:470)
at scala.collection.Iterator$$anon$10.hasNext(Iterator.scala:592)
at scala.collection.Iterator$$anon$6.hasNext(Iterator.scala:470)
at scala.collection.mutable.StringBuilder.appendAll(StringBuilder.scala:185)
at mdoc.internal.document.Printing$.printOneLine(Printing.scala:28)
at mdoc.internal.worksheets.WorksheetProvider.$anonfun$renderSummary$1(WorksheetProvider.scala:141)
at mdoc.internal.worksheets.WorksheetProvider.$anonfun$renderSummary$1$adapted(WorksheetProvider.scala:124)
at scala.collection.IterableOnceOps.foldLeft(IterableOnce.scala:646)
at scala.collection.IterableOnceOps.foldLeft$(IterableOnce.scala:642)
at scala.collection.AbstractIterator.foldLeft(Iterator.scala:1288)
at mdoc.internal.worksheets.WorksheetProvider.renderSummary(WorksheetProvider.scala:124)
at mdoc.internal.worksheets.WorksheetProvider.renderDecoration(WorksheetProvider.scala:73)
at mdoc.internal.worksheets.WorksheetProvider.$anonfun$evaluateWorksheet$3(WorksheetProvider.scala:42)
at scala.collection.immutable.List.map(List.scala:250)
at mdoc.internal.worksheets.WorksheetProvider.$anonfun$evaluateWorksheet$2(WorksheetProvider.scala:41)
at scala.collection.Iterator$$anon$10.nextCur(Iterator.scala:585)
at scala.collection.Iterator$$anon$10.hasNext(Iterator.scala:599)
at scala.collection.Iterator$$anon$6.hasNext(Iterator.scala:470)
at scala.collection.Iterator$$anon$9.hasNext(Iterator.scala:574)
at scala.collection.immutable.List.prependedAll(List.scala:152)
at scala.collection.IterableOnceOps.toList(IterableOnce.scala:1251)
at scala.collection.IterableOnceOps.toList$(IterableOnce.scala:1251)
at scala.collection.AbstractIterator.toList(Iterator.scala:1288)
at mdoc.internal.worksheets.WorksheetProvider.evaluateWorksheet(WorksheetProvider.scala:48)
at mdoc.internal.worksheets.Mdoc.evaluateWorksheet(Mdoc.scala:55)
at scala.meta.internal.worksheets.WorksheetProvider.scala$meta$internal$worksheets$WorksheetProvider$$evaluateWorksheet(WorksheetProvider.scala:363)
at scala.meta.internal.worksheets.WorksheetProvider$$anon$1.liftedTree1$1(WorksheetProvider.scala:267)
at scala.meta.internal.worksheets.WorksheetProvider$$anon$1.run(WorksheetProvider.scala:267)
I'm sorry that I cannot share the code or data that produces this.
Yes, I'll report an issue to mdoc too. I understand that throwing exceptions might be a design choice for this library. However, it seems like it should be possible to make pprint.Render a little safer, given that the underlying fansi library allows one to control exception throwing behavior.
The text was updated successfully, but these errors were encountered:
Right here:
PPrint/pprint/src/pprint/Renderer.scala
Line 147 in 3abeed8
fansi.Str(_)
allows one to pass in an ErrorMode controlling whether an exception is thrown. But this call here defaults to throwing an exception. One can also sanitize the input before it is sent tofansi.Str(_)
, but that is not done either. There do not appear to be hooks to allow you to do either of these things if so desired, but I'm virtually ignorant of this codebase so I wouldn't know.The reason this behavior is bad is that
mdoc
processing of scala worksheets explodes if the output of some line of code contains content that would causefansi.Str(_)
to explode, with no straightforward way to avoid this behavior. I'm seeing this frequently in my current project:I'm sorry that I cannot share the code or data that produces this.
Yes, I'll report an issue to
mdoc
too. I understand that throwing exceptions might be a design choice for this library. However, it seems like it should be possible to makepprint.Render
a little safer, given that the underlyingfansi
library allows one to control exception throwing behavior.The text was updated successfully, but these errors were encountered: