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
v language uses a shared array, the shared array slice operation, running code error.
// shared_array.v:fnmain() {
shareda:= ["a", "b"]
a << ["c", "d"]
println("a: ${ rlock{ a } }") //print: ["a","b","c","d"]a3:=rlock{ a[3] } //print: dprintln("a3: ${ rlock{ a3 } }")
// The following two lines run an error:a_slice:=rlock{ a[1..3] } //Slice gone wrongprintln("a[1..3]: ${ rlock{ a_slice } }") //expect: ["b", "c"]
}
Reproduction Steps
fnmain() {
shareda:= ["a", "b"]
a << ["c", "d"]
println("a: ${ rlock{ a } }") //print: ["a","b","c","d"]a3:=rlock{ a[3] } //print: dprintln("a3: ${ rlock{ a3 } }")
// The following two lines run an error:a_slice:=rlock{ a[1..3] } //Slice gone wrongprintln("a[1..3]: ${ rlock{ a_slice } }") //expect: ["b", "c"]
}
Expected Behavior
Normal should be able to take the slice and output the correct result. For example, this example should output correctly:
a[1..3]: ["b", "c"]
Current Behavior
The run error message is as follows:
~ $ v run shared_array.v
================== C compilation error (from cc): ==============
cc: /data/data/com.termux/files/usr/tmp/v_10264/shared_array.01KJEX8FMH7VYB2SPMPKQHDZD0.tmp.c:8820:7: error: assigning to '__shared__Array_string' (aka 'struct __shared__Array_string') from incompatible type 'array' (aka 'struct array')
cc: 8820 | _t5 = builtin__array_slice((*a).val, 1, 3);
cc: | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc: /data/data/com.termux/files/usr/tmp/v_10264/shared_array.01KJEX8FMH7VYB2SPMPKQHDZD0.tmp.c:8824:29: error: member reference type '__shared__Array_string' (aka 'struct __shared__Array_string') is not a pointer; did you mean to use '.'?
cc: 8824 | Array_string a_slice = _t5->val;
cc: | ~~~^~
cc: | .
cc: 2 errors generated.
================================================================
Try passing `-g` when compiling, to see a .v file:line information, that correlates more with the C error.
(Alternatively, pass `-show-c-output`, to print the full C error message).
builder error:
==================
|V full version |V 0.5.0 a8b0e1d5ed3096edce359cd5d7d2fbb7ab50d31e.57e617a
|:-------------------|:-------------------
|OS |termux, 5.10.136-android12-9-00020-gc9f59ef34367-ab9585114, #1 SMP PREEMPT Wed Feb 8 23:50:57 UTC 2023
|Processor |8 cpus, 64bit, little endian
|Memory |N/A
| |
|V executable |/data/data/com.termux/files/home/v/v
|V last modified time|2026-02-27 07:02:36
| |
|V home dir |OK, value: /data/data/com.termux/files/home/v
|VMODULES |OK, value: /data/data/com.termux/files/home/.vmodules
|VTMP |OK, value: /data/data/com.termux/files/usr/tmp/v_10264
|Current working dir |OK, value: /data/data/com.termux/files/home
| |
|Git version |git version 2.51.0
|V git status |57e617aa-dirty
|.git/config present |true
| |
|cc version |clang version 20.1.8
|gcc version |clang version 20.1.8
|clang version |Android (dev, +pgo, -bolt, +lto, -mlgo, based on r522817b) clang version 18.0.2 (https://android.googlesource.com/toolchain/llvm-project d8003a456d14a3deb8054cdaa529ffbf02d9b262)
|tcc version |N/A
|tcc git status |thirdparty-unknown-unknown de82a130
|emcc version |N/A
|glibc version |readelf: Error: 'readlink (GNU coreutils) 9.7
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.
Describe the bug
v language uses a shared array, the shared array slice operation, running code error.
Reproduction Steps
Expected Behavior
Normal should be able to take the slice and output the correct result. For example, this example should output correctly:
a[1..3]: ["b", "c"]
Current Behavior
The run error message is as follows:
Possible Solution
No response
Additional Information/Context
No response
V version
V 0.5.0 57e617a
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.