jsweet icon indicating copy to clipboard operation
jsweet copied to clipboard

Parameter and local scopes mixed for overloaded constructors

Open vorth opened this issue 2 years ago • 0 comments

This is a regression; it worked in 2.3.7.

Paste the following code into the live sandbox:

package org.jsweet;

import static def.dom.Globals.*;

public class IcosahedralSymmetryPerspective {

	private String aaa;
	
    public IcosahedralSymmetryPerspective( int xxx ) {
       // xxx here is clearly bound to the parameter definition, or should be,
       //   but JSweet claims we are accessing a variable before its definition.
       // Change the parameter name to yyy and you'll see why in the transpiled code.
        this( xxx + "" );
    }
    
    protected IcosahedralSymmetryPerspective( String bbb ) {
        this.aaa = bbb;

        int xxx = 99; // This is the local variable definition that collides incorrectly with the parameter in the other constructor
		System.out.println( xxx );
	}
}

vorth avatar Aug 21 '22 02:08 vorth