Skip to content

Commit

Permalink
luau-compile: Fix usage of vector-ctor without vector-lib (#1172)
Browse files Browse the repository at this point in the history
When --vector-lib is not specified, CompileOptions::vectorLib was set to
an empty string. This resulted in the builtin matching not working,
since vectorLib must either be a null pointer or a pointer to a valid
global identifier.

---------

Co-authored-by: vegorov-rbx <[email protected]>
  • Loading branch information
zeux and vegorov-rbx authored Feb 26, 2024
1 parent 3b0e93b commit c932485
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions CLI/Compile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@ struct GlobalOptions
int optimizationLevel = 1;
int debugLevel = 1;

std::string vectorLib;
std::string vectorCtor;
std::string vectorType;

const char* vectorLib = nullptr;
const char* vectorCtor = nullptr;
const char* vectorType = nullptr;
} globalOptions;

static Luau::CompileOptions copts()
Expand All @@ -58,10 +57,9 @@ static Luau::CompileOptions copts()
result.optimizationLevel = globalOptions.optimizationLevel;
result.debugLevel = globalOptions.debugLevel;

// globalOptions outlive the CompileOptions, so it's safe to use string data pointers here
result.vectorLib = globalOptions.vectorLib.c_str();
result.vectorCtor = globalOptions.vectorCtor.c_str();
result.vectorType = globalOptions.vectorType.c_str();
result.vectorLib = globalOptions.vectorLib;
result.vectorCtor = globalOptions.vectorCtor;
result.vectorType = globalOptions.vectorType;

return result;
}
Expand Down

0 comments on commit c932485

Please sign in to comment.