Skip to content

Accessible private field in generic struct #26433

Description

@iperov

Describe the bug

Can access private field in generic struct

Reproduction Steps

module cont

pub struct Foo[T] {
    i int
}

pub struct Bar {
    i int
}
fn main() 
{  
   q := cont.Foo[int]{i:3} // no error
    
   w := cont.Bar{i:3} // error: cannot access private field `i` on `cont.Bar`    
}

Expected Behavior

expected error

Current Behavior

no error

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.5.0 37577eb

Environment details (OS name and version, etc.)

V full version V 0.5.0 37577eb
OS windows, Microsoft Windows 10 Pro 19045 64-bit
Processor 8 cpus, 64bit, little endian, Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz
Memory 45GB/63.94GB
V executable C:\PORTABLE\DEVELOP\V\VProject_internal\v\v.exe
V last modified time 2026-01-21 15:55:10
V home dir OK, value: C:\PORTABLE\DEVELOP\V\VProject_internal\v
VMODULES OK, value: C:\PORTABLE\DEVELOP\V\VProject_internal_z\u.vmodules
VTMP OK, value: C:\PORTABLE\DEVELOP\V\VProject_internal_z\t\v_0
Current working dir OK, value: C:\PORTABLE\DEVELOP\V\VProject\master
Git version git version 2.50.1.windows.1
V git status N/A
.git/config present false
cc version N/A
gcc version gcc (MinGW-W64 x86_64-ucrt-posix-seh, built by Brecht Sanders, r4) 15.2.0
clang version N/A
msvc version N/A
tcc version tcc version 0.9.27 (x86_64 Windows)
tcc git status N/A
emcc version N/A
glibc version N/A

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.

Metadata

Metadata

Assignees

Labels

BugThis tag is applied to issues which reports bugs.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions