This CL adds support to the test runner for the test outcome
expectation syntax that uses `// [...]` to indicate which diagnostic
we should expect with the given tool. Currently, `...` is `analyzer`
when testing the analyzer and `cfe` when testing the common front end.
After landing this CL, it also supports `// [spec_parser]`.
This change would allow us to migrate several tests from the multi-test
format (like `code; //# 01: compile-time error`) to the new format, in
particular tests with intentional syntax errors.
Change-Id: I5dd2560a873eb7433d3e07aa8f393e83c51b28e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501161
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
This adds internal nodes for the encoding of various versions of for-in loops and moves the lowering to be performed as part of the inference. This avoids the need to create lowered and external AST nodes directly during body building.
Change-Id: If559bc19ff9e6aacb457413c71956c18eae2a4b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499542
Reviewed-by: Paul Berry <paulberry@google.com>
Letting isolate go seems to be problematic. If this native messaging api is used during runtime call, then original isolate might end up on a different worker os thread causing remembered frame pointer(remembered as part of entering runtime call) to become invalid due to different stack bounds of this new thread. Invalid frame pointer causes immediate assertion failures during stack walk done for GC purposes or for exception handling.
TEST=ci, https://dart-review.git.corp.google.com/c/sdk/+/486522/comments/ee54d99f_a5c2a9d4
Change-Id: If69076bb9e107502dfef819de73829d9682bb134
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501220
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
Discard memory-expensive driver data only when a driver first reaches
the idle work priority, instead of doing it on every scheduler loop
while it remains idle.
Track drivers whose idle discard has already run, and clear that state
when a driver gets more work or is removed. This preserves the
fine-dependency idle cleanup while avoiding repeated calls during long
idle periods.
Change-Id: If480e473fe2a1e8b6c4725cdd4ac4359afdba4a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500500
Reviewed-by: Paul Berry <paulberry@google.com>
It's possible that there are nested paths in LSP workspace folders, such as:
/foo
/fooBar
/bar/foo
We shouldn't just replace each path we were given, as it might replace the wrong parts of other parts. Instead, require the path to be surrounded by quotes, or prefixed by a quote and followed by the appropriate path separator.
I also tweaked the benchmark test a little to report the time for the first call separately from the others, since that one triggers the regex build.
On my machine, timings currently are:
```
Replacing 250 paths in payload of 2097152 bytes
Iteration #1, First: 43ms, Rest: 30ms
Iteration #2, First: 38ms, Rest: 30ms
Iteration #3, First: 33ms, Rest: 30ms
Iteration #4, First: 37ms, Rest: 30ms
Iteration #5, First: 31ms, Rest: 29ms
```
Change-Id: I75de1fb36a16636e0f50099cced1d5386318d589
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/491640
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Remove the `reportScannerErrors` option from `Scanner.tokenize`. The
parser handles scanner error tokens directly, so the scanner no longer
needs a mode that translates and reports them before parsing.
Update all callers to use the simplified `tokenize()` API. Adjust parser
recovery expectations where diagnostics are now reported at the
synthetic token location chosen by parser.
Change-Id: Ia2d479ba57b3156f1a4bab47c32444892c9d0aa4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500361
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
On 32-bit arm, when generating subtype test cache stub,
[delayed_type_args_reg] could be the same as [TypeTestABI::kInstanceReg]
(due to lack of registers).
As a result, when loading delayed type arguments from an instantiated
generic closure, [TypeTestABI::kInstanceReg] is eagerly overwritten,
which results in garbage delayed type arguments.
With the linear probe cache this would cause repeated cache misses.
With the hash-based cache this would cause a crash.
Bug: b/507666702
Change-Id: I1093f9277d874154a121ef644ecd7aa76320f789
TEST=runtime/tests/vm/dart/regress_b_507666702_test.dart
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500842
Reviewed-by: Tess Strickland <sstrickl@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
This adds an AsyncModifier class that holds both the AsyncMarker, used in the kernel encoding, and the file offset of the async modifier. This is used throughout the front end and ensures that the correct offset is used for errors reported on the async modifier.
Change-Id: If16d293ffb9b2e8fa8eca8c65f7548d920c5d56b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500720
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Kallen Tu <kallentu@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
The test_runner skips test runs on all but front-end-only configurations
in the case where the test contains expectations that there will be
a compile-time error. This CL changes the "front-end-only"
classification such that the spec parser is included.
Before this CL, this implies that a test with a syntax error and an
expectation that this syntax error will be reported is simply skipped
when using `tools/test.py -c spec_parser ...`. With this CL, the
spec parser will be executed on that test, as it should.
Change-Id: I32ed313b5da20c189ca2f9b6b9ea3bb45f5072c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500721
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Adds logic to the `RemoveTypeName` correction producer to ensure that
after the correction is applied, the spacing matches what `dart
format` would do. For example, `C()` is changed to `new()` rather than
`new ()`, and `factory C()` is changed to `factory()` rather than
`factory ()`.
This will make it easier for me to visually inspect intermediate
results when transitioning the SDK and google3 to language version
3.13. It also should provide a (marginally) nicer user experience.
Change-Id: I30babde38e58438ea39279ed0d5859ce6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500880
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Replace the positional Scanner constructors with a single constructor
that takes the input text and error reporting callback as named required
arguments.
Remove the unused fasta forwarding constructor, reader offset handling,
and stored first token. The scanner now keeps only the input text and
returns the token stream directly from tokenize.
Update analyzer, analysis server, plugin, CLI, scrape, and scanner test
call sites to use the named constructor arguments.
Change-Id: Ieabb7b28570d4a963563fb2d1c5ef5ac0c89032a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500340
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Broaden search candidate selection to consider all names that can
syntactically denote an element, instead of only the element's own name.
Let the analysis driver answer reference-name queries for a set of
names. Use that to search for constructor references through declaring
type names, type aliases, and alias chains, including unnamed
constructors whose source spelling may omit the constructor name. Also
keep the declaring libraries in the candidate set so local references
are not filtered out before indexing.
Record super formal parameter names as referenced names. These names can
denote parameters from the selected super constructor, so they must be
available when narrowing files for search.
This improves reference search for constructor calls through type
aliases, dot-shorthand constructor invocations and tear-offs, and static
members used with dot shorthand or through an alias.
Fixes: https://github.com/dart-lang/sdk/issues/62219
Change-Id: Ia50ed3fd2e97f99d4aaf350314d08b930f86062c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500280
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Keep each executable fragment's formal parameter list complete across an
augmentation chain by adding synthetic missing parameters both to
earlier fragments and to the current fragment. Link matching positional
parameters by position and named parameters by name, preserving
duplicate named parameters in declaration order.
This lets every formal parameter element have a fragment in each
executable fragment, while still allowing consumers that need only
written parameters to filter by `isOriginDeclaration`.
Update type building so synthetic fragments from other executable
fragments do not prevent the first real declaration from initializing
the parameter element type. Keep later real declarations from
overwriting a type that was already established by a previous real
fragment.
Add small collection helpers used by the new linking logic, and expand
augmentation element-model expectations to cover regular, field-formal,
and super-formal parameters with missing, reordered, duplicated, and
shape-changing parameters.
Change-Id: Ie4c959744385cb8dcc46bbbb5c5e9e4e5c30d461
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500220
Reviewed-by: Johnni Winther <johnniwinther@google.com>
When we call out to JS and the function type is declared as `void` we
don't observe the result from JS. That means we can import the JS
function as a wasm function type without results.
We then synthesize a `null` value, in case a caller of the external JS
function uses/observes the `void` result value.
=> This CL does the same for `JS<void>(...)` calls.
We also remove the "inline" replacement optimization in the js interop
transformer. That makes all `JS<...>()` calls to be handled in a uniform
way.
=> Our backend's inliner should inline it iff beneficial for size.
Change-Id: I78032aae0dcdcaaf52701c628cea71af1de0d5e6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499880
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
This CL enables the primary constructors feature by default in Dart 3.13.
The primary constructors feature is a brevity feature. There are no new semantics, but it allows us to express declarations in a less verbose way.
This feature allows one constructor and a set of instance variables to be specified in the header of a declaration.
Currently a declaration with a constructor and some fields is written as:
```dart
// Current syntax.
class Point {
int x;
int y;
Point(this.x, this.y);
}
```
With a primary constructor, we would write the above as:
```
class Point(var int x, var int y);
```
If a primary constructor needs an initializer list or a body, they can be
specified inside the class using the `this` body syntax:
```dart
class Point(var int x, var int y) {
this : assert(x >= 0) {
print('Point created at $x, $y');
}
}
```
As part of this feature, you can also use the `new` and `factory` keywords to
declare constructors in the class body without repeating the class name:
```dart
class Point {
int x, y;
// Equivalent to Point(this.x, this.y)
new(this.x, this.y);
// Equivalent to Point.origin()
new origin() : x = 0, y = 0;
// Equivalent to factory Point.clone(Point other)
factory clone(Point other) => Point(other.x, other.y);
}
```
To learn more about the feature, check out the feature specification located here: https://github.com/dart-lang/language/blob/main/accepted/future-releases/primary-constructors/feature-specification.md
Tested: Has existing language, CFE, analyzer, analysis server tests.
Bug: https://github.com/dart-lang/sdk/issues/61524
Change-Id: I296f2fcd918b87bf2a1dd00256340759866c2423
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489241
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Michael Thomsen <mit@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>