Skip to content
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

Bug: Invalid indentation allowed after do #5458

Open
edemaine opened this issue Oct 4, 2023 · 0 comments
Open

Bug: Invalid indentation allowed after do #5458

edemaine opened this issue Oct 4, 2023 · 0 comments

Comments

@edemaine
Copy link
Contributor

edemaine commented Oct 4, 2023

Bug report (minor)

Input Code

foo = do
  bar = getBar()
  indented
  indented
notIndented
notIndented

Expected 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant