-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[vm] Fix access to parameters in async closure body inside field init…
…ializer For async closure parsed_function_ could be an outer function which is unrelated to the closure. So, ScopeBuilder should not attempt to mark parameters of parsed_function_ with set_is_forced_stack() if it sees kSyncYielding FunctionNode. Parameter variables might not be even allocated if async closure is used inside an instance field initializer and parsed_function_ is a constructor. TEST=runtime/tests/vm/dart/regress_45306_test.dart Fixes #45306 Change-Id: I1b0082cb0e217039c43f19b35d77190493069edc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/191325 Reviewed-by: Martin Kustermann <[email protected]> Commit-Queue: Alexander Markov <[email protected]>
- Loading branch information
1 parent
7c8c6b3
commit a2900a5
Showing
3 changed files
with
71 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
// Regression test for https://github.com/dart-lang/sdk/issues/45306. | ||
// Verifies that ScopeBuilder doesn't crash on an async closure inside | ||
// instance field initializer. | ||
|
||
class X { | ||
late final Y y = Y( | ||
() async {}, | ||
); | ||
|
||
final double? a; | ||
final double? b; | ||
final String? c; | ||
|
||
X({ | ||
this.a, | ||
this.b, | ||
this.c, | ||
}); | ||
} | ||
|
||
typedef Callback = Future<void> Function(); | ||
|
||
class Y { | ||
Y(Callback? f); | ||
} | ||
|
||
void main() { | ||
X(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
// Regression test for https://github.com/dart-lang/sdk/issues/45306. | ||
// Verifies that ScopeBuilder doesn't crash on an async closure inside | ||
// instance field initializer. | ||
|
||
class X { | ||
final Y y = Y( | ||
() async {}, | ||
); | ||
|
||
final double a; | ||
final double b; | ||
final String c; | ||
|
||
X({ | ||
this.a, | ||
this.b, | ||
this.c, | ||
}); | ||
} | ||
|
||
typedef Callback = Future<void> Function(); | ||
|
||
class Y { | ||
Y(Callback f); | ||
} | ||
|
||
void main() { | ||
X(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters