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

Support type inference for binary operations #105

Closed
sergeypospelov opened this issue Jun 19, 2023 · 1 comment · Fixed by #119
Closed

Support type inference for binary operations #105

sergeypospelov opened this issue Jun 19, 2023 · 1 comment · Fixed by #119
Assignees

Comments

@sergeypospelov
Copy link
Member

sergeypospelov commented Jun 19, 2023

Suppose you have the following example:

public int example(short s, char c) {
    return s + c;
}

I expect to see a 3-address code in JcInstList with type annotations as illustrated below:

%0: Int = (arg$0: Char + arg$1: Short): Int
return (%0: Int)

But instead I get:

%0: Char = (arg$0: Char + arg$1: Short): Char
return (%0: Char)

Maybe, the 3-address code builder should infer types for binary expressions based on argument types. E.g., for cases when one of the arguments is char, the result should be at least of int type.

@sergeypospelov
Copy link
Member Author

Consider this function:

  public int example(char s, char c) {
      return s + c;
  }

JacoDB thinks type of s + c is char, but actually it's int.

@sergeypospelov sergeypospelov reopened this Jul 5, 2023
lehvolk pushed a commit that referenced this issue Jul 5, 2023
sergeypospelov added a commit that referenced this issue Jul 5, 2023
lehvolk pushed a commit that referenced this issue Jul 6, 2023
lehvolk pushed a commit that referenced this issue Jul 6, 2023
lehvolk pushed a commit that referenced this issue Jul 6, 2023
@lehvolk lehvolk closed this as completed Jul 7, 2023
lehvolk pushed a commit that referenced this issue Jul 7, 2023
lehvolk pushed a commit that referenced this issue Jul 7, 2023
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.

2 participants