mirror of
https://github.com/morluto/rea
synced 2026-10-27 22:45:19 -04:00
fix(javascript): exclude class member keys from lexical reads
Classify noncomputed class member keys and private names at the shared reference owner, avoiding false reads and closure captures. Preserve computed keys and initializer/body reads. Validation: regression controls, fresh public CLI/MCP workflows and complete exact-head CI passed. Fixes #3310.
This commit is contained in:
@@ -725,11 +725,24 @@ const isNonReferenceKey = (node: t.Identifier, parent: t.Node): boolean =>
|
||||
parent.key === node &&
|
||||
!parent.computed &&
|
||||
!(t.isObjectProperty(parent) && parent.shorthand)) ||
|
||||
isNoncomputedClassMemberKey(node, parent) ||
|
||||
t.isPrivateName(parent) ||
|
||||
(t.isExportSpecifier(parent) && parent.exported === node) ||
|
||||
t.isLabeledStatement(parent) ||
|
||||
t.isBreakStatement(parent) ||
|
||||
t.isContinueStatement(parent);
|
||||
|
||||
/** A noncomputed class member name is a property key, never a lexical read. */
|
||||
const isNoncomputedClassMemberKey = (
|
||||
node: t.Identifier,
|
||||
parent: t.Node,
|
||||
): boolean =>
|
||||
(t.isClassMethod(parent) ||
|
||||
t.isClassProperty(parent) ||
|
||||
t.isTSDeclareMethod(parent)) &&
|
||||
parent.key === node &&
|
||||
!parent.computed;
|
||||
|
||||
const patternNames = (pattern: t.Node): string[] => {
|
||||
if (t.isTSParameterProperty(pattern)) return patternNames(pattern.parameter);
|
||||
if (t.isIdentifier(pattern)) return [pattern.name];
|
||||
|
||||
Reference in New Issue
Block a user