diff options
Diffstat (limited to 'src/string_mutable.zig')
-rw-r--r-- | src/string_mutable.zig | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/string_mutable.zig b/src/string_mutable.zig index 2b8d80429..e6738ae7f 100644 --- a/src/string_mutable.zig +++ b/src/string_mutable.zig @@ -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); } |