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

Discrepancy handling assertions on properties of object in else vs elseif #2322

Closed
muglug opened this issue Nov 11, 2019 · 0 comments
Closed
Labels

Comments

@muglug
Copy link
Collaborator

muglug commented Nov 11, 2019

class C {
  public string $a = '';
  public string $b = '';
}

function testElse(C $obj) : void {
  if ($obj->a === "foo") {
  } elseif ($obj->b === "bar") {
  } else if ($obj->b === "baz") {}

  if ($obj->b === "baz") {}
}
  
function testElseif(C $obj) : void {
  if ($obj->a === "foo") {
  } elseif ($obj->b === "bar") {
  } elseif ($obj->b === "baz") {}

  if ($obj->b === "baz") {}
}

https://psalm.dev/r/730908ebe7

Expected: no issue
Actual: erroneous output in elseif test

@muglug muglug added the bug label Nov 11, 2019
@muglug muglug closed this as completed in fbd1cf0 Nov 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant