mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 08:24:39 +00:00
![Sigmund Cherem](/assets/img/avatar_default.png)
Expandos collide after a hot restart. This currently fails because the DDC implementation uses a static field (_keyCounter) to compute a unique name for each expando. After a hot-restart the counter gets reset and keys get reused accidentally. A hacky fix would be to ensure this field is not reset after restarts, but a more robust fix would be to use a weak map implementation like dart2js does. Change-Id: I991874aabf836be66cbd44de07dd38e681415ae7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199221 Reviewed-by: Nicholas Shahan <nshahan@google.com>
31 lines
627 B
Dart
31 lines
627 B
Dart
// Copyright (c) 2019, 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.
|
|
|
|
import 'dart:_runtime' as dart;
|
|
|
|
import 'package:expect/expect.dart';
|
|
import 'package:js/js.dart';
|
|
|
|
final e = Expando<int>();
|
|
|
|
@JS()
|
|
external void eval(String s);
|
|
|
|
@JS()
|
|
external Object get singleton;
|
|
|
|
void main() {
|
|
eval('''
|
|
if (!self.singleton) {
|
|
self.singleton = {};
|
|
}
|
|
''');
|
|
var o = singleton;
|
|
Expect.equals(null, e[o]);
|
|
e[o] = 1;
|
|
|
|
dart.hotRestart();
|
|
Expect.equals(null, e[o]);
|
|
}
|