summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--prism/encoding.c2
-rw-r--r--test/prism/format_errors_test.rb7
2 files changed, 8 insertions, 1 deletions
diff --git a/prism/encoding.c b/prism/encoding.c
index bdb9958e97..c8e0941d1d 100644
--- a/prism/encoding.c
+++ b/prism/encoding.c
@@ -2252,7 +2252,7 @@ static const uint8_t pm_utf_8_dfa[] = {
*/
static pm_unicode_codepoint_t
pm_utf_8_codepoint(const uint8_t *b, ptrdiff_t n, size_t *width) {
- assert(n >= 1);
+ assert(n >= 0);
size_t maximum = (size_t) n;
uint32_t codepoint;
diff --git a/test/prism/format_errors_test.rb b/test/prism/format_errors_test.rb
index 34d320a7b6..bc0b26165d 100644
--- a/test/prism/format_errors_test.rb
+++ b/test/prism/format_errors_test.rb
@@ -12,6 +12,13 @@ module Prism
| ^ unexpected '<', ignoring it
| ^ unexpected '>', ignoring it
ERROR
+
+ assert_equal <<~'ERROR', Debug.format_errors('"%W"\u"', false)
+ > 1 | "%W"\u"
+ | ^ expected a newline or semicolon after the statement
+ | ^ invalid token
+ | ^ expected a closing delimiter for the string literal
+ ERROR
end
end
end