-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Describe the bug
There are a subtle differnce between how checks for internface and sum type is performed based on how the variable is declared.
module main
interface ISomeStruct {
something string
}
struct SomeStruct {
something string
}
fn test(s &ISomeStruct) {
println(s) // shows &ISomeStruct(0x0) for working example , then &nil for failing example
if s is SomeStruct {
println("match")
} else {
println("no match")
}
}
fn main() {
y:=unsafe { nil }
test(y) // work
test(unsafe { nil }) // does not work signal 11: segmentation fault
}
Reproduction Steps
Run code in description.
Expected Behavior
Same behaviour, nog sgment fault.
Current Behavior
v run bug4.v
&ISomeStruct(0x0)
no match
&nil
signal 11: segmentation fault
0 libsystem_platform.dylib 0x00007ff81d2155ed _sigtramp + 29
1 dyld 0x00007ff81ceb5ff4 ZN3lsl19PersistentAllocator12reserveRangeERNS_5BTreeINS_13MemoryManager6BufferENS0_17RegionSizeCompareELb0EE14const_iteratorES3 + 666
2 bug4 0x0000000101aa8dea main__main + 74
3 bug4 0x0000000101aa8ff7 main + 71
4 dyld 0x00007ff81ce8d418 start + 1896
Possible Solution
No response
Additional Information/Context
This is destilled from v-analyze issue #162 that happens in the v-analyze
V version
0.4.10
Environment details (OS name and version, etc.)
| V full version | V 0.4.10 ded45dc |
|---|---|
| OS | macos, macOS, 13.7.6, 22H625 |
| Processor | 4 cpus, 64bit, little endian, Intel(R) Core(TM) i7-7567U CPU @ 3.50GHz |
| Memory | 0.5GB/16GB |
| V executable | /Users/martin/Development/v/v/v |
| V last modified time | 2025-05-15 07:44:50 |
| V home dir | OK, value: /Users/martin/Development/v/v |
| VMODULES | OK, value: /Users/martin/.vmodules |
| VTMP | OK, value: /tmp/v_501 |
| Current working dir | OK, value: /Users/martin/Development/bugs |
| Git version | git version 2.49.0 |
| V git status | weekly.2025.20 |
| .git/config present | true |
| cc version | Apple clang version 15.0.0 (clang-1500.1.0.2.5) |
| gcc version | Apple clang version 15.0.0 (clang-1500.1.0.2.5) |
| clang version | Apple clang version 15.0.0 (clang-1500.1.0.2.5) |
| tcc version | tcc version 0.9.27 (x86_64 Darwin) |
| tcc git status | thirdparty-macos-amd64 975f1ad8 |
| emcc version | N/A |
| glibc version | N/A |
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.