2
0
Эх сурвалжийг харах

unspecify negative startIndex in String.indexOf and String.lastIndexOf (#8365)

Aleksandr Kuzmenko 5 жил өмнө
parent
commit
622649d151

+ 2 - 1
extra/CHANGES.txt

@@ -5,10 +5,11 @@
 	js : use abstract type name for generating its implementation class (#9006)
 	js : use abstract type name for generating its implementation class (#9006)
 	js : improve haxe.ds.StringMap implementation (#8909)
 	js : improve haxe.ds.StringMap implementation (#8909)
 	js : improve interface checking and make it more minifier-friendly (#9178)
 	js : improve interface checking and make it more minifier-friendly (#9178)
-    lua : improve error handling behavior when throwing objects/instances.
+	lua : improve error handling behavior when throwing objects/instances.
 
 
 	Standard Library:
 	Standard Library:
 
 
+	all : negative `startIndex` argument of `String.indexOf` and `String.lastIndexOf` is unspecified (#8365)
 	all : added Array.contains (#9179)
 	all : added Array.contains (#9179)
 
 
 2019-12-17: 4.0.5
 2019-12-17: 4.0.5

+ 5 - 2
std/String.hx

@@ -78,11 +78,12 @@ extern class String {
 		String.
 		String.
 
 
 		If `startIndex` is given, the search is performed within the substring
 		If `startIndex` is given, the search is performed within the substring
-		of `this` String starting from `startIndex` (if `startIndex` is posivite
-		or 0) or `max(this.length + startIndex, 0)` (if `startIndex` is negative).
+		of `this` String starting from `startIndex`.
 
 
 		If `startIndex` exceeds `this.length`, -1 is returned.
 		If `startIndex` exceeds `this.length`, -1 is returned.
 
 
+		If `startIndex` is negative, the result is unspecifed.
+
 		Otherwise the search is performed within `this` String. In either case,
 		Otherwise the search is performed within `this` String. In either case,
 		the returned position is relative to the beginning of `this` String.
 		the returned position is relative to the beginning of `this` String.
 
 
@@ -99,6 +100,8 @@ extern class String {
 		is performed within `this` String. In either case, the returned position
 		is performed within `this` String. In either case, the returned position
 		is relative to the beginning of `this` String.
 		is relative to the beginning of `this` String.
 
 
+		If `startIndex` is negative, the result is unspecifed.
+
 		If `str` cannot be found, -1 is returned.
 		If `str` cannot be found, -1 is returned.
 	**/
 	**/
 	function lastIndexOf(str:String, ?startIndex:Int):Int;
 	function lastIndexOf(str:String, ?startIndex:Int):Int;