Open radeusgd opened 9 months ago
Anything indented belongs to the most recent less-indented line. I will make the error message more specific--I think if it mentions that the unexpected item encountered was a block it would be more clear what is happening.
There is also the question of whether doc-comments should create blocks: see #5443. I think unlike plain comments, an indented doc comment should create a block. I think it's better to assume the input is incomplete rather than incorrect, so a block ending in a doc comment should be treated as missing a following item (which would be a warning), not incorrectly indented (which could cause incorrect documentation association if we try to recover from).
Let's take this program:
It runs ok and prints
Hello world!
.Now let's add an indented comment:
It now fails and we can see that the import is not resolved:
If we take a similar program, but with a polyglot import:
Without the comment it runs and prints like above (the import is unused, doesn't matter). But with the added comment, we can see that the import is parsed in some unexpected way:
We can see that for some reason the import is processed together with the comment that comes after it.