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 on Yield "*" (star, asterisk) #3542

Open
JoshMayberry opened this issue Mar 31, 2021 · 1 comment
Open

Error on Yield "*" (star, asterisk) #3542

JoshMayberry opened this issue Mar 31, 2021 · 1 comment
Labels

Comments

@JoshMayberry
Copy link

If you yield the string "*", it will throw the following error: "E021 Expected '*' and instead saw '*'".

Example Code that would throw the error:

x = Array.from(function*() {
	yield "@";
	yield "*"; // This line
	yield "#";
}());
@jugglinmike
Copy link
Member

Confirmed. Here are a few workarounds you can use until this gets fixed:

function * g() {
  yield ('*');
}

function * g() {
  yield '* '[0];
}

function * g() {
  const star = '*';
  yield star;
}

This is due to an unfortunate symmetry in JSHint between tokens for literals and tokens for other terminals. We have to take extra care to specify which one of those two things we're talking about, and in this case, we failed to do that.

Anyway, thanks for taking the time to file a report!

@jugglinmike jugglinmike added the P2 label Apr 19, 2021
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