diff options
author | 2021-12-15 15:15:54 -0800 | |
---|---|---|
committer | 2021-12-15 17:08:04 -0800 | |
commit | e10fe8aaad81e7bd958244adb8584107d7aef18e (patch) | |
tree | d92fad573ff98e6a60c379cf5040626ee88cbc63 /src/string_mutable.zig | |
parent | feb45edf6d9e33d55e89f5dbca9758bce010b14a (diff) | |
download | bun-e10fe8aaad81e7bd958244adb8584107d7aef18e.tar.gz bun-e10fe8aaad81e7bd958244adb8584107d7aef18e.tar.zst bun-e10fe8aaad81e7bd958244adb8584107d7aef18e.zip |
[JS transpiler] Ensure reserved words don't end up in nonUniqueIdentifier()
Diffstat (limited to 'src/string_mutable.zig')
-rw-r--r-- | src/string_mutable.zig | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/string_mutable.zig b/src/string_mutable.zig index b8084dd50..5dc153c99 100644 --- a/src/string_mutable.zig +++ b/src/string_mutable.zig @@ -63,6 +63,8 @@ pub const MutableString = struct { if (!iterator.next(&cursor)) return "_"; + const JSLexerTables = @import("./js_lexer_tables.zig"); + // Common case: no gap necessary. No allocation necessary. needs_gap = !js_lexer.isIdentifierStart(cursor.c); if (!needs_gap) { @@ -76,6 +78,10 @@ pub const MutableString = struct { } } + if (!needs_gap and str.len >= 3 and str.len <= 10) { + return JSLexerTables.StrictModeReservedWordsRemap.get(str) orelse str; + } + if (needs_gap) { var mutable = try MutableString.initCopy(allocator, str[0..start_i]); needs_gap = false; |