Skip to content

checker: wrapping mutable array in parenthesis circumvents checker #24584

@4hnme

Description

@4hnme

Describe the bug

when taking a pointer to an element of a mutable array, adding extra parenthesis sidesteps safety check

Reproduction Steps

mut arr := [1, 2, 3]
mut ptr1 := &(arr[1]) // <- this should error, but it doesn't
mut ptr2 := &arr[1]   // <- this errors, unless put inside unsafe block

Expected Behavior

the checker should catch this

Current Behavior

the checker ignores it

Possible Solution

No response

Additional Information/Context

there's already a check in place for the exact situation, but it is sidestepped with added parenthesis. my attempts at dump debugging show that in this case typ_sym is treated like an immutable value rather than a mutable array

V version

V 0.4.10 52c7130

Environment details (OS name and version, etc.)

V full version V 0.4.10 52c7130
OS linux, "Void Linux"
Processor 4 cpus, 64bit, little endian, Intel(R) Core(TM) i5-2500 CPU @ 3.30GHz
Memory 1.11GB/7.74GB
V executable /home/username/thirdparty/v/v
V last modified time 2025-05-26 13:18:58
V home dir OK, value: /home/username/thirdparty/v
VMODULES OK, value: /home/username/.vmodules
VTMP OK, value: /tmp/v_1000
Current working dir OK, value: /home/username/thirdparty/v
Git version git version 2.49.0
V git status weekly.2025.08-533-g52c7130a
.git/config present true
cc version cc (GCC) 14.2.1 20250405
gcc version gcc (GCC) 14.2.1 20250405
clang version clang version 19.1.4
tcc version tcc version 0.9.28rc 2025-02-13 HEAD@f8bd136d (x86_64 Linux)
tcc git status thirdparty-linux-amd64 696c1d84
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.

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions