Restrict the type of the last expression in at-eval blocks #1919
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, you are generally allowed to have at-eval to return anything, and the resulting object will get spliced into the document somehow, but we do not really define how we treat arbitrary objects (HTML just
repr
s them and dumps the resulting string as text in the document).In practice, and based on our docs, most of the time you're expected to either return
nothing
(so nothing gets displayed) orMarkdown.MD
(so you get properly rendered Markdown). This makes that requirement general and explicit, making it easier to support this block in the writers (that now know that it will always be eithernothing
orMarkdown.MD
, and don't have to deal with arbitrary types).This can be breaking because it was possible to get somewhat reasonable output for some return types and it's possible that people are using it (in particular, I am concerned about cases where people might be returning various
Markdown.*
nodes without wrapping them inMarkdown.MD
). For that reason, this does not make that case quite an error, but instead you get a warning, and the resulting object isshow
ed into a text representation and displayed as a code block (so there is behavior change for users).