From aca53b24dbce0f33af605bef6ea35a9d64ccdb47 Mon Sep 17 00:00:00 2001 From: Nate Biggs Date: Fri, 18 Jul 2025 11:00:31 -0700 Subject: [PATCH] [js_interop] Use safe name when creating JSExport intermediary var. Bug: https://github.com/dart-lang/sdk/issues/61140 Change-Id: I01b863338f8cfa01150073286f83820ffe39c256 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441280 Commit-Queue: Nate Biggs Reviewed-by: Srujan Gaddam --- .../lib/src/transformations/shared_interop_transformer.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/_js_interop_checks/lib/src/transformations/shared_interop_transformer.dart b/pkg/_js_interop_checks/lib/src/transformations/shared_interop_transformer.dart index d5b3a881081..47d3b5756b3 100644 --- a/pkg/_js_interop_checks/lib/src/transformations/shared_interop_transformer.dart +++ b/pkg/_js_interop_checks/lib/src/transformations/shared_interop_transformer.dart @@ -50,6 +50,8 @@ class SharedInteropTransformer extends Transformer { final TypeEnvironment _typeEnvironment; final Procedure _typeofEquals; + int exportNameIdentifierCounter = 0; + StaticInvocation get invocation => _invocation!; SharedInteropTransformer( @@ -395,7 +397,9 @@ class SharedInteropTransformer extends Transformer { // A new map VariableDeclaration is created and added to the block of // statements for each export name. var getSetMap = VariableDeclaration( - '#${exportName}Mapping', + // Don't use the exportName here because it might not be a valid JS + // identifier. + '#${exportNameIdentifierCounter++}Mapping', initializer: getLiteral(), type: ExtensionType(_jsObject, Nullability.nonNullable), isSynthesized: true,