Index: pkg/source_span/lib/src/file.dart |
diff --git a/pkg/source_span/lib/src/file.dart b/pkg/source_span/lib/src/file.dart |
index 5680733d49733b39a48e867606d20865ddba9a82..14aa22627fe4747d8e42f9442d9952cbf9c6f00d 100644 |
--- a/pkg/source_span/lib/src/file.dart |
+++ b/pkg/source_span/lib/src/file.dart |
@@ -207,6 +207,11 @@ class FileSpan extends SourceSpanMixin { |
FileSpan._(this.file, this._start, this._end) { |
if (_end < _start) { |
throw new ArgumentError('End $_end must come after start $_start.'); |
+ } else if (_end > file.length) { |
+ throw new RangeError("End $_end must not be greater than the number " |
+ "of characters in the file, ${file.length}."); |
+ } else if (_start < 0) { |
+ throw new RangeError("Start may not be negative, was $_start."); |
} |
} |