mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
* Fixes #2946 * Update string_mutable.zig * Fixes #2948 --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
This commit is contained in:
@@ -109,7 +109,12 @@ pub const MutableString = struct {
|
||||
}
|
||||
|
||||
if (needs_gap) {
|
||||
var mutable = try MutableString.initCopy(allocator, str[0..start_i]);
|
||||
var mutable = try MutableString.initCopy(allocator, if (start_i == 0)
|
||||
// the first letter can be a non-identifier start
|
||||
// https://github.com/oven-sh/bun/issues/2946
|
||||
"_"
|
||||
else
|
||||
str[0..start_i]);
|
||||
needs_gap = false;
|
||||
|
||||
var slice = str[start_i..];
|
||||
@@ -137,6 +142,10 @@ pub const MutableString = struct {
|
||||
has_needed_gap = true;
|
||||
}
|
||||
|
||||
if (comptime bun.Environment.allow_assert) {
|
||||
std.debug.assert(js_lexer.isIdentifier(mutable.list.items));
|
||||
}
|
||||
|
||||
return try mutable.list.toOwnedSlice(allocator);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user