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

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

Open
Dozzler opened this issue Dec 6, 2021 · 0 comments

Comments

@Dozzler
Copy link
Collaborator

Dozzler commented Dec 6, 2021

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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant