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

spec: incorrect requirement for the embedded field #69460

Closed
leabit opened this issue Sep 13, 2024 · 3 comments
Closed

spec: incorrect requirement for the embedded field #69460

leabit opened this issue Sep 13, 2024 · 3 comments
Labels

Comments

@leabit
Copy link

leabit commented Sep 13, 2024

What is the URL of the page with the issue?

https://go.dev/ref/spec#Struct_types

What is your user agent?

Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36

Screenshot

No response

What did you do?

I came across a discussion about the incorrect terminology used in the specification when referring to promoted methods of the alias to unnamed type, and the changes that were made to address this issue. However, there remains another related problem, and I believe its resolution should also be considered as part of the overall solution. The specification states the following:

An embedded field must be specified as a type name T or as a pointer to a non-interface type name *T, and T itself may not be a pointer type.

If the type name denotes only defined types everything would be fine, however, it also denotes type alias to the unnamed (undefined) types.

What did you see happen?

So according to the specification, the following code is invalid since type name T is a pointer type:

package main

type T = *int

type S struct {
	T
}

func main() {}

However, it compiles.

What did you expect to see?

To not compile (actually to compile, but to correct the specification to properly address this as well).

@leabit leabit added the pkgsite label Sep 13, 2024
@leabit
Copy link
Author

leabit commented Sep 13, 2024

Al right, it looks like the same issue was already mentioned in #22005, however, nothing has been done for 7 years

@seankhliao
Copy link
Member

Duplicate of #22005

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants