diff --git a/common/src/main/java/me/topchetoeu/j2s/common/parsing/Source.java b/common/src/main/java/me/topchetoeu/j2s/common/parsing/Source.java index 531778e..abd3c92 100644 --- a/common/src/main/java/me/topchetoeu/j2s/common/parsing/Source.java +++ b/common/src/main/java/me/topchetoeu/j2s/common/parsing/Source.java @@ -12,6 +12,8 @@ public class Source { private int[] lineStarts; public Location loc(int offset) { + if (offset < 0) offset = 0; + if (offset > src.length()) offset = src.length(); return new SourceLocation(filename, lineStarts, offset); } public boolean is(int i, char c) {