mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: more typing checks
This commit is contained in:
parent
75510e2ea1
commit
0f0bef2d33
@ -1467,6 +1467,10 @@ fn (p mut Parser) bool_expression() string {
|
||||
}
|
||||
p.check_space(p.tok)
|
||||
p.check_types(p.bterm(), typ)
|
||||
if typ != 'bool' {
|
||||
p.error('logical operators `&&` and `||` require booleans')
|
||||
|
||||
}
|
||||
}
|
||||
if typ == '' {
|
||||
println('curline:')
|
||||
@ -2467,6 +2471,9 @@ fn (p mut Parser) expression() string {
|
||||
p.gen(',')
|
||||
}
|
||||
}
|
||||
if is_str && tok_op != .plus {
|
||||
p.error('strings only support `+` operator')
|
||||
}
|
||||
p.check_types(p.term(), typ)
|
||||
if (is_str || is_ustr) && tok_op == .plus && !p.is_js {
|
||||
p.gen(')')
|
||||
|
@ -53,4 +53,7 @@ fn test_mod() {
|
||||
assert 4 % 2 == 0
|
||||
x := 2
|
||||
assert u64(5) % x == 1
|
||||
mut a := 10
|
||||
a %= 2
|
||||
assert a == 0
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user