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

Allow comments between elsif / else and argument lists / Blocks #59

Closed
catb0t opened this issue Nov 8, 2018 · 2 comments
Closed

Allow comments between elsif / else and argument lists / Blocks #59

catb0t opened this issue Nov 8, 2018 · 2 comments
Labels

Comments

@catb0t
Copy link
Contributor

catb0t commented Nov 8, 2018

if /* ok */ () {
} /* ok */ else /* not ok */ {
}

the third comment, which doesn't parse and claims else is a variable, should be fine since else's Block is on its same line -- not like else \n { }, which is correct for being broken.

Also the second ok comment becomes not OK when there was a preceding elsif:

if /* ok */ () {
} /* ok */ elsif /* not ok */ () {  # with elsif
} /* errors here now */ else {  
}

but the comment before elsif is still legal. So it's quite specific.

You recently patched allowing almost arbitrary whitespace in if/else, I think the comments should be treated the same way -- unless it's not worth the implementation.

@catb0t catb0t changed the title Comments between elsif / else and their Block Allow comments between elsif / else and their argument list or the last Block Nov 8, 2018
@catb0t catb0t changed the title Allow comments between elsif / else and their argument list or the last Block Allow comments between elsif / else and argument lists / Blocks Nov 8, 2018
@catb0t
Copy link
Contributor Author

catb0t commented Nov 8, 2018

Hmm, if /* ok */ () /* not ok */ {} is also not legal, because the if can't find its Block. But it should, if the comments were parsed away properly?

@catb0t catb0t added the syntax label Nov 9, 2018
@trizen
Copy link
Owner

trizen commented Apr 22, 2019

If allowed, this would lead to unreadable code.

Comments can be used at the end of the line and between the branches, which is more than enough:

if (false) {   # some comment
    say 'if'
} # end of if

# some more
# comments here

elsif (true) {   # elsif branch
    say 'elsif'
}

@trizen trizen closed this as completed Apr 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants