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

Duplicate field initializers: compile error expected but doesn't occur #921

Closed
DartBot opened this issue Dec 20, 2011 · 5 comments
Closed
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.

Comments

@DartBot
Copy link

DartBot commented Dec 20, 2011

This issue was originally filed by [email protected]


Ran this on our latest VM build, no compile error.

Spec ch. 7.5.1 says: Let k be a generative constructor. [...] It is a compile-time error if more than one initializer corresponding to a given instance variable appears in k's initializer list.

However, in the following example:
class C {
  C() : x = 1, y = 2, this.x = 3;
  var x;
  var y;
}
main() {
  try {
    C c = new C();
    print(c.x);
  } catch(var x) {}
}

no compile-time error occurs and both initializers are executed, which is evident after print().

other constructor variations:
C() : x = 1, y = 2, x = 3;
C(x, y) : this.x = x, this.x = y;
demonstrate the same behaviour

@DartBot
Copy link
Author

DartBot commented Dec 20, 2011

This comment was originally written by [email protected]


Same for the next assertion:
It is a compile-time error if k's initializer list contains an initializer for a variable that is initialized by means of an initializing formal of k.

No compile-time error for constructors like
C(this.x, foo) : this.x = foo;
or C(this.x, foo) : x = foo;

@ghost
Copy link

ghost commented Dec 20, 2011

Set owner to @mhausner.
Added Area-VM, Triaged labels.

@iposva-google
Copy link
Contributor

Added Accepted label.

@DartBot
Copy link
Author

DartBot commented Aug 1, 2012

This comment was originally written by @mhausner


I have a review out to fix this.


Added Started label.

@DartBot
Copy link
Author

DartBot commented Aug 1, 2012

This comment was originally written by @mhausner


Fixed at r10146


Added Fixed label.

@DartBot DartBot added Type-Defect area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. labels Aug 1, 2012
copybara-service bot pushed a commit that referenced this issue May 12, 2023
…er, mime, mockito, native, path, test, watcher, webdev, yaml_edit

Revisions updated by `dart tools/rev_sdk_deps.dart`.

browser_launcher (https://github.com/dart-lang/browser_launcher/compare/ed11524..551e101):
  551e101  2023-05-11  dependabot[bot]  Bump actions/checkout from 3.5.0 to 3.5.2 (#43)
  29a57a0  2023-05-11  Elliott Brooks  Disable test (#44)

file (https://github.com/google/file.dart/compare/b905180..e90e5ed):
  e90e5ed  2023-05-11  Bernardo Ferrari  Migrate to Dart 3 (#210)

http (https://github.com/dart-lang/http/compare/db84d12..981b63b):
  981b63b  2023-05-11  Brian Quinlan  Support the NSURLSession WebSocket API (#921)

leak_tracker (https://github.com/dart-lang/leak_tracker/compare/46a1fa0..bc7f604):
  bc7f604  2023-05-11  Polina Cherkasova  Fix typo. (#61)

logging (https://github.com/dart-lang/logging/compare/4779d7e..b75cba7):
  b75cba7  2023-05-10  Devon Carew  blast_repo fixes (#137)

matcher (https://github.com/dart-lang/matcher/compare/5890f2b..4dfd9ad):
  4dfd9ad  2023-05-10  dependabot[bot]  Bump actions/checkout from 3.5.0 to 3.5.2 (#218)

mime (https://github.com/dart-lang/mime/compare/57fbf6e..eb9d54b):
  eb9d54b  2023-05-10  Devon Carew  blast_repo fixes (#95)

mockito (https://github.com/dart-lang/mockito/compare/56173fa..51a7728):
  51a7728  2023-05-12  Copybara-Service  Merge pull request #597 from danielgomezrico:feat/returnInOrder
  7a93b61  2023-01-15  Daniel Gomez Rico  Add `returnInOrder` to `Mock`
  34da8da  2023-05-02  Nate Bosch  Import `packge:matcher` directly instead of `test_api`

native (https://github.com/dart-lang/native/compare/908e61f..64aa5b5):
  64aa5b5  2023-05-12  Daco Harkes  [native_assets_cli] Add `outDirName` (#38)
  fdcd0eb  2023-05-09  Devon Carew  contribute a PR labeler (#37)
  d44eae5  2023-05-08  Daco Harkes  Give tests on MacOS more time (#36)
  3b39e07  2023-05-04  Daco Harkes  [c_compiler] Make `logger` required (#35)

path (https://github.com/dart-lang/path/compare/1552cfd..f8d15c2):
  f8d15c2  2023-05-10  Devon Carew  blast_repo fixes (#144)

test (https://github.com/dart-lang/test/compare/0b306dd..931410c):
  931410c8  2023-05-10  Nate Bosch  Fix CI (#2014)

watcher (https://github.com/dart-lang/watcher/compare/9430592..1584936):
  1584936  2023-05-12  Brian Quinlan  Update to 1.1.0 in preparation for release. (#145)

webdev (https://github.com/dart-lang/webdev/compare/469b105..60616ba):
  60616bac  2023-05-10  Elliott Brooks  Syntax error in DCM workflow file(#2108)

yaml_edit (https://github.com/dart-lang/yaml_edit/compare/763ca94..87dcf31):
  87dcf31  2023-05-10  Devon Carew  blast_repo fixes (#53)

Change-Id: I4d25e4ccb60a86a6b5f8a66cfc6ae09f6df0a954
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303005
Reviewed-by: Konstantin Shcheglov <[email protected]>
Auto-Submit: Devon Carew <[email protected]>
Commit-Queue: Konstantin Shcheglov <[email protected]>
copybara-service bot pushed a commit that referenced this issue May 17, 2023
…est_process, tools, webdev

Revisions updated by `dart tools/rev_sdk_deps.dart`.

convert (https://github.com/dart-lang/convert/compare/b652c00..9a387f0):
  9a387f0  2023-05-16  Devon Carew  blast_repo fixes (#83)

dartdoc (https://github.com/dart-lang/dartdoc/compare/2952f6b..702f3ff):
  702f3ff7  2023-05-16  Devon Carew  Update dependabot.yaml (#3415)

http (https://github.com/dart-lang/http/compare/981b63b..fb3b4be):
  fb3b4be  2023-05-16  Brian Quinlan  Revert "Support the NSURLSession WebSocket API (#921)" (#931)

mockito (https://github.com/dart-lang/mockito/compare/51a7728..3fadd2d):
  3fadd2d  2023-05-17  Ilya Yanok  Let users provide dummy values for types
  b14d571  2023-05-15  Googler  Fix for InvalidType

native (https://github.com/dart-lang/native/compare/e01aa63..3d89166):
  3d89166  2023-05-16  Daco Harkes  Add iOS x64 back (#41)

protobuf (https://github.com/dart-lang/protobuf/compare/05058a7..038872b):
  038872b  2023-05-16  Oleh Prypin  Remove implementation of `hashCode` because it makes enum values non-const in Dart 3 (#831)

test (https://github.com/dart-lang/test/compare/8e444df..cdedf40):
  cdedf40c  2023-05-16  Nate Bosch  Prepare to publish (#2016)

test_process (https://github.com/dart-lang/test_process/compare/b6a6cd5..d7a1711):
  d7a1711  2023-05-16  Nate Bosch  Prepare to publish (#44)

tools (https://github.com/dart-lang/tools/compare/62c9604..49da4ca):
  49da4ca  2023-05-12  Polina Cherkasova  Add memory events. (#92)

webdev (https://github.com/dart-lang/webdev/compare/60616ba..2b2ae0e):
  2b2ae0e8  2023-05-15  Elliott Brooks  Try to fix dependabot PRs (#2112)
  d19dafe0  2023-05-15  Elliott Brooks  Manual update deps (#2113)
  c0eb1069  2023-05-15  Elliott Brooks  Disable tests using webdriver (#2115)
  a16bc9f2  2023-05-15  Elliott Brooks  Dart Debug Extension builder fix (#2117)

Change-Id: Icd714c5d54cd3aee999e4ae3cc3a97928dc1a821
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304120
Commit-Queue: Devon Carew <[email protected]>
Auto-Submit: Devon Carew <[email protected]>
Reviewed-by: Konstantin Shcheglov <[email protected]>
This issue was closed.
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.
Projects
None yet
Development

No branches or pull requests

2 participants