Open kangalio opened 4 years ago
The playground sends stdout and stderr output separately. There's no way to know in what order the individual stdout and stderr output lines were printed, hence the only solution for the bot is to print the two separately.
It could look like this:
?play
fn main() {
let a = 123;
println!("hello!");
dbg!(a);
}
------------- Standard error -------------
[src/main.rs:2] a = 123
------------- Standard output ------------
hello!
and for ?eval maybe a more lightweight view:
let a = 123;
println!("hello!");
dbg!(a);
a
[src/main.rs:2] a = 123
hello!
123
When there is no stderr output (apart from normal rustc stderr), the existing view would be used
Another question is how this could interact with #21: when stderr and stdout combined exceed the message limit, which one of the two should be truncated? The best solution is probably to truncate them both equally
In my alternative Discord bot that aims to supersede RustbotPython, stderr and stdout are printed one after another, separated with a newline. https://github.com/kangalioo/rustbot/blob/5844ad49ebd2deba24ce900eda15305b6eb8b6b2/src/code_execution/playground.rs#L448-L454
Interaction with #21 is done by just truncating the end of the generated message. Stdout comes last, ergo stdout would be truncated first. This behavior was decided on for ease of implementation.
It's often a tripping point that
dbg!()
doesn't seem to work in the?eval
and?play
command. Only when an experienced bot user comes along the confusion is cleared up.Wouldn't it be possible to echo stderr by default in all the evaluation commands? This should not include rustc output but only output from the executable. The
?playwarn
command could be kept to toggle rustc stderr output