[vm] Make _CastError.{_url,_line,_column} nullable fields
The ! operator causes _CastErrors to be thrown without the
_CastError.{_url,_line,_column} fields to be set (see
runtime/vm/runtime_entry.cc:NullErrorHelper).
This CL makes the fields nullable. An alternative would be to remove the
fields entirely since the fields are not used and the position of the
failed null check is visible from top frame in the stack frame as well.
Though the fields are visible in the debugger and there are other
situations where they are correctly set (e.g. in type errors that cause
_CastError to be thrown). To avoid changing this behavior, we make them
nullable.
Fixes https://github.com/dart-lang/sdk/issues/49279
TEST=vm/dart{,_2}/regress_49279_test
Change-Id: Ieff9e84819d5afa83c8950ad1f99d684d184340a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248980
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
This commit is contained in:
committed by
Commit Bot
parent
2b700003d9
commit
4703d2c54e
@@ -0,0 +1,13 @@
|
||||
// Copyright (c) 2022, 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.
|
||||
|
||||
// VMOptions=--null-assertions --no-sound-null-safety --enable-asserts
|
||||
|
||||
void main() {
|
||||
try {
|
||||
null!;
|
||||
} on TypeError {
|
||||
// _CastError implements TypeError
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// Copyright (c) 2022, 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.
|
||||
|
||||
// VMOptions=--null-assertions --no-sound-null-safety --enable-asserts
|
||||
|
||||
void main() {
|
||||
try {
|
||||
null!;
|
||||
} on TypeError {
|
||||
// _CastError implements TypeError
|
||||
}
|
||||
}
|
||||
@@ -122,9 +122,9 @@ class _CastError extends Error implements CastError, TypeError {
|
||||
String toString() => _errorMsg;
|
||||
|
||||
// Fields _url, _line, and _column are only used for debugging purposes.
|
||||
final String _url;
|
||||
final int _line;
|
||||
final int _column;
|
||||
final String? _url;
|
||||
final int? _line;
|
||||
final int? _column;
|
||||
final String _errorMsg;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user