Provide a better error when code is put outside of a function #92615
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Examples in the documentation often provide excerpts instead of full programs. A beginner might try compiling that code directly, and be confused that it doesn't work. Currently, the error messages for that case don't provide any hints as to what might be wrong:
Ideally the output should look like:
The text was updated successfully, but these errors were encountered: