Skip to content
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

Closed
DartBot opened this issue Oct 24, 2011 · 12 comments
Closed

Typechecking of map literals does not always work in checked mode #221

DartBot opened this issue Oct 24, 2011 · 12 comments
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented Oct 24, 2011

This issue was originally filed by olov.l...@gmail.com


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").

@DartBot
Copy link
Author

DartBot commented Oct 25, 2011

This comment was originally written by drfibonacci@google.com


Removed Type-Defect label.
Added Type-Enhancement, Area-Language, Triaged labels.

@DartBot
Copy link
Author

DartBot commented Oct 25, 2011

This comment was originally written by olov.l...@gmail.com


Isn't this a type-checking bug (i.e. a type-defect)?

@DartBot
Copy link
Author

DartBot commented Oct 25, 2011

This comment was originally written by olov.las...@gmail.com


I guess my choice of title was slightly misleading. A better one would be "Type-checker ignores type-annotated Map literals".

@gbracha
Copy link
Contributor

gbracha commented Nov 3, 2011

Looks like a bug to me.


Set owner to @crelier.
Removed Area-Language label.
Added Area-VM, Accepted labels.
Changed the title to: "Typechecking of map literals does not always work in checked mode".

@crelier
Copy link
Contributor

crelier commented Nov 22, 2011

Fixed in the VM in r1764.

@crelier
Copy link
Contributor

crelier commented Nov 22, 2011

Still needs fixing in dartc and frog.


Removed the owner.
Removed Area-VM label.
Added Area-Compiler, Triaged labels.

@sigmundch
Copy link
Member

Fixed for frog in r2187

@DartBot
Copy link
Author

DartBot commented Jan 19, 2012

This comment was originally written by zundel@google.com


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.

@DartBot
Copy link
Author

DartBot commented Jan 26, 2012

This comment was originally written by zundel@google.com


Fixed in dartc r3619. Closing.


Added Fixed label.

@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed type-enhancement labels Mar 1, 2016
nex3 pushed a commit that referenced this issue Aug 31, 2016
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.

R=vsm@google.com

Review URL: https://codereview.chromium.org/1207313002.
nex3 pushed a commit that referenced this issue Aug 31, 2016
@lrhn
Copy link
Member

lrhn commented Sep 1, 2016

Closed incorrect issue, this one is still open.

@lrhn lrhn reopened this Sep 1, 2016
@kevmoo kevmoo added area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. and removed Resolution: fixed labels Sep 1, 2016
@a-siva
Copy link
Contributor

a-siva commented Sep 1, 2016

Why has this been reopened and assigned 'area-vm'? according to the comments this bug was fixed in the VM on Nov 22, 2011.

@lrhn
Copy link
Member

lrhn commented Sep 1, 2016

Whoops. I was reopening bugs accidentally closed by the dev-compiler merge, and one of their commits seemd to close #270 and #221 - I didn't notice that 221 was already closed. My mistake.

copybara-service bot pushed a commit that referenced this issue Jan 2, 2024
…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 <scheglov@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

7 participants