MSVC C4244 warning fix

Fix for the C4244(Possible data loss) warning for MSVC
This commit is contained in:
rafa_br34 2022-01-12 05:57:03 -03:00 committed by GitHub
parent b7a7b92d12
commit 77d9e8c038
Signed by: DevComp
GPG key ID: 4AEE18F83AFDEB23

View file

@ -714,17 +714,18 @@ void BytecodeBuilder::writeLineInfo(std::string& ss) const
// third pass: write resulting data
int logspan = log2(span);
writeByte(ss, logspan);
writeByte(ss, static_cast<unsigned char>(logspan));
uint8_t lastOffset = 0;
for (size_t i = 0; i < lines.size(); ++i)
{
int delta = lines[i] - baseline[i >> logspan];
// Check delta if is a valid byte value
LUAU_ASSERT(delta >= 0 && delta <= 255);
writeByte(ss, delta - lastOffset);
lastOffset = delta;
writeByte(ss, static_cast<uint8_t>(delta) - lastOffset);
lastOffset = static_cast<uint8_t>(delta);
}
int lastLine = 0;