Skip to content

Commit

Permalink
fix: Null safety error in CharIterator with Haxe 4.3.4 (#13)
Browse files Browse the repository at this point in the history
Co-authored-by: Sebastian Thomschke <[email protected]>
  • Loading branch information
BoloVEVO and sebthom authored Mar 14, 2024
1 parent a026c8c commit 12a0414
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/hx/strings/CharIterator.hx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ class CharIterator {
var prevBufferNextIdx = -1;


var prevBufferLength(get,never):Int;
inline function get_prevBufferLength():Int
return @:nullSafety(Off) prevBuffer.length;


public var current(get, never):Null<Char>;
inline function get_current()
return index > -1 ? currChar : null;
Expand Down Expand Up @@ -134,7 +139,7 @@ class CharIterator {
line = prevChar.line;
col = prevChar.col;

prevBufferNextIdx = prevBufferPrevIdx + 1 < prevBuffer.length ? prevBufferPrevIdx + 1 : -1;
prevBufferNextIdx = prevBufferPrevIdx + 1 < prevBufferLength ? prevBufferPrevIdx + 1 : -1;
prevBufferPrevIdx--;
return currChar;
}
Expand All @@ -158,7 +163,7 @@ class CharIterator {
line = prevChar.line;
col = prevChar.col;
prevBufferPrevIdx = prevBufferNextIdx - 1;
prevBufferNextIdx = prevBufferNextIdx + 1 < prevBuffer.length ? prevBufferNextIdx + 1 : -1;
prevBufferNextIdx = prevBufferNextIdx + 1 < prevBufferLength ? prevBufferNextIdx + 1 : -1;
return currChar;
}

Expand All @@ -176,7 +181,7 @@ class CharIterator {

if (prevBuffer != null) {
prevBuffer.add(new CharWithPos(currChar, index, col, line));
prevBufferPrevIdx = prevBuffer.length - 2;
prevBufferPrevIdx = prevBufferLength - 2;
prevBufferNextIdx = -1;
}

Expand Down

0 comments on commit 12a0414

Please sign in to comment.