This code
```
import 'dart:isolate';
Future<void> main([List<String> arguments = const []]) async {
await something();
print("After the call!");
if (1+1==2) throw "This will be swallowed";
print("This will never be printed.");
}
Future<void> something() async {
Isolate.current.setErrorsFatal(false);
}
```
prints
```
$ out/ReleaseX64/dart pkg/front_end/test/fasta/hmm.dart
After the call!
$ echo $?
0
```
I.e. it dies silently, swallowing the throw and has a 0 exit code.
Using package:testing (and having it run at least one thing), it
previously did this so that if anything crashed, say, in user code
after the run (or maybe even some places inside package:testing?) it
would just swallow the error and leave a 0 exit code.
This CL sets the errors fatal thing to true (which must be the default)
causing the normal behaviour of it not swallowing any throws.
Change-Id: I9850bbf504e172cc4077e5e17265833ef58dfe90
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/350321
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
This is a follow up to
https://dart-review.googlesource.com/c/sdk/+/349881
Now that there's only one implementation of TypeConstraintGatherer, it
can be merged with the abstract class.
Change-Id: Iaf50548da2841c7dfb51126de9f746fac1a8ad0d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/350242
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Previously we were reusing the ensureNativeTypeToDartType function to
check that Dart function passed as a callback matches the native type.
This works if the types exactly match, but the subtyping test is
backwards, so it doesn't allow certain cases that should be allowed. The
main case is that when the native function type returns void, the Dart
function should be allowed to return anything.
So I added ensureDartTypeToNativeType, which reverses the subtype test.
As well as making the return types more permissive, this has also
changed what parameters are allowed to be passed to callbacks. For
example, in tests/ffi/vmspecific_static_checks_typeddata_test.dart:80,
passing a Handle to a function expecting an Int8List used to work, but
is now a compile error. I think this change is an improvement, because
previously it would have been possible to pass any type of object to
that callback. So this change turns some potential runtime type errors
into compile errors. But technically I think this is a breaking change.
Fixes: https://github.com/dart-lang/sdk/issues/53659
Bug: https://github.com/dart-lang/sdk/issues/53659
Change-Id: I6846a59fc309ec897cba8f985d7dd0a63b912b42
TEST=tests/ffi/function_callbacks_subtype_test.dart and others
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346440
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Only try to resolve the uri when `debugExternalPackageLibraries` is
false, which is when it is actually needed.
Change-Id: I5aade6214657eccbdb5e294a8bfb5e2968aa6b3d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349631
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Helin Shiah <helinx@google.com>
Auto-Submit: Chingjun Lau <chingjun@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
The type category table is a O(number-of-classes) sized byte array that
maps from class-id to either a type category (function, record, ...) or
a masqueraded class-id.
* for flute this table takes up around 1 KB.
* this prevents from making concrete class-ids come before all abstract
class ids
After recent changes the core RTT implementation no longer involves
masqueraded types (i.e. `<obj> is/as <type>` and `<type> <: <type>`
queries don't trigger masquerading functionality)
This CL removes the type category table, the special casing in the
class-id assignment and the compiler support for building the table.
Instead we move the logic to pure dart code, which can use normal `is`
checks to perform its function.
We add one optimization: The compiler will provide the class-id from
which one only non-masqueraded classes come. This makes the masquerading
function have a fast path.
* We use `Wasm{TypedData,String}Base` marker interfaces i
`dart:_internal` to check for wasm-backed implementations
* We use `-Ddart.wasm.js_compatibility` to provide JSCM mode
We add a test that actually exercises the 2 modes.
Change-Id: I051c35b17878950402a1336df871a686b649f732
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349641
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
To prepare for the site dropping prettify.
Change-Id: I90367bd67ae0216572aa9defe6aa180a34942e35
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349761
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
* avoid allocating _RecordType objects for `<obj> is/as <record-type>`
=> Introduce `Record._checkRecordType()`
=> Use `Record._recordRuntimeType` (which is now not masquerading) for
other purposes (e.g. verification)
* avoid using masqueraded types for `<obj> is/as <record-type>`
=> Introduce `Record._masqueradedRecordRuntimeType`
Although we introduce 2 extra methods on `Record` that are overriden,
it's O(record-shapes-in-program) and therefore not a big overhead.
=> This will enforce the invariant that the actual type check
implementation (i.e. for `<obj> is/as <type>` or
for `<type> <: <type>`) *never* calls back into
masquerading functionality
=> This in return means we can make the masquerading functionality
using `<obj> is <type>` checks.
Change-Id: I3e3a0411022042a8e735aaeed396cc8f90d8c9c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349800
Reviewed-by: Slava Egorov <vegorov@google.com>
This adds the dart:_macros library to the SDK and adds support for accessing dart:_macros from package:macros. The library is not used yet.
This change is needed as a prestep to adding the package:macros and using it in the CFE and analyzer, and needs to be rolled in as the checked in sdk before package:macros can be supported.
TEST=ci
Change-Id: Ife3ffd48527e3a196048d2ddf7387b8b7818f3a3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348680
Reviewed-by: Jake Macdonald <jakemac@google.com>
Reviewed-by: William Hesse <whesse@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
This is already functional, but I noticed the message needed to be updated. I also added tests for the case, mostly corresponding to the existing ones for classes.
Change-Id: I3529691f640bfbde3d8018b002b9ddf65c4ac4e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349762
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
We discussed this some time ago, and I found another place where
I would like to report at a `SyntacticEntity`. So, if I'm going to
add something, I can just as well make `ErrorReporter` better.
Change-Id: I46d99e8959c7a5fd700cc2cba775114bfefec04d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349709
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This adds support for the legacy server to switch to URIs using a client capability. In this mode, all "FilePaths" will be URI strings over the protocol (in both directions).
It also allows the server to send LSP notifications (wrapped inside an "lsp.notification" notification, matching how requests/responses work). Notifications are automatically enabled if the client uses any LSP methods or sends the new "supportsUris" capability.
Change-Id: I5d2b76e396862129c61de70d57397603c958a02d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349120
Reviewed-by: Jaime Wren <jwren@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
- Since "Futures", "Streams", and "Zones" are plural and not in code syntax, can make them lowercase to be consistent with the `dart:core` entry in the same list.
- Use the full "platform interopability" term when introducing the libraries, as it might be a newer term for readers.
- Replaces "interoping" term as after searching it seems not common and easily mistaken.
- Fixes spelling of "function"
Change-Id: Ia887b427789a50d70cb47228c677fe2fd03499e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349421
Reviewed-by: Kevin Moore <kevmoo@google.com>
Commit-Queue: Kevin Moore <kevmoo@google.com>
Reviewed-by: Marya Belanger <mbelanger@google.com>
(Note an additional pre-existing test in `context_locatator_test:test_locateRoots_nested_options_overriddenOptions`.)
Fixes https://github.com/dart-lang/sdk/issues/54791
Change-Id: Ie67e9d840bec1caaa3548a8803f3a9b452807249
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349625
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
This CL adds doc import information to UnlinkedLibraryDirective and reports any static errors such as `URI_DOES_NOT_EXIST` from the doc imports.
The doc imports should be treated similarly to actual imports so it uses a lot of the same logic.
Based largely on Sam's WIP work in this CL:
https://dart-review.googlesource.com/c/sdk/+/344340
Bug: https://github.com/dart-lang/sdk/issues/50702
Change-Id: Ic001fd6d4077eea04905288be0424e7b11b2b56c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345361
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
+ tidy up some redundant package versions that are inherited from the ConfigurationFiles mixin.
Change-Id: I93329cbf65af3a68ed27284903e7becac01cf5ea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349380
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Dart-Code has defaulted this flag to true for a while now and this flag was intended to be temporary to allow for our own testing.
Change-Id: Iad679303480151627fa2dead26b4a3a9f625c773
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349742
Reviewed-by: Jaime Wren <jwren@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Elias Yishak <eliasyishak@google.com>
1.9.0 contains a fix for parsing file:// URIs with encoded colons that we can get from VS Code and is the version analyzer_plugin now requires.
Change-Id: I193ce4660116b2847a280516ba33f076f75494aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349741
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
FFI loads and stores via structs can have a TypedData as receiver,
so this CL updates those loads to `kMayBeInnerPointer`.
This CL adds an IL test to verify that for `Pointer` loads the untagged
value is treated correctly as `kCannotBeInnerPointer`.
(And adds some prefer-inline pragmas to make some common operations
be inlined to avoid allocating `Pointer` objects.)
This CL updates the load in the FFI closures to use a load-field.
This can also potentially enable not allocating a pointer object when
this closure is inlined.
TEST=tests/ffi/unwrap_typeddata_generated_test.dart
TEST=tests/ffi
CoreLibraryReviewExempt: Only adding some pragmas.
Change-Id: If687e54c676f275cc849b3fed526a13766ab331a
Cq-Include-Trybots: luci.dart.try:vm-aot-android-release-arm64c-try,vm-aot-android-release-arm_x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64-try,vm-appjit-linux-debug-x64-try,vm-asan-linux-release-x64-try,vm-checked-mac-release-arm64-try,vm-eager-optimization-linux-release-ia32-try,vm-eager-optimization-linux-release-x64-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try,vm-fuchsia-release-x64-try,vm-kernel-linux-debug-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-linux-debug-ia32-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-mac-debug-arm64-try,vm-mac-debug-x64-try,vm-msan-linux-release-x64-try,vm-reload-linux-debug-x64-try,vm-reload-rollback-linux-debug-x64-try,vm-ubsan-linux-release-x64-try,vm-win-debug-arm64-try,vm-win-debug-x64-try,vm-win-release-ia32-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349241
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Analyzer fix https://github.com/dart-lang/sdk/issues/54754 has
landed. A new version of package:analyzer and package:dartdoc have
been released. `pub global activate dartdoc` should now work.
Patchset 1 is identical to the original CL.
The only difference is an extra test testing with negative offsets.
=== Original CL description ===
Structs and unions can now be created from an existing typed data
with the new `create` methods.
The typed data argument to these `create` methods is optional. If
the typed data argument is omitted, a new typed data of the right
size will be allocated.
Compound field reads and writes are unchecked. (These are
TypedDataBase loads and stores, rather than TypedData loads and stores.
And Pointers have no byte length.) Therefore the `create` method taking
existing TypedData objects check whether the length in bytes it at
least the size of the compound.
TEST=pkg/analyzer/test/src/diagnostics/creation_of_struct_or_union_test.dart
TEST=pkg/vm/testcases/transformations/ffi/struct_typed_data.dart
TEST=tests/ffi/structs_typed_data_test.dart
TEST=tests/ffi/vmspecific_static_checks_test.dart
Closes: https://github.com/dart-lang/sdk/issues/45697
Closes: https://github.com/dart-lang/sdk/issues/53418
Change-Id: Id7f30bcd4a6ae55a8298b39c9eadf4e80bc699a9
CoreLibraryReviewExempt: FFI is a VM and WASM only feature.
Cq-Include-Trybots: luci.dart.try:vm-aot-android-release-arm64c-try,vm-aot-android-release-arm_x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-win-debug-arm64-try,vm-aot-win-release-x64-try,vm-appjit-linux-debug-x64-try,vm-asan-linux-release-x64-try,vm-checked-mac-release-arm64-try,vm-eager-optimization-linux-release-ia32-try,vm-eager-optimization-linux-release-x64-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try,vm-fuchsia-release-x64-try,vm-kernel-linux-debug-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-linux-debug-ia32-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-mac-debug-arm64-try,vm-mac-debug-x64-try,vm-msan-linux-release-x64-try,vm-reload-linux-debug-x64-try,vm-reload-rollback-linux-debug-x64-try,vm-ubsan-linux-release-x64-try,vm-win-debug-arm64-try,vm-win-debug-x64-try,vm-win-release-ia32-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349260
Reviewed-by: Martin Kustermann <kustermann@google.com>