Skip to content

Strange things happen when multiple arrays are declared in a comma-separated list #19

Description

@Dozzler
program calculate{

	function foo() : Integer[] {
		a, b : Integer[];
		a := new Integer[3];
		for i = 0 to #a -1 {
			a[i] := 1;
		}
		
		return a;
	}
	
	procedure print_two_arrays(firstArray, secondArray : Integer[]) {
		println(firstArray);
		println(secondArray);
	}
	
	procedure bar() {
		s, t : Integer[];
		
		s := {1,2,3};
		t := foo();
		
		print_two_arrays(s, foo());    // this prints : "null \n {1,1,1}"
		print_two_arrays(s, t);          // this prints : "{1,2,3} \n {1,1,1}"
	}
	
	bar();
}

Expected would be "{1,2,3} \n {1,1,1}" in both cases.
This does NOT occur, when "foo()" is written as follows:

function foo() : Integer[] {
	a : Integer[];
	b : Integer[];
        a := new Integer[3];
	for i = 0 to #a -1 {
		a[i] := 1;
	}
		
	return a;
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions