Kampfkarren / selene

A blazing-fast modern Lua linter written in Rust
https://kampfkarren.github.io/selene/
Mozilla Public License 2.0
600 stars 76 forks source link

`unused_variable` false positive #504

Closed ketrab2004 closed 1 year ago

ketrab2004 commented 1 year ago

When using a function before it's defined it thinks that it isn't used.

doSomething()

function doSomething() -- doSomething is defined, but never used selene::unused_variable
    print("something")
end

In regular lua this would error but in luau this works just fine.

Kampfkarren commented 1 year ago

In regular lua this would error but in luau this works just fine.

That isn't true for your code in specific. Luau doesn't change this behavior at all.

That being said, you are roughly right about the bug, this is a duplicate of #212

ketrab2004 commented 1 year ago

That is odd, because for me in 5.4 and 5.3 it does error, but not with luau.

input:1: attempt to call a nil value (global 'doSomething')

Kampfkarren commented 1 year ago

image

ketrab2004 commented 1 year ago

Oh nevermind, my minimal reproducible example is wrong.

function main()
    doSomething()
end

function doSomething()
    print("something")
end

main()