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

FP: incorrectly detected derived variable bounds in loop #2675

Closed
dktapps opened this issue Dec 5, 2019 · 3 comments
Closed

FP: incorrectly detected derived variable bounds in loop #2675

dktapps opened this issue Dec 5, 2019 · 3 comments
Labels
Milestone

Comments

@dktapps
Copy link
Contributor

dktapps commented Dec 5, 2019

Bug report

Version is 0.12.0

It appears that bounds for the derived variable $i has the bounds applied from the for loop variables.

Code snippet that reproduces the problem

<?php

declare(strict_types=1);

class MyClass{
	public $t = 0;

	public function test() : array{
		$result = [];
		for($xx = 0; $xx <= 2; ++$xx){
			for($zz = 0; $zz <= 2; ++$zz){
				$i = $zz * 3 + $xx;
				if($i === 4){
					continue; //center chunk
				}
				$result[$i] = true;
			}
		}
		return $result;
	}
}

https://phpstan.org/r/a1836aad-4d1e-42df-ad12-f8772c4b2ffb

Expected output

No errors (on level 4, at least).

@dktapps
Copy link
Contributor Author

dktapps commented Dec 28, 2019

Seems like this is fixed in 0.12.3.

@dktapps dktapps closed this as completed Dec 28, 2019
@ondrejmirtes ondrejmirtes reopened this Dec 28, 2019
@ondrejmirtes
Copy link
Member

Please don’t close issues without proper regression tests.

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants