diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts
index 10fa0e27b97..ebe8aa16f60 100644
--- a/src/compiler/diagnosticInformationMap.generated.ts
+++ b/src/compiler/diagnosticInformationMap.generated.ts
@@ -6,6 +6,7 @@ module ts {
Identifier_expected: { code: 1003, category: DiagnosticCategory.Error, key: "Identifier expected." },
_0_expected: { code: 1005, category: DiagnosticCategory.Error, key: "'{0}' expected." },
Trailing_comma_not_allowed: { code: 1009, category: DiagnosticCategory.Error, key: "Trailing comma not allowed." },
+ A_file_cannot_have_a_reference_to_itself: { code: 1006, category: DiagnosticCategory.Error, key: "A file cannot have a reference to itself." },
Asterisk_Slash_expected: { code: 1010, category: DiagnosticCategory.Error, key: "'*/' expected." },
Unexpected_token: { code: 1012, category: DiagnosticCategory.Error, key: "Unexpected token." },
Catch_clause_parameter_cannot_have_a_type_annotation: { code: 1013, category: DiagnosticCategory.Error, key: "Catch clause parameter cannot have a type annotation." },
@@ -340,7 +341,6 @@ module ts {
Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: { code: 4077, category: DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using name '{1}' from private module '{2}'." },
Parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4078, category: DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using private name '{1}'." },
The_current_host_does_not_support_the_0_option: { code: 5001, category: DiagnosticCategory.Error, key: "The current host does not support the '{0}' option." },
- A_file_cannot_have_a_reference_to_itself: { code: 5006, category: DiagnosticCategory.Error, key: "A file cannot have a reference to itself." },
Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: DiagnosticCategory.Error, key: "Cannot find the common subdirectory path for the input files." },
Cannot_read_file_0_Colon_1: { code: 5012, category: DiagnosticCategory.Error, key: "Cannot read file '{0}': {1}" },
Unsupported_file_encoding: { code: 5013, category: DiagnosticCategory.Error, key: "Unsupported file encoding." },
diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json
index 146b4df0905..7a395b071e5 100644
--- a/src/compiler/diagnosticMessages.json
+++ b/src/compiler/diagnosticMessages.json
@@ -14,6 +14,10 @@
"Trailing comma not allowed.": {
"category": "Error",
"code": 1009
+ },
+ "A file cannot have a reference to itself.": {
+ "category": "Error",
+ "code": 1006
},
"'*/' expected.": {
"category": "Error",
@@ -1355,10 +1359,7 @@
"category": "Error",
"code": 5001
},
- "A file cannot have a reference to itself.": {
- "category": "Error",
- "code": 5006
- },
+
"Cannot find the common subdirectory path for the input files.": {
"category": "Error",
"code": 5009
diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts
index e47311895dd..d393d43b8f4 100644
--- a/src/compiler/parser.ts
+++ b/src/compiler/parser.ts
@@ -3822,24 +3822,26 @@ module ts {
}
else {
var matchResult = fullTripleSlashReferencePathRegEx.exec(comment);
+ var start = range.pos;
+ var end = range.end;
+ var length = end - start;
if (!matchResult) {
- var start = range.pos;
- var length = range.end - start;
errorAtPos(start, length, Diagnostics.Invalid_reference_directive_syntax);
}
else {
+ var referenceFilename = matchResult[3];
var basePath = getDirectoryPath(file.filename);
- var referenceFilename = normalizePath(combinePaths(basePath, matchResult[3]));
- if (file.filename === referenceFilename) {
- errorAtPos(range.pos, range.end - range.pos, Diagnostics.A_file_cannot_have_a_reference_to_itself);
- }
- else {
- referencedFiles.push({
- pos: range.pos,
- end: range.end,
- filename: matchResult[3]
- });
- }
+ var referenceFullPath = normalizePath(combinePaths(basePath, referenceFilename));
+ if (file.filename === referenceFullPath) {
+ errorAtPos(start, length, Diagnostics.A_file_cannot_have_a_reference_to_itself);
+ }
+ else {
+ referencedFiles.push({
+ pos: start,
+ end: end,
+ filename: referenceFilename
+ });
+ }
}
}
}
diff --git a/tests/baselines/reference/selfReferencingFile.errors.txt b/tests/baselines/reference/selfReferencingFile.errors.txt
index 0a72bdf5867..727be1ea0b2 100644
--- a/tests/baselines/reference/selfReferencingFile.errors.txt
+++ b/tests/baselines/reference/selfReferencingFile.errors.txt
@@ -1,10 +1,10 @@
-tests/cases/compiler/selfReferencingFile.ts(1,1): error TS5006: A file cannot have a reference to itself.
+tests/cases/compiler/selfReferencingFile.ts(1,1): error TS1006: A file cannot have a reference to itself.
==== tests/cases/compiler/selfReferencingFile.ts (1 errors) ====
///
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-!!! error TS5006: A file cannot have a reference to itself.
+!!! error TS1006: A file cannot have a reference to itself.
class selfReferencingFile {
diff --git a/tests/baselines/reference/selfReferencingFile3.errors.txt b/tests/baselines/reference/selfReferencingFile3.errors.txt
index 84e3650de9e..e6e8deb5d47 100644
--- a/tests/baselines/reference/selfReferencingFile3.errors.txt
+++ b/tests/baselines/reference/selfReferencingFile3.errors.txt
@@ -1,10 +1,10 @@
-tests/cases/compiler/selfReferencingFile3.ts(1,1): error TS5006: A file cannot have a reference to itself.
+tests/cases/compiler/selfReferencingFile3.ts(1,1): error TS1006: A file cannot have a reference to itself.
==== tests/cases/compiler/selfReferencingFile3.ts (1 errors) ====
///
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-!!! error TS5006: A file cannot have a reference to itself.
+!!! error TS1006: A file cannot have a reference to itself.
class selfReferencingFile3 {