Skip to content
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

repeat…until val ~= nil should satisfy the need for nil checks #2531

Open
dljsjr opened this issue Feb 19, 2024 · 0 comments
Open

repeat…until val ~= nil should satisfy the need for nil checks #2531

dljsjr opened this issue Feb 19, 2024 · 0 comments

Comments

@dljsjr
Copy link

dljsjr commented Feb 19, 2024

I have some code where I have to wait for a forked process to create a file and I can't get feedback over its return status or stdout, so I use a polling pattern similar to this:

local val = nil

-- kick off the external process
fork_process(...)

repeat
    val = check_for_val(...)
until val ~= nil

val:foo()

In this current form, I get a diagnostic that says I need to perform a nil check on val before calling foo, but the loop condition here should be considered the nil check.

This already works for while val == nil do...end so it would be nice to see it for repeat...until val~= nil as well.

@dljsjr dljsjr changed the title repeat…until val ~= nil should satisfy the need for subsequent nil checks repeat…until val ~= nil should satisfy the need for nil checks Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant