mirror of
https://github.com/vlang/v.git
synced 2025-09-08 14:51:53 -04:00
bootstrap: cleanup code checking for overflowing int literals, ease forwards compatibility with V versions before ef758a7
This commit is contained in:
parent
5407dbbde7
commit
ccfa65aa14
@ -1038,7 +1038,7 @@ pub fn last_error() IError {
|
||||
}
|
||||
|
||||
// Magic constant because zero is used explicitly at times
|
||||
pub const error_code_not_set = 0x7EFEFEFE
|
||||
pub const error_code_not_set = int(0x7EFEFEFE)
|
||||
|
||||
@[params]
|
||||
pub struct SystemError {
|
||||
|
@ -169,7 +169,7 @@ fn (mut v Builder) setup_ccompiler_options(ccompiler string) {
|
||||
if v.pref.os == .macos && os.exists('/opt/procursus') {
|
||||
ccoptions.linker_flags << '-Wl,-rpath,/opt/procursus/lib'
|
||||
}
|
||||
mut user_darwin_version := 999_999_999
|
||||
mut user_darwin_version := 999_999
|
||||
mut user_darwin_ppc := false
|
||||
$if macos {
|
||||
user_darwin_version = os.uname().release.split('.')[0].int()
|
||||
|
@ -211,12 +211,8 @@ fn (mut c Checker) assign_stmt(mut node ast.AssignStmt) {
|
||||
}
|
||||
if left_type == ast.int_type {
|
||||
if mut right is ast.IntegerLiteral {
|
||||
mut is_large := right.val.len > 13
|
||||
if !is_large && right.val.len > 9 {
|
||||
val := right.val.i64()
|
||||
is_large = overflows_i32(val)
|
||||
}
|
||||
if is_large {
|
||||
val := right.val.i64()
|
||||
if overflows_i32(val) {
|
||||
c.error('overflow in implicit type `int`, use explicit type casting instead',
|
||||
right.pos)
|
||||
}
|
||||
|
@ -1789,12 +1789,8 @@ fn (mut c Checker) const_decl(mut node ast.ConstDecl) {
|
||||
// Check for int overflow
|
||||
if field.typ == ast.int_type {
|
||||
if mut field.expr is ast.IntegerLiteral {
|
||||
mut is_large := field.expr.val.len > 13
|
||||
if !is_large && field.expr.val.len > 9 {
|
||||
val := field.expr.val.i64()
|
||||
is_large = overflows_i32(val)
|
||||
}
|
||||
if is_large {
|
||||
val := field.expr.val.i64()
|
||||
if overflows_i32(val) {
|
||||
c.error('overflow in implicit type `int`, use explicit type casting instead',
|
||||
field.expr.pos)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user