Skip to content

Conversation

@uniqueiniquity
Copy link
Contributor

Fixes #26376.
Currently, if we are performing an async code fix, we inspect each variable to see if it will collide with any other variables used after the code has been changed. However, for a conflicting variable foo, we will always rename it foo_1, even if another variable has also been renamed to foo_1. This PR stores the original names of variables during the rename operation so that the numbering can be done correctly.

@uniqueiniquity uniqueiniquity added this to the TypeScript 3.1 milestone Sep 11, 2018
@uniqueiniquity uniqueiniquity requested review from a user and amcasey September 11, 2018 18:31

if (clone && !includeTrivia) suppressLeadingAndTrailingTrivia(clone);
if (callback && node) callback(node!, clone);
if (callback && node && clone) callback(node!, clone);
Copy link

Choose a reason for hiding this comment

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

Looks like this wasn't detected due to a compiler bug. #27050

@amcasey
Copy link
Member

amcasey commented Sep 13, 2018

export function getSynthesizedDeepCloneWithRenames<T extends Node | undefined>(node: T, includeTrivia = true, renameMap?: Map<Identifier>, checker?: TypeChecker, callback?: (originalNode: Node, clone: Node) => any): T {

Maybe return early if node is undefined?


Refers to: src/services/utilities.ts:1657 in 95e5f7d. [](commit_id = 95e5f7d, deletion_comment = False)

// ==ASYNC FUNCTION::Convert to async function==

async function f() {
let x_2;
Copy link
Member

Choose a reason for hiding this comment

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

x_2 [](start = 5, length = 3)

Nit: It's kind of weird that the catch parameter got "1".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's just because we rename from left to right in the pre-fixed form. Not sure if that's worth fixing at this point.

numberOfAssignmentsOriginal: number;
}

interface SymbolAndIdentifier {
Copy link
Member

Choose a reason for hiding this comment

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

As we discussed offline, this might be more readable if the original names were tracked in a frequency table on the side.

Copy link
Member

@amcasey amcasey left a comment

Choose a reason for hiding this comment

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

LGTM, modulo suggestions

@uniqueiniquity uniqueiniquity merged commit bce34ad into microsoft:master Sep 14, 2018
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Async / Await Refactoring - Catch Block Parameter are not checked for collisions

2 participants