Skip to content

Anonymous Structs don't have initialized values in it #23896

@shininglove

Description

@shininglove

Describe the bug

Values that are set in the array aren't reflected when used in a for loop or when printing the array.

Reproduction Steps

module main

fn main() {
   tsts := [struct {age: 'Vlang', name: 20}]
   for tst in tsts {
      println(tst.name)
      // ^0
      println(tst.age)
      // ^''
  }
}

Expected Behavior

module main

fn main() {
   tsts := [struct {age: 'Vlang', name: 20}]
   for tst in tsts {
      println(tst.name)
      // ^20
      println(tst.age)
      // ^'Vlang'
  }
}

Current Behavior

returns default values of the type

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.9 23c5bc7

Environment details (OS name and version, etc.)

V full version V 0.4.9 9ae8cc3.23c5bc7
OS linux, Linux version 5.15.167.4 (gcc (GCC) 11.2.0, GNU ld (GNU Binutils) 2.37)
Processor Intel(R)
Memory 14.94GB/15.55GB
V executable ~/programs/v/v
V last modified time 2025-03-09 21:13:19
V home dir OK, value: ~/programs/v
VMODULES OK, value: ~/.vmodules
Current working dir OK, value: ~/langs/vlang
Git version git version 2.48.1
V git status weekly.2024.37-1238-g23c5bc78
.git/config present true
cc version cc (GCC) 14.2.1 20250207
gcc version gcc (GCC) 14.2.1 20250207
clang version clang version 19.1.7
tcc version tcc version 0.9.28rc 2024-07-31 HEAD@1cee0908 (x86_64 Linux)
tcc git status thirdparty-linux-amd64 0134e9b9
emcc version N/A
glibc version ldd (GNU libc) 2.41

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.Status: ConfirmedThis bug has been confirmed to be valid by a contributor.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions