You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: Bar must at least have 1 field or it will be interpreted as nil and work
structFoo {
bar &Bar= Bar{}
}
structBar {
field int
}
fnmain() {
dump(Foo{})
}
If type Foo.bar is &Bar but is provided Bar it will throw this C error: /tmp/v_60000/../../../../../../box/code.v:10: error: cannot convert 'struct main__Bar' to 'struct main__Bar *'
If type Foo.bar is Bar but is provided &Bar it will convert &Bar to Bar but Bar's field values will be corrupted like #20969
Reproduction Steps
structFoo {
bar &Bar= Bar{}
}
structBar {
field int
}
fnmain() {
dump(Foo{})
}
Expected Behavior
Proper serialisation of the default field values or V error
Current Behavior
If type Foo.bar is &Bar but is provided Bar it will throw this C error: /tmp/v_60000/../../../../../../box/code.v:10: error: cannot convert 'struct main__Bar' to 'struct main__Bar *'
If type Foo.bar is Bar but is provided &Bar it will convert &Bar to Bar but Bar's field values will be corrupted like #20969
Possible Solution
Whilst default field values don't work, setting them at runtime does, so adding those checks at comptime for default field values might help
Additional Information/Context
Found and tested in V playground
V version
V 0.4.5 0e2b604
Environment details (OS name and version, etc.)
V full version: V 0.4.5 0e2b604
OS: linux, Debian GNU/Linux 11 (bullseye) (VM)
Processor: 1 cpus, 64bit, little endian, Intel(R) Xeon(R) CPU E5-2686 v4 @ 2.30GHz
getwd: /home/admin/playground
vexe: /home/admin/v/v
vexe mtime: 2024-05-11 08:25:23
vroot: OK, value: /home/admin/v
VMODULES: OK, value: .vmodules
VTMP: OK, value: /tmp/v_0
Git version: git version 2.30.2
Git vroot status: Error: fatal: detected dubious ownership in repository at '/home/admin/v'
To add an exception for this directory, call:
git config --global --add safe.directory /home/admin/v
.git/config present: true
CC version: cc (Debian 10.2.1-6) 10.2.1 20210110
thirdparty/tcc status: Error: fatal: detected dubious ownership in repository at '/home/admin/v/thirdparty/tcc'
To add an exception for this directory, call:
git config --global --add safe.directory /home/admin/v/thirdparty/tcc
Error: fatal: detected dubious ownership in repository at '/home/admin/v/thirdparty/tcc'
To add an exception for this directory, call:
git config --global --add safe.directory /home/admin/v/thirdparty/tcc
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.
The text was updated successfully, but these errors were encountered:
Describe the bug
Note: Bar must at least have 1 field or it will be interpreted as nil and work
If type Foo.bar is &Bar but is provided Bar it will throw this C error:
/tmp/v_60000/../../../../../../box/code.v:10: error: cannot convert 'struct main__Bar' to 'struct main__Bar *'
If type Foo.bar is Bar but is provided &Bar it will convert &Bar to Bar but Bar's field values will be corrupted like #20969
Reproduction Steps
Expected Behavior
Proper serialisation of the default field values or V error
Current Behavior
If type Foo.bar is &Bar but is provided Bar it will throw this C error:
/tmp/v_60000/../../../../../../box/code.v:10: error: cannot convert 'struct main__Bar' to 'struct main__Bar *'
If type Foo.bar is Bar but is provided &Bar it will convert &Bar to Bar but Bar's field values will be corrupted like #20969
Possible Solution
Whilst default field values don't work, setting them at runtime does, so adding those checks at comptime for default field values might help
Additional Information/Context
Found and tested in V playground
V version
V 0.4.5 0e2b604
Environment details (OS name and version, etc.)
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.
The text was updated successfully, but these errors were encountered: