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

Make initializing formals introduce a name to the initialization list. #1839

Closed
lrhn opened this issue Feb 24, 2012 · 3 comments
Closed

Make initializing formals introduce a name to the initialization list. #1839

lrhn opened this issue Feb 24, 2012 · 3 comments
Assignees
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). P3 A lower priority bug or feature request type-enhancement A request for a change that isn't a bug

Comments

@lrhn
Copy link
Member

lrhn commented Feb 24, 2012

Currently
 class C {
   int x;
   int y;
   C(this.x) : y = x + 1;
 }
will not work, because the last "x" refers to neither the field "x" (since this" is not in scope of the initializers) or the argument "x" (since an initializing formal doesn't introduce a name).

I sometimes want to both initialize a field and use the value to initialize another (arguably redundant) field or to create a super-parameter.
In those cases, it would be nice if the code above would allow the last "x" to refer to the parameter (which would be a parameter reference, and not a this-reference). The variable's scope should not be extended to the constructor body, just to the initializer list.

Instead I have to make the parameter non-initializing and add a redundant "this.x=x," to the initializer list.

@gbracha
Copy link
Contributor

gbracha commented Feb 28, 2012

Set owner to @gbracha.
Added Accepted label.

@gbracha
Copy link
Contributor

gbracha commented May 24, 2012

The this.x syntax is a sugar intended for simple cases. You can write a classic constructor in that case.


Added WontFix label.

@lrhn lrhn added Type-Enhancement P3 A lower priority bug or feature request area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). labels May 24, 2012
@kevmoo kevmoo added closed-not-planned Closed as we don't intend to take action on the reported issue type-enhancement A request for a change that isn't a bug and removed resolution-wont_fix labels Mar 1, 2016
copybara-service bot pushed a commit that referenced this issue Jan 4, 2023
…_launcher, clock, crypto, csslib, dartdoc, html, http, http_multi_server, intl, package_config, pool, protobuf, pub_semver, source_map_stack_trace, source_maps, source_span, sse, stack_trace, stream_channel, term_glyph, test, test_descriptor, test_process, test_reflective_loader, watcher, web_socket_channel, yaml

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

bazel_worker (https://github.com/dart-lang/bazel_worker/compare/9f21e1d..b35c25e):
  b35c25e  2023-01-03  dependabot[bot]  Bump actions/checkout from 3.1.0 to 3.2.0 (#66)

benchmark_harness (https://github.com/dart-lang/benchmark_harness/compare/ee7a253..76881df):
  76881df  2023-01-03  dependabot[bot]  Bump actions/checkout from 3.1.0 to 3.2.0 (#80)

boolean_selector (https://github.com/dart-lang/boolean_selector/compare/5082b3d..ba7d86b):
  ba7d86b  2023-01-03  dependabot[bot]  Bump actions/checkout from 3.1.0 to 3.2.0 (#41)

browser_launcher (https://github.com/dart-lang/browser_launcher/compare/2712dda..f2f01e4):
  f2f01e4  2023-01-03  dependabot[bot]  Bump actions/checkout from 3.1.0 to 3.2.0 (#37)

clock (https://github.com/dart-lang/clock/compare/8a8231f..6b8b7bf):
  6b8b7bf  2023-01-03  dependabot[bot]  Bump actions/checkout from 3.1.0 to 3.2.0 (#41)

crypto (https://github.com/dart-lang/crypto/compare/bf0c33b..f854f2f):
  f854f2f  2023-01-03  dependabot[bot]  Bump actions/checkout from 3.1.0 to 3.2.0 (#138)

csslib (https://github.com/dart-lang/csslib/compare/34203c0..d776535):
  d776535  2023-01-03  dependabot[bot]  Bump actions/checkout from 3.1.0 to 3.2.0 (#156)

dartdoc (https://github.com/dart-lang/dartdoc/compare/ce25524..9ed196f):
  9ed196f1  2023-01-03  Sam Rawlins  Move many test files to test_reflective_loader (#3284)

html (https://github.com/dart-lang/html/compare/28fb8b9..3dd00b0):
  3dd00b0  2023-01-03  dependabot[bot]  Bump actions/checkout from 3.1.0 to 3.2.0 (#193)

http (https://github.com/dart-lang/http/compare/38d5dd9..d434d42):
  d434d42  2023-01-03  Brian Quinlan  Make it possible to use a custom CronetEngine with runWithClient (#843)

http_multi_server (https://github.com/dart-lang/http_multi_server/compare/e31c698..beb40a7):
  beb40a7  2023-01-03  dependabot[bot]  Bump actions/checkout from 3.1.0 to 3.2.0 (#47)

intl (https://github.com/dart-lang/intl/compare/59e7bff..c61fdd1):
  c61fdd1  2023-01-04  dependabot[bot]  Bump actions/checkout from 3.1.0 to 3.2.0 (#528)
  2a5e3a2  2023-01-04  Copybara-Service  Merge pull request #527 from mateendev3:patch-2
  07a5847  2022-12-31  Mateen Mehmood  Update date_format.dart

package_config (https://github.com/dart-lang/package_config/compare/abb4aec..2e1a8ec):
  2e1a8ec  2023-01-03  dependabot[bot]  Bump actions/checkout from 3.1.0 to 3.2.0 (#128)

pool (https://github.com/dart-lang/pool/compare/1ea5b03..713e631):
  713e631  2023-01-03  dependabot[bot]  Bump actions/checkout from 3.1.0 to 3.2.0 (#59)

protobuf (https://github.com/dart-lang/protobuf/compare/1d1c92a..dd04535):
  dd04535  2023-01-04  Mahdi K. Fard  Fix avoid_renaming_method_parameters linter warning. (#783)
  4b1fc34  2023-01-04  Mahdi K. Fard  Removes a non-existing lint rule. (#784)

pub_semver (https://github.com/dart-lang/pub_semver/compare/1723111..3946e33):
  3946e33  2023-01-03  dependabot[bot]  Bump actions/checkout from 3.1.0 to 3.2.0 (#76)

source_map_stack_trace (https://github.com/dart-lang/source_map_stack_trace/compare/8d8078f..e5f9564):
  e5f9564  2023-01-03  dependabot[bot]  Bump actions/checkout from 3.1.0 to 3.2.0 (#31)

source_maps (https://github.com/dart-lang/source_maps/compare/b031e2c..d995912):
  d995912  2023-01-03  dependabot[bot]  Bump actions/checkout from 3.1.0 to 3.2.0 (#70)

source_span (https://github.com/dart-lang/source_span/compare/d1d47e5..72d5c55):
  72d5c55  2023-01-03  dependabot[bot]  Bump actions/checkout from 3.1.0 to 3.2.0 (#89)

sse (https://github.com/dart-lang/sse/compare/2de27fe..3c37edb):
  3c37edb  2023-01-03  dependabot[bot]  Bump actions/checkout from 3.1.0 to 3.2.0 (#73)

stack_trace (https://github.com/dart-lang/stack_trace/compare/cf3562e..c08ee90):
  c08ee90  2023-01-03  dependabot[bot]  Bump actions/checkout from 3.1.0 to 3.2.0 (#125)

stream_channel (https://github.com/dart-lang/stream_channel/compare/9143047..0a7800a):
  0a7800a  2023-01-03  dependabot[bot]  Bump actions/checkout from 3.1.0 to 3.2.0 (#83)

term_glyph (https://github.com/dart-lang/term_glyph/compare/822cd5b..2bf4594):
  2bf4594  2023-01-03  dependabot[bot]  Bump actions/checkout from 3.1.0 to 3.2.0 (#30)

test (https://github.com/dart-lang/test/compare/8235a25..3415089):
  34150897  2023-01-03  dependabot[bot]  Bump ossf/scorecard-action from 2.0.6 to 2.1.2 (#1838)
  5f01dd97  2023-01-03  dependabot[bot]  Bump github/codeql-action from 1.0.26 to 2.1.37 (#1839)

test_descriptor (https://github.com/dart-lang/test_descriptor/compare/13dbc20..b73c691):
  b73c691  2023-01-03  dependabot[bot]  Bump actions/checkout from 3.1.0 to 3.2.0 (#46)

test_process (https://github.com/dart-lang/test_process/compare/1774aa7..62ea2ba):
  62ea2ba  2023-01-03  dependabot[bot]  Bump actions/checkout from 3.1.0 to 3.2.0 (#37)

test_reflective_loader (https://github.com/dart-lang/test_reflective_loader/compare/52b6753..cf58259):
  cf58259  2023-01-03  dependabot[bot]  Bump actions/checkout from 3.1.0 to 3.2.0 (#43)

watcher (https://github.com/dart-lang/watcher/compare/3259107..2e0db71):
  2e0db71  2023-01-03  dependabot[bot]  Bump actions/checkout from 3.1.0 to 3.2.0 (#132)

web_socket_channel (https://github.com/dart-lang/web_socket_channel/compare/a90e740..ebd0fe9):
  ebd0fe9  2023-01-03  dependabot[bot]  Bump actions/checkout from 3.1.0 to 3.2.0 (#244)

yaml (https://github.com/dart-lang/yaml/compare/f699275..02be51e):
  02be51e  2023-01-03  dependabot[bot]  Bump actions/checkout from 3.1.0 to 3.2.0 (#133)

Change-Id: I56af76e89a75b0712b290ea154f606781183bec7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278368
Auto-Submit: Devon Carew <devoncarew@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
@lrhn lrhn removed the closed-not-planned Closed as we don't intend to take action on the reported issue label Jul 4, 2023
@lrhn
Copy link
Member Author

lrhn commented Jul 4, 2023

It was added eventually.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). P3 A lower priority bug or feature request type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

3 participants