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

Inferred types should be backtracked up to method definition #9

Open
sk- opened this issue Sep 11, 2013 · 1 comment
Open

Inferred types should be backtracked up to method definition #9

sk- opened this issue Sep 11, 2013 · 1 comment

Comments

@sk-
Copy link

sk- commented Sep 11, 2013

When inferring types within a function, those should be used to compute the type signature of the function. For example

<?php

function foo($foo) {
    return $foo + 2;
}

gives the error

Notice: Type mismatch: expected: Numeric, found: Any
return $foo + 2;

However, the type inferencer should detect that in this case foo receives a numeric argument and enforce it later.

@colder
Copy link
Owner

colder commented Sep 11, 2013

Hi,

you are right, in this case we could do backward analysis to come up with best-constraints for arguments. That would resolve such cases. It is however non trivial to do this inter-procedurally, (with e.g. recursive functions).

The only way currently is to solve this by annotating the function that it takes a numeric argument.

CaptainEmerson pushed a commit to SoftwareEngineeringToolDemos/FSE-2010-Phantm that referenced this issue Jun 24, 2016
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

No branches or pull requests

2 participants