-
-
Notifications
You must be signed in to change notification settings - Fork 377
Diagnostics for unnecessary assert #3128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ccb359f
to
d062eb5
Compare
Judging from the screenshot, the message expression of type `boolean` is always truthy
from assert(true)
seems a bit misleading 😕 .
false
is also aboolean
type, butassert(false)
won't cause problem
Ah true, not sure why the printed type evaluates to boolean
instead of true
. I'll investigate
d062eb5
to
c2cd754
Compare
Opted to just not print the expression type for now
is it test for multi return function?
---@return string?, string? local function f() end assert(f())
I think that if it is always falsy is also an unnecessary assertion. right?
assert(nil and 5) -- always falsy
c2cd754
to
1c285e0
Compare
I think that if it is always falsy is also an unnecessary assertion. right?
assert(nil and 5) -- always falsy
True, but this PR only handles unnecessary if true. I'll add that as well, but wanted to keep the scope small at first.
is it test for multi return function?
---@return string?, string? local function f() end assert(f())
Works here as well, I added a test
Thank you!
image