mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 04:43:37 -05:00
Changed error spans for duplicate default clauses, added tests for it.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
==== tests/cases/compiler/switchStatementsWithMultipleDefaults.ts (4 errors) ====
|
||||
==== tests/cases/compiler/switchStatementsWithMultipleDefaults.ts (8 errors) ====
|
||||
|
||||
var x = 10;
|
||||
|
||||
@@ -24,14 +24,25 @@
|
||||
switch (x * x) {
|
||||
default: // No issues.
|
||||
default: // Error; second 'default' clause.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
break;
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
~~~~~~~~
|
||||
!!! A 'default' clause cannot appear more than once in a 'switch' statement.
|
||||
break;
|
||||
case 10000:
|
||||
x /= x;
|
||||
default:
|
||||
default: // Error, third 'default' clause
|
||||
~~~~~~~~
|
||||
!!! A 'default' clause cannot appear more than once in a 'switch' statement.
|
||||
def\u0061ult: // Error, fourth 'default' clause.
|
||||
~~~~~~~~~~~~~
|
||||
!!! A 'default' clause cannot appear more than once in a 'switch' statement.
|
||||
// Errors on fifth-seventh
|
||||
default: return;
|
||||
~~~~~~~~
|
||||
!!! A 'default' clause cannot appear more than once in a 'switch' statement.
|
||||
default: default:
|
||||
~~~~~~~~
|
||||
!!! A 'default' clause cannot appear more than once in a 'switch' statement.
|
||||
~~~~~~~~
|
||||
!!! A 'default' clause cannot appear more than once in a 'switch' statement.
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,10 @@ switch (x) {
|
||||
break;
|
||||
case 10000:
|
||||
x /= x;
|
||||
default:
|
||||
default: // Error, third 'default' clause
|
||||
def\u0061ult: // Error, fourth 'default' clause.
|
||||
// Errors on fifth-seventh
|
||||
default: return;
|
||||
default: default:
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user