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

arithmetic operations with numeric should trigger InvalidOperand when strictBinaryOperands is true #6168

Closed
orklah opened this issue Jul 23, 2021 · 1 comment · Fixed by #6169

Comments

@orklah
Copy link
Collaborator

orklah commented Jul 23, 2021

This can't be reproduced on psalm.dev but here's the snippet anyway:
https://psalm.dev/r/100b60f446

numeric can contain int, float or numeric-string, so when strictBinaryOperands is enabled, doing operations with it should trigger InvalidOperand

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/100b60f446
<?php

/**
 * @param numeric $number
 */
function scope( $number): float|int
{
    $number = $number*2;
    return $number;
}
Psalm output (using commit 198fdf8):

ERROR: InvalidReturnStatement - 9:12 - The inferred type 'numeric' does not match the declared return type 'float|int' for scope

ERROR: InvalidReturnType - 6:27 - The declared return type 'float|int' for scope is incorrect, got 'numeric'

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

Successfully merging a pull request may close this issue.

1 participant