Commit Graph

24193 Commits

Author SHA1 Message Date
Kallen Tu 1f534ed52d [tests] Primary constructors - var tests, update final tests, primary initializer scope.
Tests for the following:
- Declaration cycles.
- A compile-time error occurs if an assignment to a primary parameter
occurs in the initializing expression of a non-late instance variable.
- A compile-time error occurs if an assignment to a primary parameter
occurs in the initializer list of the body part of a primary
constructor.
- Late variables cannot access primary constructor parameters.
- Declarations without primary constructors don't have a primary
initializer scope.
- The primary initializer scope is the current scope for the
initializing expression, if any, of each non-late instance variable
declaration. It is also the current scope for the initializer list in the body part of the primary constructor, if any.
- The primary parameter scope is the current scope for the body of the
body part of the primary constructor, if any. Every primary parameter
which is not declaring, not initializing, and not a super parameter is
introduced into this scope.
- It's a compile-time error to write a formal non-declaring parameter with a `var` keyword and no type annotation.

Bug: https://github.com/dart-lang/sdk/issues/61687
Change-Id: If4dde05ac61fb69ef06a85df3bc36a47b1df57b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/479420
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2026-02-11 15:20:52 -08:00
Shanu Kumawat b6920ec07c [vm/ffi] Migrate 9 static check tests to new format
Converts the old multitest format (using //# markers) to the new format with explicit [analyzer] and [cfe] error expectations for the following tests:

- regress_44986_test.dart
- regress_46085_test.dart
- regress_47673_2_test.dart
- regress_51041_test.dart
- vmspecific_function_callbacks_negative_test.dart
- vmspecific_regress_38993_test.dart
- vmspecific_static_checks_ffinative_test.dart
- vmspecific_static_checks_varargs_test.dart
- vmspecific_variance_function_checks_test.dart

Updates #60212
TEST=tests/ffi/static_checks/
R=omersa@google.com

Change-Id: I92ea8d3e9ad750b17a7c0fa15f249f55936739cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478460
Auto-Submit: Shanu Kumawat <shanu.kumawat.dev@gmail.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-02-11 11:06:39 -08:00
Konstantin Shcheglov 689a374343 DeCo. Fix expectation in language/primary_constructors/header/enum_declaring_parameter_error_test.dart
Change-Id: I8cd2bb5ab27b246422157c405e51b497b1edcde8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/479681
Reviewed-by: Kallen Tu <kallentu@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-02-10 12:34:46 -08:00
Johnni Winther 48b4989bfa [PrimaryConstructors] Update analyzer error expectations
Change-Id: I2a37ae333deb3c9b8142fd7683af9a05d908d2d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478364
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2026-02-10 02:04:13 -08:00
Johnni Winther 1a88f3b7ce [cfe][PrimaryConstructors] Update primary constructor parameter scope
This updates the primary constructor parameter scope to be nested within the body scope of the enclosing declaration instead of the type parameter scope of the enclosing declaration.

Part of #61700

Change-Id: I8be1e7c4c9b81d1f4f8e6423d6c241b1222568b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/479000
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2026-02-10 00:40:53 -08:00
Robert Nystrom 0a25f21359 Fix a language test.
I'm guessing this was supposed to be a setter given its name and the
fact that it otherwise doesn't test anything not already covered by the
previous test.

The author probably just copy/pasted the method, renamed it, and forgot
to actually make it a setter.

Change-Id: Ibc1fc9f383498e104e9bba5fb2240a2e4ecea5bc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/479081
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
2026-02-09 10:20:05 -08:00
Alexander Markov c9e8e8a1f1 [vm] Fix handling of overflow in Bigint_mulAdd intrinsic
'inc' x86/x64 instruction does not affect CF.

TEST=corelib/bigint_test
Fixes https://github.com/dart-lang/sdk/issues/62572

Change-Id: Ibca032c5cc354d8d8df29fddd80353a04c6f1763
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478800
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2026-02-09 09:43:28 -08:00
Ömer Ağacan 652565b083 [dart2wasm] Handle undefined and null when converting errors caught from JS to string
In `_JavaScriptError`, instead of using `toString` method of the caught
objects, use the `String` constructor.

Fixes crashes when printing `null` and `undefined` exception values.

This is not directly related to #55481, but the issue was caught while
working on it.

Change-Id: Id6f7124730b4ffa125bd9d0fc8bcf3ed4de15a81
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478367
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2026-02-09 05:40:11 -08:00
Lasse R.H. Nielsen c549b92ecd Retire experiments released in SDK 3.10.0.
Change-Id: I550649155a2c659d943e491d0f41704c79e64500
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/457022
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2026-02-09 05:34:14 -08:00
Nate Biggs 2308a15e09 [dart2js] Fix record tracing w.r.t to closures.
We were losing track of records (and their contents) when they flowed into a closure. Now we correctly bailout when we encounter this situation.

This matches the behavior we have for tracing other collection objects.

Change-Id: I2b0945f9ab9732e3f460cefee451c7b853316ad5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478780
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2026-02-06 16:06:56 -08:00
Ömer Ağacan a3a8a6b6ac [dart2js] Skip test js_error_stack_trace_test with CSP
The test uses `eval`.

Change-Id: I8b6c083b14d8d20d72dd0a53feab6486611ac3b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478882
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2026-02-06 11:00:10 -08:00
Johnni Winther 5a8b4a89b1 [cfe][PrimaryConstructors] Report error on body without primary
This adds reporting of a primary constructor body declaration without a primary constructor declaration.

This current spec does not require an error on multiple primary constructor body declaration, but should, since this is not a all well-defined. An error is reported for this as well and the language test is updated to expect this error.

Part #61700

Change-Id: I88700d46971ac46b4c1a3d2e77980f642ee12fc9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478620
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2026-02-06 08:25:12 -08:00
Johnni Winther 4ca0fde9f7 [PrimaryConstructors] Update tests for var in enum declaring parameter
language/primary_constructors/header/enum_declaring_parameter_error_test is added exercise this.

language/primary_constructors/syntax/header_syntax_test and language/primary_constructors/syntax/final_formal_parameter_error_test are updated to not use 'var' modifier for enum declaring parameters.

A message is added to the CFE to avoid referring to the implicit const enum primary constructor as "marked as 'const'".

Part of #61524 #61700

Change-Id: Ic2c3c43d08c42d44dade04c116a73e3be1d22bd5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478420
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2026-02-06 03:44:45 -08:00
Konstantin Shcheglov 8c7e9a045c DeCo. Report nonFinalFieldInEnum for not final declaring formal parameter.
Bug: https://github.com/dart-lang/sdk/issues/62585
Change-Id: I7c9ef6eb22d95dac3142b1ba65c3effab074b3e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478500
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-02-05 13:55:11 -08:00
Konstantin Shcheglov 9ab1f4c68a CQ. Fix rewrite to FunctionExpressionInvocation in cascaded invocation.
Change-Id: I06d88bb37284c112d35ada865aed6ea8e21a0990
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478501
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-02-05 11:18:32 -08:00
Sergey G. Grekhov 6f769f282e [co19] .status file cleanup
Remove non-existent tests from .status files

Change-Id: Icedfb28d9dd6d6b02f372f20610e24c22f61d646
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478582
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2026-02-05 05:18:02 -08:00
Ömer Ağacan 51c73837b0 [dart2wasm] Tweak JS exception stack trace handling
Currently when we catch an exception thrown from JS we assume that it's
an `Error`, with a `stack` property.

This causes crashes when the exception value is not an `Error`, and the
behavior is also inconsistent with dart2js, which returns an empty stack
trace.

This fixes the crash and makes the behavior consistent with dart2js. To
make sure the behavior stays consistent, the relevant test is updated
and moved from a dart2wasm-specific directory to a web directory.

Change-Id: Ic6af7d919678ba585854c6531a103c0a5764e099
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478400
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2026-02-05 02:08:09 -08:00
Liam Appelbe 4679c040c6 [vm] Sync ffi callbacks can enter owned target isolate
Adds a new code path for NativeCallable.isolateLocal invocations. If
the current thread is not entered into any isolate, but owns the
target isolate, then it enters the target isolate, invokes, then exits
the isolate.

Fixes: https://github.com/dart-lang/sdk/issues/61623
TEST=tests/ffi/function_callbacks_isolate_ownership_test.dart
Change-Id: I401f185fadf7d2a55190dafd15387e1c418c67c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/452380
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2026-02-05 01:29:23 -08:00
Kevin Moore ef8682a9f8 [dart:wasm] implement most useful floating point SIMD ops
Change-Id: I44958086921812c7eb1a4be6b826c1be9a50738b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478340
Reviewed-by: Nate Biggs <natebiggs@google.com>
Auto-Submit: Kevin Moore <kevmoo@google.com>
Commit-Queue: Kevin Moore <kevmoo@google.com>
2026-02-04 20:31:45 -08:00
Kevin Moore 152e01ff69 [dart2wasm] "publicly" implement WasmV128
And add corresponding operations

Change-Id: Ib39ec04969281a35615e1b4ae41d1b4ec1c100ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478242
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Kevin Moore <kevmoo@google.com>
2026-02-03 22:17:49 -08:00
Kevin Moore 44cfe5b3fa [dart2wasm] Add equality to the v128 types
Change-Id: I6a07d1bec1ccc4b3a528399f9201c661bcef3e03
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478083
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Kevin Moore <kevmoo@google.com>
2026-02-03 20:51:11 -08:00
FMorschel 97153c68df [analyzer] Fixes invalid_constant false-positive for prefixed static access
Fixes: https://github.com/dart-lang/sdk/issues/61714
Change-Id: I1fba28e87f138c85040a75b742ca1850ef1b7984
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478040
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2026-02-03 17:29:05 -08:00
Konstantin Shcheglov 51003df5c3 CQ. Move constructor body diagnostics into ErrorVerifier
Centralize diagnostics for illegal constructor/method bodies in
ErrorVerifier instead of reporting them from the AST builder and Fasta
error conversion.

This consolidates several overlapping checks and fixes inconsistent
error locations (for example, reporting at `external`/`const` instead of
at `{`/`=>`).

Key changes:
- Remove constructor-body validation from AstBuilder (const bodies, const
  factories) and stop converting the corresponding Fasta codes to analyzer
  diagnostics to avoid duplicate reporting.
- Add a single verifier entry point that validates whether a body is allowed
  based on:
  - factory vs generative
  - const vs non-const
  - external vs non-external
  - redirecting vs non-redirecting
- Reuse the same validation for both regular constructors and primary
  constructors, and report at the body token for stable source ranges.
- Add a shared check for `external` functions/methods with block or expression
  bodies, and apply it consistently to top-level functions and class members.
- Align expectation files to the new, body-based error ranges and remove
  formatter-crash classification where the new reporting no longer triggers it.

Change-Id: Ie91ea08a7b5505d3e6443b12317c45359bac1c2d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/477780
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-02-03 11:38:23 -08:00
Kevin Moore 0f230f3262 [dart2wasm] test all new simd instructions
With one fix
Also added a test script to make future hacking easier

Change-Id: I05c75dd4c458f7c3404ed7dba25484296764a549
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/477941
Commit-Queue: Kevin Moore <kevmoo@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2026-02-03 11:07:42 -08:00
Nate Biggs 5a02a7a019 [dart2wasm] SIMD instructions template
SIMD proposal:
https://github.com/WebAssembly/spec/blob/main/proposals/simd/SIMD.md

This only implements a few of the available SIMD instructions as a
template for further contribution. kevmoo@ plans to continue
implementing these.

Bug: https://github.com/dart-lang/sdk/issues/62516
Change-Id: Ib229feecf58714e92fcb1461f968919658cbce29
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476540
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2026-02-03 10:01:43 -08:00
Alexander Aprelev 37b14e84f4 [core/shared] Allow for RegExp to work in isolategroup-bound callbacks.
TEST=run_isolate_group_run_test

Bug: https://github.com/dart-lang/sdk/issues/61030
Change-Id: I3c4734464e1902458edb4a03f5a9e9384509356b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476860
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2026-01-30 11:16:13 -08:00
Konstantin Shcheglov 8baa15d70a DeCo. Report extraneousModifier for primary constructor body.
Change-Id: I0b1fcf22d2d5b6fefaf6797ce6cd7317eff1def8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476561
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2026-01-30 07:53:43 -08:00
Sergey G. Grekhov a8c491c7bd [co19] Roll co19 to fe77de3965ea88a6dc1ecdf425adc0ef935f9097
2026-01-30 sgrekhov22@gmail.com Fixes dart-lang/co19#3577. Fix typo in `augmenting_class_like_declarations_A02_t26_lib.dart` (dart-lang/co19#3578)
2026-01-30 sgrekhov22@gmail.com Fixes dart-lang/co19#3575. Fix typos in `static_processing_A25_t05.dart` (dart-lang/co19#3576)
2026-01-29 sgrekhov22@gmail.com dart-lang/co19#3182. Rename enums tests according to they spec chapter name (dart-lang/co19#3573)
2026-01-29 sgrekhov22@gmail.com Fixes dart-lang/co19#3570. Update expected errors positions for the analyzer (dart-lang/co19#3572)
2026-01-29 sgrekhov22@gmail.com dart-lang/co19#3182. Fix `augmenting_variables_getters_setters_*`, add missing (dart-lang/co19#3571)
2026-01-28 sgrekhov22@gmail.com dart-lang/co19#3182. Remove obsolete `augmenting_variables` tests (dart-lang/co19#3569)
2026-01-27 sgrekhov22@gmail.com dart-lang/co19#3182. Add/update `complete_declarations_*` tests (dart-lang/co19#3566)
2026-01-27 sgrekhov22@gmail.com dart-lang/co19#3182. Add new test to existing `augmenting_class_like_declarations_*` (dart-lang/co19#3567)
2026-01-26 sgrekhov22@gmail.com Fixes dart-lang/co19#3562. Fix enum in `static_semantics_A02_t02.dart` (dart-lang/co19#3564)
2026-01-26 sgrekhov22@gmail.com Fixes dart-lang/co19#3562. Fix typo in `static_semantics_A05_t02.dart` (dart-lang/co19#3565)
2026-01-26 sgrekhov22@gmail.com Fixes dart-lang/co19#3560. Don't use `var` as a formal parameter type (dart-lang/co19#3561)
2026-01-23 sgrekhov22@gmail.com dart-lang/co19#3182. Rename `augmenting_declarations_*` to `applying_augmentations_*` (dart-lang/co19#3559)

R=athom@google.com, eernst@google.com

Cq-Include-Trybots: luci.dart.try:analyzer-linux-release-try,dart2js-minified-linux-d8-try
Change-Id: I33e43c97edc30ce142add9f2048a8e988ee5fc42
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476720
Auto-Submit: Sergey Grekhov <sgrekhov22@gmail.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2026-01-30 06:24:16 -08:00
Alexander Aprelev 27d4f2c79d [core/shared] Mark _CopyingBytesBuilder._emptyList shared
This enables use of BytesBuilder in isolategroup-bound callbacks.

TEST=run_isolate_group_run_test
CoreLibraryReviewExempt: this adds vm-specific pragma
Bug: https://github.com/dart-lang/sdk/issues/61030
Change-Id: Ic73887af099e6a7636e939d378dbe08a2f0c8f98
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476601
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2026-01-29 14:31:47 -08:00
Konstantin Shcheglov 7d8f83831c PrNP. Don't report finalNotInitializedConstructor for duplicate fields.
When a class declares the same instance field name more than once, the
"not initialized by this constructor" diagnostics are inherently
cascading. The root problem is the duplicate definition, and there is no
single unambiguous field declaration for the constructor verifier to
reason about.

Track duplicate field names per interface and suppress constructor
field-initialization diagnostics for those names (both final and
non-nullable). This avoids emitting misleading `finalNotInitialized*`
errors in code that is already invalid due to a duplicate field.

Update language/diagnostic expectations accordingly, including the
constructor regression and PrNP collision annotations.

Change-Id: I1095bae9ce0aaa876cbacaa970d7379ed70d7568
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/475560
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-01-28 17:48:57 -08:00
Nate Biggs c2f0ff4739 [dart2js] Handle JS interop functions with more than 52 parameters.
Attached test fails without this new change in place.

Bug: https://github.com/dart-lang/sdk/issues/62528
Change-Id: I7b658b9a404294678f9f94e93da490dcd975c7e4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476260
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2026-01-28 15:33:35 -08:00
Kallen Tu 9d555c3f5c [tests] Dot shorthands - Inaccessible context types with and without aliases.
Moved the functions with a type alias context type to the library with
the private declaration and added a function with an un-aliased type
to make sure we aren't able to use dot shorthands with inaccessible
declarations in either case.

Follow up to https://dart-review.googlesource.com/c/sdk/+/475266

Change-Id: I8d481b5733afdbbcc6b9e53cde1af4cf03b14f9f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/475931
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2026-01-28 10:37:06 -08:00
Alexander Aprelev 9d92474635 [vm/shared] Allow for print to work in isolategroup-bound callbacks.
TEST=ci
CoreLibraryReviewExempt:no-op split of printToZone into getter/setter, with different implementation only for vm.
Change-Id: I915c9330458cb2ba3f0f13ab109af12bacc233d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/475926
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2026-01-28 08:52:08 -08:00
Ömer Ağacan 11b6bd85d6 [dart2wasm] Add dart2wasm never-inline pragma to a function being checked in a stack trace test
Fixes tests with optimized builds:

- language/stack_trace/full1_test
- language/stack_trace/stack_trace_test

language/stack_trace/demangle_ctors_test will be fixed once we fix
#62523.

Change-Id: I788500e67045fa63783cc316eaf010728d077a3b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476100
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2026-01-28 04:41:56 -08:00
Ömer Ağacan 992a07a552 [dart2wasm] Generate dart2js sourcemap extensions to map minified class names to full names
Reuse dart2js's source map extension format to map minified class names
shown in error messages and runtime type strings ("minified:Class123")
to original class names.

The extension field is only generated when minifying, and with multiple
modules, only in the main module's source map.

- Without minification runtime type strings and error messages already
  include the full class name, so mapping is not necessary.

- With multiple modules, the existing tools use the main module's source
  map to deobfuscate errors.

Because wasm-opt is not aware of this custom section and it also changes
the names section, when optimizing, we read the original names before
calling wasm-opt, and write the section back to the source map file for
the optimized Wasm.

When not optimizing we generate the source map with the custom section
directly.

Example deobfuscation using the new source maps:

    $ dart pkg/dart2js_tools/bin/lookup_name.dart test.wasm.map Class123
    Class123 => AsyncError (a global name)

The custom section is a bit verbose for what dart2wasm needs: we could
map numbers to name indices instead of strings to name indices, as
dart2wasm minifies class names to numbers. However to avoid updating a
bunch of tools in g3, SDK, maybe also in Flutter and devtools, we reuse
dart2js's format, at least for now.

Issue: https://github.com/dart-lang/sdk/issues/60711
Change-Id: I2cda331723c6f0c7e7ef5f4772feaf420dc8c6ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/474660
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2026-01-28 02:48:30 -08:00
Martin Kustermann 2dabb7225e [dart2wasm] Fix bug in dart2wasm UTF-8 decoder
The UTF-8 decoder processes the input bytes in chunks of 1024 bytes. It
had the assumption that processing a chunk can at most yield 1024 UTF-16
code units. But the previous chunk may have had an uninished unicode
point that will (when finished in the next chunk) need to be encoded as
2 UTF-16 code units.

So decoding a 1024 byte chunk may yield 1025 UTF-16 code units.

=> Ensure the fixed buffer can hold 1025 UTF-16 code units.

Closes https://github.com/flutter/flutter/issues/180942

Change-Id: I53bb5b96647d84205153c0df6d468f2e77acef41
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/475042
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2026-01-28 02:48:25 -08:00
Kallen Tu e59b0e6e9b [tests] Dot shorthands - Tests for using shorthands with inaccessible declarations.
As per https://github.com/dart-lang/language/issues/4606#issuecomment-3753427148,
it's a compile-time error to use a dot shorthand to access an
inaccessible private declaration (one in another library). Even when the context type is a type alias, this is not allowed.

Areas of tests covered:
- Same and different libraries.
- Classes, extension types, mixins, enums.
- Dot shorthand constructors, const constructors, invocations, property accesses.
- With type alias context type.

Bug: https://github.com/dart-lang/sdk/issues/62504
Change-Id: I9cd77cc4ee818006efddebdf05c38be7eb1d4045
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/475266
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2026-01-26 13:29:31 -08:00
Konstantin Shcheglov 7b7d495d5f DeCo. Report extraneousModifier as appropriate.
Reports `extraneousModifier` when the primary constructors feature is
enabled and `final` or `var` is used in a formal parameter declaration
that's not part of a primary constructor.

Change-Id: I32e530cc60b89a7385e382def7b4c33e90199a7a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/475343
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2026-01-26 12:17:40 -08:00
Johnni Winther 5551ce036d [cfe] Remove BodyBuilderContext.function
This removes BodyBuilderContext.function to avoid accessing the FunctionNode in a partial state.

Change-Id: Idb172b01d067119abf98cd1c4c92a29773a06115
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471700
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2026-01-26 01:49:03 -08:00
Lasse R.H. Nielsen 9c81de5338 Update to primary constructor tests for extension types.
Checks that there is no inference from super-interface
members for the representation type/getter.

Check that object-instance-member-names cannot be
used as extension member declarations,
both before and after primary constructors.

Adds a few more tests for good measure.
(Could be redundant.)

Change-Id: Idb75cc0bcbc9718ffec5967ed6ed1463a1c3a149
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/475061
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Kallen Tu <kallentu@google.com>
2026-01-23 01:59:13 -08:00
Slava Egorov 25ffce7e36 [vm/win] Avoid unnecessary consoles for dartvm.exe
If dart.exe is not attached to the console then it should spawn
dartvm.exe detached to avoid creating an unnecessary console
window.

Fixes https://github.com/dart-lang/build/issues/4312

TEST=standalone/io/windows_no_unnecessary_console_test

Change-Id: I1de65accca5e28f3cfbe44a70f782525f0059bf0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/475000
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2026-01-22 08:17:43 -08:00
Lasse R.H. Nielsen 5c91a9d3fa Revert analyzer change to have extension members inherit types.
The specification doesn't allow that.
Until that changes, and we have a specification for how it works,
extension type members do not inherit types.

(Discussion: https://github.com/dart-lang/language/issues/4605)

Needs updating golden files in Google3, which seem to record the "override" relation between an extension member an a class instance member, which now isn't there.
(Likely just a revert of two files of "cl/853261361", which was introduced when the analyzer change first landed.)

Change-Id: Iff259d491fbde174e3fabd87c8ec8db8e7960f20
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/473280
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2026-01-22 04:43:42 -08:00
Tess Strickland e283e135ef [gardening] Adjust status file info for moved tests.
Tests from language/vm were moved to vm/dart/language, so move the
related lines from the status files.

Also fix the list of tests for the stress test trybot.

TEST=ci on vm-aot-dwarf-linux-product-x64
           vm-aot-obfuscate-linux-release-x64
           vm-appjit-linux-debug-x64
           vm-appjit-linux-product-x64
           vm-appjit-linux-release-x64

Cq-Include-Trybots: luci.dart.try:vm-appjit-linux-release-x64-try,vm-appjit-linux-product-x64-try,vm-appjit-linux-debug-x64-try,vm-aot-dwarf-linux-product-x64-try,vm-aot-obfuscate-linux-release-x64-try
Change-Id: I48eb25207551c0a9ba637023d36497f184c4a4b7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/474700
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2026-01-21 04:58:13 -08:00
Ryan Macnak 97a00247f8 [test] Disable TSAN thread leak detection for more tests that call exit.
Cf. cee7000c1a.

TEST=tsan
Bug: https://github.com/dart-lang/sdk/issues/62405
Change-Id: I03d6bd34e57c249f0e62ae87179614b9871e0436
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/474483
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-01-20 14:47:53 -08:00
Ömer Ağacan 99d503b105 [dart2wasm] Avoid redundant null checks of JS interop returns
Split JS-to-Dart conversion functions into two categories:

- Those that handle `null` and `undefined` and return Dart `null`.
- Those that don't expect `null` or `undefined`.

Then based on the return value of an interop function, call the right
one.

This moves null checks from interop call sites to conversion functions,
effectively outlining the duplicated null checks.

Boxing functions like `JSInt8ArrayImpl.fromArrayRef` are renamed as
`fromRef`, for consistency with other boxing functions, and also because
`fromRef` is more accurate. These functions already check the type and
so they can be passed any `externref`, not just those that represent JS
arrays.

Fixes #61906.

Issue: https://github.com/dart-lang/sdk/issues/61906
Change-Id: I54e80fe2e541ae6ef384c2c008f2dbc1e7e3bd76
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/473261
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2026-01-20 04:32:41 -08:00
Konstantin Shcheglov 230e1d16ce DeCo. Report mixinClassDeclaresConstructor on primary constructors.
Bug: https://github.com/dart-lang/sdk/issues/61701
Change-Id: I5e9027850366e38a4c33f6710c4f1fc8bbdc906a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/474001
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-01-19 17:01:59 -08:00
Lasse R.H. Nielsen 8d1ed4b750 Move VM-specific tests out of tests/{language,corelib}.
Change-Id: Iaeae638d2e3fb46409f04982975e78ad4c4eebe5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/472865
Auto-Submit: Lasse Nielsen <lrn@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2026-01-19 04:17:22 -08:00
Alexander Aprelev 026bb7cfeb [vm/gardening] Handle child process racing to exit.
Writing to stdin of already exited child process might not raise an error, will cause infinite loop in the test.

Fixes https://github.com/dart-lang/sdk/issues/56400
TEST=ci

Change-Id: I0100b5e5d782ae3682d634a47759b78146243274
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/473821
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2026-01-16 13:00:40 -08:00
Nate Biggs 2366fd740e [dart2wasm] Only use printable characters for minified string names.
Change-Id: I9f5de6bb28e6d9e9967e2dafdaf0261bec4c4571
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/473180
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2026-01-16 08:26:13 -08:00
Simon Binder 7d8cd032dc [dart2wasm] Interfaces for accessing memories
This adds the `Memory` class to `dart:_wasm`, allowing Dart code to
load and store numeric types in linear memory.
Since `dart2wasm` doesn't generate a memory instance by default, there
is no singleton instance of `Memory`. Instead, memories are defined as
`external` top-level getters annotated with a pragma like
`@pragma('wasm:memory-tyype', MemoryType(limits: Limits(1, 10)))` to
declare their type.

Interop happens in a static way: Methods on `Memory` cannot be torn-off
and, since the target memory is encoded directly in the store/load
instruction, there's also no polymorphism for memories in Dart.
Attempting to call methods on a memory instance that isn't a direct
reference to its definition is a compile-time error.

Memories can also be imported and exported through the existing
`wasm:import` and `wasm:export` pragmas.

TEST=tests/web/wasm/memory_test.dart

Change-Id: I726f33ac2ec04afab55c5a2b6bc09079d0193e02
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/470020
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2026-01-15 03:45:21 -08:00