Fix line numbers in errors for scripts starting with leading comments or whitespace #2686
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.
This is basically a port of the following fix in the Ammonite repo com-lihaoyi/Ammonite#1361. There were some changes when the logic was first ported from Ammonite to Mill, resulting in a much smaller code change than was necessary in the Ammonite repo
There are two related follow up PRs that AFAICT do not apply to Mill: com-lihaoyi/Ammonite#1363
and com-lihaoyi/Ammonite#1369. Both have to do with the special handling of multi-statement top-level-blocks
{...}
, that is a thing in the Ammonite REPL (to allow multiple top-level declarations to be entered into the REPL before submitting it) but doesn't apply to Mill scripts.I have updated the integration tests to include a bunch of random comments and imports to reproduce the problem causing the tests to fail, and verified the fix causes the tests to pass. Also this caused a previously passing test to fail (
2-custom-build-logic
), which on inspection appears like it was asserting the wrong thing, so I fixed the assertFixes #2681