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

Regression: use_build_context_synchronously false positives on certain conditionals #59303

Closed
mernen opened this issue Sep 19, 2023 · 3 comments
Assignees
Labels
analyzer-linter Issues with the analyzer's support for the linter package area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. linter-false-positive linter-set-flutter P2 A bug or feature request we're likely to work on

Comments

@mernen
Copy link

mernen commented Sep 19, 2023

Example:

import 'package:flutter/material.dart';

class TestState extends State {
  final _somethingElse = false;

  void testLeftHandMounted() async {
    await Future.value(0);
    if (!mounted || _somethingElse) return;

    Navigator.pop(context); // bogus use_build_context_synchronously (3.13 only)
  }

  void testRightHandMounted() async {
    await Future.value(0);
    if (_somethingElse || !mounted) return;

    Navigator.pop(context); // bogus use_build_context_synchronously (3.13, beta, master)
  }

  @override
  Widget build(BuildContext context) => const Placeholder();
}

The first test was fixed on unstable builds (still a regression on stable), but the second one remains:

Flutter testLeftHandMounted testRightHandMounted
3.7.12
3.10.6
stable (3.13.4)
beta (3.15.0-15.1.pre)
master

The specific version tested for master was Flutter engine 10c480310926d7e04a77ba8a04d321f9d225a545.

@pq
Copy link
Member

pq commented Sep 19, 2023

@srawlins

@pq pq added the P2 A bug or feature request we're likely to work on label Sep 19, 2023
@srawlins
Copy link
Member

Thanks for the excellent bug report!

@srawlins srawlins self-assigned this Sep 20, 2023
copybara-service bot referenced this issue Sep 20, 2023
This PR fixes the case demonstrated in the new test, where
a mounted check occurs on the right side of an or-binary
expression.

Fixes https://github.com/dart-lang/linter/issues/4753

Change-Id: I3c4ac8a42f7f87502fb217763506fa5294f6b017
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326864
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
@srawlins
Copy link
Member

Fixed at HEAD.

@devoncarew devoncarew added analyzer-linter Issues with the analyzer's support for the linter package area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. labels Nov 20, 2024
@devoncarew devoncarew transferred this issue from dart-lang/linter Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-linter Issues with the analyzer's support for the linter package area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. linter-false-positive linter-set-flutter P2 A bug or feature request we're likely to work on
Projects
None yet
Development

No branches or pull requests

4 participants