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: add typeof(expr).unaliased_typ #22806

Merged
merged 4 commits into from
Nov 10, 2024

Conversation

felipensp
Copy link
Member

@felipensp felipensp commented Nov 8, 2024

This PR adds typeof(expr).unaliased_typ and typeof[Type].unaliased_typ.

struct Foo {
	a int
}

type Bar = Foo

type ArrBar = []Bar

fn test_main() {
	assert typeof[Bar]().unaliased_typ == typeof[Foo]().unaliased_typ
	assert typeof[int]().unaliased_typ != typeof[Foo]().unaliased_typ
	assert typeof[int]().unaliased_typ == typeof[int]().unaliased_typ
	assert typeof[ArrBar]().unaliased_typ == typeof[[]Bar]().idx

	a := Bar{}
	assert typeof(a).unaliased_typ == typeof[Foo]().idx

	b := ArrBar{}
	assert typeof(b).unaliased_typ == typeof[[]Bar]().idx
}

Huly®: V_0.6-21252

@felipensp felipensp changed the title v: add typeof().unaliased_typ v: add typeof(expr).unaliased_typ Nov 8, 2024
@felipensp felipensp marked this pull request as ready for review November 8, 2024 21:48
@spytheman
Copy link
Member

Please rebase over master.

@spytheman spytheman merged commit c9ecc5b into vlang:master Nov 10, 2024
71 checks passed
@medvednikov
Copy link
Member

medvednikov commented Nov 11, 2024

typ is only used when we cant use type
unaliased_type should be the name

(well now we can use type instead of typ as well)

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.

3 participants