-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Labels
BugThis tag is applied to issues which reports bugs.This tag is applied to issues which reports bugs.Status: ConfirmedThis bug has been confirmed to be valid by a contributor.This bug has been confirmed to be valid by a contributor.Unit: CheckerBugs/feature requests, that are related to the type checker.Bugs/feature requests, that are related to the type checker.Unit: CompilerBugs/feature requests, that are related to the V compiler in general.Bugs/feature requests, that are related to the V compiler in general.
Description
Describe the bug
A function that expects a variadic array of empty interface elements behaves badly when elements are from an array of another type, being spread with ...
P.S. I am also encountering a cgen error on the project I am currently working on, which I think is related to this issue. Due to the complexity of the project, the cgen error is not reproduced in the below snippet. Please, see here
Actually, I figured out the cgen error is caused by this line
Reproduction Steps
module main
import arrays
interface Value {}
fn some_function(values ...Value) {
println(values)
for v in values {
match v {
string {
println(v)
}
else {
println('bro?')
}
}
}
}
fn main() {
country_ids := [
'AD',
'AE',
'AF',
'AG',
'AI',
'AL',
'AM',
'AO',
'AQ',
'AR',
'AS',
'AT',
'AU',
'AW',
'AX',
'AZ',
'BA',
'BB',
'BD',
'BE',
]
region_id := 'something'
some_function(...country_ids) // spreading []string
some_function(...arrays.concat([Value(region_id)], ...country_ids)) // arrays.concat also fails to cast members
}
Expected Behavior
This should either cause a compilation error, or (what I think should be correct) elements should be cast to the empty interface.
Current Behavior
No runtime error, unexpected runtime behavior
Possible Solution
No response
Additional Information/Context
No response
V version
V 0.4.10 47f8f34
Environment details (OS name and version, etc.)
v doctor
|V full version |V 0.4.10 537605a.47f8f34
|:-------------------|:-------------------
|OS |linux, "openmamba release 2024.6 for x86_64 (rolling)"
|Processor |8 cpus, 64bit, little endian, Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz
|Memory |10.37GB/31.16GB
| |
|V executable |/home/einar/.local/lib64/v/v
|V last modified time|2025-05-09 13:43:59
| |
|V home dir |OK, value: /home/einar/.local/lib64/v
|VMODULES |OK, value: /home/einar/.vmodules
|VTMP |OK, value: /tmp/v_1000
|Current working dir |OK, value: /home/einar/Documents/projects/vlang/active/peony
| |
|Git version |git version 2.49.0
|V git status |weekly.2025.17-69-g47f8f347
|.git/config present |true
| |
|cc version |cc (GCC) 14.2.1 20240909
|gcc version |gcc (GCC) 14.2.1 20240909
|clang version |N/A
|tcc version |tcc version 0.9.28rc 2024-07-31 HEAD@1cee0908 (x86_64 Linux)
|tcc git status |thirdparty-linux-amd64 0134e9b9
|emcc version |N/A
|glibc version |ldd (GNU libc) 2.41
Metadata
Metadata
Assignees
Labels
BugThis tag is applied to issues which reports bugs.This tag is applied to issues which reports bugs.Status: ConfirmedThis bug has been confirmed to be valid by a contributor.This bug has been confirmed to be valid by a contributor.Unit: CheckerBugs/feature requests, that are related to the type checker.Bugs/feature requests, that are related to the type checker.Unit: CompilerBugs/feature requests, that are related to the V compiler in general.Bugs/feature requests, that are related to the V compiler in general.