mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
table: i8 -128 was being cast to int closes #4164
This commit is contained in:
parent
3b621c0ce6
commit
f58875a202
@ -903,22 +903,26 @@ fn (table &Table) cgen_name_type_pair(name, typ string) string {
|
||||
}
|
||||
|
||||
fn is_valid_int_const(val, typ string) bool {
|
||||
x := val.int()
|
||||
return match typ {
|
||||
// x := val.int()
|
||||
match typ {
|
||||
'char'{
|
||||
0 <= x && x <= 255
|
||||
x := val.int()
|
||||
return 0 <= x && x <= 255
|
||||
}
|
||||
'byte'{
|
||||
0 <= x && x <= 255
|
||||
x := val.int()
|
||||
return 0 <= x && x <= 255
|
||||
}
|
||||
'u16'{
|
||||
0 <= x && x <= 65535
|
||||
x := val.u16()
|
||||
return 0 <= x && x <= 65535
|
||||
}
|
||||
// case 'u32': return 0 <= x && x <= math.MaxU32
|
||||
// case 'u64': return 0 <= x && x <= math.MaxU64
|
||||
// ////////////
|
||||
'i8'{
|
||||
-128 <= x && x <= 127
|
||||
x := val.i8()
|
||||
return -128 <= x && x <= 127
|
||||
}
|
||||
/*
|
||||
case 'i16': return math.min_i16 <= x && x <= math.max_i16
|
||||
@ -929,7 +933,7 @@ fn is_valid_int_const(val, typ string) bool {
|
||||
// x64 := val.i64()
|
||||
// return i64(-(1<<63)) <= x64 && x64 <= i64((1<<63)-1)
|
||||
else {
|
||||
true}}
|
||||
return true}}
|
||||
}
|
||||
|
||||
fn (p mut Parser) typ_to_fmt(typ string, level int) string {
|
||||
|
Loading…
Reference in New Issue
Block a user