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

Variable might not have been initialized #270

Open
zsrv opened this issue Apr 25, 2023 · 0 comments
Open

Variable might not have been initialized #270

zsrv opened this issue Apr 25, 2023 · 0 comments
Labels
bug Something isn't working Priority: Medium Medium priority Subsystem: Statement Structure Anything concerning how statements are structured in a method

Comments

@zsrv
Copy link

zsrv commented Apr 25, 2023

Version: Quiltflower 1.10.0 (commit d43976c)

Original code:

public class Example {
    private void myMethod() {
        Object[] myObjects = new Object[]{};
        int[] myInts = new int[]{1, 2, 3};
        if (myObjects != null) {
            int i;
            int myObjectsLength = myObjects.length;
            for (i = 0; i < myInts.length; ++i) {
                int myInt = myInts[i];
                int[] myInts2 = myInts;
                int myInts2Length = myInts2.length;
                if (myInts2Length != myObjectsLength) {
                    System.out.println(myInts2Length + " " + myObjectsLength);
                }
            }
        }
    }
}

Quiltflower output:

public class Example {
   private void myMethod() {
      Object[] myObjects = new Object[0];
      int[] myInts = new int[]{1, 2, 3};
      if (myObjects != null) {
         for (int myInt : myObjects) {
            int myInts2Length = myInts.length;
            byte myObjectsLength;
            if (myInts2Length != myObjectsLength) {
               System.out.println(myInts2Length + " " + myObjectsLength);
            }
         }
      }
   }
}

The output results in these errors:

Incompatible types. Found: 'int', required: 'java.lang.Object'
Variable 'myObjectsLength' might not have been initialized
@jaskarth jaskarth added bug Something isn't working Subsystem: Statement Structure Anything concerning how statements are structured in a method Priority: Medium Medium priority labels Apr 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Priority: Medium Medium priority Subsystem: Statement Structure Anything concerning how statements are structured in a method
Projects
None yet
Development

No branches or pull requests

2 participants