aboutsummaryrefslogtreecommitdiff
path: root/test/cases/compile_errors/invalid_unicode_escape.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2024-07-31 11:51:19 -0700
committerAndrew Kelley <andrew@ziglang.org>2024-07-31 16:57:42 -0700
commit377e8579f9539c56fc5988c9a452a01438af89f3 (patch)
tree542f9ac9cf63e7b083e9a606e6c8a77eade2e6ce /test/cases/compile_errors/invalid_unicode_escape.zig
parentc08effc20abe2595ba5c83e25b78c274ec9c58ec (diff)
downloadzig-377e8579f9539c56fc5988c9a452a01438af89f3.tar.gz
zig-377e8579f9539c56fc5988c9a452a01438af89f3.zip
std.zig.tokenizer: simplify
I pointed a fuzzer at the tokenizer and it crashed immediately. Upon inspection, I was dissatisfied with the implementation. This commit removes several mechanisms: * Removes the "invalid byte" compile error note. * Dramatically simplifies tokenizer recovery by making recovery always occur at newlines, and never otherwise. * Removes UTF-8 validation. * Moves some character validation logic to `std.zig.parseCharLiteral`. Removing UTF-8 validation is a regression of #663, however, the existing implementation was already buggy. When adding this functionality back, it must be fuzz-tested while checking the property that it matches an independent Unicode validation implementation on the same file. While we're at it, fuzzing should check the other properties of that proposal, such as no ASCII control characters existing inside the source code. Other changes included in this commit: * Deprecate `std.unicode.utf8Decode` and its WTF-8 counterpart. This function has an awkward API that is too easy to misuse. * Make `utf8Decode2` and friends use arrays as parameters, eliminating a runtime assertion in favor of using the type system. After this commit, the crash found by fuzzing, which was "\x07\xd5\x80\xc3=o\xda|a\xfc{\x9a\xec\x91\xdf\x0f\\\x1a^\xbe;\x8c\xbf\xee\xea" no longer causes a crash. However, I did not feel the need to add this test case because the simplified logic eradicates most crashes of this nature.
Diffstat (limited to 'test/cases/compile_errors/invalid_unicode_escape.zig')
-rw-r--r--test/cases/compile_errors/invalid_unicode_escape.zig3
1 files changed, 1 insertions, 2 deletions
diff --git a/test/cases/compile_errors/invalid_unicode_escape.zig b/test/cases/compile_errors/invalid_unicode_escape.zig
index 1555f2be80..956b4a37a2 100644
--- a/test/cases/compile_errors/invalid_unicode_escape.zig
+++ b/test/cases/compile_errors/invalid_unicode_escape.zig
@@ -6,6 +6,5 @@ export fn entry() void {
// backend=stage2
// target=native
//
-// :2:15: error: expected expression, found 'invalid bytes'
-// :2:21: note: invalid byte: 'z'
+// :2:21: error: expected hex digit or '}', found 'z'