Resolve test failures with web configurations

This CL adds code such that web compilers can recognize that `Let` nodes
can have a non-temporary variable as parameter. Before this CL, ddc
configurations fail in many anonymous method tests because the given
explicitly declared parameter isn't made available to the body of the
anonymous method.

Bug: https://github.com/dart-lang/sdk/issues/63184
Change-Id: I308c89e91e3856a06fa8f003d213cda0d93ae261
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498060
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
This commit is contained in:
Erik Ernst
2026-05-09 07:13:11 -07:00
committed by dart-scoped@luci-project-accounts.iam.gserviceaccount.com
parent d5ac7d4a57
commit 8028bd03fb
2 changed files with 12 additions and 0 deletions
@@ -8065,6 +8065,12 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
var init = _visitExpression(v.initializer!);
var body = _visitExpression(node.body);
var temp = _tempVariables.remove(v);
// TODO(eernst): Remove the following `if` if anonymous-methods is rejected.
// Otherwise, revise this method to be more readable.
// See https://github.com/dart-lang/language/issues/260.
if (temp == null && !_isTemporaryVariable(v)) {
temp = _emitVariableRef(v);
}
if (temp != null) {
if (_letVariables != null) {
init = js_ast.Assignment(temp, init);
@@ -8938,6 +8938,12 @@ class LibraryCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
var init = _visitExpression(v.initializer!);
var body = _visitExpression(node.body);
var temp = _tempVariables.remove(v);
// TODO(eernst): Remove the following `if` if anonymous-methods is rejected.
// Otherwise, revise this method to be more readable.
// See https://github.com/dart-lang/language/issues/260.
if (temp == null && !_isTemporaryVariable(v)) {
temp = _emitVariableRef(v);
}
if (temp != null) {
if (_letVariables != null) {
init = js_ast.Assignment(temp, init);