From da7557c453afe4f35368e2395d6d1392de5c28d6 Mon Sep 17 00:00:00 2001 From: JohnnyMorganz Date: Sat, 1 Jun 2024 13:36:21 +0200 Subject: [PATCH] Add FFlag --- Analysis/src/AstQuery.cpp | 3 ++- tests/AstQuery.test.cpp | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Analysis/src/AstQuery.cpp b/Analysis/src/AstQuery.cpp index 12aacabb..928e5dfb 100644 --- a/Analysis/src/AstQuery.cpp +++ b/Analysis/src/AstQuery.cpp @@ -12,6 +12,7 @@ #include LUAU_FASTFLAG(DebugLuauDeferredConstraintResolution); +LUAU_FASTFLAGVARIABLE(LuauFixBindingForGlobalPos, false); namespace Luau { @@ -334,7 +335,7 @@ static std::optional findBindingLocalStatement(const SourceModule { // Bindings coming from global sources (e.g., definition files) have a zero position. // They cannot be defined from a local statement - if (binding.location == Location{{0, 0}, {0, 0}}) + if (FFlag::LuauFixBindingForGlobalPos && binding.location == Location{{0, 0}, {0, 0}}) return std::nullopt; std::vector nodes = findAstAncestryOfPosition(source, binding.location.begin); diff --git a/tests/AstQuery.test.cpp b/tests/AstQuery.test.cpp index 4deaf648..c53fe731 100644 --- a/tests/AstQuery.test.cpp +++ b/tests/AstQuery.test.cpp @@ -6,6 +6,8 @@ #include "doctest.h" #include "Fixture.h" +LUAU_FASTFLAG(LuauFixBindingForGlobalPos); + using namespace Luau; struct DocumentationSymbolFixture : BuiltinsFixture @@ -333,6 +335,7 @@ TEST_CASE_FIXTURE(Fixture, "find_expr_ancestry") TEST_CASE_FIXTURE(BuiltinsFixture, "find_binding_at_position_global_start_of_file") { + ScopedFastFlag sff{FFlag::LuauFixBindingForGlobalPos, true}; check("local x = string.char(1)"); const Position pos(0, 12);