diff --git a/vlib/builtin/string.v b/vlib/builtin/string.v index bfccc11703..196a279bc5 100644 --- a/vlib/builtin/string.v +++ b/vlib/builtin/string.v @@ -1306,7 +1306,7 @@ pub fn (s string) strip_margin(del ...byte) string { mut ret := malloc(s.len + 1) mut count := 0 for i := 0; i < s.len; i++ { - if (s[i] in [`\n`, `\r`]) { + if s[i] in [`\n`, `\r`] { ret[count] = s[i] count++ // CRLF diff --git a/vlib/builtin/utf8.v b/vlib/builtin/utf8.v index 4d48dc0a3f..6b4e83b99c 100644 --- a/vlib/builtin/utf8.v +++ b/vlib/builtin/utf8.v @@ -16,14 +16,14 @@ pub fn utf32_to_str(code u32) string { buffer[0] = icode return tos(buffer, 1) } - if (icode <= 2047/* 0x7FF */) { + if icode <= 2047/* 0x7FF */ { buffer[0] = 192/*0xC0*/ | (icode>>6)/* 110xxxxx */ buffer[1] = 128/*0x80*/ | (icode & 63/*0x3F*/)/* 10xxxxxx */ return tos(buffer, 2) } - if (icode <= 65535/* 0xFFFF */) { + if icode <= 65535/* 0xFFFF */ { buffer[0] = 224/*0xE0*/ | (icode>>12)/* 1110xxxx */ buffer[1] = 128/*0x80*/ | ((icode>>6) & 63/*0x3F*/)/* 10xxxxxx */ @@ -32,7 +32,7 @@ pub fn utf32_to_str(code u32) string { return tos(buffer, 3) } - if (icode <= 1114111/* 0x10FFFF */) { + if icode <= 1114111/* 0x10FFFF */ { buffer[0] = 240/*0xF0*/ | (icode>>18)/* 11110xxx */ buffer[1] = 128/*0x80*/ | ((icode>>12) & 63/*0x3F*/)/* 10xxxxxx */ @@ -54,14 +54,14 @@ pub fn utf32_to_str_no_malloc(code u32, buf voidptr) string { buffer[0] = icode return tos(buffer, 1) } - if (icode <= 2047/* 0x7FF */) { + if icode <= 2047/* 0x7FF */ { buffer[0] = 192/*0xC0*/ | (icode>>6)/* 110xxxxx */ buffer[1] = 128/*0x80*/ | (icode & 63/*0x3F*/)/* 10xxxxxx */ return tos(buffer, 2) } - if (icode <= 65535/* 0xFFFF */) { + if icode <= 65535/* 0xFFFF */ { buffer[0] = 224/*0xE0*/ | (icode>>12)/* 1110xxxx */ buffer[1] = 128/*0x80*/ | ((icode>>6) & 63/*0x3F*/)/* 10xxxxxx */ @@ -70,7 +70,7 @@ pub fn utf32_to_str_no_malloc(code u32, buf voidptr) string { return tos(buffer, 3) } - if (icode <= 1114111/* 0x10FFFF */) { + if icode <= 1114111/* 0x10FFFF */ { buffer[0] = 240/*0xF0*/ | (icode>>18)/* 11110xxx */ buffer[1] = 128/*0x80*/ | ((icode>>12) & 63/*0x3F*/)/* 10xxxxxx */ @@ -153,21 +153,21 @@ pub fn string_from_wide2(_wstr &u16, len int) string { fn utf8_len(c byte) int { mut b := 0 mut x := c - if ((x & 240) != 0) { + if (x & 240) != 0 { // 0xF0 x >>= 4 } else { b += 4 } - if ((x & 12) != 0) { + if (x & 12) != 0 { // 0x0C x >>= 2 } else { b += 2 } - if ((x & 2) == 0) { + if (x & 2) == 0 { // 0x02 b++ } diff --git a/vlib/compiler/gen_c.v b/vlib/compiler/gen_c.v index 40496c61f2..14d236665a 100644 --- a/vlib/compiler/gen_c.v +++ b/vlib/compiler/gen_c.v @@ -64,10 +64,10 @@ fn (p mut Parser) gen_fn_decl(f Fn, typ, str_args string) { // blank identifer assignment `_ = 111` fn (p mut Parser) gen_blank_identifier_assign() { - assign_error_tok_idx := p.token_idx + //assign_error_tok_idx := p.token_idx p.check_name() p.check_space(.assign) - is_indexer := p.peek() == .lsbr + //is_indexer := p.peek() == .lsbr is_fn_call,next_expr := p.is_expr_fn_call(p.token_idx) pos := p.cgen.add_placeholder() expr_tok := p.cur_tok_index() @@ -77,9 +77,9 @@ fn (p mut Parser) gen_blank_identifier_assign() { p.error_with_token_index('${next_expr}() $err_used_as_value', expr_tok) } p.is_var_decl = false - if !is_indexer && !is_fn_call { - p.error_with_token_index('assigning `$next_expr` to `_` is redundant', assign_error_tok_idx) - } + //if !is_indexer && !is_fn_call { + //p.error_with_token_index('assigning `$next_expr` to `_` is redundant', assign_error_tok_idx) + //} // handle or if p.tok == .key_orelse { p.gen_handle_option_or_else(typ, '', pos) diff --git a/vlib/compiler/live.v b/vlib/compiler/live.v index 9747dda876..61caf2a0aa 100644 --- a/vlib/compiler/live.v +++ b/vlib/compiler/live.v @@ -9,10 +9,10 @@ fn (v &V) generate_hotcode_reloading_compiler_flags() []string { mut a := []string if v.pref.is_live || v.pref.is_so { // See 'man dlopen', and test running a GUI program compiled with -live - if (v.pref.os == .linux || os.user_os() == 'linux') { + if v.pref.os == .linux || os.user_os() == 'linux' { a << '-rdynamic' } - if (v.pref.os == .mac || os.user_os() == 'mac') { + if v.pref.os == .mac || os.user_os() == 'mac' { a << '-flat_namespace' } } diff --git a/vlib/compiler/table.v b/vlib/compiler/table.v index 394e80821a..2c411b299e 100644 --- a/vlib/compiler/table.v +++ b/vlib/compiler/table.v @@ -388,7 +388,7 @@ fn (p &Parser) known_fn_in_mod(name string) bool { existing_fn := p.table.find_fn(name) or { return false } - if (existing_fn.mod == p.mod || existing_fn.mod == 'builtin') { + if existing_fn.mod == p.mod || existing_fn.mod == 'builtin' { return true } return false diff --git a/vlib/os/os.v b/vlib/os/os.v index 60385de082..1a445ac97a 100644 --- a/vlib/os/os.v +++ b/vlib/os/os.v @@ -699,7 +699,7 @@ pub fn get_lines() []string { mut inputstr := []string for { line = get_line() - if (line.len <= 0) { + if line.len <= 0 { break } line = line.trim_space() diff --git a/vlib/strconv/atof.v b/vlib/strconv/atof.v index f1f0ca6748..5111383a7b 100644 --- a/vlib/strconv/atof.v +++ b/vlib/strconv/atof.v @@ -334,7 +334,7 @@ fn parser(s string) (int,PrepNumber) { result = parser_pzero } } - else if (pn.exponent > 309) { + else if pn.exponent > 309 { if pn.negative { result = parser_minf } diff --git a/vlib/time/time.v b/vlib/time/time.v index 8a29b5c510..b4287d61e6 100644 --- a/vlib/time/time.v +++ b/vlib/time/time.v @@ -172,7 +172,7 @@ pub fn day_of_week(y, m, d int) int { // https://stackoverflow.com/a/6385934 t := [0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4] mut sy := y - if (m < 3) { + if m < 3 { sy = sy - 1 } return (sy + sy / 4 - sy / 100 + sy / 400 + t[m - 1] + d - 1) % 7 + 1 diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 274b91f773..fb7e9fe4ae 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -961,6 +961,12 @@ pub fn (c mut Checker) if_expr(node mut ast.IfExpr) table.Type { } node.typ = table.void_type for i, branch in node.branches { + match branch.cond { + ast.ParExpr{ + c.error('unnecessary `()` in an if condition. use `if expr {` instead of `if (expr) {`.', node.pos) + } + else {} + } typ := c.expr(branch.cond) if i < node.branches.len - 1 || !node.has_else { typ_sym := c.table.get_type_symbol(typ) diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index fa6bff07d3..dfe1f9745e 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -785,7 +785,7 @@ fn (g mut Gen) fn_args(args []table.Arg, is_variadic bool) { is_varg := i == args.len - 1 && is_variadic if is_varg { varg_type_str := int(arg.typ).str() - if (!varg_type_str in g.variadic_args) { + if !(varg_type_str in g.variadic_args) { g.variadic_args[varg_type_str] = 0 } arg_type_name = 'varg_' + g.typ(arg.typ).replace('*', '_ptr') diff --git a/vlib/v/parser/comptime.v b/vlib/v/parser/comptime.v index 68da656cd9..75238cd5a1 100644 --- a/vlib/v/parser/comptime.v +++ b/vlib/v/parser/comptime.v @@ -29,7 +29,7 @@ fn (p mut Parser) comp_if() ast.CompIf { if ((!is_not && os != p.pref.os) || (is_not && os == p.pref.os)) && !p.pref.output_cross_c { skip_os = true p.check(.lcbr) - p.warn('SKIPPING $val os=$os p.pref.os=$p.pref.os') + //p.warn('skipping $if $val os=$os p.pref.os=$p.pref.os') mut stack := 1 for { if p.tok.kind == .key_return { @@ -74,6 +74,10 @@ fn (p mut Parser) comp_if() ast.CompIf { return node } +const ( +todo_delete_me = pref.OS.linux // TODO import warning bug +) + fn os_from_string(os string) pref.OS { match os { 'linux' {