Changed error spans for duplicate default clauses, added tests for it.

This commit is contained in:
Daniel Rosenwasser
2014-07-21 15:56:52 -07:00
parent 4ac676f718
commit fa04d4d699
3 changed files with 27 additions and 9 deletions

View File

@@ -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.
}
}

View File

@@ -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:
}
}