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

vfmt removing shared from before shared struct {...} #23440

Closed
islonely opened this issue Jan 11, 2025 · 4 comments · Fixed by #23448
Closed

vfmt removing shared from before shared struct {...} #23440

islonely opened this issue Jan 11, 2025 · 4 comments · Fixed by #23448
Labels
Bug This tag is applied to issues which reports bugs. shared types Status: Confirmed This bug has been confirmed to be valid by a contributor. Unit: vfmt Bugs/feature requests, that are related to the `vfmt`, the formatter for V.

Comments

@islonely
Copy link
Contributor

islonely commented Jan 11, 2025

V version: V 0.4.9 bed28d1, press to see full `v doctor` output
V full version V 0.4.9 4225a34.bed28d1
OS macos, macOS, 15.1.1, 24B91
Processor 8 cpus, 64bit, little endian, Apple M3
Memory 0.08GB/16GB
V executable /Users/adamoates/v/v
V last modified time 2025-01-11 13:57:09
V home dir OK, value: /Users/adamoates/v
VMODULES OK, value: /Users/adamoates/.vmodules
VTMP OK, value: /tmp/v_501
Current working dir OK, value: /Users/adamoates/Documents/shattlebip
Git version git version 2.39.5 (Apple Git-154)
V git status weekly.2025.1-29-gbed28d1e (6 commit(s) behind V master)
.git/config present true
cc version Apple clang version 16.0.0 (clang-1600.0.26.4)
gcc version Apple clang version 16.0.0 (clang-1600.0.26.4)
clang version Apple clang version 16.0.0 (clang-1600.0.26.4)
tcc version tcc version 0.9.28rc 2024-02-05 HEAD@105d70f7 (AArch64 Darwin)
tcc git status thirdparty-macos-arm64 713692d4
emcc version N/A
glibc version N/A

What did you do?
v fmt foo.v

struct Foo {
	bar shared struct {
		foo int
		bar int
	}
}

What did you see?

struct Foo {
	bar struct {
		foo int
		bar int
	}
}

What did you expect to see?

Expected code to remain unchanged after vfmt

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

Copy link

Connected to Huly®: V_0.6-21871

@felipensp
Copy link
Member

It is not a vfmt issue only. The resulting C code is not a shared struct.

@felipensp felipensp added Bug This tag is applied to issues which reports bugs. Status: Confirmed This bug has been confirmed to be valid by a contributor. labels Jan 12, 2025
@JalonSolov
Copy link
Contributor

Can anonymous structs be shared?

@spytheman
Copy link
Member

spytheman commented Jan 13, 2025

Can anonymous structs be shared?

I do not see why not.
If the language allows them and wants to be consistent, even though they lack a type name, they should have a field name, when declared inside another struct, so you should be able to: lock instance.field_name {...} and then do stuff inside that block, that access instance.field_name.anon_struct_fieldname .

@spytheman spytheman added Unit: vfmt Bugs/feature requests, that are related to the `vfmt`, the formatter for V. shared types labels Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs. shared types Status: Confirmed This bug has been confirmed to be valid by a contributor. Unit: vfmt Bugs/feature requests, that are related to the `vfmt`, the formatter for V.
Projects
None yet
4 participants