Skip to content

TypeScript gets into bad editing state with async arrow functions #37522

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

Closed
DanielRosenwasser opened this issue Mar 23, 2020 · 8 comments
Closed
Assignees
Labels
Bug A bug in TypeScript

Comments

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Mar 23, 2020

This seems to be an issue with 3.8 and newer. 3.7.5 doesn't exhibit this behavior.

There's a couple of ways to observe this. First, try writing out the following code character-by-character.

let x = async () => {
    
}

You'll get

let x = async () => {
        ~~~~~~~~
Cannot find name 'async'.

Alternatively, paste the full example into a buffer. Then erase the c in async.

let x = asyn () => {
    
}

Give it a second, then add it back. TypeScript doesn't seem to refresh its semantic diagnostics for some reason.

You'll get

let x = async () => {
        ~~~~
Cannot find name 'asyn'.
@DanielRosenwasser
Copy link
Member Author

First time I can see this behavior is 3.8.0-dev.20191219.

@DanielRosenwasser
Copy link
Member Author

DanielRosenwasser commented Mar 23, 2020

https://github.com/microsoft/TypeScript/pulls?q=is%3Apr+closed%3A2019-12-17..2019-12-19+is%3Aclosed might be (?) a reasonable filter to figure out what started this.

@DanielRosenwasser DanielRosenwasser added the Bug A bug in TypeScript label Mar 23, 2020
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 3.9.1 milestone Mar 23, 2020
@DanielRosenwasser
Copy link
Member Author

I'm not 100% sure, but I'm fairly certain this is caused by #35731. It's one of the only parser changes, and switches a lot of parsing checks on arrow functions to check the modifier list instead of ModifierFlags. Maybe @andrewbranch (and even @CyrusNajmabadi, hi!) can help out here.

@andrewbranch
Copy link
Member

I am interested in incremental parsing and have a vague high-level familiarity with the algorithm, so if @sandersn runs out of time, wants a hand, or just wants to pawn this one off, I’d be happy to take a look.

@sandersn
Copy link
Member

sandersn commented Apr 1, 2020

I'm very likely to be out of time for this release, and I'm not familiar with the algorithm. So I'll give it to you, @andrewbranch

I remember that PR was the second attempt, after @PranavSenthilnathan and I abandoned the first attempt as "probably a bad idea". It might still be a bad idea!

@sandersn sandersn assigned andrewbranch and unassigned sandersn Apr 1, 2020
@andrewbranch
Copy link
Member

@DanielRosenwasser I can’t reproduce this in VS Code with 3.8.0-dev.20191219, 3.8.3, or current master, or in the playground. Are there any other tricks to get this to happen?

@andrewbranch
Copy link
Member

@DanielRosenwasser are you still able to reproduce this?

@andrewbranch
Copy link
Member

No one can reproduce this so I’m going to close... 😬

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

No branches or pull requests

3 participants