Bug: Invalid indentation allowed after `do`
edemaine opened this issue · 0 comments
edemaine commented
Bug report (minor)
Input Code
foo = do
bar = getBar()
indented
indented
notIndented
notIndentedExpected Behavior
Compilation error: unexpected indentation of indented on line 3
Current Behavior
var bar, foo;
foo = (bar = getBar())();
indented;
indented;
notIndented;
notIndented;Analysis
The token stream incorrectly has no DEDENT token:
[IDENTIFIER foo] [= =] [DO do] [IDENTIFIER bar] [= =] [IDENTIFIER getBar] [CALL_START (] [CALL_END )] [TERMINATOR \n] [IDENTIFIER indented] [TERMINATOR \n] [IDENTIFIER notIndented] [TERMINATOR \n]
Hopefully not too hard a fix...
Context
The current behavior (pointed out by a user) could lead users to write buggy code, because it seems like the indented code is executed "within" the do, but it isn't. (Unlike e.g. if the do was followed by -> as is usual.)
Environment
- CoffeeScript version: 2.7.0
- Node.js version: 19.9.0