Skip to content

Commit ccfa65a

Browse files
committed
bootstrap: cleanup code checking for overflowing int literals, ease forwards compatibility with V versions before ef758a7
1 parent 5407dbb commit ccfa65a

File tree

4 files changed

+6
-14
lines changed

4 files changed

+6
-14
lines changed

vlib/os/os.c.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,7 @@ pub fn last_error() IError {
10381038
}
10391039

10401040
// Magic constant because zero is used explicitly at times
1041-
pub const error_code_not_set = 0x7EFEFEFE
1041+
pub const error_code_not_set = int(0x7EFEFEFE)
10421042

10431043
@[params]
10441044
pub struct SystemError {

vlib/v/builder/cc.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ fn (mut v Builder) setup_ccompiler_options(ccompiler string) {
169169
if v.pref.os == .macos && os.exists('/opt/procursus') {
170170
ccoptions.linker_flags << '-Wl,-rpath,/opt/procursus/lib'
171171
}
172-
mut user_darwin_version := 999_999_999
172+
mut user_darwin_version := 999_999
173173
mut user_darwin_ppc := false
174174
$if macos {
175175
user_darwin_version = os.uname().release.split('.')[0].int()

vlib/v/checker/assign.v

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,8 @@ fn (mut c Checker) assign_stmt(mut node ast.AssignStmt) {
211211
}
212212
if left_type == ast.int_type {
213213
if mut right is ast.IntegerLiteral {
214-
mut is_large := right.val.len > 13
215-
if !is_large && right.val.len > 9 {
216-
val := right.val.i64()
217-
is_large = overflows_i32(val)
218-
}
219-
if is_large {
214+
val := right.val.i64()
215+
if overflows_i32(val) {
220216
c.error('overflow in implicit type `int`, use explicit type casting instead',
221217
right.pos)
222218
}

vlib/v/checker/checker.v

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,12 +1789,8 @@ fn (mut c Checker) const_decl(mut node ast.ConstDecl) {
17891789
// Check for int overflow
17901790
if field.typ == ast.int_type {
17911791
if mut field.expr is ast.IntegerLiteral {
1792-
mut is_large := field.expr.val.len > 13
1793-
if !is_large && field.expr.val.len > 9 {
1794-
val := field.expr.val.i64()
1795-
is_large = overflows_i32(val)
1796-
}
1797-
if is_large {
1792+
val := field.expr.val.i64()
1793+
if overflows_i32(val) {
17981794
c.error('overflow in implicit type `int`, use explicit type casting instead',
17991795
field.expr.pos)
18001796
}

0 commit comments

Comments
 (0)