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>
This CL adds an implementation of anonymous `=>` methods in the CFE
which is sufficiently complete to handle the existing test cases in
language/anonymous_methods/expression.
Coverage is handled by adding magic comments to ignore the fact that new
code is not covered by existing testcases. This will be settled in a
separate CL.
To keep the failures visible, the failures in configurations
dart2js-hostasserts-linux-d8-try, dart2js-linux-chrome-try,
dart2js-minified-linux-d8-try, and ddc-linux-chrome-try have not been
approved. It seems likely to me that those are bugs in dart2js and in
DDC.
Change-Id: Ia70fedd4de6166d6a3bf8a108f49728b6e16c9f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494440
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
This introduces the `dynamically-callable` section in the dynamic
interface and adds an initial, but incomplete, validation pass for it.
The current validator:
* Checks that dynamic calls use a selector that matches one of the
exposed members in the `dynamically-callable` section.
* Validates that subtypes of `dynamically-callable` classes
added in a dynamic module don't overlap with classes
implementing `noSuchMethod`.
Note that the latter check is incomplete. Additional checks need to be
added when building the host app to reject subtypes defined in the host.
Future changes:
* validate during host compilation about other subtypes
* move validation for classes exposed in the dynamic interface to be done while compiling the host
* reject mixin methods that contain dynamic calls during host compilation.
* accept providing an allow list of valid selectors during compilation of dynamic modules, so it module-to-module calls are supported too.
TEST=CFE unit tests
Change-Id: I8d12192ef374c34a48fbdf2ba5002d2850ce926f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494001
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
This removes the remaining support for `augment super` in the parser, analyzer and CFE.
`augment super` will not be part of the augmentations feature.
Change-Id: Ie8a185bba067ab6ecf3b3229ecc20d5c284842bd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/493401
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
This CL adds a new `can-be-used-as-type` section in the dynamic
interface to expose the type of a class or extension type, without
making them callable or exposing their members.
Details:
* add the new section to the documentation
* add support in the TFA transformation to annotate kernel nodes
* add support to the validator to check for proper usage from dynamic modules
* add CFE, transformation, and end2end tests.
The CL ignores DDC and Dart2wasm at the moment and we intend to approve
any failures. It's possible that DDC works due to its modular nature.
BUG=b/488343137
TEST=cfe, annotator, and e2e tests
Change-Id: I900b22b85950f8ac379eabaa2ef58f075e18519c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486340
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
And they may not be extended, implemented and mixed in.
It would be cleaner if we test the static checks with the [cfe]
test expectations. However, those test suites are not set up to
run from a package context, which `@RecordUse` annotations must be.
TEST=pkg/compiler/test/record_use/record_use_test.dart
TEST=pkg/dart2wasm/test/record_use_test.dart
TEST=pkg/vm/test/transformations/record_use_test.dart
Change-Id: Ia4e93a6f25ad4c246503ebf8ece67e7d4bca1410
Cq-Include-Trybots: luci.dart.try:dart2wasm-asserts-linux-chrome-try,dart2wasm-asserts-minified-linux-d8-try,dart2wasm-linux-chrome-try,dart2wasm-linux-d8-try,dart2wasm-linux-firefox-try,dart2wasm-linux-jscm-chrome-try,dart2wasm-linux-optimized-jsc-try,pkg-linux-debug-try,pkg-linux-release-arm64-try,pkg-linux-release-try,pkg-mac-release-arm64-try,pkg-mac-release-try,pkg-win-release-arm64-try,pkg-win-release-try,dart2js-canary-linux-try,dart2js-hostasserts-linux-d8-try,dart2js-linux-chrome-try,dart2js-linux-firefox-try,dart2js-mac-chrome-try,dart2js-mac-safari-try,dart2js-minified-csp-linux-chrome-try,dart2js-minified-linux-d8-try,dart2js-unit-linux-x64-release-try,dart2js-win-chrome-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482220
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Michael Goderbauer <goderbauer@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Record only for definitions in libraries with a `package:` uri.
* Converts all the tests to be in packages.
* Bonus: This removes the uri-mapping in equality checks.
* These packages are added to the root pub workspace.
* For the dart2js tests we need to do some juggling to keep the
tests files in memory.
* Only support `package:` uris
* Removed all the `relativizeUri` code for file paths.
* Start emitting errors on non `package:` uris with a `@RecordUse()`
annotation.
Unrelated cleanups:
* We no longer support recording const instances in annotations, this
PR cleans up code in `kernel` and `type_flow`.
TEST=pkg/compiler/test/record_use/record_use_test.dart
TEST=pkg/dart2wasm/test/record_use_test.dart
TEST=pkg/vm/test/transformations/record_use_test.dart
Closes: https://github.com/dart-lang/native/issues/2891
Change-Id: I1bc6905291230375e185930d2c000700ac778f85
Cq-Include-Trybots: luci.dart.try:dart2wasm-asserts-linux-chrome-try,dart2wasm-asserts-minified-linux-d8-try,dart2wasm-linux-chrome-try,dart2wasm-linux-d8-try,dart2wasm-linux-firefox-try,dart2wasm-linux-jscm-chrome-try,dart2wasm-linux-optimized-jsc-try,pkg-linux-debug-try,pkg-linux-release-arm64-try,pkg-linux-release-try,pkg-mac-release-arm64-try,pkg-mac-release-try,pkg-win-release-arm64-try,pkg-win-release-try,dart2js-canary-linux-try,dart2js-hostasserts-linux-d8-try,dart2js-linux-chrome-try,dart2js-linux-firefox-try,dart2js-mac-chrome-try,dart2js-mac-safari-try,dart2js-minified-csp-linux-chrome-try,dart2js-minified-linux-d8-try,dart2js-unit-linux-x64-release-try,dart2js-win-chrome-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478920
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
This CL adds some elements of the implementation of anonymous methods:
- _fe.../messages.yaml: Add error message about wrong parameter list.
- analysis_server/.../error_fix_status.yaml: Add status of above error.
- analyzer/.../src/.../ast.dart: Add new AST classes AnonymousArrowBody
AnonymousBlockBody, AnonymousMethodBody, AnonymousMethodInvocation.
- analyzer/.../to_source_visitor.dart: Add new `visit` methods.
- analyzer/.../ast_builder.dart: add `endAnonymousMethodInvocation`.
- analyzer/.../resolver.dart: add new `visit` methods.
Change-Id: Ifa562c653f608884319ad9a1d87e169d9fac4b75
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/475043
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@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>
Eventually, the analyzer and front end will need to use the
corresponding public name as the effective name of the parameter. That
means that in addition to seeing if the parameter has a public name or
not, we actually need it. Instead of calculating the public name in the
parser and then plumbing it through the formal parameter listener, I
did the error reporting separately in the front end and analyzer.
Let me know if you think that makes sense. I can also move the other
private named parameters (back) out of the parser and into the two
front ends to be consistent if you want.
Change-Id: I9ca6c003b962d9b14d8dfa46eea4b31689935f04
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/458703
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Change how the parser reports errors for named parameters that start with `_` in anticipation of supporting private named parameters.
With "private named parameters" some private named parameters are errors and some aren't. It's still an error to have a private named parameter that doesn't refer to a field. This updates the error reporting to implement that. It also consolidates the error reporting into the parser. Prior to this CL, analyzer would discard the parser's private named parameter errors and then re-detect and report them itself.
The errors you get now when the experiment is off are:
* If the parameter doesn't refer to a field, you get the old error that you can't have a private named parameter.
* If the parameter does refer to a field, you get an error telling you to enable the experiment. When the experiment ships, this changes to an error about updating the library's language version.
And when the experiment is on:
* If the parameter doesn't refer to a field, you get a new error that you can't have a private named parameter unless it refers to a field.
* If the parameter does refer to a field, it reports no error. It doesn't actually support private named parameters that refer to fields yet.
Let me know what I got wrong. It was a little tricky to figure out how it should behave when the experiment is off. One option is to have no user-visible changes in behavior at all when the experiment is off. So the feature is fully hidden behind the experiment.
But most other code I saw seems to take an approach where if the feature is off, it acknowledges the existence of the feature but tells the user it's disabled. I went with this approach but I don't know if that's something we should only do when it's closer to shipping.
Change-Id: I0fc4e9b06c8e7f0abc868e0f49d2b3e625c8dade
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/456540
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Since that stops `dart:_js_annotations` from building on dart2wasm,
let's stop supporting that, too.
This causes `package:js` to no longer work on dart2wasm, but none of the
allowlisted packages use it any longer, so we can simply migrate tests
off of it.
Fixes: #56502Fixes: #61550
Change-Id: I6a6a696438255ebf25a5a17131cdbd327ba81581
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/453645
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Replaces the remaining `analyzerCode: FOO` entries in
`pkg/_fe_analyzer_shared/messages.yaml` with `psuedoSharedCode: FOO`
entries. A `pseudoSharedCode` entry carries two pieces of information:
it indicates that the error code is "pseudo-shared" (meaning that
there is manually maintained logic that translates it from a CFE
diagnostic to an analyzer diagnostic), and it provides an enum value
that can be used by the manually maintained logic to identify which
analyzer error to translate to.
In the few cases where diagnostic had a `pseudoShared: true`
annotation but no `analyzerCode`, a fresh `pseudoSharedCode` is
introduced.
The diagnostic code generation logic is updated accordingly. The logic
that translates CFE diagnostics to analyzer diagnostics is also
updated.
This change carries two benefits:
- It more accurately reflects reality; calling these codes
`analyzerCode` was inaccurate because there was no automated process
to verify that they corresponded to actual analyzer error codes, and
in fact in many cases they didn't.
- It avoids confusion with the `analyzerCode` values in
`pkg/_fe_analyzer_shared/messages.yaml`, which _do_ in fact
correspond to actual analyzer error codes.
Change-Id: I6a6a69640fe4b04da0296086d052be46126a1ebd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/453102
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Removes most of the analyzerCode values in
`pkg/front_end/messages.yaml`. The only ones that remain are those
associated with diagnostics marked `pseudoShared: true`; they are the
only ones whose values actually had an effect on generated code.
The removed analyzerCode values were of little value, since they
didn't have any effect and there were no tests to keep them
synchronized with actual analyzer error codes. In many cases, these
values did not even match any existing analyzer error code.
Removing these unused values will make it easier to make follow-on
improvements to the existing analyzerCode values, which do have a
functional effect.
Change-Id: I6a6a6964c93a0fd0b9cf48adbcda814e5f7eb178
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/452884
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Adds a translation of the scanner error code `Encoding` to the
`translateErrorToken` function. Previously, this error was unhandled,
so if the scanner encountered invalid unicode, the analyzer would
crash.
Change-Id: I6a6a696433016dddd2cbc0660922ea5248d54419
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/452901
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Moves all the diagnostics that are shared between the analyzer and the
CFE from `pkg/front_end/messages.yaml` to
`pkg/_fe_analyzer_shared/messages.yaml`.
This CL was generated by the following steps:
- Run the `move_shared_diagnostics.dart` script introduced in
https://dart-review.googlesource.com/c/sdk/+/448606.
- Manually modify `pkg/front_end/messages.status` to reflect the
diagnostics that have been moved.
Change-Id: I6a6a6964d618089f8fe8d447b4344800bad5d532
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/448660
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Updates the code in `pkg/analyzer_utilities/lib/messages.dart` to
attempt to read CFE messages from both
`pkg/_fe_analyzer_shared/messages.yaml` and
`pkg/front_end/messages.yaml`, and updates clients accordingly.
Also updates the `messages_suite.dart` test and the presubmit rules to
ensure that the contents of `pkg/_fe_analyzer_shared/messages.yaml`
will be appropriately tested.
Since the file `pkg/_fe_analyzer_shared/messages.yaml` doesn't exist
yet, temporaryhacks have been added to pretend the file is empty if it
can't be found.
In a follow-up CL, I will move messages that are shared between the
analyzer and the CFE to `pkg/_fe_analyzer_shared/messages.yaml`.
Change-Id: I6a6a6964c1c02f20df9ae8e34f23e734bbe88c22
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/448605
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
* No more "Fail" status in messages.status.
* Removed unused messages.
* Added examples for (almost?) all messages where it's possible.
* Add messages suite to coverage suite and update coverage.
== Additional notes
=== From the yaml spec (https://yaml.org/spec/1.2.2/)
```
2.3. Scalars
Scalar content can be written in block notation, using a literal style (indicated by “|”) where all line breaks are significant. Alternatively, they can be written with the folded style (denoted by “>”) where each line break is folded to a space unless it ends an empty or a more-indented line.
```
So we should probably use `|` and not `>` for code (especially if starting with a comment line (e.g. `// @dart=3.1`)) - and the other way around for messages.
=== These three settings
```
exampleAllowOtherCodes: true
exampleAllowMultipleReports: true
includeErrorContext: true
```
(or some combination of them)
closes https://github.com/dart-lang/sdk/issues/53634.
(one already existed, but was renamed)
Change-Id: I91a8ecee88d0600015252e289b068f60b1d1aeeb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/444600
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Instead of validating the erasure of an extension type,
validate that extension type declaration and type arguments
are specified as callable.
TEST=pkg/dynamic_modules/test/data/extension_type2
Fixes b/411433443
Change-Id: I063f0a622abd0d75594c4095573b29a7888f5afb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/423882
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
This splits up [computeAmbiguousDeclarationForScope] into
[computeAmbiguousDeclarationForExport], which is moved to [LibraryBuilder], and [computeAmbiguousDeclarationForImport].
Change-Id: I2fad4784904eef6caf731a41300b98c6f172039d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387080
Reviewed-by: Jens Johansen <jensj@google.com>
- Rename resource identifiers in the VM to usage recordings.
- Use package:record_use for serialization.
- Rename and use the experimental flag for this feature.
- Recognize tear-offs and top-level methods as well.
Next steps:
- Add constant instance recording.
- Expose API in package:native_assets_cli's link callback.
TEST=pkg/vm/test/transformations/record_use_test.dart
Change-Id: I8af3625165f78925ae943711245af93a239d1012
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383040
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Moritz Sümmermann <mosum@google.com>
Adds a new `@Array.variable()` to specify that the last element of
structs is a variable length inline array.
This CL does not add any checks for passing structs with variable
length inline arrays by value or directly calling them with
`AllocatorAlloc.call`. Instead, the implementation defaults to what
C does, allocate as if there are 0 elements in the variable length
inline array.
TEST=tests/ffi/*
CoreLibraryReviewExempt: VM only
Closes: https://github.com/dart-lang/sdk/issues/55964
Change-Id: I524d8a1d710b1a744b392e05fa884908c3ff1f12
Cq-Include-Trybots: dart/try:vm-aot-android-release-arm64c-try,vm-aot-android-release-arm_x64-try,vm-aot-asan-linux-release-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-msan-linux-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-tsan-linux-release-x64-try,vm-aot-ubsan-linux-release-x64-try,vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64-try,vm-aot-win-debug-x64c-try,vm-appjit-linux-debug-x64-try,vm-asan-linux-release-arm64-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-arm64-try,vm-fuchsia-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-arm64-try,vm-msan-linux-release-x64-try,vm-reload-linux-debug-x64-try,vm-reload-rollback-linux-debug-x64-try,vm-tsan-linux-release-arm64-try,vm-tsan-linux-release-x64-try,vm-ubsan-linux-release-arm64-try,vm-ubsan-linux-release-x64-try,vm-win-debug-arm64-try,vm-win-debug-x64-try,vm-win-debug-x64c-try,vm-win-release-ia32-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371960
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Like type parameters, these parameters can't be passed from JS and
such functions already do not work as intended as there is no way
to pass named args to a JS function. These named parameters were
being silently ignored in dart2wasm when creating the function
trampoline.
Change-Id: Iebb890de05f8b242e0542c1ec8f2c0582c5232df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368062
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>