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

feat(parser): add for-await-of parsing #543

Merged
merged 1 commit into from
Apr 14, 2021
Merged

Conversation

Fuco1
Copy link
Contributor

@Fuco1 Fuco1 commented Jan 11, 2020

Fixes #412

@@ -2632,14 +2632,17 @@ so many of its properties will be nil.
object
in-pos
each-pos
foreach-p forof-p
await-pos
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

await-pos is unused, isn't it? When printing, etc.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same could be said for each-pos, of course, but let's not worry about that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can remove them both, I think they aren't necessary. But maybe some 3rd party depends on it, who knows.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Up to you.

lp rp)))
"AST node for a for..in loop."
iterator ; [var] foo in ...
object ; object over which we're iterating
in-pos ; buffer position of 'in' keyword
each-pos ; buffer position of 'each' keyword, if foreach-p
await-pos ; buffer position of 'await' keyword, if forawait-p
foreach-p ; t if it's a for-each loop
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also set foreach-p to a symbol (e.g. AWAIT), instead of adding a new field. But I'm okay with either.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did it this way to not possibly break existing integrations outside this package. If we're okay with removing backward compatibility we can use as symbol as you say.

Maybe in the future they will allow for each await () ? :D

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Integrations that use an (eq ... t) check? I wouldn't be too worried about those.

Would for each await actually make any kind of sense?

Copy link
Contributor Author

@Fuco1 Fuco1 Jan 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather even (if foreach-p ...) which would now be set to a symbol even in the case it is not an each keyword. But of course we would rename the field so I guess in fact that mitigates the problem and should allow an easy migration path.

I'm honestly not even sure what for each does. So probably not, never used it in my life.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually if we don't rename the field, it should make the "migration" easier: only dependents that know about "for await" would recognize it, and the rest would continue to compile and treat the AST nodes as "for each". Which is the outdated syntax.

It was Mozilla's extension. The modern counterpart is "for of": https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Statements/for_each...in

Copy link
Collaborator

@dgutov dgutov Jan 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, I'm fine with either (rename or not). But reusing the field seems more economical.

@dgutov
Copy link
Collaborator

dgutov commented Jan 13, 2020

Could you add a NEWS entry as well?

@Fuco1
Copy link
Contributor Author

Fuco1 commented Jan 14, 2020

@dgutov will do thanks for the feedback

@goranmoomin
Copy link

@Fuco1 May I ask the status of this? I would very much like if this gets merged...

@Fuco1
Copy link
Contributor Author

Fuco1 commented Sep 17, 2020

@pcr910303 The status is that I forgot about it 😊

@dgutov is the news entry the only thing blocking this?

@dgutov
Copy link
Collaborator

dgutov commented Sep 17, 2020

@Fuco1 Pretty much.

The other two discussions don't seem critical.

@wyuenho
Copy link
Contributor

wyuenho commented Apr 14, 2021

Jesus, please just merge this and add the NEWS entry in a separate commit. There's absolutely no need to be bureaucratic here.

@dgutov
Copy link
Collaborator

dgutov commented Apr 14, 2021

Okay.

@dgutov dgutov merged commit 776355a into mooz:master Apr 14, 2021
@dgutov
Copy link
Collaborator

dgutov commented Apr 14, 2021

I don't know if it was that unreasonable to expect the contributor to do at least one revision after review, but oh well.

@wyuenho
Copy link
Contributor

wyuenho commented Apr 14, 2021

It is unreasonable if you hold up perfectly good progress for over a year due to a missing NEWS entry that nobody reads and you can add yourself.

@dgutov
Copy link
Collaborator

dgutov commented Apr 15, 2021

Next time you have an idea about what somebody else should do, try helping.

@wyuenho
Copy link
Contributor

wyuenho commented Apr 15, 2021

Help how? You are the maintainer, not me and I don't care about the NEWS entry. I commented, you got a notification, the code got merged after over a year. That's helping everyone.

@dgutov
Copy link
Collaborator

dgutov commented Apr 15, 2021

You are the maintainer, not me and I don't care about the NEWS entry.

So rather than pitch in to maintain the project standards, you chose to be rude instead.

Thanks for the reminder, but the rest could have been done better.

@wyuenho
Copy link
Contributor

wyuenho commented Apr 15, 2021

I'll make sure I point out the obviously unreasonableness of holding up a perfectly good PR for over year next time. Without any exclamations involving any deities. I promise.

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

Successfully merging this pull request may close these issues.

Support for Async Iterators/Generators syntax
4 participants