Skip to content

Commit

Permalink
BytecodeBuilder::dumpConstant import indexes containing whitespace …
Browse files Browse the repository at this point in the history
…are now bracket wrapped
  • Loading branch information
Lonegwadiwaitor committed Dec 24, 2023
1 parent 401f99e commit 0f0c1ab
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions Compiler/src/BytecodeBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand Down

0 comments on commit 0f0c1ab

Please sign in to comment.