Skip to content

Commit

Permalink
Add FFlag
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnnyMorganz committed Jun 1, 2024
1 parent 7c5dffd commit da7557c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Analysis/src/AstQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <algorithm>

LUAU_FASTFLAG(DebugLuauDeferredConstraintResolution);
LUAU_FASTFLAGVARIABLE(LuauFixBindingForGlobalPos, false);

namespace Luau
{
Expand Down Expand Up @@ -334,7 +335,7 @@ static std::optional<AstStatLocal*> 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<AstNode*> nodes = findAstAncestryOfPosition(source, binding.location.begin);
Expand Down
3 changes: 3 additions & 0 deletions tests/AstQuery.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include "doctest.h"
#include "Fixture.h"

LUAU_FASTFLAG(LuauFixBindingForGlobalPos);

using namespace Luau;

struct DocumentationSymbolFixture : BuiltinsFixture
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit da7557c

Please sign in to comment.