mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
expression: set integer literals as int by default
This commit is contained in:
@ -787,13 +787,7 @@ fn (p mut Parser) factor() string {
|
||||
}
|
||||
.number {
|
||||
// Check if float (`1.0`, `1e+3`) but not if is hexa (e.g. 0xEE contains `E` but is not float)
|
||||
if (p.lit.contains('.') || p.lit.contains('e') || p.lit.contains('E')) && !(p.lit[..2] in ['0x', '0X']) {
|
||||
typ = 'f64'
|
||||
}
|
||||
else {
|
||||
v_u64 := p.lit.u64()
|
||||
typ = if u64(u32(v_u64)) < v_u64 { 'u64' } else { 'int' }
|
||||
}
|
||||
typ = if (p.lit.contains('.') || p.lit.contains('e') || p.lit.contains('E')) && !(p.lit[..2] in ['0x', '0X']) { 'f64' } else { 'int' }
|
||||
if p.expected_type != '' && !is_valid_int_const(p.lit, p.expected_type) {
|
||||
p.error('constant `$p.lit` overflows `$p.expected_type`')
|
||||
}
|
||||
|
Reference in New Issue
Block a user