v icon indicating copy to clipboard operation
v copied to clipboard

cgen: fix multi return with option type

Open felipensp opened this issue 3 years ago • 0 comments

Fix #17465

fn tuple() ?(int, int) {
	return 1, 2
}

fn tuple2() ?(string, int) {
	return '', 2
}

fn tuple3() ?(?int, ?int) {
	return none, none
}

fn tuple4() ?(?int, ?int) {
	return none
}

fn test_tuple_1() {
	a, b := tuple()
	assert a == 1
	assert b == 2
}

fn test_tuple_2() {
	a, b := tuple2()
	assert a == ''
	assert b == 2
}

fn test_tuple_3() {
	a, b := tuple3()
	assert a == none
	assert b == none
}

fn test_tuple_4() {
	a, b := tuple4()
	assert a == none
	assert b == none
}

felipensp avatar Mar 03 '23 15:03 felipensp