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

co19/LanguageFeatures/Patterns/null_check_A02_t01 #1837

Closed
scheglov opened this issue Feb 7, 2023 · 0 comments
Closed

co19/LanguageFeatures/Patterns/null_check_A02_t01 #1837

scheglov opened this issue Feb 7, 2023 · 0 comments
Assignees
Labels
bad-test Report tests in need of updates. When closed, the tests should be considered good

Comments

@scheglov
Copy link

scheglov commented Feb 7, 2023

FAILED: dart2analyzer-none release_arm64 co19/LanguageFeatures/Patterns/null_check_A02_t01
Expected: Pass
Actual: MissingCompileTimeError

--- Command "dart2analyzer" (took 16ms):
DART_CONFIGURATION=ReleaseARM64 sdk/bin/dart --packages=.dart_tool/package_config.json pkg/analyzer_cli/bin/analyzer.dart --use-analysis-driver-memory-byte-store --dart-sdk=/Users/scheglov/Source/Dart/sdk.git/sdk/sdk -Dtest_runner.configuration=custom-configuration-1 --enable-experiment=patterns --ignore-unrecognized-flags --packages=/Users/scheglov/Source/Dart/sdk.git/sdk/.dart_tool/package_config.json --format=json /Users/scheglov/Source/Dart/sdk.git/sdk/tests/co19/src/LanguageFeatures/Patterns/null_check_A02_t01.dart

static error failures:
- Unexpected error at line 25, column 16, length 1: STATIC_WARNING.UNNECESSARY_NULL_CHECK_PATTERN

- Unexpected error at line 39, column 20, length 1: STATIC_WARNING.UNNECESSARY_NULL_CHECK_PATTERN

- Unexpected error at line 51, column 11, length 1: STATIC_WARNING.UNNECESSARY_NULL_CHECK_PATTERN

--- Re-run this test:
python3 tools/test.py -m release -c dart2analyzer -a arm64 co19/LanguageFeatures/Patterns/null_check_A02_t01

Code

String test1(int? x) {
  switch (x) {
    case int? v1! && == 1 || int? v1?:
//                                  ^
// [analyzer] STATIC_WARNING.UNNECESSARY_NULL_CHECK_PATTERN
// [cfe] The null-check pattern will have no effect because the matched type isn't nullable.
      return "match-1";
    case int v2?:
      return "match-2";
    default:
      return "no match";
  }
}

In case int v2?: the matched type is int, by the same reason why it is int for int? v1? in the previous case - we have already executed int? v1!.

@sgrekhov sgrekhov self-assigned this Feb 8, 2023
@sgrekhov sgrekhov added the bad-test Report tests in need of updates. When closed, the tests should be considered good label Feb 8, 2023
copybara-service bot pushed a commit to dart-lang/sdk that referenced this issue Feb 21, 2023
2023-02-17 [email protected] dart-lang/co19#1399. [Records] Allow legacy libraries that don't support records to still be able to see the Record class in "dart:core" (dart-lang/co19#1571)
2023-02-17 [email protected] dart-lang/co19#1860. Fix type_inference_A12_t01.dart. Don't expect warning (dart-lang/co19#1862)
2023-02-17 [email protected] Fixes dart-lang/co19#1860. Fix roll failures (dart-lang/co19#1861)
2023-02-16 [email protected] dart-lang/co19#1401. Calculating the static type of the pattern tests added (dart-lang/co19#1847)
2023-02-16 [email protected] dart-lang/co19#1401. Shared case scope test with labels and default case added (dart-lang/co19#1858)
2023-02-15 [email protected] Fixes dart-lang/co19#1837. Add additional unnecessary null-ckeck warnings (dart-lang/co19#1842)

Change-Id: I3a1f5deafd4f2868574f085495417ed37fe845b9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284080
Reviewed-by: Alexander Thomas <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bad-test Report tests in need of updates. When closed, the tests should be considered good
Projects
None yet
Development

No branches or pull requests

2 participants