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

8$: Warn on for(;;){}while(cond); #954

Open
strager opened this issue Mar 21, 2023 · 4 comments
Open

8$: Warn on for(;;){}while(cond); #954

strager opened this issue Mar 21, 2023 · 4 comments
Labels
for hire Get paid for working on this task: https://quick-lint-js.com/hiring.html

Comments

@strager
Copy link
Collaborator

strager commented Mar 21, 2023

In the following examples, the programmer intended to write a do-while loop:

for(;;) {
} while (cond);

while (cond) {
} while (cond);

If we see while after a for or while loop's body, without any newline after the }, report a diagnostic.

@strager strager added the for hire Get paid for working on this task: https://quick-lint-js.com/hiring.html label Mar 21, 2023
@footgod368 footgod368 removed their assignment May 31, 2023
@cphamWSU
Copy link

cphamWSU commented Nov 9, 2023

Hello, I'd like to take on this task as part of classwork to contribute to an open source project.

This is my first time doing so, and I'd love to reach out for some guidance. What would be the best medium to ask for help?

@strager
Copy link
Collaborator Author

strager commented Nov 9, 2023

Hello, I'd like to take on this task as part of classwork to contribute to an open source project.

Awesome! I'm happy to help you with this.

What would be the best medium to ask for help?

Here are some options:

@cphamWSU
Copy link

Thanks for the quick response. I've been familiarizing myself with the relevant code and implementing the initial steps for a diagnostic. Now that I'm onto writing the production code, I wanted to check if I was on the right track.

Using parse_and_visit_do_while from parse-statement.cpp as a reference for how to evaluate source code tokens, my assumption is that the solution for this issue would be to add some logic that checks for tokens following the right curly brace inside of parse_and_visit_for and parse_and_visit_while in the same file. I would imagine that has_leading_newline will also end up playing a role.

Does any of that sound right?

@strager
Copy link
Collaborator Author

strager commented Nov 16, 2023

@cphamWSU Adding checks at the end of parse_and_visit_for sounds about right. Checking has_leading_newline for the while token sounds like a good idea too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for hire Get paid for working on this task: https://quick-lint-js.com/hiring.html
Projects
None yet
Development

No branches or pull requests

3 participants