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

Unhelpful errors for decr operator #12346

Closed
stevemessick opened this issue Aug 9, 2013 · 8 comments
Closed

Unhelpful errors for decr operator #12346

stevemessick opened this issue Aug 9, 2013 · 8 comments
Labels
analyzer-ux area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug

Comments

@stevemessick
Copy link
Contributor

Username: kasperl

I have some code and when I by accident change a '-' in the source code to '--', I get 6 problems and one warning.

int index = hashCode & (buckets.length -- 1);

Expected an identifier
Expected to find ')'
Expected to find ';'
Expected to find ';'
Expected to find ';'
Unexpected token ')'
Undefined name ''

Somehow these warnings do not really help me spot the problem.

////////////////////////////////////////////////////////////////////////////////////
Editor: 0.6.15_r25822 (2013-08-06)
OS: Mac OS X - x86_64 (10.8.4)
JVM: 1.6.0_51

projects: 2

open dart files: 3

auto-run pub: true
localhost resolves to: 127.0.0.1
mem max/total/free: 996 / 148 / 66 MB
thread count: 17
index: 157401 relationships in 35920 keys in 152 sources

SDK installed: true
Dartium installed: true
analysis engine: new

@bwilkerson
Copy link
Member

Removed this from the M6 milestone.
Added this to the M7 milestone.

@jwren
Copy link
Member

jwren commented Sep 19, 2013

M7 -> M8


Removed this from the M7 milestone.
Added this to the M8 milestone.

@bwilkerson
Copy link
Member

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

@bwilkerson
Copy link
Member

Removed Type-Defect label.
Added Type-Enhancement, Analyzer-UX labels.

@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 Priority-Medium area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. analyzer-ux labels Aug 4, 2014
@kevmoo kevmoo added P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug and removed triaged labels Feb 29, 2016
@srawlins
Copy link
Member

Interesting. Here's a better example:

void main() {
  int a = 7;
  int b = a -- 2;
  b = 5 & (a -- 2);
}

(https://dartpad.dartlang.org/e1e1b8a97f5958fa80ed007dd73bec93)

On line 3, there is a simple error: Unexpected token '2'. But on line 4, it doesn't recover as well:

error: Expected to find ';'
error: Expected to find ')'
error: Unexpected token ')'

@bwilkerson bwilkerson removed their assignment Aug 15, 2016
@srawlins
Copy link
Member

And now it's even better: one error on line 3, two on line 4:

$ cat 12346.dart 
void main() {
  int a = 7;
  int b = a -- 2;
  b = 5 & (a -- 2);
}
$ dartanalyzer --version
dartanalyzer version 2.0.0-dev.63.0
$ dartanalyzer --preview-dart-2 12346.dart 
Analyzing 12346.dart...
  error • Unexpected text '2' at 12346.dart:3:16 • unexpected_token
  error • Expected to find ')' at 12346.dart:4:17 • expected_token
  error • Unexpected text ')' at 12346.dart:4:18 • unexpected_token
  hint • The value of the local variable 'b' isn't used at 12346.dart:3:7 • unused_local_variable
3 errors and 1 hint found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-ux area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

6 participants