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
I have a struct definition in module consts and in module draw I want to declare an array of Point's like this: mut points := &[]consts.Point{} but it generates a compile error of "unexpected token {, expecting (". Example below:
bug_consts.v:
modulebug_constspubstructPoint {
pub:
x f32
y f32
}
bug_draw.v:
modulebug_drawimportbug_constsimportconststypeAliasPoint= bug_consts.Point // ToDo: HACK to overcome compiler issuepub fnbug_compile() []bug_consts.Point {
mutbad_points:=&[]bug_consts.Point{} // generates compiler error unexpected token `{`, expecting `(`mutgood_points:=&[]AliasPoint{} // compiles OKreturn*bad_points // I cannot return the type I want, returning good_points is the wrong type, casting using 'as' didn't work
}
Current V version: V 0.4.0 ecca3b1, timestamp: 2023-08-01 20:45:50 +0300
Environment details (OS name and version, etc.)
dave@dcn-mini-pc/precious/.../v/canvas >>> v doctor
V full version: V 0.4.0 ecca3b1
OS: linux, "Manjaro Linux"
Processor: 12 cpus, 64bit, little endian, Intel(R) Core(TM) i5-10600K CPU @ 4.10GHz
Describe the bug
I have a struct definition in module consts and in module draw I want to declare an array of Point's like this: mut points := &[]consts.Point{} but it generates a compile error of "unexpected token
{
, expecting(
". Example below:bug_consts.v:
bug_draw.v:
Expected Behavior
No compile errors
Current Behavior
Compiler says:
bug_draw/bug_draw.v:9:39: error: unexpected token
{
, expecting(
7 |
8 | pub fn bug_compile() []bug_consts.Point {
9 | mut bad_points := &[]bug_consts.Point{} // generates compiler error unexpected token
{
, expecting(
| ^
Reproduction Steps
Compile the two files given in the description
Possible Solution
No response
Additional Information/Context
No response
V version
Current V version: V 0.4.0 ecca3b1, timestamp: 2023-08-01 20:45:50 +0300
Environment details (OS name and version, etc.)
dave@dcn-mini-pc/precious/.../v/canvas >>> v doctor
V full version: V 0.4.0 ecca3b1
OS: linux, "Manjaro Linux"
Processor: 12 cpus, 64bit, little endian, Intel(R) Core(TM) i5-10600K CPU @ 4.10GHz
getwd: /precious/fellsafe/v/canvas
vexe: /home/dave/v/v
vexe mtime: 2023-08-01 19:03:56
vroot: OK, value: /home/dave/v
VMODULES: OK, value: /home/dave/.vmodules
VTMP: OK, value: /tmp/v_1000
Git version: git version 2.40.1
Git vroot status: weekly.2023.23-357-gecca3b15
.git/config present: true
CC version: cc (GCC) 13.1.1 20230429
thirdparty/tcc status: thirdparty-linux-amd64 12f392c3
The text was updated successfully, but these errors were encountered: