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

Error in 16.1 #1026

Open
AskYous opened this issue Aug 22, 2016 · 4 comments
Open

Error in 16.1 #1026

AskYous opened this issue Aug 22, 2016 · 4 comments

Comments

@AskYous
Copy link

AskYous commented Aug 22, 2016

Hello,

In 16.1, it says:

Use braces with all multi-line blocks.

But in the examples, there's a contradiction:

// good
if (test) return false;

And

// bad
function foo() { return false; }

The second one shouldn't say 'bad' since it's not multi-line block like the rule says.

@ljharb
Copy link
Collaborator

ljharb commented Aug 22, 2016

The first example is permitted since it's a single-line block.

I agree we should remove the second example.

However, I think perhaps we should rewrite this section to always require braces in every scenario, period. Too many bugs are caused by omitting braces, and adding a second line intending it to be indented under the conditional.

@chrisngobanh
Copy link
Contributor

Isn't it a little redundant to say that you should include braces with multi-line blocks since a block cannot have multiple lines without braces?

@ljharb
Copy link
Collaborator

ljharb commented Aug 24, 2016

In this case, "multi-line block" is referring to "whatever the user thinks is a block" - which will only require braces if they understand how blocks work. Someone coming from a significant-whitespace language, for example, may not understand that difference.

@hshoff
Copy link
Member

hshoff commented Aug 26, 2016

this goes way back to 2012 #3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants