parser: fix `sizeof(int)` when used as call arg for external function (#5855)

pull/5865/head
Uwe Krüger 2020-07-17 10:31:35 +02:00 committed by GitHub
parent 3583302ad4
commit f6947d111b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -122,7 +122,10 @@ pub fn (mut p Parser) expr(precedence int) ast.Expr {
pos: pos
}
} else {
save_expr_mod := p.expr_mod
p.expr_mod = ''
sizeof_type := p.parse_type()
p.expr_mod = save_expr_mod
node = ast.SizeOf{
is_type: true
typ: sizeof_type

View File

@ -0,0 +1,6 @@
import math
fn test_sizeof() {
r := math.f32_from_bits(sizeof(int))
assert r > 5.6e-45 && r < 5.7e-45
}