-
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
"var" as explicit non-final marker #252
Comments
This comment was originally written by drfibonacci@google.com Removed Type-Defect label. |
This comment was originally written by robert.eagle...@gmail.com Very much in the spirit of browser-based (i.e. ECMA-based) languages. Also a feature of the Go language, also by Google. |
Added apr30-triage label. |
Removed apr30-triage label. |
Added triage1 label. |
Much as I sympathize, we ultimately decided that it was not worth rocking the boat. |
…ctor, browser_launcher, cli_util, clock, collection, convert, crypto, csslib, dartdoc, ecosystem, ffi, fixnum, glob, html, http, http_multi_server, http_parser, json_rpc_2, lints, logging, markdown, matcher, mime, mockito, native, package_config, path, pool, pub_semver, shelf, source_map_stack_trace, source_maps, source_span, sse, stack_trace, stream_channel, string_scanner, term_glyph, test, test_descriptor, test_process, test_reflective_loader, tools, typed_data, usage, watcher, web_socket_channel, webdev, yaml, yaml_edit Revisions updated by `dart tools/rev_sdk_deps.dart`. args (https://github.com/dart-lang/args/compare/5a4e16f..df9b428): df9b428 2023-10-02 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#256) 892f013 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#257) async (https://github.com/dart-lang/async/compare/75efa6c..def4482): def4482 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#253) a0ca552 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#252) bazel_worker (https://github.com/dart-lang/bazel_worker/compare/159e671..b1b6a66): b1b6a66 2023-10-02 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#82) bb9e48d 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#81) benchmark_harness (https://github.com/dart-lang/benchmark_harness/compare/7d0d28e..59aea95): 59aea95 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#94) e3f6207 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#93) boolean_selector (https://github.com/dart-lang/boolean_selector/compare/f255921..9431e01): 9431e01 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#51) browser_launcher (https://github.com/dart-lang/browser_launcher/compare/1f69393..25bc94a): 25bc94a 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#50) cli_util (https://github.com/dart-lang/cli_util/compare/44118e3..9e48f0d): 9e48f0d 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#90) clock (https://github.com/dart-lang/clock/compare/1e75f08..200a020): 200a020 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#56) 8a2b550 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#57) collection (https://github.com/dart-lang/collection/compare/91afde4..d27bfaf): d27bfaf 2023-10-02 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#314) 5d568ae 2023-10-02 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#313) convert (https://github.com/dart-lang/convert/compare/c058c8f..140b2f0): 140b2f0 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#87) crypto (https://github.com/dart-lang/crypto/compare/1e26879..b38dd62): b38dd62 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#153) csslib (https://github.com/dart-lang/csslib/compare/bd30a1a..f6b68dd): f6b68dd 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#190) 4b1ee3f 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#189) dartdoc (https://github.com/dart-lang/dartdoc/compare/a3cfdc4..59947b1): 59947b14 2023-09-25 Sam Rawlins Do not hide stacktrace of DartdocFailures (#3505) d95af5c7 2023-09-25 dependabot[bot] Bump actions/checkout from 4.0.0 to 4.1.0 (#3506) ecosystem (https://github.com/dart-lang/ecosystem/compare/3da2dd3..dcbd2ee): dcbd2ee 2023-10-02 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#184) 3006120 2023-10-01 dependabot[bot] Bump peter-evans/create-or-update-comment (#183) 69334aa 2023-10-01 dependabot[bot] Bump actions/upload-artifact (#181) 3dd6c69 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#185) 2c5523c 2023-10-01 dependabot[bot] Bump actions/cache from 3.3.1 to 3.3.2 (#182) 5b7d3fd 2023-09-28 Devon Carew update package:dart_flutter_team_lints to use the beta package:lints (#179) 297e63e 2023-09-28 Devon Carew fix an issue validating pre-release git publishing tags (#180) 1154183 2023-09-28 Moritz Check for `DO_NOT_SUBMIT` strings. (#178) bc2dd27 2023-09-28 Moritz Add api tool call for testing (#153) eb8e398 2023-09-27 Moritz Do not fail `publish` on forks (#177) f40a4eb 2023-09-25 Devon Carew improve support for '-dev' and '-wip' package versions (#173) ffi (https://github.com/dart-lang/ffi/compare/d36e05a..ee70dd4): ee70dd4 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#214) fixnum (https://github.com/dart-lang/fixnum/compare/87ed065..ef0a587): ef0a587 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#115) glob (https://github.com/dart-lang/glob/compare/9c1996f..0046533): 0046533 2023-10-02 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#83) f6ebc74 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#84) html (https://github.com/dart-lang/html/compare/a1b193e..49e2c8e): 49e2c8e 2023-10-02 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#228) fb2de8a 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#227) http (https://github.com/dart-lang/http/compare/1251619..88ec75e): 88ec75e 2023-10-01 dependabot[bot] Bump actions/checkout from 3 to 4 (#1025) 08143d1 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#1024) 2c99da1 2023-10-01 dependabot[bot] Bump actions/cache from 3.3.1 to 3.3.2 (#1023) http_multi_server (https://github.com/dart-lang/http_multi_server/compare/9d62ea3..03041aa): 03041aa 2023-10-02 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#59) 5efaa07 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#58) http_parser (https://github.com/dart-lang/http_parser/compare/d2d03e7..c557f57): c557f57 2023-10-02 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#78) a629fd6 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#79) json_rpc_2 (https://github.com/dart-lang/json_rpc_2/compare/50a3786..0521afb): 0521afb 2023-10-02 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#104) 4782145 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#103) lints (https://github.com/dart-lang/lints/compare/b044aca..140c802): 140c802 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#158) 624a09d 2023-09-28 Devon Carew add dangling_library_doc_comments, remove prefer_void_to_null (#157) 296efaf 2023-09-28 Devon Carew remove no_wildcard_variable_uses; improve testing (#156) c266a04 2023-09-26 Devon Carew rev to 3.0.0-beta in preparation for publishing (#153) logging (https://github.com/dart-lang/logging/compare/bcaad0f..642ed21): 642ed21 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#149) 287f4cb 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#148) markdown (https://github.com/dart-lang/markdown/compare/6cfd6f1..ae766d5): ae766d5 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#556) matcher (https://github.com/dart-lang/matcher/compare/80910d6..11daad9): 11daad9 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#229) mime (https://github.com/dart-lang/mime/compare/37ef637..f3b9c49): f3b9c49 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#105) mockito (https://github.com/dart-lang/mockito/compare/097e563..610c3dc): 610c3dc 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#699) 73930cd 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#698) native (https://github.com/dart-lang/native/compare/be4aaf7..22500ea): 22500ea 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#144) 5bfc7ff 2023-10-01 dependabot[bot] Bump coverallsapp/github-action from 2.2.1 to 2.2.3 (#145) 0b7885a 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#143) package_config (https://github.com/dart-lang/package_config/compare/ae7ad83..100533d): 100533d 2023-10-02 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#141) a4b474a 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#142) path (https://github.com/dart-lang/path/compare/96d9183..abcf38c): abcf38c 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#151) pool (https://github.com/dart-lang/pool/compare/a5bee35..4bcc7de): 4bcc7de 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#75) pub_semver (https://github.com/dart-lang/pub_semver/compare/f0be74a..8e5a58f): 8e5a58f 2023-10-02 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#93) 81da7c8 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#92) shelf (https://github.com/dart-lang/shelf/compare/4851978..c15fc6f): c15fc6f 2023-10-01 dependabot[bot] Bump actions/cache from 3.3.1 to 3.3.2 (#386) e47c00e 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#384) b9c898e 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#385) 9b96b9b 2023-09-26 Michael Thomsen Add backend tag in pubspec.yaml (#381) source_map_stack_trace (https://github.com/dart-lang/source_map_stack_trace/compare/196d7bf..73d449c): 73d449c 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#42) 2c4840e 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#43) source_maps (https://github.com/dart-lang/source_maps/compare/eb3d40a..fc6aa16): fc6aa16 2023-10-02 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#83) dfca7d5 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#82) source_span (https://github.com/dart-lang/source_span/compare/48d0f57..92e50bf): 92e50bf 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#102) c212afa 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#103) sse (https://github.com/dart-lang/sse/compare/eeb2588..606387e): 606387e 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#89) stack_trace (https://github.com/dart-lang/stack_trace/compare/bcf2a0b..1c36cd7): 1c36cd7 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#143) stream_channel (https://github.com/dart-lang/stream_channel/compare/0ce7ab6..bf74065): bf74065 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#95) string_scanner (https://github.com/dart-lang/string_scanner/compare/da9142c..616424c): 616424c 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#63) term_glyph (https://github.com/dart-lang/term_glyph/compare/1b28285..19abf84): 19abf84 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#42) test (https://github.com/dart-lang/test/compare/8191a35..367aa39): 367aa397 2023-10-02 Jacob MacDonald release test_core and test (#2112) 672be9d7 2023-10-02 Ben Konyi Update package:vm_service to 12.0.0 (#2110) de324cc7 2023-10-01 dependabot[bot] Bump github/codeql-action from 2.21.5 to 2.21.9 (#2106) 31b94dbb 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#2105) d56c2150 2023-10-01 dependabot[bot] Bump actions/cache from 3.0.11 to 3.3.2 (#2108) b93f1b50 2023-10-01 dependabot[bot] Bump actions/upload-artifact from 3.1.2 to 3.1.3 (#2109) a077b673 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#2107) 566d70a2 2023-09-26 Lau Ching Jun Filter test by line when kernel is compiled with --filesystem-scheme. (#2101) 7ec1bbf5 2023-09-25 Nate Bosch Drop support for legacy iframe communication (#2099) d3f4b368 2023-09-25 Nate Bosch Tighten types in test utils (#2097) 9d997910 2023-09-25 Nate Bosch Add types to Browser implementation url arguments (#2096) test_descriptor (https://github.com/dart-lang/test_descriptor/compare/030193d..55b5eac): 55b5eac 2023-10-02 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#57) c2ba59e 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#56) test_process (https://github.com/dart-lang/test_process/compare/2a6ee23..5efd0bf): 5efd0bf 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#49) test_reflective_loader (https://github.com/dart-lang/test_reflective_loader/compare/45c57d6..8593eb1): 8593eb1 2023-10-02 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#52) 4857e22 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#53) tools (https://github.com/dart-lang/tools/compare/3c248df..f318c80): f318c80 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#177) 0480655 2023-10-01 dependabot[bot] Bump coverallsapp/github-action from 2.2.1 to 2.2.3 (#176) 73583e8 2023-09-29 Devon Carew update package:cli_config to the latest package:dart_flutter_team_lints (#171) b293897 2023-09-28 Devon Carew update to the latest package:dart_flutter_team_lints (#173) 242fdb5 2023-09-28 Devon Carew update to the latest package:dart_flutter_team_lints (#172) a51f779 2023-09-28 Elias Yishak Use constant for no op client id (#168) e83caee 2023-09-27 Moritz Allow `publish` to write comments on forks (#169) typed_data (https://github.com/dart-lang/typed_data/compare/80e8943..d1c15ed): d1c15ed 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#73) e13af06 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#74) usage (https://github.com/dart-lang/usage/compare/7b12d51..d7d2964): d7d2964 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#198) 920c6e8 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#199) watcher (https://github.com/dart-lang/watcher/compare/1aed03e..c480e2d): c480e2d 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#151) web_socket_channel (https://github.com/dart-lang/web_socket_channel/compare/af945f1..364013d): 364013d 2023-10-02 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#286) 50dada7 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#285) webdev (https://github.com/dart-lang/webdev/compare/3078f48..7c2c2d7): 7c2c2d70 2023-10-01 dependabot[bot] Bump actions/checkout from 3.2.0 to 4.1.0 (#2245) 7739a114 2023-09-26 Elliott Brooks Refactor tests to handle new `ToolConfiguration` (#2243) 4e350cde 2023-09-21 Elliott Brooks Fix issue with the inspector panel in the Dart Debug Extension (#2242) bbddba29 2023-09-21 Elliott Brooks Prepare the Dart Debug Extension for release to version 1.36 (#2241) cc5db13f 2023-09-21 Elliott Brooks Rename plainUri to debugUri and send it to the extension (#2238) 48fc725f 2023-09-20 Elliott Brooks Add a new workspaceName parameter to DWDS on start up (#2237) d2dae560 2023-09-20 Elliott Brooks Refactor: Update the parameters for `DWDS.start` (#2231) yaml (https://github.com/dart-lang/yaml/compare/ae00187..9f0d649): 9f0d649 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#153) 8e70ffb 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#152) yaml_edit (https://github.com/dart-lang/yaml_edit/compare/4a9734d..a7e7fba): a7e7fba 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#58) f33e3d0 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#59) 8a380e8 2023-09-28 Sigurd Meldgaard Change AliasError to AliasException (#57) Change-Id: I22f88e36d2eceb03495dabcf1265e9043364e0bd Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329260 Auto-Submit: Devon Carew <devoncarew@google.com> Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Commit-Queue: Devon Carew <devoncarew@google.com>
This issue was originally filed by mndr...@gmail.com
Original discussed at https://groups.google.com/a/dartlang.org/group/misc/browse_thread/thread/c0975d735bb47eb6
Proposal:
Allow "var" before any type declaration as an explicit statement that the developer intends the variable to be non-final. The presence of "var" before a type has no effect on the program's behavior because it only declares what is already the default. The "var" is only there to document developer intent and for future static analysis tools.
If I've read the spec correctly, I intend section 5 to have the following, modified definition:
finalVarOrType:
final type? |
var type? |
type
;
Motivation:
Some developers prefer to work with single-assignment variables, but manually marking each variable as final is a burden. Making all variables final by default burdens other developers (see earlier discussions[1][2]). Without changes to Dart, "final-ists" could write a static analysis tool to warn about multiple-assignment:
int x = 7;
int y = 1;
x = x + y; // tool warns: multiple assignment to variable "x"
Without this proposal, the tool could use special comments to exempt specific variables from the restriction.
int x = 7; /* {non-final} */
With this proposal, the developer accomplishes the same thing with
var int x = 7;
Since all existing Dart code is still valid under this proposal, I can't see any additional burden for developers coming from Java/JS/C#. Developers wanting to enforce single-assignment carry the burden of their own preference since they have to write the static analysis tool (or compiler option).
Any thoughts or questions? Is such a change acceptable?
The text was updated successfully, but these errors were encountered: