1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

parser: parse non-identifier expressions for sizeof too (#7781)

This commit is contained in:
Nick Treleaven
2021-01-01 13:38:11 +00:00
committed by GitHub
parent 5ae3637d27
commit d15d13674c
3 changed files with 28 additions and 4 deletions

View File

@@ -1,6 +1,17 @@
import math
fn test_sizeof() {
struct S1 {
i voidptr
}
fn test_math_sizeof() {
r := math.f32_from_bits(sizeof(int))
assert r > 5.6e-45 && r < 5.7e-45
}
fn test_sizeof() {
// depends on compiler
assert sizeof(``) in [u32(2), 4]
// depends on -m32/64
assert sizeof(S1) in [u32(4), 8]
}