Преглед изворни кода

[eval] fix index on indexOf

Simon Krajewski пре 7 година
родитељ
комит
e1be7461ba
2 измењених фајлова са 3 додато и 1 уклоњено
  1. 1 1
      src/macro/eval/evalStdLib.ml
  2. 2 0
      tests/unit/src/unitstd/Unicode.unit.hx

+ 1 - 1
src/macro/eval/evalStdLib.ml

@@ -1966,7 +1966,7 @@ module StdString = struct
 			else if this.sascii then
 				vint (Rope.search_forward_string (Lazy.force str.sstring) this.srope i)
 			else begin
-				vint ((fst (find_substring this str false i)) lsr 1)
+				vint ((fst (find_substring this str false (i lsl 1))) lsr 1)
 			end
 		with Not_found ->
 			vint (-1)

+ 2 - 0
tests/unit/src/unitstd/Unicode.unit.hx

@@ -24,6 +24,8 @@ var s = "abc";
 s.indexOf("éé")<0;
 s.lastIndexOf("éé")<0;
 
+"012::345€".indexOf("::", 1) == 3;
+
 var s = String.fromCharCode(0x1f602);
 s == "😂";