Fix an invalid assert when processing escaped strings.
The assert assumed that the escaped character could not appear at the end of the string.
Fixes #117
PiperOrigin-RevId: 266975471
diff --git a/lib/Parser/Token.cpp b/lib/Parser/Token.cpp
index f944d69..b8bbb23 100644
--- a/lib/Parser/Token.cpp
+++ b/lib/Parser/Token.cpp
@@ -90,7 +90,7 @@
continue;
}
- assert(i + 1 < e && "invalid string should be caught by lexer");
+ assert(i + 1 <= e && "invalid string should be caught by lexer");
auto c1 = bytes[i++];
switch (c1) {
case '"':
diff --git a/test/IR/parser.mlir b/test/IR/parser.mlir
index 5528a0e..8dc8573 100644
--- a/test/IR/parser.mlir
+++ b/test/IR/parser.mlir
@@ -1079,3 +1079,6 @@
// CHECK-LABEL: func @ptr_to_function() -> !unreg.ptr<() -> ()>
func @ptr_to_function() -> !unreg.ptr<() -> ()>
+
+// CHECK-LABEL: func @escaped_string_char(i1 {foo.value = "\0A"})
+func @escaped_string_char(i1 {foo.value = "\n"})