Skip to content

parser, checker, cgen: fix fn return alias of fixed array - #19116

Merged
medvednikov merged 1 commit into
vlang:masterfrom
yuyi98:fix_return_alias_of_fixed_array
Aug 11, 2023
Merged

medvednikov merged 1 commit into
vlang:masterfrom
yuyi98:fix_return_alias_of_fixed_array

Conversation

@yuyi98

@yuyi98 yuyi98 commented Aug 11, 2023

Copy link
Copy Markdown
Member

This PR fix fn return alias of fixed array.

  • Don't change return type from alias type to fixed array type in parser chase.
  • Fmt is correct.
  • Change the related tests.
type Mat = [2][2]int

fn main() {
	a := Mat([[1, 2]!, [3, 4]!]!)
	println(a.foo())
	z := a.foo()
	assert z == [[1, 2]!, [3, 4]!]!
}

fn (v Mat) foo() Mat {
	return v
}

fn bar() Mat {
	return Mat([[1, 2]!, [3, 4]!]!)
}

PS D:\Test\v\tt1> v run .
Mat([[1, 2], [3, 4]])

Fmt is correct.

@spytheman spytheman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@felipensp

Copy link
Copy Markdown
Member

Nice!

@medvednikov
medvednikov merged commit 61ffbe1 into vlang:master Aug 11, 2023
@yuyi98
yuyi98 deleted the fix_return_alias_of_fixed_array branch August 12, 2023 00:36
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

Successfully merging this pull request may close these issues.

4 participants