Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(resolve): function call with same name variable in scope #159

Merged
merged 1 commit into from
Feb 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions server/src/e2e/suite/testcases/resolve/basic.test
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ fun test() {
------------------------------------------------------------------------
4:4 -> 3:8 resolved

========================================================================
Local variable resolve with same name function in call
========================================================================
fun value() {}

fun test() {
let value = 1;
<caret>value();
}
------------------------------------------------------------------------
4:4 -> 0:4 resolved

========================================================================
Parameter resolve
========================================================================
Expand Down
11 changes: 9 additions & 2 deletions server/src/psi/Reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,14 +312,21 @@ export class Reference {
}
}

if (!this.processBlock(proc, state)) return false

if (parent?.type === "asm_arrangement_args") {
// `asm(cell self) extends fun storeRef(self: Builder, cell: Cell): Builder`
// ^^^^ this
return this.resolveAsmArrangementArgs(parent, proc, state)
}

if (parent?.type === "static_call_expression") {
// let context = context();
// context();
// ^^^^^^^ resolve only as global symbol
return this.processAllEntities(proc, state)
}

if (!this.processBlock(proc, state)) return false

return this.processAllEntities(proc, state)
}

Expand Down