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

psalm-mutation-free not working #3870

Closed
AndrolGenhald opened this issue Jul 22, 2020 · 3 comments
Closed

psalm-mutation-free not working #3870

AndrolGenhald opened this issue Jul 22, 2020 · 3 comments
Labels

Comments

@AndrolGenhald
Copy link
Collaborator

AndrolGenhald commented Jul 22, 2020

The @psalm-mutation-free example in the documentation doesn't show any errors: https://psalm.dev/r/23642086f5

Git bisecting points to this commit as introducing the issue.

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/23642086f5
<?php
class D {
  private string $s;

  public function __construct(string $s) {
    $this->s = $s;
  }

  /**
   * @psalm-mutation-free
   */
  public function getShort() : string {
    return substr($this->s, 0, 5);
  }

  /**
   * @psalm-mutation-free
   */
  public function getShortMutating() : string {
    $this->s .= "hello"; // this is a bug
    return substr($this->s, 0, 5);
  }
}
Psalm output (using commit ced2646):

No issues!

@muglug muglug added the bug label Jul 22, 2020
@muglug muglug closed this as completed in 3848fa6 Jul 23, 2020
@AndrolGenhald
Copy link
Collaborator Author

@muglug It looks like the issue persists (haven't tested locally, but psalm.dev still shows no errors with the latest commit).

muglug added a commit that referenced this issue Jul 24, 2020
@muglug
Copy link
Collaborator

muglug commented Jul 24, 2020

That example should be caught too now, sorry

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

2 participants