Skip to content

Can not infer basic assignments in nested loop. #2494

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

Open
Luke100000 opened this issue Jan 23, 2024 Discussed in #2471 · 1 comment
Open

Can not infer basic assignments in nested loop. #2494

Luke100000 opened this issue Jan 23, 2024 Discussed in #2471 · 1 comment
Labels
bug Something isn't working

Comments

@Luke100000
Copy link
Contributor

Discussed in #2471

Originally posted by Luke100000 January 8, 2024
Why can it not infer the type here? How would I rewrite this to be type conform, without spamming type annotations?

local y = 0

for i = 1, 2 do
    y = y + 1 -- here, y is inferred as an integer correctly

    for j = 1, 2 do
        y = y + 1 -- can not infer type
    end

    -- sometimes a bit more complexity is required to trigger the issue, so lets add another loop
    for j = 1, 2 do
        y = y + 1 -- can not infer type
    end
end

print(y)
@sumneko sumneko added the bug Something isn't working label Jan 24, 2024
@RomanSpector
Copy link

#2236

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants