mirror of
https://github.com/luau-lang/luau.git
synced 2025-04-10 22:00:54 +01:00
Check if binding is at global position
This commit is contained in:
parent
bd19a9779e
commit
7c5dffd424
1 changed files with 5 additions and 0 deletions
|
@ -332,6 +332,11 @@ std::optional<TypeId> findExpectedTypeAtPosition(const Module& module, const Sou
|
||||||
|
|
||||||
static std::optional<AstStatLocal*> findBindingLocalStatement(const SourceModule& source, const Binding& binding)
|
static std::optional<AstStatLocal*> findBindingLocalStatement(const SourceModule& source, const Binding& binding)
|
||||||
{
|
{
|
||||||
|
// 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}})
|
||||||
|
return std::nullopt;
|
||||||
|
|
||||||
std::vector<AstNode*> nodes = findAstAncestryOfPosition(source, binding.location.begin);
|
std::vector<AstNode*> nodes = findAstAncestryOfPosition(source, binding.location.begin);
|
||||||
auto iter = std::find_if(nodes.rbegin(), nodes.rend(), [](AstNode* node) {
|
auto iter = std::find_if(nodes.rbegin(), nodes.rend(), [](AstNode* node) {
|
||||||
return node->is<AstStatLocal>();
|
return node->is<AstStatLocal>();
|
||||||
|
|
Loading…
Add table
Reference in a new issue