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

v: allow alias as fixed array on return #18817

Merged
merged 7 commits into from
Jul 13, 2023

Conversation

felipensp
Copy link
Member

@felipensp felipensp commented Jul 7, 2023

Fix #18796

type U24 = [3]u8

fn from_u32(val u32) U24 {
	mut v := U24([3]u8{})
	_ = v[2]
	v[0] = u8((val >> 16) & 0xFF)
	v[1] = u8((val >> 8) & 0xFF)
	v[2] = u8(val & 0xFF)
	return v
}

fn to_u32(v U24) u32 {
	return u32(v[2]) | u32(v[1]) << u8(8) | u32(v[0]) << 16
}

fn main() {
	a := u32(1)
	v := from_u32(a)
	dump(v)
}

copilot:summary

copilot:walkthrough

@felipensp felipensp added the Tests To Fix This PR requiring only test fixes. label Jul 8, 2023
@felipensp felipensp removed the Tests To Fix This PR requiring only test fixes. label Jul 9, 2023
@felipensp felipensp marked this pull request as ready for review July 12, 2023 03:43
vlib/v/ast/types.v Outdated Show resolved Hide resolved
Copy link
Member

@spytheman spytheman left a comment

Choose a reason for hiding this comment

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

Good work, only the tests need some cleanup imho.

@spytheman spytheman merged commit 413ffbf into vlang:master Jul 13, 2023
49 checks passed
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.

function return (aliased) fixed sized arrays still bring in error
3 participants