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

Array binding pattern with only OmittedExpressions does not check RHS of for-of loop #48630

Open
Fireboltofdeath opened this issue Apr 10, 2022 Β· 7 comments
Labels
Bug Good First Issue Help Wanted
Milestone

Comments

@Fireboltofdeath
Copy link

@Fireboltofdeath Fireboltofdeath commented Apr 10, 2022 β€’

Bug Report

πŸ”Ž Search Terms

array binding patterns for-of loop omittedexpression binding elements

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

// doesn't error
for (const [,] of doesntExist() /= 2) {

}

// does error
for (const [_,,,] of doesntExist() /= 2) {

}

πŸ™ Actual behavior

The right hand side of the for-of loop is not checked at all.

This appears to be because OmittedExpression is not actually a BindingElement and the right hand side's type is only checked whenever encountering a BindingElement in checkVariableLikeDeclaration or when there are no elements in the pattern.

πŸ™‚ Expected behavior

The right hand side of the for-of loop to be checked.

@RyanCavanaugh RyanCavanaugh added Bug Help Wanted labels Apr 11, 2022
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Apr 11, 2022
@RyanCavanaugh RyanCavanaugh added the Good First Issue label Apr 11, 2022
@wannieman98
Copy link

@wannieman98 wannieman98 commented Apr 14, 2022

Can I give this issue a try?

@Fireboltofdeath
Copy link
Author

@Fireboltofdeath Fireboltofdeath commented Apr 15, 2022

Can I give this issue a try?

Yes, feel free.

@wannieman98
Copy link

@wannieman98 wannieman98 commented Apr 15, 2022

Can I get some help on where I should begin looking to tackle this issue? Thanks!

@Fireboltofdeath
Copy link
Author

@Fireboltofdeath Fireboltofdeath commented Apr 15, 2022 β€’

You should take a look in checkVariableLikeDeclaration which is where the right side of the for-of loop gets checked, when encountering a binding element or pattern.

@wannieman98
Copy link

@wannieman98 wannieman98 commented Apr 16, 2022

Hi, sorry for another question, but I had been trying to fix the problem but I am not sure whether the [,] counts as a variable declaration or array literal. Could I get a clarification on that?

@bentongxyz
Copy link

@bentongxyz bentongxyz commented Apr 24, 2022

Hi there, if this is not being actively worked on right now, may I give this a try?
Thanks!

1 similar comment
@bentongxyz
Copy link

@bentongxyz bentongxyz commented Apr 24, 2022

Hi there, if this is not being actively worked on right now, may I give this a try?
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Good First Issue Help Wanted
Projects
None yet
Development

No branches or pull requests

4 participants