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

Downward inference issue on negation expression with non-nullable enabled #40033

Closed
vsmenon opened this issue Jan 9, 2020 · 2 comments
Closed
Assignees
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. NNBD Issues related to NNBD Release

Comments

@vsmenon
Copy link
Member

vsmenon commented Jan 9, 2020

Similar to #40022, but started seeing this on the ReleaseX64NNBD build at head this morning.

Given, I expect T in main to be inferred as bool:

T JS<T extends Object>(x) => x as T;

main() {
  if (!JS(42)) print('hi');
}

I get:

> PATH=~/dart/sdk/xcodebuild/ReleaseX64NNBD/dart-sdk/bin:$PATH dartanalyzer --enable-experiment=non-nullable cast.dart 
Analyzing cast.dart...
  error • A negation operand must have a static type of 'bool'. • cast.dart:4:8 • non_bool_negation_expression
1 error found.

I get the error above if I use ReleaseX64 as well and the experiment on.

With the experiment off and ReleaseX64, I get:

> PATH=~/dart/sdk/xcodebuild/ReleaseX64/dart-sdk/bin:$PATH dartanalyzer  cast.dart 
Analyzing cast.dart...
No issues found!

FYI - @scheglov

@vsmenon vsmenon added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. NNBD Issues related to NNBD Release labels Jan 9, 2020
@scheglov scheglov self-assigned this Jan 9, 2020
@scheglov
Copy link
Contributor

scheglov commented Jan 9, 2020

I can reproduce it, looking quickly into the code it seems that we don't set the context type before resolving the operand.

@scheglov
Copy link
Contributor

scheglov commented Jan 9, 2020

@scheglov scheglov closed this as completed Jan 9, 2020
dart-bot pushed a commit that referenced this issue Jan 9, 2020
Bug: #40033
Change-Id: I2c9020f54f794fb7f009bec22af7753e73271c3b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130921
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. NNBD Issues related to NNBD Release
Projects
None yet
Development

No branches or pull requests

2 participants