question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Switch statement cases not showing syntax error if a case is already present

See original GitHub issue

Steps to Reproduce

void test(){
  int a = 10;
  switch(a) {
    case 0: // looks OK
      break;
    case 0: // not OK, it should show syntax error
      break;
  }
}

Version info

Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel dev, v1.3.13, on Mac OS X 10.14 18A389, locale en-GB) [✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3) [✓] iOS toolchain - develop for iOS devices (Xcode 10.1) [✓] Android Studio (version 3.3) [✓] Connected device (1 available)

• No issues found!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
pqcommented, Mar 24, 2019

Perfect. If you add a line to the rules: list,

   - no_duplicate_case_values

you should be good to go!

1reaction
dark-chocolatecommented, Mar 24, 2019

Did the trick. Thank you 😃

Edit: I wonder why it wasn’t included in the file by default, and if I need to find more rules like this, where can I find them?

Read more comments on GitHub >

github_iconTop Results From Across the Web

bash switch-case statement gives syntax error - Stack Overflow
when using case statements, you need to end each clause with ;; : case $option in a ) # do something ;; b...
Read more >
Spurious syntax error for certain switch-case-if scenario #7404
Type '(a: any) => { if(c: any): any; }' is not assignable to type 'number'. A function whose declared type is neither 'void'...
Read more >
switch - JavaScript - MDN Web Docs - Mozilla
The switch statement evaluates an expression, matching the expression's value against a series of case clauses, and executes statements after the first case...
Read more >
switch - Manual - PHP
The switch statement is similar to a series of IF statements on the same expression. In many occasions, you may want to compare...
Read more >
switch statement - cppreference.com
If condition evaluates to a value that doesn't match any of the case: labels, and the default: label is not present, then none...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found