Report duplicate identifier errors on all locations for merged declarations to align with local declarations

This commit is contained in:
Mohamed Hegazy 2014-10-14 15:18:44 -07:00
parent 318575ce75
commit cffc62aa1b
21 changed files with 161 additions and 129 deletions

View File

@ -226,6 +226,9 @@ module ts {
forEach(source.declarations, node => {
error(node.name ? node.name : node, Diagnostics.Duplicate_identifier_0, symbolToString(source));
});
forEach(target.declarations, node => {
error(node.name ? node.name : node, Diagnostics.Duplicate_identifier_0, symbolToString(source));
});
}
}

View File

@ -1,15 +0,0 @@
tests/cases/compiler/functionTypeArgumentArrayAssignment.ts(3,2): error TS2300: Duplicate identifier 'length'.
==== tests/cases/compiler/functionTypeArgumentArrayAssignment.ts (1 errors) ====
interface Array<T> {
foo: T;
length: number;
~~~~~~
!!! error TS2300: Duplicate identifier 'length'.
}
function map<U>() {
var ys: U[] = [];
}

View File

@ -1,15 +1,20 @@
//// [functionTypeArgumentArrayAssignment.ts]
interface Array<T> {
foo: T;
length: number;
}
module test {
interface Array<T> {
foo: T;
length: number;
}
function map<U>() {
var ys: U[] = [];
function map<U>() {
var ys: U[] = [];
}
}
//// [functionTypeArgumentArrayAssignment.js]
function map() {
var ys = [];
}
var test;
(function (test) {
function map() {
var ys = [];
}
})(test || (test = {}));

View File

@ -0,0 +1,27 @@
=== tests/cases/compiler/functionTypeArgumentArrayAssignment.ts ===
module test {
>test : typeof test
interface Array<T> {
>Array : Array<T>
>T : T
foo: T;
>foo : T
>T : T
length: number;
>length : number
}
function map<U>() {
>map : <U>() => void
>U : U
var ys: U[] = [];
>ys : U[]
>U : U
>[] : U[]
}
}

View File

@ -1,43 +1,42 @@
tests/cases/compiler/instanceofOperator.ts(6,7): error TS2300: Duplicate identifier 'Object'.
tests/cases/compiler/instanceofOperator.ts(11,1): error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
tests/cases/compiler/instanceofOperator.ts(14,16): error TS2359: The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.
tests/cases/compiler/instanceofOperator.ts(15,19): error TS2359: The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.
tests/cases/compiler/instanceofOperator.ts(18,1): error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
tests/cases/compiler/instanceofOperator.ts(20,1): error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
tests/cases/compiler/instanceofOperator.ts(12,5): error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
tests/cases/compiler/instanceofOperator.ts(15,20): error TS2359: The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.
tests/cases/compiler/instanceofOperator.ts(16,23): error TS2359: The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.
tests/cases/compiler/instanceofOperator.ts(19,5): error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
tests/cases/compiler/instanceofOperator.ts(21,5): error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
==== tests/cases/compiler/instanceofOperator.ts (6 errors) ====
==== tests/cases/compiler/instanceofOperator.ts (5 errors) ====
// Spec:
// The instanceof operator requires the left operand to be of type Any or an object type, and the right
// operand to be of type Any or a subtype of the Function interface type. The result is always of the
// Boolean primitive type.
class Object { }
~~~~~~
!!! error TS2300: Duplicate identifier 'Object'.
var obj: Object;
module test {
class Object { }
var obj: Object;
4 instanceof null;
~
4 instanceof null;
~
!!! error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
// Error and should be error
obj instanceof 4;
~
// Error and should be error
obj instanceof 4;
~
!!! error TS2359: The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.
Object instanceof obj;
~~~
Object instanceof obj;
~~~
!!! error TS2359: The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.
// Error on left hand side
null instanceof null;
~~~~
// Error on left hand side
null instanceof null;
~~~~
!!! error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
obj instanceof Object;
undefined instanceof undefined;
~~~~~~~~~
obj instanceof Object;
undefined instanceof undefined;
~~~~~~~~~
!!! error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
}

View File

@ -4,21 +4,23 @@
// operand to be of type Any or a subtype of the Function interface type. The result is always of the
// Boolean primitive type.
class Object { }
var obj: Object;
module test {
class Object { }
var obj: Object;
4 instanceof null;
4 instanceof null;
// Error and should be error
obj instanceof 4;
Object instanceof obj;
// Error and should be error
obj instanceof 4;
Object instanceof obj;
// Error on left hand side
null instanceof null;
obj instanceof Object;
undefined instanceof undefined;
// Error on left hand side
null instanceof null;
obj instanceof Object;
undefined instanceof undefined;
}
@ -27,17 +29,20 @@ undefined instanceof undefined;
// The instanceof operator requires the left operand to be of type Any or an object type, and the right
// operand to be of type Any or a subtype of the Function interface type. The result is always of the
// Boolean primitive type.
var Object = (function () {
function Object() {
}
return Object;
})();
var obj;
4 instanceof null;
// Error and should be error
obj instanceof 4;
Object instanceof obj;
// Error on left hand side
null instanceof null;
obj instanceof Object;
undefined instanceof undefined;
var test;
(function (test) {
var Object = (function () {
function Object() {
}
return Object;
})();
var obj;
4 instanceof null;
// Error and should be error
obj instanceof 4;
Object instanceof obj;
// Error on left hand side
null instanceof null;
obj instanceof Object;
undefined instanceof undefined;
})(test || (test = {}));

View File

@ -1,9 +1,12 @@
tests/cases/compiler/file1.ts(2,5): error TS2300: Duplicate identifier 'var1'.
tests/cases/compiler/file2.ts(1,5): error TS2300: Duplicate identifier 'var1'.
==== tests/cases/compiler/file1.ts (0 errors) ====
==== tests/cases/compiler/file1.ts (1 errors) ====
let var1 = 0;
~~~~
!!! error TS2300: Duplicate identifier 'var1'.
==== tests/cases/compiler/file2.ts (1 errors) ====
let var1 = 0;

View File

@ -1,9 +1,12 @@
tests/cases/compiler/file1.ts(2,5): error TS2300: Duplicate identifier 'var1'.
tests/cases/compiler/file2.ts(1,7): error TS2300: Duplicate identifier 'var1'.
==== tests/cases/compiler/file1.ts (0 errors) ====
==== tests/cases/compiler/file1.ts (1 errors) ====
let var1 = 0;
~~~~
!!! error TS2300: Duplicate identifier 'var1'.
==== tests/cases/compiler/file2.ts (1 errors) ====
const var1 = 0;

View File

@ -1,9 +1,12 @@
tests/cases/compiler/file1.ts(2,7): error TS2300: Duplicate identifier 'var1'.
tests/cases/compiler/file2.ts(1,5): error TS2300: Duplicate identifier 'var1'.
==== tests/cases/compiler/file1.ts (0 errors) ====
==== tests/cases/compiler/file1.ts (1 errors) ====
const var1 = 0;
~~~~
!!! error TS2300: Duplicate identifier 'var1'.
==== tests/cases/compiler/file2.ts (1 errors) ====
let var1 = 0;

View File

@ -1,9 +1,12 @@
tests/cases/compiler/file1.ts(2,7): error TS2300: Duplicate identifier 'var1'.
tests/cases/compiler/file2.ts(1,7): error TS2300: Duplicate identifier 'var1'.
==== tests/cases/compiler/file1.ts (0 errors) ====
==== tests/cases/compiler/file1.ts (1 errors) ====
const var1 = 0;
~~~~
!!! error TS2300: Duplicate identifier 'var1'.
==== tests/cases/compiler/file2.ts (1 errors) ====
const var1 = 0;

View File

@ -1,9 +1,12 @@
tests/cases/compiler/file1.ts(2,5): error TS2300: Duplicate identifier 'var1'.
tests/cases/compiler/file2.ts(1,5): error TS2300: Duplicate identifier 'var1'.
==== tests/cases/compiler/file1.ts (0 errors) ====
==== tests/cases/compiler/file1.ts (1 errors) ====
var var1 = 0;
~~~~
!!! error TS2300: Duplicate identifier 'var1'.
==== tests/cases/compiler/file2.ts (1 errors) ====
let var1 = 0;

View File

@ -1,9 +1,12 @@
tests/cases/compiler/file1.ts(2,5): error TS2300: Duplicate identifier 'var1'.
tests/cases/compiler/file2.ts(1,5): error TS2300: Duplicate identifier 'var1'.
==== tests/cases/compiler/file1.ts (0 errors) ====
==== tests/cases/compiler/file1.ts (1 errors) ====
let var1 = 0;
~~~~
!!! error TS2300: Duplicate identifier 'var1'.
==== tests/cases/compiler/file2.ts (1 errors) ====
var var1 = 0;

View File

@ -1,18 +0,0 @@
tests/cases/compiler/letDeclarations3.ts(3,5): error TS2300: Duplicate identifier 'l1'.
tests/cases/compiler/letDeclarations3.ts(3,9): error TS2300: Duplicate identifier 'l1'.
tests/cases/compiler/letDeclarations3.ts(3,13): error TS2300: Duplicate identifier 'l1'.
==== tests/cases/compiler/letDeclarations3.ts (3 errors) ====
// Duplicate variables
let l1, l1, l1;
~~
!!! error TS2300: Duplicate identifier 'l1'.
~~
!!! error TS2300: Duplicate identifier 'l1'.
~~
!!! error TS2300: Duplicate identifier 'l1'.
// unexpected 'let'
let l2, let, l3;

View File

@ -1,23 +0,0 @@
tests/cases/conformance/parser/ecmascript5/parserOptionalTypeMembers1.ts(2,5): error TS2300: Duplicate identifier 'configurable'.
tests/cases/conformance/parser/ecmascript5/parserOptionalTypeMembers1.ts(3,5): error TS2300: Duplicate identifier 'enumerable'.
tests/cases/conformance/parser/ecmascript5/parserOptionalTypeMembers1.ts(4,5): error TS2300: Duplicate identifier 'value'.
tests/cases/conformance/parser/ecmascript5/parserOptionalTypeMembers1.ts(5,5): error TS2300: Duplicate identifier 'writable'.
==== tests/cases/conformance/parser/ecmascript5/parserOptionalTypeMembers1.ts (4 errors) ====
interface PropertyDescriptor {
configurable?: boolean;
~~~~~~~~~~~~
!!! error TS2300: Duplicate identifier 'configurable'.
enumerable?: boolean;
~~~~~~~~~~
!!! error TS2300: Duplicate identifier 'enumerable'.
value?: any;
~~~~~
!!! error TS2300: Duplicate identifier 'value'.
writable?: boolean;
~~~~~~~~
!!! error TS2300: Duplicate identifier 'writable'.
get?(): any;
set?(v: any): void;
}

View File

@ -1,5 +1,5 @@
//// [parserOptionalTypeMembers1.ts]
interface PropertyDescriptor {
interface PropertyDescriptor2 {
configurable?: boolean;
enumerable?: boolean;
value?: any;

View File

@ -0,0 +1,23 @@
=== tests/cases/conformance/parser/ecmascript5/parserOptionalTypeMembers1.ts ===
interface PropertyDescriptor2 {
>PropertyDescriptor2 : PropertyDescriptor2
configurable?: boolean;
>configurable : boolean
enumerable?: boolean;
>enumerable : boolean
value?: any;
>value : any
writable?: boolean;
>writable : boolean
get?(): any;
>get : () => any
set?(v: any): void;
>set : (v: any) => void
>v : any
}

View File

@ -1,3 +1,4 @@
in1.d.ts(1,8): error TS2300: Duplicate identifier 'a'.
in2.d.ts(1,8): error TS2300: Duplicate identifier 'a'.
@ -14,8 +15,10 @@ in2.d.ts(1,8): error TS2300: Duplicate identifier 'a'.
class MyClass{ }
}
}
==== in1.d.ts (0 errors) ====
==== in1.d.ts (1 errors) ====
import a = A;
~
!!! error TS2300: Duplicate identifier 'a'.
==== in2.d.ts (1 errors) ====
import a = A;
~

View File

@ -1,3 +1,4 @@
in1.d.ts(1,8): error TS2300: Duplicate identifier 'a'.
in2.d.ts(1,8): error TS2300: Duplicate identifier 'a'.
@ -14,8 +15,10 @@ in2.d.ts(1,8): error TS2300: Duplicate identifier 'a'.
class MyClass{ }
}
}
==== in1.d.ts (0 errors) ====
==== in1.d.ts (1 errors) ====
import a = A;
~
!!! error TS2300: Duplicate identifier 'a'.
==== in2.d.ts (1 errors) ====
import a = A;
~

View File

@ -1,8 +1,10 @@
interface Array<T> {
foo: T;
length: number;
}
module test {
interface Array<T> {
foo: T;
length: number;
}
function map<U>() {
var ys: U[] = [];
function map<U>() {
var ys: U[] = [];
}
}

View File

@ -1,4 +1,4 @@
interface PropertyDescriptor {
interface PropertyDescriptor2 {
configurable?: boolean;
enumerable?: boolean;
value?: any;