mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 21:06:50 -05:00
Fix handling of aruments in the emitter
Two problems are fixed: * `isArgumentsLocalBinding` did only `PropertyAccessExpression`, now it's also doing `PropertyAssignment` (doesn't affect other files, since it's only used in the emitter). * `visitShorthandPropertyAssignment` should call `visitIdentifier` on the synthesized id. (For completion it might be better to make it visit the the original?) Fixes #38594.
This commit is contained in:
@@ -36095,15 +36095,16 @@ namespace ts {
|
||||
// Emitter support
|
||||
|
||||
function isArgumentsLocalBinding(nodeIn: Identifier): boolean {
|
||||
if (!isGeneratedIdentifier(nodeIn)) {
|
||||
const node = getParseTreeNode(nodeIn, isIdentifier);
|
||||
if (node) {
|
||||
const isPropertyName = node.parent.kind === SyntaxKind.PropertyAccessExpression && (<PropertyAccessExpression>node.parent).name === node;
|
||||
return !isPropertyName && getReferencedValueSymbol(node) === argumentsSymbol;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
// Note: does not handle isShorthandPropertyAssignment (and probably a few more)
|
||||
if (isGeneratedIdentifier(nodeIn)) return false;
|
||||
const node = getParseTreeNode(nodeIn, isIdentifier);
|
||||
if (!node) return false;
|
||||
const parent = node.parent;
|
||||
if (!parent) return false;
|
||||
const isPropertyName = ((isPropertyAccessExpression(parent)
|
||||
|| isPropertyAssignment(parent))
|
||||
&& parent.name === node);
|
||||
return !isPropertyName && getReferencedValueSymbol(node) === argumentsSymbol;
|
||||
}
|
||||
|
||||
function moduleExportsSomeValue(moduleReferenceExpression: Expression): boolean {
|
||||
|
||||
@@ -583,13 +583,10 @@ namespace ts {
|
||||
if (!convertedLoopState) {
|
||||
return node;
|
||||
}
|
||||
if (isGeneratedIdentifier(node)) {
|
||||
return node;
|
||||
if (resolver.isArgumentsLocalBinding(node)) {
|
||||
return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = createUniqueName("arguments"));
|
||||
}
|
||||
if (node.escapedText !== "arguments" || !resolver.isArgumentsLocalBinding(node)) {
|
||||
return node;
|
||||
}
|
||||
return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = createUniqueName("arguments"));
|
||||
return node;
|
||||
}
|
||||
|
||||
function visitBreakOrContinueStatement(node: BreakOrContinueStatement): Statement {
|
||||
@@ -3517,7 +3514,7 @@ namespace ts {
|
||||
return setTextRange(
|
||||
createPropertyAssignment(
|
||||
node.name,
|
||||
getSynthesizedClone(node.name)
|
||||
visitIdentifier(getSynthesizedClone(node.name))
|
||||
),
|
||||
/*location*/ node
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user