From 0f0c1ab8913082a23733ad0995cbf77c2a35eca9 Mon Sep 17 00:00:00 2001 From: Will Date: Sun, 24 Dec 2023 09:55:01 +0000 Subject: [PATCH] `BytecodeBuilder::dumpConstant` import indexes containing whitespace are now bracket wrapped --- Compiler/src/BytecodeBuilder.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Compiler/src/BytecodeBuilder.cpp b/Compiler/src/BytecodeBuilder.cpp index 703ccee9..2b5da2aa 100644 --- a/Compiler/src/BytecodeBuilder.cpp +++ b/Compiler/src/BytecodeBuilder.cpp @@ -1735,7 +1735,16 @@ void BytecodeBuilder::dumpConstant(std::string& result, int k) const LUAU_ASSERT(id.type == Constant::Type_String && id.valueString <= debugStrings.size()); const StringRef& str = debugStrings[id.valueString - 1]; - formatAppend(result, ".%.*s", int(str.length), str.data); + + /* check if index contains whitespace */ + if (strchr(str.data, ' ')) + { + formatAppend(result, "[\"%.*s\"]", int(str.length), str.data); + } + else + { + formatAppend(result, ".%.*s", int(str.length), str.data); + } } if (count > 2) @@ -1744,7 +1753,16 @@ void BytecodeBuilder::dumpConstant(std::string& result, int k) const LUAU_ASSERT(id.type == Constant::Type_String && id.valueString <= debugStrings.size()); const StringRef& str = debugStrings[id.valueString - 1]; - formatAppend(result, ".%.*s", int(str.length), str.data); + + /* check if index contains whitespace */ + if (strchr(str.data, ' ')) + { + formatAppend(result, "[\".%.*s\"]", int(str.length), str.data); + } + else + { + formatAppend(result, ".%.*s", int(str.length), str.data); + } } } break;