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

No warning for unreachable break #3511

Closed
stevemessick opened this issue Jun 11, 2012 · 12 comments
Closed

No warning for unreachable break #3511

stevemessick opened this issue Jun 11, 2012 · 12 comments
Labels
analyzer-warning Issues with the analyzer's Warning codes area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request type-enhancement A request for a change that isn't a bug

Comments

@stevemessick
Copy link
Contributor

while(true) {
...
}

gives no warning if the break statement is missing or unreachable.
////////////////////////////////////////////////////////////////////////////////////
Editor Version: 8124

@bwilkerson
Copy link
Member

While this kind of detection is not required by the spec, I do agree that it would be good to have.


Added this to the Later milestone.
Removed Priority-Medium label.
Added Priority-Low label.

@bwilkerson
Copy link
Member

Removed this from the Later milestone.
Added this to the M3 milestone.

@scheglov
Copy link
Contributor

Removed this from the M3 milestone.
Added this to the Later milestone.
Added AnalysisEngine label.

@DartBot
Copy link

DartBot commented Apr 7, 2013

This comment was originally written by [email protected]


Added Editor-AnalysisEngine label.

@bwilkerson
Copy link
Member

Removed AnalysisEngine, Editor-AnalysisEngine labels.

@bwilkerson
Copy link
Member

Removed Type-Defect label.
Added Type-Enhancement label.

@bwilkerson
Copy link
Member

Added Analyzer-Hint label.

@kasperl
Copy link

kasperl commented Jul 10, 2014

Removed this from the Later milestone.
Added Oldschool-Milestone-Later label.

@kasperl
Copy link

kasperl commented Aug 4, 2014

Removed Oldschool-Milestone-Later label.

@stevemessick stevemessick added Type-Enhancement P3 A lower priority bug or feature request area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. analyzer-warning Issues with the analyzer's Warning codes labels Aug 4, 2014
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed triaged labels Feb 29, 2016
@srawlins
Copy link
Member

"or unreachable" seems strange to pair with this request. Aren't any unreachable statements just dead code (a warning that already exists).

Or, for the following code, would you like two warnings (DEAD_CODE, INFINITE_LOOP):

while (true) {
  // no break statements.
  functionThatCouldThrowOrExit();
  // no break statements.
}

@bwilkerson
Copy link
Member

I think he meant "or if the break is unreachable" as in:

while (true) {
  if (3 < 2) break;
}

Basically, don't be fooled just because there is a break statement if it can never get you out of the loop.

@srawlins
Copy link
Member

This is a duplicate of a newer bug which has more information, #29196.

copybara-service bot pushed a commit that referenced this issue Aug 23, 2022
Changes:
```
> git log --format="%C(auto) %h %s" ac7db6c..ec35d46
 https://dart.googlesource.com/pub.git/+/ec35d462 Fix null-safety warning in dart.dart (#3514)
 https://dart.googlesource.com/pub.git/+/7d30cf0b Allow pubspec key 'funding' (#3529)
 https://dart.googlesource.com/pub.git/+/8ff63a8e Fix remaining usages of path.prettyUri on git uris (#3524)
 https://dart.googlesource.com/pub.git/+/bc32a30e Fix typo "exitcode" (#3511)

```

Diff: https://dart.googlesource.com/pub.git/+/ac7db6c07318efa4a8712110275eaf70f96a6d00~..ec35d46261b610e558dfd0d8525ca3fc8387b4b7/
Change-Id: I535f4fab8940ee8400ef75369d35fb4c1ee3adab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/255990
Reviewed-by: Sarah Zakarias <[email protected]>
Commit-Queue: Sigurd Meldgaard <[email protected]>
copybara-service bot pushed a commit that referenced this issue Aug 23, 2022
This reverts commit 78636aa.

Reason for revert: This breaks the google3 roll. We need to roll frontend_server_client first.

Original change's description:
> Bump pub to ec35d46261b610e558dfd0d8525ca3fc8387b4b7
>
> Changes:
> ```
> > git log --format="%C(auto) %h %s" ac7db6c..ec35d46
>  https://dart.googlesource.com/pub.git/+/ec35d462 Fix null-safety warning in dart.dart (#3514)
>  https://dart.googlesource.com/pub.git/+/7d30cf0b Allow pubspec key 'funding' (#3529)
>  https://dart.googlesource.com/pub.git/+/8ff63a8e Fix remaining usages of path.prettyUri on git uris (#3524)
>  https://dart.googlesource.com/pub.git/+/bc32a30e Fix typo "exitcode" (#3511)
>
> ```
>
> Diff: https://dart.googlesource.com/pub.git/+/ac7db6c07318efa4a8712110275eaf70f96a6d00~..ec35d46261b610e558dfd0d8525ca3fc8387b4b7/
> Change-Id: I535f4fab8940ee8400ef75369d35fb4c1ee3adab
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/255990
> Reviewed-by: Sarah Zakarias <[email protected]>
> Commit-Queue: Sigurd Meldgaard <[email protected]>

[email protected],[email protected]

Change-Id: I9f46b5a63f8c3f0b11a9fe1d348696b1f988e5ca
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256080
Reviewed-by: Sigurd Meldgaard <[email protected]>
Commit-Queue: Sigurd Meldgaard <[email protected]>
Reviewed-by: Jonas Jensen <[email protected]>
copybara-service bot pushed a commit that referenced this issue Aug 25, 2022
This is a reland of commit 78636aa

Original change's description:
> Bump pub to ec35d46261b610e558dfd0d8525ca3fc8387b4b7
>
> Changes:
> ```
> > git log --format="%C(auto) %h %s" ac7db6c..ec35d46
>  https://dart.googlesource.com/pub.git/+/ec35d462 Fix null-safety warning in dart.dart (#3514)
>  https://dart.googlesource.com/pub.git/+/7d30cf0b Allow pubspec key 'funding' (#3529)
>  https://dart.googlesource.com/pub.git/+/8ff63a8e Fix remaining usages of path.prettyUri on git uris (#3524)
>  https://dart.googlesource.com/pub.git/+/bc32a30e Fix typo "exitcode" (#3511)
>
> ```
>
> Diff: https://dart.googlesource.com/pub.git/+/ac7db6c07318efa4a8712110275eaf70f96a6d00~..ec35d46261b610e558dfd0d8525ca3fc8387b4b7/
> Change-Id: I535f4fab8940ee8400ef75369d35fb4c1ee3adab
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/255990
> Reviewed-by: Sarah Zakarias <[email protected]>
> Commit-Queue: Sigurd Meldgaard <[email protected]>

Change-Id: I9c50c7b5ea01fc24cc97b328766ad7d2b9c4b36e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256280
Reviewed-by: Sarah Zakarias <[email protected]>
Commit-Queue: Sigurd Meldgaard <[email protected]>
copybara-service bot pushed a commit that referenced this issue Oct 10, 2023
…t_channel, webdriver

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

dartdoc (https://github.com/dart-lang/dartdoc/compare/524b2b6..5156398):
  5156398c  2023-10-09  Sam Rawlins  Fix sidebar links for pub packages (#3510)
  960bac41  2023-10-09  dependabot[bot]  Bump ossf/scorecard-action from 2.2.0 to 2.3.0 (#3513)
  affc5b44  2023-10-08  Sam Rawlins  Remove some old, unused options (#3511)
  c147aa19  2023-10-06  Sam Rawlins  Fix left sidebar (#3507)

mockito (https://github.com/dart-lang/mockito/compare/49859e4..47a5588):
  47a5588  2023-10-06  Ilya Yanok  Don't try to compare fakes to real objects
  6b9eab9  2023-10-06  Ilya Yanok  Undo the formatting fix
  5ad2ff4  2023-10-05  Ilya Yanok  Change default dummy value for `String` to contain some info
  78c650b  2023-10-05  Ilya Yanok  Use SDK 3.0.0 for stable tests
  adbe265  2023-10-04  Ilya Yanok  Use 3.1.3 as stable SDK

native (https://github.com/dart-lang/native/compare/fd21f5b..22f4481):
  22f4481  2023-10-10  Daco Harkes  [native_assets_builder] Fix pub warning in tests (#155)

protobuf (https://github.com/dart-lang/protobuf/compare/c16bc89..c559fe5):
  c559fe5  2023-10-10  Ömer Sinan Ağacan  Release protoc_plugin-21.1.2 (#881)
  32ed0fe  2023-10-09  Ömer Sinan Ağacan  Fix a bug in comment parsing (#879)

test (https://github.com/dart-lang/test/compare/367aa39..4341470):
  4341470a  2023-10-06  Nate Bosch  Mention integration_test as an ignored directory (#2115)

tools (https://github.com/dart-lang/tools/compare/f318c80..92c5c15):
  92c5c15  2023-10-10  Devon Carew  update to the latest package:dart_flutter_team_lints (#174)

web_socket_channel (https://github.com/dart-lang/web_socket_channel/compare/364013d..f3ac1bf):
  f3ac1bf  2023-10-06  Nate Bosch  Mention `ready` in the docs for `connect` (#287)

webdriver (https://github.com/google/webdriver.dart/compare/21976d6..eaf9c58):
  eaf9c58  2023-10-05  Nate Bosch  Spawn test server in a background isolate (#285)
  ccd01e5  2023-10-05  dependabot[bot]  Bump actions/checkout from 3.6.0 to 4.1.0 (#284)
  f753b3e  2023-10-05  dependabot[bot]  Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#283)
  6bd246f  2023-10-05  Devon Carew  require dart 3.0; add publishing automation (#282)

Change-Id: I83ec9986cc8acc60be76267c2d1127f237e2b5c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329943
Auto-Submit: Devon Carew <[email protected]>
Commit-Queue: Konstantin Shcheglov <[email protected]>
Reviewed-by: Konstantin Shcheglov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-warning Issues with the analyzer's Warning codes area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. 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

7 participants