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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>