Skip to content

Commit

Permalink
Ensure duplicate let/const declarations accross files are reported
Browse files Browse the repository at this point in the history
  • Loading branch information
mhegazy committed Oct 14, 2014
1 parent 1dde985 commit 318575c
Show file tree
Hide file tree
Showing 19 changed files with 187 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ module ts {

function getExcludedSymbolFlags(flags: SymbolFlags): SymbolFlags {
var result: SymbolFlags = 0;
if (flags & SymbolFlags.BlockScoped) result |= SymbolFlags.BlockScopedExcludes;
if (flags & SymbolFlags.Variable) result |= SymbolFlags.VariableExcludes;
if (flags & SymbolFlags.Property) result |= SymbolFlags.PropertyExcludes;
if (flags & SymbolFlags.EnumMember) result |= SymbolFlags.EnumMemberExcludes;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
tests/cases/compiler/file2.ts(1,5): error TS2300: Duplicate identifier 'var1'.


==== tests/cases/compiler/file1.ts (0 errors) ====

let var1 = 0;

==== tests/cases/compiler/file2.ts (1 errors) ====
let var1 = 0;
~~~~
!!! error TS2300: Duplicate identifier 'var1'.
13 changes: 13 additions & 0 deletions tests/baselines/reference/letDeclarations-scopes-duplicates2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//// [tests/cases/compiler/letDeclarations-scopes-duplicates2.ts] ////

//// [file1.ts]

let var1 = 0;

//// [file2.ts]
let var1 = 0;

//// [file1.js]
let var1 = 0;
//// [file2.js]
let var1 = 0;
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
tests/cases/compiler/file2.ts(1,7): error TS2300: Duplicate identifier 'var1'.


==== tests/cases/compiler/file1.ts (0 errors) ====

let var1 = 0;

==== tests/cases/compiler/file2.ts (1 errors) ====
const var1 = 0;
~~~~
!!! error TS2300: Duplicate identifier 'var1'.
13 changes: 13 additions & 0 deletions tests/baselines/reference/letDeclarations-scopes-duplicates3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//// [tests/cases/compiler/letDeclarations-scopes-duplicates3.ts] ////

//// [file1.ts]

let var1 = 0;

//// [file2.ts]
const var1 = 0;

//// [file1.js]
let var1 = 0;
//// [file2.js]
const var1 = 0;
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
tests/cases/compiler/file2.ts(1,5): error TS2300: Duplicate identifier 'var1'.


==== tests/cases/compiler/file1.ts (0 errors) ====

const var1 = 0;

==== tests/cases/compiler/file2.ts (1 errors) ====
let var1 = 0;
~~~~
!!! error TS2300: Duplicate identifier 'var1'.
13 changes: 13 additions & 0 deletions tests/baselines/reference/letDeclarations-scopes-duplicates4.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//// [tests/cases/compiler/letDeclarations-scopes-duplicates4.ts] ////

//// [file1.ts]

const var1 = 0;

//// [file2.ts]
let var1 = 0;

//// [file1.js]
const var1 = 0;
//// [file2.js]
let var1 = 0;
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
tests/cases/compiler/file2.ts(1,7): error TS2300: Duplicate identifier 'var1'.


==== tests/cases/compiler/file1.ts (0 errors) ====

const var1 = 0;

==== tests/cases/compiler/file2.ts (1 errors) ====
const var1 = 0;
~~~~
!!! error TS2300: Duplicate identifier 'var1'.
13 changes: 13 additions & 0 deletions tests/baselines/reference/letDeclarations-scopes-duplicates5.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//// [tests/cases/compiler/letDeclarations-scopes-duplicates5.ts] ////

//// [file1.ts]

const var1 = 0;

//// [file2.ts]
const var1 = 0;

//// [file1.js]
const var1 = 0;
//// [file2.js]
const var1 = 0;
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
tests/cases/compiler/file2.ts(1,5): error TS2300: Duplicate identifier 'var1'.


==== tests/cases/compiler/file1.ts (0 errors) ====

var var1 = 0;

==== tests/cases/compiler/file2.ts (1 errors) ====
let var1 = 0;
~~~~
!!! error TS2300: Duplicate identifier 'var1'.
13 changes: 13 additions & 0 deletions tests/baselines/reference/letDeclarations-scopes-duplicates6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//// [tests/cases/compiler/letDeclarations-scopes-duplicates6.ts] ////

//// [file1.ts]

var var1 = 0;

//// [file2.ts]
let var1 = 0;

//// [file1.js]
var var1 = 0;
//// [file2.js]
let var1 = 0;
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
tests/cases/compiler/file2.ts(1,5): error TS2300: Duplicate identifier 'var1'.


==== tests/cases/compiler/file1.ts (0 errors) ====

let var1 = 0;

==== tests/cases/compiler/file2.ts (1 errors) ====
var var1 = 0;
~~~~
!!! error TS2300: Duplicate identifier 'var1'.
13 changes: 13 additions & 0 deletions tests/baselines/reference/letDeclarations-scopes-duplicates7.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//// [tests/cases/compiler/letDeclarations-scopes-duplicates7.ts] ////

//// [file1.ts]

let var1 = 0;

//// [file2.ts]
var var1 = 0;

//// [file1.js]
let var1 = 0;
//// [file2.js]
var var1 = 0;
7 changes: 7 additions & 0 deletions tests/cases/compiler/letDeclarations-scopes-duplicates2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// @target: ES6

// @Filename: file1.ts
let var1 = 0;

// @Filename: file2.ts
let var1 = 0;
7 changes: 7 additions & 0 deletions tests/cases/compiler/letDeclarations-scopes-duplicates3.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// @target: ES6

// @Filename: file1.ts
let var1 = 0;

// @Filename: file2.ts
const var1 = 0;
7 changes: 7 additions & 0 deletions tests/cases/compiler/letDeclarations-scopes-duplicates4.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// @target: ES6

// @Filename: file1.ts
const var1 = 0;

// @Filename: file2.ts
let var1 = 0;
7 changes: 7 additions & 0 deletions tests/cases/compiler/letDeclarations-scopes-duplicates5.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// @target: ES6

// @Filename: file1.ts
const var1 = 0;

// @Filename: file2.ts
const var1 = 0;
7 changes: 7 additions & 0 deletions tests/cases/compiler/letDeclarations-scopes-duplicates6.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// @target: ES6

// @Filename: file1.ts
var var1 = 0;

// @Filename: file2.ts
let var1 = 0;
7 changes: 7 additions & 0 deletions tests/cases/compiler/letDeclarations-scopes-duplicates7.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// @target: ES6

// @Filename: file1.ts
let var1 = 0;

// @Filename: file2.ts
var var1 = 0;

0 comments on commit 318575c

Please sign in to comment.