unisonweb / unison

A friendly programming language from the future
https://unison-lang.org
Other
5.81k stars 271 forks source link

transcripts: Distinguish between failure to parse block and failure to parse content #5395

Open sellout opened 1 month ago

sellout commented 1 month ago

Embedded the transcript rather than writing it directly to make the info string issue visible.

A block like
``` ucm :error
scratch/main> this isn’t a command

will allow the transcript to succeed, since the error happens when the transcript is run.

However, a block like

///> this isn’t a command

should succeed, but won’t, because we only return a structure containing the info flags (:error) if the content also parses successfully.

We should instead return different errors for failing to parse the structure of the block vs failing to parse its content, with the latter preserving the flags so we can still handle :error properly when the content fails to parse.

More reasonably, a block like

scratch/main> this isn’t a command

won’t succeed, because we have a parse error before we even finish the info string, so we can’t know that we expect the block to error. I think we could rescue some of these cases as well (unknown tags vs completely unrecognizable info string), but it’s probably worth waiting for #5214 for that.