Skip to content

Variadic constructors do not always compile correctly. #91

Open
@jaredlll08

Description

@jaredlll08
@ZenCodeType.Name("example.MyThing")
public class MyThing {

	@ZenCodeType.Constructor
	public MyThing(String... arr) {
	}

}
import example.MyThing;
new MyThing();

new MyThing(["hello", "world"]);

produces:

ERROR:   [Ljava.lang.String;
public class test {
    public static void run(String[] var0) {
        new MyThing(new String[]{new String[0]});
        new MyThing(new String[]{new String[]{"hello", "world"}});
    }
}
// class version 52.0 (52)
// access flags 0x1
public class script/test {

  // compiled from: test.zs

  // access flags 0x9
  public static run([Ljava/lang/String;)V
   L0
    LINENUMBER 2 L0
    NEW org/openzen/zenscript/scriptingexample/MyThing
    DUP
    LDC 1
    ANEWARRAY java/lang/String
    DUP
    LDC 0
    LDC 0
    ANEWARRAY java/lang/String
    AASTORE
    INVOKESPECIAL org/openzen/zenscript/scriptingexample/MyThing.<init> ([Ljava/lang/String;)V
    POP
   L1
    LINENUMBER 4 L1
    NEW org/openzen/zenscript/scriptingexample/MyThing
    DUP
    LDC 1
    ANEWARRAY java/lang/String
    DUP
    LDC 0
    LDC 2
    ANEWARRAY java/lang/String
    DUP
    LDC 0
    LDC "hello"
    AASTORE
    DUP
    LDC 1
    LDC "world"
    AASTORE
    AASTORE
    INVOKESPECIAL org/openzen/zenscript/scriptingexample/MyThing.<init> ([Ljava/lang/String;)V
    POP
    RETURN
    MAXSTACK = 9
    MAXLOCALS = 1
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingbytecodeAll issues that relate to the generation of Java Bytecode

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions