Merge branch 'petrih-vector-literals' of https://github.com/petrihakkinen/luau into petrih-vector-literals

This commit is contained in:
Petri Häkkinen 2023-11-10 15:57:02 +02:00
commit 50904b04e8
2 changed files with 3 additions and 3 deletions

View file

@ -1131,7 +1131,7 @@ struct Compiler
}
// disable fast path for vectors because supporting it would require a new opcode
if (isConstantVector(right))
if (operandIsConstant && isConstantVector(right))
operandIsConstant = false;
uint8_t rl = compileExprAuto(left, rs);

View file

@ -4498,12 +4498,12 @@ TEST_CASE("VectorLiterals")
{
ScopedFastFlag sff("LuauVectorLiterals", true);
CHECK_EQ("\n" + compileFunction("return Vector3.new(1, 2, 3)", 0, 2, true), R"(
CHECK_EQ("\n" + compileFunction("return Vector3.new(1, 2, 3)", 0, 2, /*enableVectors*/ true), R"(
LOADK R0 K0 [1, 2, 3]
RETURN R0 1
)");
CHECK_EQ("\n" + compileFunction("print(Vector3.new(1, 2, 3))", 0, 2, true), R"(
CHECK_EQ("\n" + compileFunction("print(Vector3.new(1, 2, 3))", 0, 2, /*enableVectors*/ true), R"(
GETIMPORT R0 1 [print]
LOADK R1 K2 [1, 2, 3]
CALL R0 1 0