-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typechecking of map literals does not always work in checked mode #221
Comments
This comment was originally written by [email protected] Removed Type-Defect label. |
This comment was originally written by [email protected] Isn't this a type-checking bug (i.e. a type-defect)? |
This comment was originally written by [email protected] I guess my choice of title was slightly misleading. A better one would be "Type-checker ignores type-annotated Map literals". |
Looks like a bug to me. Set owner to @crelier. |
Fixed in the VM in r1764. |
Still needs fixing in dartc and frog. Removed the owner. |
Fixed for frog in r2187 |
This comment was originally written by [email protected] Specifically, what needs to be done is dartc is to put run-time type checks into the array/map initializers. The checks on assignment (l[1] = 2) are working. |
This comment was originally written by [email protected] Fixed in dartc r3619. Closing. Added Fixed label. |
Right now it maps straight to ES6 generators. This should handle some basic cases, but there's more work to get all of the corners working. For example: it doesn't implement Iterable yet. [email protected] Review URL: https://codereview.chromium.org/1207313002.
Closed incorrect issue, this one is still open. |
Why has this been reopened and assigned 'area-vm'? according to the comments this bug was fixed in the VM on Nov 22, 2011. |
…watcher, yaml, yaml_edit Revisions updated by `dart tools/rev_sdk_deps.dart`. crypto (https://github.com/dart-lang/crypto/compare/63e9a90..f2efb98): f2efb98 2024-01-02 Kevin Moore Require Dart 3.2, update and fix lints (#158) logging (https://github.com/dart-lang/logging/compare/324a0b5..4d35a4e): 4d35a4e 2024-01-01 dependabot[bot] Bump actions/stale from 8.0.0 to 9.0.0 (#152) mime (https://github.com/dart-lang/mime/compare/56359b0..ca9f059): ca9f059 2024-01-01 dependabot[bot] Bump actions/stale from 8.0.0 to 9.0.0 (#111) path (https://github.com/dart-lang/path/compare/115ea2a..57a049c): 57a049c 2024-01-01 dependabot[bot] Bump actions/stale from 8.0.0 to 9.0.0 (#157) 5b6aac7 2023-12-20 Kevin Moore blast_repo fixes (#156) pool (https://github.com/dart-lang/pool/compare/3c1bd42..4c49000): 4c49000 2024-01-01 dependabot[bot] Bump actions/stale from 8.0.0 to 9.0.0 (#79) 7e03d80 2023-12-20 Kevin Moore blast_repo fixes (#78) shelf (https://github.com/dart-lang/shelf/compare/b3adc7c..733588f): 733588f 2024-01-01 dependabot[bot] Bump actions/stale from 8.0.0 to 9.0.0 (#401) 1eab426 2024-01-01 dependabot[bot] Bump actions/labeler from 4.3.0 to 5.0.0 (#402) 10cbffe 2023-12-14 Kevin Moore Run web tests with wasm with dev Dart sdk (#398) stack_trace (https://github.com/dart-lang/stack_trace/compare/4abff44..0f4710c): 0f4710c 2024-01-01 dependabot[bot] Bump actions/stale from 8.0.0 to 9.0.0 (#148) tools (https://github.com/dart-lang/tools/compare/ed81684..2f59ab4): 2f59ab4 2024-01-02 Daco Harkes [graphs] Clean up lints for Dart 3.3 (#221) 01fa883 2024-01-01 dependabot[bot] Bump actions/stale from 8.0.0 to 9.0.0 (#223) 9d4fe2f 2024-01-01 dependabot[bot] Bump actions/labeler from 4.3.0 to 5.0.0 (#222) 6d260b8 2023-12-14 Elias Yishak Update USAGE_GUIDE to update the `flutterChannelCount` key in `LogFileStats` (#219) 56a30ce 2023-12-11 Elias Yishak Add `enabledFeatures` key to `Analytics` constructors (#217) watcher (https://github.com/dart-lang/watcher/compare/dc45f19..66cd694): 66cd694 2024-01-01 dependabot[bot] Bump actions/stale from 8.0.0 to 9.0.0 (#161) 679d308 2023-12-20 Kevin Moore blast_repo fixes (#160) yaml (https://github.com/dart-lang/yaml/compare/98a3aab..509fd72): 509fd72 2023-12-11 Kevin Moore update lints, require Dart 3.0 (#156) yaml_edit (https://github.com/dart-lang/yaml_edit/compare/9b9d33c..47eb20e): 47eb20e 2024-01-01 dependabot[bot] Bump actions/stale from 8.0.0 to 9.0.0 (#63) a39ec39 2023-12-20 Kevin Moore blast_repo fixes (#62) Change-Id: I8009f4957a0eb751f36c2ec1be8aacbfc44ca586 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/344400 Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Devon Carew <[email protected]>
This issue was originally filed by [email protected]
If we provide type information when instantiating a new Map, we get runtime type-checking (VM, checked mode):
var m1 = new Map<String, int>();
m1["str"] = "hello"; // error: type OneByteString is not assignable to type int
m1[1] = 2; // error: type Smi is not assignable to type String
I can't get the same behavior if I use Map literals, neither in the literal initializer nor in subsequent []= operations. No exception gets thrown for these two lines:
var m2 = <String, String>{"a": 0}; // Map literal doesn't type-check values
m2[2] = 1; // nor does []= (for keys or values)
I understand that Dart restricts Map literal keys to Strings and that those are already checked ("map entry key must be string literal").
The text was updated successfully, but these errors were encountered: