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

V error not allowing locking of element in array of shared structs #23449

Open
islonely opened this issue Jan 12, 2025 · 2 comments
Open

V error not allowing locking of element in array of shared structs #23449

islonely opened this issue Jan 12, 2025 · 2 comments
Labels
shared types Unit: Parser Bugs/feature requests, that are related to the V parser or syntax (*not* semantic ones).

Comments

@islonely
Copy link
Contributor

islonely commented Jan 12, 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.24GB/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/.vmodules/islonely/mouse
Git version git version 2.39.5 (Apple Git-154)
V git status weekly.2025.1-29-gbed28d1e (10 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 -g -o vdbg cmd/v && ./vdbg /Users/adamoates/Documents/test.v && /Users/adamoates/Documents/test

struct Foo {
mut:
    bars []shared Bar
}

struct Bar {}

fn main() {
    mut foo := Foo{}
    foo.foo << Bar{}
    lock foo.bars[0] {
        println(foo.bars[0])
    }
}

What did you see?

/Users/adamoates/Documents/test.v:11:18: error: unexpected token `[`, expecting one or more shared variable names
    9 |     mut foo := Foo{}
   10 |     foo.foo << Bar{}
   11 |     lock foo.bars[0] {
      |                  ^
   12 |         println(foo.bars[0])
   13 |     }

What did you expect to see?

Expected code to compile and lock the first element in the array.

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-21879

@spytheman spytheman added shared types Unit: Parser Bugs/feature requests, that are related to the V parser or syntax (*not* semantic ones). labels Jan 13, 2025
@spytheman
Copy link
Member

Please use complete examples.

The above lacks foo fields, and the declaration for Bar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
shared types Unit: Parser Bugs/feature requests, that are related to the V parser or syntax (*not* semantic ones).
Projects
None yet
Development

No branches or pull requests

2 participants