-
Notifications
You must be signed in to change notification settings - Fork 2k
Erratic behavior of partial outdents #4127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Actually, this might be related to #3625 . |
No, it's not a duplicate of this one. Our lexer is too permissive, and accepts any amount of indent as one indent. That's what you're seeing here. I'm on my phone so I can't look for dups right now, though. |
I'm not sure if you're saying that the behavior is intended, I'm pretty sure it's not. To emphasize, adding spaces alternates between the two outputs. As in the output goes back and forth even though Here's a graphic (try):
Add another space and the position of the second outdent changes (try).
|
From #1275:
It's pretty much about "not breaking backwards compatibility" at this point |
Guys, aren't you misreading the issues? Seriously, your quote is completely unrelated to this issue. It's actually not related to #1275 either. You quote
and that's perfectly fine. The issue is that the quoted behavior is not implemented correctly and sometimes the outdent token is placed at an incorrect location. In #1275 the OP also noticed that the behavior is different with odd vs even number of spaces and none of the collaborators addressed that. Looking at the code it's actually worse than that because the placement of the outdent token depends on the indent of the enclosing block, in this case on the indentation difference between So please, if you're ok with that behavior, could you say that explicitly? Right now it just seems that you're not reading the issue carefully enough. |
No, I get what you mean. I don't think it has anything to do with being odd or even, I just think it's a |
This has nothing to do with |
I'd argue this should have to – we should stick to |
I still don't understand how |
it's the first indent the lexer encountered, and it should probably be enforced. Sadly, this'd probably break too much code that relies on a different behavior (or even people doing "unconventional" spacings with array/object literals, that happens a whole lot), so if your proposed fix works without breaking other tests, it'd be nice to have. |
I've been trying to figure out how indentation works in Coffeescript and I came across this snippet.
Adding spaces before
g
alternates the result betweenand
Looking at the lexer, it seems that the outdebt caused by overindented
g
is being compared to the indent betweenif a
andif c
lines. That's surely unintended -- shouldn't thee
line simply remove the outstanding outdebt introduced byg
? I.e. if I understand the intent correctly,g
ande
should be considered to be at the same indent level regardless of the indent ofg
(as long as it's smaller thand
).The text was updated successfully, but these errors were encountered: