Definite un-assignedness for assignment expression

Issue #51 resolved
Erik Hogeman created an issue

JLS version 7, Chapter 16.1.8 states:

 V is definitely unassigned after the assignment expression iff a is not V and V is definitely unassigned after b.

The attribute for assignment expression definite unassignedness does not comply with the specification:

eq AssignExpr.isDUafter(Variable v) = getSource().isDUafter(v);

The attribute only checks the source unassignedness.

Proposed fix:

eq AssignExpr.isDUafter(Variable v) {
    //Bug in java 4 implementation, see 16.1.8 second bullet. Must check that v != a 
    if(getDest().isVariable() && getDest().varDecl() == v) 
        return false;
    else
        return getSource().isDUafter(v);
}

Comments (2)

  1. Jesper Öqvist

    Test case for this bug:

    public class Test {
            public void m() {
                    final int f;
                    f = 3;
                    f = 4;// expect error because f not definitely unassigned
                    System.out.println(""+f);
            }
    }
    
  2. Log in to comment