From f1f05c943e0a71da298a1e7e501ab67570e7c9f4 Mon Sep 17 00:00:00 2001 From: vbot Date: Mon, 25 Apr 2022 17:09:51 +0000 Subject: [PATCH] [v:master] b81f06e36 - checker: remove already handled "undefined" errors --- v.c | 634 ++++++++++++++++++++++++++++++++++++-------------------- v_win.c | 626 +++++++++++++++++++++++++++++++++++-------------------- 2 files changed, 806 insertions(+), 454 deletions(-) diff --git a/v.c b/v.c index 2fe40dd..cde7a09 100644 --- a/v.c +++ b/v.c @@ -1,11 +1,11 @@ -#define V_COMMIT_HASH "9d764cd25" +#define V_COMMIT_HASH "b81f06e36" #ifndef V_COMMIT_HASH - #define V_COMMIT_HASH "5e8c4a3" + #define V_COMMIT_HASH "9d764cd25" #endif #ifndef V_CURRENT_COMMIT_HASH - #define V_CURRENT_COMMIT_HASH "9d764cd" + #define V_CURRENT_COMMIT_HASH "b81f06e" #endif // V comptime_definitions: @@ -9211,6 +9211,7 @@ Option_void v__checker__Checker_check_expected(v__checker__Checker* c, v__ast__T VV_LOCAL_SYMBOL string v__checker__Checker_expected_msg(v__checker__Checker* c, v__ast__Type got, v__ast__Type expected); bool v__checker__Checker_symmetric_check(v__checker__Checker* c, v__ast__Type left, v__ast__Type right); void v__checker__Checker_infer_fn_generic_types(v__checker__Checker* c, v__ast__Fn func, v__ast__CallExpr* node); +int v__checker__Checker_sizeof_integer(v__checker__Checker* c, v__ast__Type a); int _const_v__checker__int_min; // inited later int _const_v__checker__int_max = 2147483647; // precomputed #define _const_v__checker__expr_level_cutoff_limit 40 @@ -13380,12 +13381,12 @@ int strings__levenshtein_distance(string a, string b) { array_set(&f, j, &(int[]) { j }); } for (int _t1 = 0; _t1 < a.len; ++_t1) { - byte ca = a.str[_t1]; + u8 ca = a.str[_t1]; int j = 1; int fj1 = (*(int*)/*ee elem_sym */array_get(f, 0)); (*(int*)/*ee elem_sym */array_get(f, 0))++; for (int _t2 = 0; _t2 < b.len; ++_t2) { - byte cb = b.str[_t2]; + u8 cb = b.str[_t2]; int mn = ((*(int*)/*ee elem_sym */array_get(f, j)) + 1 <= (*(int*)/*ee elem_sym */array_get(f, j - 1)) + 1 ? ((*(int*)/*ee elem_sym */array_get(f, j)) + 1) : ((*(int*)/*ee elem_sym */array_get(f, j - 1)) + 1)); if (cb != ca) { mn = (mn <= fj1 + 1 ? (mn) : (fj1 + 1)); @@ -13473,7 +13474,7 @@ string strings__find_between_pair_u8(string input, u8 start, u8 end) { int marks = 0; int start_index = -1; for (int i = 0; i < input.len; ++i) { - byte b = input.str[i]; + u8 b = input.str[i]; if (b == start) { if (start_index == -1) { start_index = i + 1; @@ -15234,7 +15235,7 @@ string strconv__f64_to_str_lnd1(f64 f, int dec_digit) { int exp_sgn = 1; int dot_res_sp = -1; for (int _t2 = 0; _t2 < s.len; ++_t2) { - byte c = s.str[_t2]; + u8 c = s.str[_t2]; if (c == ('-')) { sgn = -1; @@ -15692,7 +15693,7 @@ string strconv__fxx_to_str_l_parse(string s) { int exp = 0; int exp_sgn = 1; for (int _t2 = 0; _t2 < s.len; ++_t2) { - byte c = s.str[_t2]; + u8 c = s.str[_t2]; if (c == '-') { sgn = -1; i++; @@ -15801,7 +15802,7 @@ string strconv__fxx_to_str_l_parse_no_dot(string s) { int exp = 0; int exp_sgn = 1; for (int _t2 = 0; _t2 < s.len; ++_t2) { - byte c = s.str[_t2]; + u8 c = s.str[_t2]; if (c == '-') { sgn = -1; i++; @@ -20726,9 +20727,9 @@ Array_string string_split_any(string s, string delim) { return string_split(s, _SLIT("")); } for (int index = 0; index < s.len; ++index) { - byte ch = s.str[index]; + u8 ch = s.str[index]; for (int _t2 = 0; _t2 < delim.len; ++_t2) { - byte delim_ch = delim.str[_t2]; + u8 delim_ch = delim.str[_t2]; if (ch == delim_ch) { array_push((array*)&res, _MOV((string[]){ string_substr(s, i, index) })); i = index + 1; @@ -20755,7 +20756,7 @@ Array_string string_split_nth(string s, string delim, int nth) { if (delim.len == (0)) { i = 1; for (int _t1 = 0; _t1 < s.len; ++_t1) { - byte ch = s.str[_t1]; + u8 ch = s.str[_t1]; if (nth > 0 && i >= nth) { array_push((array*)&res, _MOV((string[]){ string_substr(s, i, (s).len) })); break; @@ -21015,9 +21016,9 @@ Array_int prefix; int string_index_any(string s, string chars) { for (int i = 0; i < s.len; ++i) { - byte ss = s.str[i]; + u8 ss = s.str[i]; for (int _t1 = 0; _t1 < chars.len; ++_t1) { - byte c = chars.str[_t1]; + u8 c = chars.str[_t1]; if (c == ss) { return i; } @@ -21119,7 +21120,7 @@ int string_count(string s, string substr) { if (substr.len == 1) { u8 target = substr.str[ 0]; for (int _t3 = 0; _t3 < s.len; ++_t3) { - byte letter = s.str[_t3]; + u8 letter = s.str[_t3]; if (letter == target) { n++; } @@ -21150,7 +21151,7 @@ bool string_contains(string s, string substr) { bool string_contains_any(string s, string chars) { for (int _t1 = 0; _t1 < chars.len; ++_t1) { - byte c = chars.str[_t1]; + u8 c = chars.str[_t1]; if (string_contains(s, u8_ascii_str(c))) { return true; } @@ -21339,7 +21340,7 @@ string string_trim(string s, string cutset) { if (!(pos_left <= s.len && pos_right >= -1 && cs_match)) break; cs_match = false; for (int _t2 = 0; _t2 < cutset.len; ++_t2) { - byte cs = cutset.str[_t2]; + u8 cs = cutset.str[_t2]; if (s.str[ pos_left] == cs) { pos_left++; cs_match = true; @@ -21347,7 +21348,7 @@ string string_trim(string s, string cutset) { } } for (int _t3 = 0; _t3 < cutset.len; ++_t3) { - byte cs = cutset.str[_t3]; + u8 cs = cutset.str[_t3]; if (s.str[ pos_right] == cs) { pos_right--; cs_match = true; @@ -21371,7 +21372,7 @@ string string_trim_left(string s, string cutset) { if (!(pos < s.len)) break; bool found = false; for (int _t2 = 0; _t2 < cutset.len; ++_t2) { - byte cs = cutset.str[_t2]; + u8 cs = cutset.str[_t2]; if (s.str[ pos] == cs) { found = true; break; @@ -21395,7 +21396,7 @@ string string_trim_right(string s, string cutset) { if (!(pos >= 0)) break; bool found = false; for (int _t2 = 0; _t2 < cutset.len; ++_t2) { - byte cs = cutset.str[_t2]; + u8 cs = cutset.str[_t2]; if (s.str[ pos] == cs) { found = true; } @@ -21612,7 +21613,7 @@ string string_after(string s, string sub) { string string_after_char(string s, u8 sub) { int pos = -1; for (int i = 0; i < s.len; ++i) { - byte c = s.str[i]; + u8 c = s.str[i]; if (c == sub) { pos = i; break; @@ -21687,7 +21688,7 @@ int string_hash(string s) { u32 h = ((u32)(0U)); if (h == 0U && s.len > 0) { for (int _t1 = 0; _t1 < s.len; ++_t1) { - byte c = s.str[_t1]; + u8 c = s.str[_t1]; h = h * 31U + ((u32)(c)); } } @@ -21734,7 +21735,7 @@ Array_string string_fields(string s) { bool is_in_word = false; bool is_space = false; for (int i = 0; i < s.len; ++i) { - byte c = s.str[i]; + u8 c = s.str[i]; is_space = (c == 32 || c == 9 || c == 10); if (!is_space) { word_len++; @@ -23216,7 +23217,7 @@ multi_return_string_int os__fd_read(int fd, int maxbytes) { Option_os__File os__open_file(string path, string mode, Array_int options) { int flags = 0; for (int _t1 = 0; _t1 < mode.len; ++_t1) { - byte m = mode.str[_t1]; + u8 m = mode.str[_t1]; if (m == ('w')) { flags |= (_const_os__o_create | _const_os__o_trunc); @@ -31889,7 +31890,7 @@ inline VV_LOCAL_SYMBOL semver__Version semver__increment_version(semver__Version VV_LOCAL_SYMBOL bool semver__is_valid_string(string input) { for (int _t1 = 0; _t1 < input.len; ++_t1) { - byte c = input.str[_t1]; + u8 c = input.str[_t1]; if (!(u8_is_letter(c) || u8_is_digit(c) || c == '.' || c == '-')) { bool _t2 = false; return _t2; @@ -31901,7 +31902,7 @@ VV_LOCAL_SYMBOL bool semver__is_valid_string(string input) { VV_LOCAL_SYMBOL bool semver__is_valid_number(string input) { for (int _t1 = 0; _t1 < input.len; ++_t1) { - byte c = input.str[_t1]; + u8 c = input.str[_t1]; if (!u8_is_digit(c)) { bool _t2 = false; return _t2; @@ -35278,7 +35279,7 @@ void v__pref__Preferences_fill_with_defaults(v__pref__Preferences* p) { } #endif } - string vhash = _SLIT("5e8c4a3"); + string vhash = _SLIT("9d764cd25"); p->cache_manager = v__vcache__new_cache_manager(new_array_from_c_array(7, 7, sizeof(string), _MOV((string[7]){string_clone(vhash), str_intp(6, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = v__pref__Backend_str(p->backend)}}, {_SLIT(" | "), 0xfe10, {.d_s = v__pref__OS_str(p->os)}}, {_SLIT(" | "), 0xfe10, {.d_s = p->ccompiler}}, {_SLIT(" | "), 0xfe10, {.d_s = p->is_prod ? _SLIT("true") : _SLIT("false")}}, {_SLIT(" | "), 0xfe10, {.d_s = p->sanitize ? _SLIT("true") : _SLIT("false")}}, {_SLIT0, 0, { .d_c = 0 }}})), string_clone(string_trim_space(p->cflags)), string_clone(string_trim_space(p->third_party_option)), string_clone(Array_string_str(p->compile_defines_all)), string_clone(Array_string_str(p->compile_defines)), string_clone(Array_string_str(p->lookup_path))}))); if (string__eq(os__user_os(), _SLIT("windows"))) { p->use_cache = false; @@ -37821,7 +37822,7 @@ void help__print_and_exit(string topic) { string vroot = os__dir(vexe); string topicdir = os__join_path(vroot, new_array_from_c_array(3, 3, sizeof(string), _MOV((string[3]){_SLIT("cmd"), _SLIT("v"), _SLIT("help")}))); for (int _t1 = 0; _t1 < topic.len; ++_t1) { - byte b = topic.str[_t1]; + u8 b = topic.str[_t1]; if ((b >= 'a' && b <= 'z') || b == '-' || (b >= '0' && b <= '9')) { continue; } @@ -38304,7 +38305,7 @@ inline bool v__util__is_func_char(u8 c) { bool v__util__contains_capital(string s) { for (int _t1 = 0; _t1 < s.len; ++_t1) { - byte c = s.str[_t1]; + u8 c = s.str[_t1]; if (c >= 'A' && c <= 'Z') { bool _t2 = true; return _t2; @@ -39839,6 +39840,15 @@ Option_void v__ast__Stmt_check_c_expr(v__ast__Stmt stmt) { if (stmt._typ == 298 /* v.ast.AssignStmt */) { return (Option_void){0}; } + else if (stmt._typ == 307 /* v.ast.ForCStmt */) { + return (Option_void){0}; + } + else if (stmt._typ == 308 /* v.ast.ForInStmt */) { + return (Option_void){0}; + } + else if (stmt._typ == 309 /* v.ast.ForStmt */) { + return (Option_void){0}; + } else if (stmt._typ == 306 /* v.ast.ExprStmt */) { if (v__ast__Expr_is_expr((*stmt._v__ast__ExprStmt).expr)) { return (Option_void){0}; @@ -47250,7 +47260,7 @@ bool v__checker__Checker_assign_stmt_defer_0 = false; v__ast__Type left_elem_type = v__ast__Table_unaliased_type(c->table, left_info.elem_type); v__ast__Array right_info = /* as */ *(v__ast__Array*)__as_cast((right_sym->info)._v__ast__Array,(right_sym->info)._typ, 411) /*expected idx: 411, name: v.ast.Array */ ; v__ast__Type right_elem_type = v__ast__Table_unaliased_type(c->table, right_info.elem_type); - if (left_info.nr_dims == right_info.nr_dims && v__ast__Type_alias_eq(left_elem_type, right_elem_type)) { + if (v__ast__Type_nr_muls(left_type_unwrapped) == v__ast__Type_nr_muls(right_type_unwrapped) && left_info.nr_dims == right_info.nr_dims && v__ast__Type_alias_eq(left_elem_type, right_elem_type)) { continue; } } @@ -47660,7 +47670,10 @@ Option_void v__checker__Checker_check_expected_call_arg(v__checker__Checker* c, } return (Option_void){0}; } - return (Option_void){ .state=2, .err=_v_error( str_intp(3, _MOV((StrIntpData[]){{_SLIT("cannot use `"), 0xfe10, {.d_s = got_typ_str}}, {_SLIT("` as `"), 0xfe10, {.d_s = expected_typ_str}}, {_SLIT("`"), 0, { .d_c = 0 }}}))), .data={EMPTY_STRUCT_INITIALIZATION} }; + if (!v__ast__Type_alias_eq(got, _const_v__ast__void_type)) { + return (Option_void){ .state=2, .err=_v_error( str_intp(3, _MOV((StrIntpData[]){{_SLIT("cannot use `"), 0xfe10, {.d_s = got_typ_str}}, {_SLIT("` as `"), 0xfe10, {.d_s = expected_typ_str}}, {_SLIT("`"), 0, { .d_c = 0 }}}))), .data={EMPTY_STRUCT_INITIALIZATION} }; + } + return (Option_void){0}; } VV_LOCAL_SYMBOL bool v__checker__Checker_check_same_module(v__checker__Checker _v_toheap_c, v__ast__Type got, v__ast__Type expected) { @@ -47908,10 +47921,10 @@ VV_LOCAL_SYMBOL v__ast__Type v__checker__Checker_promote_num(v__checker__Checker v__ast__Type type_hi = left_type; v__ast__Type type_lo = right_type; if (v__ast__Type_idx(type_hi) < v__ast__Type_idx(type_lo)) { - v__ast__Type _var_16285 = type_hi; - v__ast__Type _var_16294 = type_lo; - type_hi = _var_16294; - type_lo = _var_16285; + v__ast__Type _var_16316 = type_hi; + v__ast__Type _var_16325 = type_lo; + type_hi = _var_16325; + type_lo = _var_16316; } int idx_hi = v__ast__Type_idx(type_hi); int idx_lo = v__ast__Type_idx(type_lo); @@ -48217,6 +48230,44 @@ void v__checker__Checker_infer_fn_generic_types(v__checker__Checker* c, v__ast__ } } +int v__checker__Checker_sizeof_integer(v__checker__Checker* c, v__ast__Type a) { + v__ast__Type t = (Array_int_contains(_const_v__ast__unsigned_integer_type_idxs, a) ? (v__ast__Type_flip_signedness(a)) : (a)); + int_literal _t1 = 0; + + if (t == (_const_v__ast__char_type_idx) || t == (_const_v__ast__i8_type_idx)) { + _t1 = 1; + } + else if (t == (_const_v__ast__i16_type_idx)) { + _t1 = 2; + } + else if (t == (_const_v__ast__int_type_idx)) { + _t1 = 4; + } + else if (t == (_const_v__ast__rune_type_idx)) { + _t1 = 4; + } + else if (t == (_const_v__ast__i64_type_idx)) { + _t1 = 8; + } + else if (t == (_const_v__ast__isize_type_idx)) { + _t1 = (c->pref->m64 ? (8) : (4)); + } + else if (t == (_const_v__ast__int_literal_type)) { + string s = v__ast__Table_type_to_str(c->table, a); + _v_panic( str_intp(2, _MOV((StrIntpData[]){{_SLIT("`"), 0xfe10, {.d_s = s}}, {_SLIT("` has unknown size"), 0, { .d_c = 0 }}}))); + VUNREACHABLE(); + _t1 = 0; + } + else { + string s = v__ast__Table_type_to_str(c->table, a); + _v_panic( str_intp(2, _MOV((StrIntpData[]){{_SLIT("`"), 0xfe10, {.d_s = s}}, {_SLIT("` is not an integer"), 0, { .d_c = 0 }}}))); + VUNREACHABLE(); + _t1 = 0; + }int r = _t1; + int _t2 = r; + return _t2; +} + VV_LOCAL_SYMBOL Array_string v__checker__all_valid_comptime_idents(void) { Array_string res = __new_array_with_default(0, 0, sizeof(string), 0); _PUSH_MANY(&res, (_const_v__checker__valid_comptime_if_os), _t1, Array_string); @@ -48856,6 +48907,14 @@ v__ast__Type former_expected_type; string rt = v__ast__Table_sym(c->table, right_type)->name; v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("negative value cannot be compared with `"), 0xfe10, {.d_s = rt}}, {_SLIT("`"), 0, { .d_c = 0 }}})), (*node->left._v__ast__IntegerLiteral).pos); } + } else if (is_left_type_signed != is_right_type_signed && left_type != _const_v__ast__int_literal_type_idx && right_type != _const_v__ast__int_literal_type_idx) { + int ls = v__checker__Checker_sizeof_integer(c, left_type); + int rs = v__checker__Checker_sizeof_integer(c, right_type); + if ((is_left_type_signed && ls < rs) || (is_right_type_signed && rs < ls)) { + string lt = v__ast__Table_sym(c->table, left_type)->name; + string rt = v__ast__Table_sym(c->table, right_type)->name; + v__checker__Checker_error(c, str_intp(3, _MOV((StrIntpData[]){{_SLIT("`"), 0xfe10, {.d_s = lt}}, {_SLIT("` cannot be compared with `"), 0xfe10, {.d_s = rt}}, {_SLIT("`"), 0, { .d_c = 0 }}})), node->pos); + } } } break; @@ -49121,8 +49180,8 @@ v__ast__Type former_expected_type; v__checker__Checker_error(c, _SLIT("array append cannot be used in an expression"), node->pos); } v__checker__Checker_check_expr_opt_call(c, node->right, right_type); - multi_return_string_v__token__Pos mr_33156 = v__checker__Checker_fail_if_immutable(c, node->left); - node->auto_locked = mr_33156.arg0; + multi_return_string_v__token__Pos mr_33737 = v__checker__Checker_fail_if_immutable(c, node->left); + node->auto_locked = mr_33737.arg0; v__ast__Type left_value_type = v__ast__Table_value_type(c->table, v__checker__Checker_unwrap_generic(c, left_type)); v__ast__TypeSymbol* left_value_sym = v__ast__Table_sym(c->table, v__checker__Checker_unwrap_generic(c, left_value_type)); if (left_value_sym->kind == v__ast__Kind__interface_) { @@ -49558,19 +49617,19 @@ VV_LOCAL_SYMBOL multi_return_string_v__token__Pos v__checker__Checker_fail_if_im if (v__ast__Type_has_flag(elem_type, v__ast__TypeFlag__shared_f)) { v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("you have to create a handle and `lock` it to modify `shared` "), 0xfe10, {.d_s = kind}}, {_SLIT(" element"), 0, { .d_c = 0 }}})), v__token__Pos_extend(v__ast__Expr_pos((*expr._v__ast__IndexExpr).left), (*expr._v__ast__IndexExpr).pos)); } - multi_return_string_v__token__Pos mr_43532 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__IndexExpr).left); - to_lock = mr_43532.arg0; - pos = mr_43532.arg1; + multi_return_string_v__token__Pos mr_44113 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__IndexExpr).left); + to_lock = mr_44113.arg0; + pos = mr_44113.arg1; } else if (expr._typ == 281 /* v.ast.ParExpr */) { - multi_return_string_v__token__Pos mr_43601 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__ParExpr).expr); - to_lock = mr_43601.arg0; - pos = mr_43601.arg1; + multi_return_string_v__token__Pos mr_44182 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__ParExpr).expr); + to_lock = mr_44182.arg0; + pos = mr_44182.arg1; } else if (expr._typ == 283 /* v.ast.PrefixExpr */) { - multi_return_string_v__token__Pos mr_43673 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__PrefixExpr).right); - to_lock = mr_43673.arg0; - pos = mr_43673.arg1; + multi_return_string_v__token__Pos mr_44254 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__PrefixExpr).right); + to_lock = mr_44254.arg0; + pos = mr_44254.arg1; } else if (expr._typ == 286 /* v.ast.SelectorExpr */) { if ((*expr._v__ast__SelectorExpr).expr_type == 0) { @@ -49620,9 +49679,9 @@ VV_LOCAL_SYMBOL multi_return_string_v__token__Pos v__checker__Checker_fail_if_im string type_str = v__ast__Table_type_to_str(c->table, (*expr._v__ast__SelectorExpr).expr_type); v__checker__Checker_error(c, str_intp(3, _MOV((StrIntpData[]){{_SLIT("field `"), 0xfe10, {.d_s = (*expr._v__ast__SelectorExpr).field_name}}, {_SLIT("` of struct `"), 0xfe10, {.d_s = type_str}}, {_SLIT("` is immutable"), 0, { .d_c = 0 }}})), (*expr._v__ast__SelectorExpr).pos); } - multi_return_string_v__token__Pos mr_45137 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__SelectorExpr).expr); - to_lock = mr_45137.arg0; - pos = mr_45137.arg1; + multi_return_string_v__token__Pos mr_45718 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__SelectorExpr).expr); + to_lock = mr_45718.arg0; + pos = mr_45718.arg1; } if ((to_lock).len != 0) { explicit_lock_needed = true; @@ -49728,9 +49787,9 @@ VV_LOCAL_SYMBOL multi_return_string_v__token__Pos v__checker__Checker_fail_if_im } else if (expr._typ == 252 /* v.ast.CallExpr */) { if (string__eq((*expr._v__ast__CallExpr).name, _SLIT("slice"))) { - multi_return_string_v__token__Pos mr_46960 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__CallExpr).left); - to_lock = mr_46960.arg0; - pos = mr_46960.arg1; + multi_return_string_v__token__Pos mr_47541 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__CallExpr).left); + to_lock = mr_47541.arg0; + pos = mr_47541.arg1; if ((to_lock).len != 0) { explicit_lock_needed = true; } @@ -50076,7 +50135,6 @@ v__ast__Type v__checker__Checker_selector_expr(v__checker__Checker* c, v__ast__S c->inside_selector_expr = old_selector_expr; c->using_new_err_struct = using_new_err_struct_save; if (typ == _const_v__ast__void_type_idx) { - v__checker__Checker_error(c, _SLIT("`void` type has no fields"), node->pos); v__ast__Type _t6 = _const_v__ast__void_type; return _t6; } @@ -50135,9 +50193,9 @@ v__ast__Type v__checker__Checker_selector_expr(v__checker__Checker* c, v__ast__S *(multi_return_v__ast__StructField_Array_v__ast__Type*) _t13.data = (multi_return_v__ast__StructField_Array_v__ast__Type){.arg0=((v__ast__StructField){.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.type_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.has_default_expr = 0,.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.is_pub = 0,.default_val = (string){.str=(byteptr)"", .is_lit=1},.is_mut = 0,.is_global = 0,.is_volatile = 0,.default_expr = {0},.default_expr_typ = 0,.name = (string){.str=(byteptr)"", .is_lit=1},.typ = 0,}),.arg1=__new_array_with_default(0, 0, sizeof(v__ast__Type), 0)}; } - multi_return_v__ast__StructField_Array_v__ast__Type mr_60068 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t13.data); - field = mr_60068.arg0; - embed_types = mr_60068.arg1; + multi_return_v__ast__StructField_Array_v__ast__Type mr_60742 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t13.data); + field = mr_60742.arg0; + embed_types = mr_60742.arg1; node->from_embed_types = embed_types; if (sym->kind == v__ast__Kind__aggregate || sym->kind == v__ast__Kind__sum_type) { unknown_field_msg = IError_name_table[err._typ]._method_msg(err._object); @@ -50171,9 +50229,9 @@ v__ast__Type v__checker__Checker_selector_expr(v__checker__Checker* c, v__ast__S *(multi_return_v__ast__StructField_Array_v__ast__Type*) _t15.data = (multi_return_v__ast__StructField_Array_v__ast__Type){.arg0=((v__ast__StructField){.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.type_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.has_default_expr = 0,.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.is_pub = 0,.default_val = (string){.str=(byteptr)"", .is_lit=1},.is_mut = 0,.is_global = 0,.is_volatile = 0,.default_expr = {0},.default_expr_typ = 0,.name = (string){.str=(byteptr)"", .is_lit=1},.typ = 0,}),.arg1=__new_array_with_default(0, 0, sizeof(v__ast__Type), 0)}; } - multi_return_v__ast__StructField_Array_v__ast__Type mr_60899 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t15.data); - field = mr_60899.arg0; - embed_types = mr_60899.arg1; + multi_return_v__ast__StructField_Array_v__ast__Type mr_61573 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t15.data); + field = mr_61573.arg0; + embed_types = mr_61573.arg1; node->from_embed_types = embed_types; } } @@ -52403,8 +52461,8 @@ v__ast__Type v__checker__Checker_postfix_expr(v__checker__Checker* c, v__ast__Po string typ_str = v__ast__Table_type_to_str(c->table, typ); v__checker__Checker_error(c, str_intp(3, _MOV((StrIntpData[]){{_SLIT("invalid operation: "), 0xfe10, {.d_s = v__token__Kind_str(node->op)}}, {_SLIT(" (non-numeric type `"), 0xfe10, {.d_s = typ_str}}, {_SLIT("`)"), 0, { .d_c = 0 }}})), node->pos); } else { - multi_return_string_v__token__Pos mr_115132 = v__checker__Checker_fail_if_immutable(c, node->expr); - node->auto_locked = mr_115132.arg0; + multi_return_string_v__token__Pos mr_115806 = v__checker__Checker_fail_if_immutable(c, node->expr); + node->auto_locked = mr_115806.arg0; } v__ast__Type _t1 = typ; return _t1; @@ -55790,6 +55848,17 @@ v__ast__Type v__checker__Checker_fn_call(v__checker__Checker* c, v__ast__CallExp v__ast__Type _t15 = _const_v__ast__string_type; return _t15; } + if (!found && (node->left)._typ == 252 /* v.ast.CallExpr */) { + v__checker__Checker_expr(c, node->left); + v__ast__CallExpr expr = /* as */ *(v__ast__CallExpr*)__as_cast((node->left)._v__ast__CallExpr,(node->left)._typ, 252) /*expected idx: 252, name: v.ast.CallExpr */ ; + v__ast__TypeSymbol* sym = v__ast__Table_sym(c->table, expr.return_type); + if (sym->kind == v__ast__Kind__function) { + v__ast__FnType info = /* as */ *(v__ast__FnType*)__as_cast((sym->info)._v__ast__FnType,(sym->info)._typ, 443) /*expected idx: 443, name: v.ast.FnType */ ; + node->return_type = info.func.return_type; + found = true; + func = info.func; + } + } if (!found) { Option_v__ast__Fn _t16; if (_t16 = v__ast__Table_find_fn(c->table, fn_name), _t16.state == 0) { @@ -56042,9 +56111,9 @@ v__ast__Type v__checker__Checker_fn_call(v__checker__Checker* c, v__ast__CallExp v__checker__Checker_error(c, _SLIT("function with `shared` arguments cannot be called inside `lock`/`rlock` block"), call_arg->pos); } if (call_arg->is_mut) { - multi_return_string_v__token__Pos mr_28526 = v__checker__Checker_fail_if_immutable(c, call_arg->expr); - string to_lock = mr_28526.arg0; - v__token__Pos pos = mr_28526.arg1; + multi_return_string_v__token__Pos mr_28813 = v__checker__Checker_fail_if_immutable(c, call_arg->expr); + string to_lock = mr_28813.arg0; + v__token__Pos pos = mr_28813.arg1; if (!v__ast__Expr_is_lvalue(call_arg->expr)) { v__checker__Checker_error(c, _SLIT("cannot pass expression as `mut`"), v__ast__Expr_pos(call_arg->expr)); } @@ -56093,6 +56162,15 @@ v__ast__Type v__checker__Checker_fn_call(v__checker__Checker* c, v__ast__CallExp if (v__ast__Type_has_flag(param.typ, v__ast__TypeFlag__generic)) { continue; } + if (param_typ_sym->kind == v__ast__Kind__array && arg_typ_sym->kind == v__ast__Kind__array) { + v__ast__Array param_info = /* as */ *(v__ast__Array*)__as_cast((param_typ_sym->info)._v__ast__Array,(param_typ_sym->info)._typ, 411) /*expected idx: 411, name: v.ast.Array */ ; + v__ast__Type param_elem_type = v__ast__Table_unaliased_type(c->table, param_info.elem_type); + v__ast__Array arg_info = /* as */ *(v__ast__Array*)__as_cast((arg_typ_sym->info)._v__ast__Array,(arg_typ_sym->info)._typ, 411) /*expected idx: 411, name: v.ast.Array */ ; + v__ast__Type arg_elem_type = v__ast__Table_unaliased_type(c->table, arg_info.elem_type); + if (v__ast__Type_nr_muls(param.typ) == v__ast__Type_nr_muls(arg_typ) && param_info.nr_dims == arg_info.nr_dims && v__ast__Type_alias_eq(param_elem_type, arg_elem_type)) { + continue; + } + } if (c->pref->translated || c->file->is_translated) { if (v__ast__Type_alias_eq(param.typ, _const_v__ast__int_type) && arg_typ_sym->kind == v__ast__Kind__enum_) { continue; @@ -56387,9 +56465,9 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal *(multi_return_v__ast__Fn_Array_v__ast__Type*) _t22.data = (multi_return_v__ast__Fn_Array_v__ast__Type){.arg0=((v__ast__Fn){.is_variadic = 0,.language = 0,.is_pub = 0,.is_ctor_new = 0,.is_deprecated = 0,.is_noreturn = 0,.is_unsafe = 0,.is_placeholder = 0,.is_main = 0,.is_test = 0,.is_keep_alive = 0,.is_method = 0,.no_body = 0,.mod = (string){.str=(byteptr)"", .is_lit=1},.file = (string){.str=(byteptr)"", .is_lit=1},.file_mode = 0,.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.return_type_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.return_type = 0,.receiver_type = 0,.name = (string){.str=(byteptr)"", .is_lit=1},.params = __new_array(0, 0, sizeof(v__ast__Param)),.source_fn = 0,.usages = 0,.generic_names = __new_array(0, 0, sizeof(string)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.is_conditional = 0,.ctdefine_idx = 0,}),.arg1=__new_array_with_default(0, 0, sizeof(v__ast__Type), 0)}; } - multi_return_v__ast__Fn_Array_v__ast__Type mr_41745 = (*(multi_return_v__ast__Fn_Array_v__ast__Type*)_t22.data); - method = mr_41745.arg0; - embed_types = mr_41745.arg1; + multi_return_v__ast__Fn_Array_v__ast__Type mr_42485 = (*(multi_return_v__ast__Fn_Array_v__ast__Type*)_t22.data); + method = mr_42485.arg0; + embed_types = mr_42485.arg1; if (embed_types.len != 0) { is_method_from_embed = true; node->from_embed_types = embed_types; @@ -56410,9 +56488,9 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal v__checker__Checker_error(c, _SLIT("method with `shared` receiver cannot be called inside `lock`/`rlock` block"), node->pos); } if ((*(v__ast__Param*)/*ee elem_sym */array_get(method.params, 0)).is_mut) { - multi_return_string_v__token__Pos mr_42876 = v__checker__Checker_fail_if_immutable(c, node->left); - string to_lock = mr_42876.arg0; - v__token__Pos pos = mr_42876.arg1; + multi_return_string_v__token__Pos mr_43616 = v__checker__Checker_fail_if_immutable(c, node->left); + string to_lock = mr_43616.arg0; + v__token__Pos pos = mr_43616.arg1; if (!v__ast__Expr_is_lvalue(node->left)) { v__checker__Checker_error(c, _SLIT("cannot pass expression as `mut`"), v__ast__Expr_pos(node->left)); } @@ -56514,9 +56592,9 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal v__checker__Checker_error(c, _SLIT("method with `shared` arguments cannot be called inside `lock`/`rlock` block"), arg->pos); } if (arg->is_mut) { - multi_return_string_v__token__Pos mr_46845 = v__checker__Checker_fail_if_immutable(c, arg->expr); - string to_lock = mr_46845.arg0; - v__token__Pos pos = mr_46845.arg1; + multi_return_string_v__token__Pos mr_47585 = v__checker__Checker_fail_if_immutable(c, arg->expr); + string to_lock = mr_47585.arg0; + v__token__Pos pos = mr_47585.arg1; if (!param_is_mut) { string tok = v__ast__ShareType_str(arg->share); v__checker__Checker_error(c, str_intp(5, _MOV((StrIntpData[]){{_SLIT("`"), 0xfe10, {.d_s = node->name}}, {_SLIT("` parameter `"), 0xfe10, {.d_s = param.name}}, {_SLIT("` is not `"), 0xfe10, {.d_s = tok}}, {_SLIT("`, `"), 0xfe10, {.d_s = tok}}, {_SLIT("` is not needed`"), 0, { .d_c = 0 }}})), v__ast__Expr_pos(arg->expr)); @@ -56570,6 +56648,17 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal Option_void _t29 = v__checker__Checker_check_expected_call_arg(c, got_arg_typ, exp_arg_typ, node->language, *arg); if (_t29.state != 0 && _t29.err._typ != _IError_None___index) { IError err = _t29.err; + v__ast__TypeSymbol* param_typ_sym = v__ast__Table_sym(c->table, exp_arg_typ); + v__ast__TypeSymbol* arg_typ_sym = v__ast__Table_sym(c->table, got_arg_typ); + if (param_typ_sym->kind == v__ast__Kind__array && arg_typ_sym->kind == v__ast__Kind__array) { + v__ast__Array param_info = /* as */ *(v__ast__Array*)__as_cast((param_typ_sym->info)._v__ast__Array,(param_typ_sym->info)._typ, 411) /*expected idx: 411, name: v.ast.Array */ ; + v__ast__Type param_elem_type = v__ast__Table_unaliased_type(c->table, param_info.elem_type); + v__ast__Array arg_info = /* as */ *(v__ast__Array*)__as_cast((arg_typ_sym->info)._v__ast__Array,(arg_typ_sym->info)._typ, 411) /*expected idx: 411, name: v.ast.Array */ ; + v__ast__Type arg_elem_type = v__ast__Table_unaliased_type(c->table, arg_info.elem_type); + if (v__ast__Type_nr_muls(exp_arg_typ) == v__ast__Type_nr_muls(got_arg_typ) && param_info.nr_dims == arg_info.nr_dims && v__ast__Type_alias_eq(param_elem_type, arg_elem_type)) { + continue; + } + } if (!v__ast__Type_alias_eq(got_arg_typ, _const_v__ast__void_type)) { v__checker__Checker_error(c, str_intp(5, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = IError_name_table[err._typ]._method_msg(err._object)}}, {_SLIT(" in argument "), 0xfe07, {.d_i32 = i + 1}}, {_SLIT(" to `"), 0xfe10, {.d_s = left_sym->name}}, {_SLIT("."), 0xfe10, {.d_s = method_name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), arg->pos); } @@ -56698,8 +56787,8 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal return _t43; } - multi_return_v__ast__StructField_Array_v__ast__Type mr_53745 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t42.data); - node->from_embed_types = mr_53745.arg1; + multi_return_v__ast__StructField_Array_v__ast__Type mr_55050 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t42.data); + node->from_embed_types = mr_55050.arg1; v__ast__Type _t44 = info.func.return_type; return _t44; } @@ -56946,6 +57035,9 @@ VV_LOCAL_SYMBOL v__ast__Type v__checker__Checker_map_builtin_method_call(v__chec v__ast__Type ret_type = _const_v__ast__void_type; if (string__eq(method_name, _SLIT("clone")) || string__eq(method_name, _SLIT("move"))) { + if (node->args.len != 0) { + v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("`."), 0xfe10, {.d_s = method_name}}, {_SLIT("()` does not have any arguments"), 0, { .d_c = 0 }}})), (*(v__ast__CallArg*)/*ee elem_sym */array_get(node->args, 0)).pos); + } if (string_at(method_name, 0) == 'm') { v__checker__Checker_fail_if_immutable(c, node->left); } @@ -56957,6 +57049,9 @@ VV_LOCAL_SYMBOL v__ast__Type v__checker__Checker_map_builtin_method_call(v__chec ret_type = v__ast__Type_clear_flag(ret_type, v__ast__TypeFlag__shared_f); } else if (string__eq(method_name, _SLIT("keys"))) { + if (node->args.len != 0) { + v__checker__Checker_error(c, _SLIT("`.keys()` does not have any arguments"), (*(v__ast__CallArg*)/*ee elem_sym */array_get(node->args, 0)).pos); + } v__ast__Map info = /* as */ *(v__ast__Map*)__as_cast((left_sym.info)._v__ast__Map,(left_sym.info)._typ, 412) /*expected idx: 412, name: v.ast.Map */ ; int typ = v__ast__Table_find_or_register_array(c->table, info.key_type); ret_type = ((typ)); @@ -57065,6 +57160,9 @@ VV_LOCAL_SYMBOL v__ast__Type v__checker__Checker_array_builtin_method_call(v__ch v__checker__Checker_check_map_and_filter(c, false, elem_typ, *node); node->return_type = _const_v__ast__bool_type; } else if (string__eq(method_name, _SLIT("clone"))) { + if (node->args.len != 0) { + v__checker__Checker_error(c, _SLIT("`.clone()` does not have any arguments"), (*(v__ast__CallArg*)/*ee elem_sym */array_get(node->args, 0)).pos); + } node->receiver_type = v__ast__Type_ref(left_type); if (v__ast__Expr_is_auto_deref_var(node->left)) { node->return_type = v__ast__Type_deref(left_type); @@ -57079,18 +57177,37 @@ VV_LOCAL_SYMBOL v__ast__Type v__checker__Checker_array_builtin_method_call(v__ch } else if (string__eq(method_name, _SLIT("contains"))) { if (node->args.len != 1) { v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("`.contains()` expected 1 argument, but got "), 0xfe07, {.d_i32 = node->args.len}}, {_SLIT0, 0, { .d_c = 0 }}})), node->pos); - } else { - v__ast__Type arg_typ = v__ast__mktyp(v__checker__Checker_expr(c, (*(v__ast__CallArg*)/*ee elem_sym */array_get(node->args, 0)).expr)); - string elem_typ_str = v__ast__Table_type_to_str(c->table, elem_typ); - string arg_typ_str = v__ast__Table_type_to_str(c->table, arg_typ); - if (!v__ast__TypeSymbol_has_method(&left_sym, _SLIT("contains")) && !string__eq(elem_typ_str, arg_typ_str)) { - v__checker__Checker_error(c, str_intp(3, _MOV((StrIntpData[]){{_SLIT("`.contains()` expected `"), 0xfe10, {.d_s = elem_typ_str}}, {_SLIT("` argument, but got `"), 0xfe10, {.d_s = arg_typ_str}}, {_SLIT("`"), 0, { .d_c = 0 }}})), node->pos); + } else if (!v__ast__TypeSymbol_has_method(&left_sym, _SLIT("contains"))) { + v__ast__Type arg_typ = v__checker__Checker_expr(c, (*(v__ast__CallArg*)/*ee elem_sym */array_get(node->args, 0)).expr); + Option_void _t2 = v__checker__Checker_check_expected_call_arg(c, arg_typ, elem_typ, node->language, (*(v__ast__CallArg*)/*ee elem_sym */array_get(node->args, 0))); + if (_t2.state != 0 && _t2.err._typ != _IError_None___index) { + IError err = _t2.err; + v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = IError_name_table[err._typ]._method_msg(err._object)}}, {_SLIT(" in argument 1 to `.contains()`"), 0, { .d_c = 0 }}})), (*(v__ast__CallArg*)/*ee elem_sym */array_get(node->args, 0)).pos); + ; } + + ; } node->return_type = _const_v__ast__bool_type; } else if (string__eq(method_name, _SLIT("index"))) { + if (node->args.len != 1) { + v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("`.index()` expected 1 argument, but got "), 0xfe07, {.d_i32 = node->args.len}}, {_SLIT0, 0, { .d_c = 0 }}})), node->pos); + } else if (!v__ast__TypeSymbol_has_method(&left_sym, _SLIT("index"))) { + v__ast__Type arg_typ = v__checker__Checker_expr(c, (*(v__ast__CallArg*)/*ee elem_sym */array_get(node->args, 0)).expr); + Option_void _t3 = v__checker__Checker_check_expected_call_arg(c, arg_typ, elem_typ, node->language, (*(v__ast__CallArg*)/*ee elem_sym */array_get(node->args, 0))); + if (_t3.state != 0 && _t3.err._typ != _IError_None___index) { + IError err = _t3.err; + v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = IError_name_table[err._typ]._method_msg(err._object)}}, {_SLIT(" in argument 1 to `.index()`"), 0, { .d_c = 0 }}})), (*(v__ast__CallArg*)/*ee elem_sym */array_get(node->args, 0)).pos); + ; + } + + ; + } node->return_type = _const_v__ast__int_type; } else if (string__eq(method_name, _SLIT("first")) || string__eq(method_name, _SLIT("last")) || string__eq(method_name, _SLIT("pop"))) { + if (node->args.len != 0) { + v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("`."), 0xfe10, {.d_s = method_name}}, {_SLIT("()` does not have any arguments"), 0, { .d_c = 0 }}})), (*(v__ast__CallArg*)/*ee elem_sym */array_get(node->args, 0)).pos); + } node->return_type = array_info.elem_type; if (string__eq(method_name, _SLIT("pop"))) { v__checker__Checker_fail_if_immutable(c, node->left); @@ -57099,8 +57216,8 @@ VV_LOCAL_SYMBOL v__ast__Type v__checker__Checker_array_builtin_method_call(v__ch node->receiver_type = left_type; } } - v__ast__Type _t2 = node->return_type; - return _t2; + v__ast__Type _t4 = node->return_type; + return _t4; } VV_LOCAL_SYMBOL void v__checker__scope_register_it(v__ast__Scope* s, v__token__Pos pos, v__ast__Type typ) { @@ -57199,6 +57316,9 @@ VV_LOCAL_SYMBOL void v__checker__Checker_for_in_stmt(v__checker__Checker* c, v__ v__ast__Scope_update_var_type(node->scope, node->key_var, key_type); } v__ast__Type value_type = v__ast__Table_value_type(c->table, typ); + if (sym->kind == v__ast__Kind__string) { + value_type = _const_v__ast__byte_type; + } if (v__ast__Type_alias_eq(value_type, _const_v__ast__void_type) || v__ast__Type_has_flag(typ, v__ast__TypeFlag__optional)) { if (!v__ast__Type_alias_eq(typ, _const_v__ast__void_type)) { v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("for in: cannot index `"), 0xfe10, {.d_s = v__ast__Table_type_to_str(c->table, typ)}}, {_SLIT("`"), 0, { .d_c = 0 }}})), v__ast__Expr_pos(node->cond)); @@ -57586,11 +57706,10 @@ VV_LOCAL_SYMBOL void v__checker__Checker_smartcast_if_conds(v__checker__Checker* _t1 = ((v__ast__Type)(0)); } v__ast__Type right_type = _t1; - right_type = v__checker__Checker_unwrap_generic(c, right_type); if (!v__ast__Type_alias_eq(right_type, ((v__ast__Type)(0)))) { v__ast__TypeSymbol* left_sym = v__ast__Table_sym(c->table, (*node._v__ast__InfixExpr).left_type); v__ast__TypeSymbol* right_sym = v__ast__Table_sym(c->table, right_type); - v__ast__Type expr_type = v__checker__Checker_unwrap_generic(c, v__checker__Checker_expr(c, (*node._v__ast__InfixExpr).left)); + v__ast__Type expr_type = v__checker__Checker_expr(c, (*node._v__ast__InfixExpr).left); if (left_sym->kind == v__ast__Kind__aggregate) { expr_type = (/* as */ *(v__ast__Aggregate*)__as_cast((left_sym->info)._v__ast__Aggregate,(left_sym->info)._typ, 429) /*expected idx: 429, name: v.ast.Aggregate */ ).sum_type; } @@ -57600,7 +57719,7 @@ VV_LOCAL_SYMBOL void v__checker__Checker_smartcast_if_conds(v__checker__Checker* } else { return; } - } else if (!v__checker__Checker_check_types(c, right_type, expr_type)) { + } else if (!v__checker__Checker_check_types(c, right_type, expr_type) && left_sym->kind != v__ast__Kind__sum_type) { string expect_str = v__ast__Table_type_to_str(c->table, right_type); string expr_str = v__ast__Table_type_to_str(c->table, expr_type); v__checker__Checker_error(c, str_intp(3, _MOV((StrIntpData[]){{_SLIT("cannot use type `"), 0xfe10, {.d_s = expect_str}}, {_SLIT("` as type `"), 0xfe10, {.d_s = expr_str}}, {_SLIT("`"), 0, { .d_c = 0 }}})), (*node._v__ast__InfixExpr).pos); @@ -58118,8 +58237,9 @@ VV_LOCAL_SYMBOL void v__checker__Checker_match_exprs(v__checker__Checker* c, v__ c->expected_type = node->expected_type; v__ast__Expr low_expr = (*expr._v__ast__RangeExpr).low; v__ast__Expr high_expr = (*expr._v__ast__RangeExpr).high; + v__ast__TypeSymbol* final_cond_sym = v__ast__Table_final_sym(c->table, node->cond_type); if ((low_expr)._typ == 271 /* v.ast.IntegerLiteral */) { - if ((high_expr)._typ == 271 /* v.ast.IntegerLiteral */ && (v__ast__TypeSymbol_is_int(&cond_type_sym) || (cond_type_sym.info)._typ == 445 /* v.ast.Enum */)) { + if ((high_expr)._typ == 271 /* v.ast.IntegerLiteral */ && (v__ast__TypeSymbol_is_int(final_cond_sym) || (final_cond_sym->info)._typ == 445 /* v.ast.Enum */)) { low = string_i64((*low_expr._v__ast__IntegerLiteral).val); high = string_i64((*high_expr._v__ast__IntegerLiteral).val); if (low > high) { @@ -58129,7 +58249,7 @@ VV_LOCAL_SYMBOL void v__checker__Checker_match_exprs(v__checker__Checker* c, v__ v__checker__Checker_error(c, _SLIT("mismatched range types"), (*low_expr._v__ast__IntegerLiteral).pos); } } else if ((low_expr)._typ == 255 /* v.ast.CharLiteral */) { - if ((high_expr)._typ == 255 /* v.ast.CharLiteral */ && (cond_type_sym.kind == v__ast__Kind__u8 || cond_type_sym.kind == v__ast__Kind__char || cond_type_sym.kind == v__ast__Kind__rune)) { + if ((high_expr)._typ == 255 /* v.ast.CharLiteral */ && (final_cond_sym->kind == v__ast__Kind__u8 || final_cond_sym->kind == v__ast__Kind__char || final_cond_sym->kind == v__ast__Kind__rune)) { low = string_at((*low_expr._v__ast__CharLiteral).val, 0); high = string_at((*high_expr._v__ast__CharLiteral).val, 0); if (low > high) { @@ -58641,6 +58761,13 @@ void v__checker__Checker_return_stmt(v__checker__Checker* c, v__ast__Return* nod array_push((array*)&expr_idxs, _MOV((int[]){ i })); } } else { + if ((expr)._typ == 266 /* v.ast.Ident */) { + if (((*expr._v__ast__Ident).obj)._typ == 324 /* v.ast.Var */) { + if ((*(*expr._v__ast__Ident).obj._v__ast__Var).smartcasts.len > 0) { + typ = v__checker__Checker_unwrap_generic(c, (*(v__ast__Type*)array_last((*(*expr._v__ast__Ident).obj._v__ast__Var).smartcasts))); + } + } + } array_push((array*)&got_types, _MOV((v__ast__Type[]){ typ })); array_push((array*)&expr_idxs, _MOV((int[]){ i })); } @@ -59113,7 +59240,7 @@ v__ast__Type v__checker__Checker_int_lit(v__checker__Checker* c, v__ast__Integer v__checker__Checker_error(c, message, node->pos); } else if (lit.len == limit.len) { for (int i = 0; i < lit.len; ++i) { - byte digit = lit.str[i]; + u8 digit = lit.str[i]; if (digit > string_at(limit, i)) { v__checker__Checker_error(c, message, node->pos); } else if (digit < string_at(limit, i)) { @@ -62114,7 +62241,7 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_array_init(v__gen__c__Gen* g, v__ast__ArrayI g->inside_lambda = false; return; } - bool need_tmp_var = g->inside_call && !g->inside_struct_init; + bool need_tmp_var = g->inside_call && !g->inside_struct_init && node.exprs.len == 0; string stmt_str = _SLIT(""); string tmp_var = _SLIT(""); if (need_tmp_var) { @@ -63541,11 +63668,27 @@ string sref_name; } v__ast__FnType func = /* as */ *(v__ast__FnType*)__as_cast((right_sym->info)._v__ast__FnType,(right_sym->info)._typ, 443) /*expected idx: 443, name: v.ast.FnType */ ; string ret_styp = v__gen__c__Gen_typ(g, func.func.return_type); - v__gen__c__Gen_write(g, str_intp(3, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = ret_styp}}, {_SLIT(" (*"), 0xfe10, {.d_s = v__gen__c__Gen_get_ternary_name(g, ident.name)}}, {_SLIT(") ("), 0, { .d_c = 0 }}}))); + string call_conv = _SLIT(""); + string msvc_call_conv = _SLIT(""); + for (int _t8 = 0; _t8 < func.func.attrs.len; ++_t8) { + v__ast__Attr attr = ((v__ast__Attr*)func.func.attrs.data)[_t8]; + + if (string__eq(attr.name, _SLIT("callconv"))) { + if (g->is_cc_msvc) { + msvc_call_conv = str_intp(2, _MOV((StrIntpData[]){{_SLIT("__"), 0xfe10, {.d_s = attr.arg}}, {_SLIT(" "), 0, { .d_c = 0 }}})); + } else { + call_conv = str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = attr.arg}}, {_SLIT0, 0, { .d_c = 0 }}})); + } + } + else { + }; + } + string call_conv_attribute_suffix = (call_conv.len != 0 ? ( str_intp(2, _MOV((StrIntpData[]){{_SLIT("__attribute__(("), 0xfe10, {.d_s = call_conv}}, {_SLIT("))"), 0, { .d_c = 0 }}}))) : (_SLIT(""))); + v__gen__c__Gen_write(g, str_intp(4, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = ret_styp}}, {_SLIT(" ("), 0xfe10, {.d_s = msvc_call_conv}}, {_SLIT("*"), 0xfe10, {.d_s = v__gen__c__Gen_get_ternary_name(g, ident.name)}}, {_SLIT(") ("), 0, { .d_c = 0 }}}))); int def_pos = g->definitions.len; v__gen__c__Gen_fn_decl_params(g, func.func.params, ((voidptr)(0)), false); strings__Builder_go_back(&g->definitions, g->definitions.len - def_pos); - v__gen__c__Gen_write(g, _SLIT(")")); + v__gen__c__Gen_write(g, str_intp(2, _MOV((StrIntpData[]){{_SLIT(")"), 0xfe10, {.d_s = call_conv_attribute_suffix}}, {_SLIT0, 0, { .d_c = 0 }}}))); } else { if (is_decl) { if (is_inside_ternary) { @@ -68380,7 +68523,7 @@ VV_LOCAL_SYMBOL void v__gen__c__write_octal_escape(strings__Builder* b, u8 c) { VV_LOCAL_SYMBOL string v__gen__c__cescape_nonascii(string original) { strings__Builder b = strings__new_builder(original.len); for (int _t1 = 0; _t1 < original.len; ++_t1) { - byte c = original.str[_t1]; + u8 c = original.str[_t1]; if (c < 32 || c > 126) { v__gen__c__write_octal_escape((voidptr)&/*qq*/b, c); continue; @@ -69450,7 +69593,7 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_selector_expr(v__gen__c__Gen* g, v__ast__Sel if (field_sym->kind == v__ast__Kind__sum_type) { v__gen__c__Gen_write(g, _SLIT("*")); } - v__ast__TypeSymbol* cast_sym = v__ast__Table_sym(g->table, typ); + v__ast__TypeSymbol* cast_sym = v__ast__Table_sym(g->table, v__gen__c__Gen_unwrap_generic(g, typ)); if (i != 0) { string dot = (v__ast__Type_is_ptr(field.typ) ? (_SLIT("->")) : (_SLIT("."))); sum_type_deref_field = /*f*/string__plus(sum_type_deref_field, str_intp(2, _MOV((StrIntpData[]){{_SLIT(")"), 0xfe10, {.d_s = dot}}, {_SLIT0, 0, { .d_c = 0 }}}))); @@ -69640,11 +69783,11 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_map_init(v__gen__c__Gen* g, v__ast__MapInit string value_typ_str = v__gen__c__Gen_typ(g, unwrap_val_typ); v__ast__TypeSymbol* value_sym = v__ast__Table_sym(g->table, unwrap_val_typ); v__ast__TypeSymbol* key_sym = v__ast__Table_final_sym(g->table, unwrap_key_typ); - multi_return_string_string_string_string mr_105072 = v__gen__c__Gen_map_fn_ptrs(g, *key_sym); - string hash_fn = mr_105072.arg0; - string key_eq_fn = mr_105072.arg1; - string clone_fn = mr_105072.arg2; - string free_fn = mr_105072.arg3; + multi_return_string_string_string_string mr_105090 = v__gen__c__Gen_map_fn_ptrs(g, *key_sym); + string hash_fn = mr_105090.arg0; + string key_eq_fn = mr_105090.arg1; + string clone_fn = mr_105090.arg2; + string free_fn = mr_105090.arg3; int size = node.vals.len; string shared_styp = _SLIT(""); string styp = _SLIT(""); @@ -70814,9 +70957,9 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_write_types(v__gen__c__Gen* g, Array_v__ast_ for (int _t3 = 0; _t3 < (*sym->info._v__ast__Struct).fields.len; ++_t3) { v__ast__StructField field = ((v__ast__StructField*)(*sym->info._v__ast__Struct).fields.data)[_t3]; if (v__ast__Type_has_flag(field.typ, v__ast__TypeFlag__optional)) { - multi_return_string_string mr_142140 = v__gen__c__Gen_optional_type_name(g, field.typ); - string styp = mr_142140.arg0; - string base = mr_142140.arg1; + multi_return_string_string mr_142158 = v__gen__c__Gen_optional_type_name(g, field.typ); + string styp = mr_142158.arg0; + string base = mr_142158.arg1; sync__RwMutex_lock(&g->done_optionals->mtx); /*lock*/ { if (!Array_string_contains(g->done_optionals->val, base)) { @@ -71087,11 +71230,11 @@ bool v__gen__c__Gen_or_block_defer_0 = false; if (string__eq(g->file->mod.name, _SLIT("main")) && (isnil(g->fn_decl) || g->fn_decl->is_main)) { string err_msg = str_intp(3, _MOV((StrIntpData[]){{_SLIT("IError_name_table["), 0xfe10, {.d_s = cvar_name}}, {_SLIT(".err._typ]._method_msg("), 0xfe10, {.d_s = cvar_name}}, {_SLIT(".err._object)"), 0, { .d_c = 0 }}})); if (g->pref->is_debug) { - multi_return_int_string_string_string mr_151194 = v__gen__c__Gen_panic_debug_info(g, or_block.pos); - int paline = mr_151194.arg0; - string pafile = mr_151194.arg1; - string pamod = mr_151194.arg2; - string pafn = mr_151194.arg3; + multi_return_int_string_string_string mr_151212 = v__gen__c__Gen_panic_debug_info(g, or_block.pos); + int paline = mr_151212.arg0; + string pafile = mr_151212.arg1; + string pamod = mr_151212.arg2; + string pafn = mr_151212.arg3; v__gen__c__Gen_writeln(g, str_intp(6, _MOV((StrIntpData[]){{_SLIT("panic_debug("), 0xfe07, {.d_i32 = paline}}, {_SLIT(", tos3(\""), 0xfe10, {.d_s = pafile}}, {_SLIT("\"), tos3(\""), 0xfe10, {.d_s = pamod}}, {_SLIT("\"), tos3(\""), 0xfe10, {.d_s = pafn}}, {_SLIT("\"), "), 0xfe10, {.d_s = err_msg}}, {_SLIT(" );"), 0, { .d_c = 0 }}}))); } else { v__gen__c__Gen_writeln(g, str_intp(2, _MOV((StrIntpData[]){{_SLIT("\tpanic_optional_not_set( "), 0xfe10, {.d_s = err_msg}}, {_SLIT(" );"), 0, { .d_c = 0 }}}))); @@ -71201,11 +71344,11 @@ VV_LOCAL_SYMBOL string v__gen__c__Gen_type_default(v__gen__c__Gen* g, v__ast__Ty { v__ast__Map info = v__ast__TypeSymbol_map_info(sym); v__ast__TypeSymbol* key_typ = v__ast__Table_sym(g->table, info.key_type); - multi_return_string_string_string_string mr_153776 = v__gen__c__Gen_map_fn_ptrs(g, *key_typ); - string hash_fn = mr_153776.arg0; - string key_eq_fn = mr_153776.arg1; - string clone_fn = mr_153776.arg2; - string free_fn = mr_153776.arg3; + multi_return_string_string_string_string mr_153794 = v__gen__c__Gen_map_fn_ptrs(g, *key_typ); + string hash_fn = mr_153794.arg0; + string key_eq_fn = mr_153794.arg1; + string clone_fn = mr_153794.arg2; + string free_fn = mr_153794.arg3; string noscan_key = v__gen__c__Gen_check_noscan(g, info.key_type); string noscan_value = v__gen__c__Gen_check_noscan(g, info.value_type); string noscan = (noscan_key.len != 0 || noscan_value.len != 0 ? (_SLIT("_noscan")) : (_SLIT(""))); @@ -71377,9 +71520,11 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_size_of(v__gen__c__Gen* g, v__ast__SizeOf no VV_LOCAL_SYMBOL void v__gen__c__Gen_enum_val(v__gen__c__Gen* g, v__ast__EnumVal node) { string styp = v__gen__c__Gen_typ(g, v__ast__Table_unaliased_type(g->table, node.typ)); - if (v__ast__Type_is_number(node.typ)) { + if (g->pref->translated && v__ast__Type_is_number(node.typ)) { + v__gen__c__Gen_write(g, str_intp(4, _MOV((StrIntpData[]){{_SLIT("/*enum val is_number "), 0xfe10, {.d_s = node.mod}}, {_SLIT(" styp="), 0xfe10, {.d_s = styp}}, {_SLIT("*/_const_main__"), 0xfe10, {.d_s = node.val}}, {_SLIT0, 0, { .d_c = 0 }}}))); + } else { + v__gen__c__Gen_write(g, str_intp(3, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = styp}}, {_SLIT("__"), 0xfe10, {.d_s = node.val}}, {_SLIT0, 0, { .d_c = 0 }}}))); } - v__gen__c__Gen_write(g, str_intp(3, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = styp}}, {_SLIT("__"), 0xfe10, {.d_s = node.val}}, {_SLIT0, 0, { .d_c = 0 }}}))); } VV_LOCAL_SYMBOL void v__gen__c__Gen_as_cast(v__gen__c__Gen* g, v__ast__AsCast node) { @@ -71733,8 +71878,8 @@ VV_LOCAL_SYMBOL string v__gen__c__Gen_interface_table(v__gen__c__Gen* g) { int params_start_pos = g->out.len; Array_v__ast__Param params = array_clone_to_depth(&method.params, 0); array_set(¶ms, 0, &(v__ast__Param[]) { ((v__ast__Param){(*(v__ast__Param*)/*ee elem_sym */array_get(params, 0)).pos,(*(v__ast__Param*)/*ee elem_sym */array_get(params, 0)).name,(*(v__ast__Param*)/*ee elem_sym */array_get(params, 0)).is_mut,(*(v__ast__Param*)/*ee elem_sym */array_get(params, 0)).is_auto_rec,(*(v__ast__Param*)/*ee elem_sym */array_get(params, 0)).type_pos,(*(v__ast__Param*)/*ee elem_sym */array_get(params, 0)).is_hidden,.typ = v__ast__Type_set_nr_muls(st, 1),}) }); - multi_return_Array_string_Array_string_Array_bool mr_168066 = v__gen__c__Gen_fn_decl_params(g, params, ((voidptr)(0)), false); - Array_string fargs = mr_168066.arg0; + multi_return_Array_string_Array_string_Array_bool mr_168158 = v__gen__c__Gen_fn_decl_params(g, params, ((voidptr)(0)), false); + Array_string fargs = mr_168158.arg0; string parameter_name = strings__Builder_cut_last(&g->out, g->out.len - params_start_pos); if (v__ast__Type_is_ptr(st)) { parameter_name = string_trim_string_left(parameter_name, _SLIT("__shared__")); @@ -71751,8 +71896,8 @@ VV_LOCAL_SYMBOL string v__gen__c__Gen_interface_table(v__gen__c__Gen* g) { *(multi_return_v__ast__Fn_Array_v__ast__Type*) _t26.data = (multi_return_v__ast__Fn_Array_v__ast__Type){.arg0=((v__ast__Fn){.is_variadic = 0,.language = 0,.is_pub = 0,.is_ctor_new = 0,.is_deprecated = 0,.is_noreturn = 0,.is_unsafe = 0,.is_placeholder = 0,.is_main = 0,.is_test = 0,.is_keep_alive = 0,.is_method = 0,.no_body = 0,.mod = (string){.str=(byteptr)"", .is_lit=1},.file = (string){.str=(byteptr)"", .is_lit=1},.file_mode = 0,.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.return_type_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.return_type = 0,.receiver_type = 0,.name = (string){.str=(byteptr)"", .is_lit=1},.params = __new_array(0, 0, sizeof(v__ast__Param)),.source_fn = 0,.usages = 0,.generic_names = __new_array(0, 0, sizeof(string)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.is_conditional = 0,.ctdefine_idx = 0,}),.arg1=__new_array_with_default(0, 0, sizeof(v__ast__Type), 0)}; } - multi_return_v__ast__Fn_Array_v__ast__Type mr_168530 = (*(multi_return_v__ast__Fn_Array_v__ast__Type*)_t26.data); - Array_v__ast__Type embed_types = mr_168530.arg1; + multi_return_v__ast__Fn_Array_v__ast__Type mr_168622 = (*(multi_return_v__ast__Fn_Array_v__ast__Type*)_t26.data); + Array_v__ast__Type embed_types = mr_168622.arg1; if (embed_types.len > 0 && !Array_string_contains(method_names, method.name)) { v__ast__TypeSymbol* embed_sym = v__ast__Table_sym(g->table, (*(v__ast__Type*)array_last(embed_types))); string method_name = str_intp(3, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = embed_sym->cname}}, {_SLIT("_"), 0xfe10, {.d_s = method.name}}, {_SLIT0, 0, { .d_c = 0 }}})); @@ -73864,7 +74009,10 @@ int ctmp; ctmp = g->tmp_count; g->tmp_count = 0; v__gen__c__Gen_gen_fn_decl_defer_5 = true; + int prev_inside_ternary = g->inside_ternary; + g->inside_ternary = 0; v__gen__c__Gen_stmts(g, node->stmts); + g->inside_ternary = prev_inside_ternary; if (node->is_noreturn) { v__gen__c__Gen_writeln(g, _SLIT("\twhile(1);")); } @@ -74120,11 +74268,12 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_call_expr(v__gen__c__Gen* g, v__ast__CallExp bool v__gen__c__Gen_call_expr_defer_0 = false; if ((node.left)._typ == 244 /* v.ast.AnonFn */) { v__gen__c__Gen_expr(g, node.left); - } - if ((node.left)._typ == 269 /* v.ast.IndexExpr */ && (node.name).len == 0) { + } else if ((node.left)._typ == 269 /* v.ast.IndexExpr */ && (node.name).len == 0) { g->is_fn_index_call = true; v__gen__c__Gen_expr(g, node.left); g->is_fn_index_call = false; + } else if ((node.left)._typ == 252 /* v.ast.CallExpr */ && (node.name).len == 0) { + v__gen__c__Gen_expr(g, node.left); } if (node.should_be_skipped) { return; @@ -74472,7 +74621,7 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_method_call(v__gen__c__Gen* g, v__ast__CallE v__gen__c__Gen_gen_expr_to_string(g, node.left, rec_type); return; } else if ((*(*node.left._v__ast__Ident).obj._v__ast__Var).smartcasts.len > 0) { - rec_type = (*(v__ast__Type*)array_last((*(*node.left._v__ast__Ident).obj._v__ast__Var).smartcasts)); + rec_type = v__gen__c__Gen_unwrap_generic(g, (*(v__ast__Type*)array_last((*(*node.left._v__ast__Ident).obj._v__ast__Var).smartcasts))); v__ast__TypeSymbol* cast_sym = v__ast__Table_sym(g->table, rec_type); if ((cast_sym->info)._typ == 429 /* v.ast.Aggregate */) { rec_type = (*(v__ast__Type*)/*ee elem_sym */array_get((*cast_sym->info._v__ast__Aggregate).types, g->aggregate_type_idx)); @@ -74840,7 +74989,7 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_fn_call(v__gen__c__Gen* g, v__ast__CallExpr if (((*expr._v__ast__Ident).obj)._typ == 324 /* v.ast.Var */) { typ = (*(*expr._v__ast__Ident).obj._v__ast__Var).typ; if ((*(*expr._v__ast__Ident).obj._v__ast__Var).smartcasts.len > 0) { - typ = (*(v__ast__Type*)array_last((*(*expr._v__ast__Ident).obj._v__ast__Var).smartcasts)); + typ = v__gen__c__Gen_unwrap_generic(g, (*(v__ast__Type*)array_last((*(*expr._v__ast__Ident).obj._v__ast__Var).smartcasts))); v__ast__TypeSymbol* cast_sym = v__ast__Table_sym(g->table, typ); if ((cast_sym->info)._typ == 429 /* v.ast.Aggregate */) { typ = (*(v__ast__Type*)/*ee elem_sym */array_get((*cast_sym->info._v__ast__Aggregate).types, g->aggregate_type_idx)); @@ -74856,11 +75005,11 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_fn_call(v__gen__c__Gen* g, v__ast__CallExpr } if (!print_auto_str) { if (g->pref->is_debug && string__eq(node.name, _SLIT("panic"))) { - multi_return_int_string_string_string mr_40302 = v__gen__c__Gen_panic_debug_info(g, node.pos); - int paline = mr_40302.arg0; - string pafile = mr_40302.arg1; - string pamod = mr_40302.arg2; - string pafn = mr_40302.arg3; + multi_return_int_string_string_string mr_40523 = v__gen__c__Gen_panic_debug_info(g, node.pos); + int paline = mr_40523.arg0; + string pafile = mr_40523.arg1; + string pamod = mr_40523.arg2; + string pafn = mr_40523.arg3; v__gen__c__Gen_write(g, str_intp(5, _MOV((StrIntpData[]){{_SLIT("panic_debug("), 0xfe07, {.d_i32 = paline}}, {_SLIT(", tos3(\""), 0xfe10, {.d_s = pafile}}, {_SLIT("\"), tos3(\""), 0xfe10, {.d_s = pamod}}, {_SLIT("\"), tos3(\""), 0xfe10, {.d_s = pafn}}, {_SLIT("\"), "), 0, { .d_c = 0 }}}))); v__gen__c__Gen_call_args(g, node); v__gen__c__Gen_write(g, _SLIT(")")); @@ -75510,6 +75659,12 @@ inline VV_LOCAL_SYMBOL void v__gen__c__Gen_ref_or_deref_arg(v__gen__c__Gen* g, v v__gen__c__Gen_expr(g, arg.expr); v__gen__c__Gen_write(g, _SLIT("->val")); return; + } else if ((arg.expr)._typ == 246 /* v.ast.ArrayInit */) { + if ((*arg.expr._v__ast__ArrayInit).is_fixed) { + if (!(*arg.expr._v__ast__ArrayInit).has_it) { + v__gen__c__Gen_write(g, str_intp(2, _MOV((StrIntpData[]){{_SLIT("("), 0xfe10, {.d_s = v__gen__c__Gen_typ(g, (*arg.expr._v__ast__ArrayInit).typ)}}, {_SLIT(")"), 0, { .d_c = 0 }}}))); + } + } } v__gen__c__Gen_expr_with_cast(g, arg.expr, arg_typ, expected_type); if (needs_closing) { @@ -75880,14 +76035,15 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_for_in_stmt(v__gen__c__Gen* g, v__ast__ForIn g->indent--; } else if (node.kind == v__ast__Kind__string) { v__ast__Expr cond = ((node.cond)._typ == 290 /* v.ast.StringLiteral */ || (node.cond)._typ == 289 /* v.ast.StringInterLiteral */ ? (v__ast__CTempVar_to_sumtype_v__ast__Expr(ADDR(v__ast__CTempVar, (v__gen__c__Gen_new_ctemp_var_then_gen(g, node.cond, _const_v__ast__string_type))))) : (node.cond)); + string field_accessor = (v__ast__Type_is_ptr(node.cond_type) ? (_SLIT("->")) : (_SLIT("."))); string i = ((string__eq(node.key_var, _SLIT("")) || string__eq(node.key_var, _SLIT("_"))) ? (v__gen__c__Gen_new_tmp_var(g)) : (node.key_var)); v__gen__c__Gen_write(g, str_intp(3, _MOV((StrIntpData[]){{_SLIT("for (int "), 0xfe10, {.d_s = i}}, {_SLIT(" = 0; "), 0xfe10, {.d_s = i}}, {_SLIT(" < "), 0, { .d_c = 0 }}}))); v__gen__c__Gen_expr(g, cond); - v__gen__c__Gen_writeln(g, str_intp(2, _MOV((StrIntpData[]){{_SLIT(".len; ++"), 0xfe10, {.d_s = i}}, {_SLIT(") {"), 0, { .d_c = 0 }}}))); + v__gen__c__Gen_writeln(g, str_intp(3, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = field_accessor}}, {_SLIT("len; ++"), 0xfe10, {.d_s = i}}, {_SLIT(") {"), 0, { .d_c = 0 }}}))); if (!string__eq(node.val_var, _SLIT("_"))) { - v__gen__c__Gen_write(g, str_intp(2, _MOV((StrIntpData[]){{_SLIT("\tbyte "), 0xfe10, {.d_s = v__gen__c__c_name(node.val_var)}}, {_SLIT(" = "), 0, { .d_c = 0 }}}))); + v__gen__c__Gen_write(g, str_intp(2, _MOV((StrIntpData[]){{_SLIT("\tu8 "), 0xfe10, {.d_s = v__gen__c__c_name(node.val_var)}}, {_SLIT(" = "), 0, { .d_c = 0 }}}))); v__gen__c__Gen_expr(g, cond); - v__gen__c__Gen_writeln(g, str_intp(2, _MOV((StrIntpData[]){{_SLIT(".str["), 0xfe10, {.d_s = i}}, {_SLIT("];"), 0, { .d_c = 0 }}}))); + v__gen__c__Gen_writeln(g, str_intp(3, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = field_accessor}}, {_SLIT("str["), 0xfe10, {.d_s = i}}, {_SLIT("];"), 0, { .d_c = 0 }}}))); } } else if (node.kind == v__ast__Kind__struct_) { v__ast__TypeSymbol* cond_type_sym = v__ast__Table_sym(g->table, node.cond_type); @@ -75970,24 +76126,28 @@ VV_LOCAL_SYMBOL bool v__gen__c__Gen_need_tmp_var_in_if(v__gen__c__Gen* g, v__ast bool _t4 = true; return _t4; } + if ((stmt.expr)._typ == 276 /* v.ast.MatchExpr */) { + bool _t5 = true; + return _t5; + } if ((stmt.expr)._typ == 252 /* v.ast.CallExpr */) { if ((*stmt.expr._v__ast__CallExpr).is_method) { v__ast__TypeSymbol* left_sym = v__ast__Table_sym(g->table, (*stmt.expr._v__ast__CallExpr).receiver_type); if (left_sym->kind == v__ast__Kind__array || left_sym->kind == v__ast__Kind__array_fixed || left_sym->kind == v__ast__Kind__map) { - bool _t5 = true; - return _t5; + bool _t6 = true; + return _t6; } } else if ((*stmt.expr._v__ast__CallExpr).or_block.kind != v__ast__OrKind__absent) { - bool _t6 = true; - return _t6; + bool _t7 = true; + return _t7; } } } } } } - bool _t7 = false; - return _t7; + bool _t8 = false; + return _t8; } VV_LOCAL_SYMBOL void v__gen__c__Gen_if_expr(v__gen__c__Gen* g, v__ast__IfExpr node) { @@ -77467,7 +77627,7 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_infix_expr_left_shift_op(v__gen__c__Gen* g, } else { v__gen__c__Gen_write(g, str_intp(2, _MOV((StrIntpData[]){{_SLIT(", _MOV(("), 0xfe10, {.d_s = elem_type_str}}, {_SLIT("[]){ "), 0, { .d_c = 0 }}}))); } - bool needs_clone = v__ast__Type_idx(array_info.elem_type) == _const_v__ast__string_type_idx && !g->is_builtin_mod; + bool needs_clone = !g->is_builtin_mod && v__ast__Type_idx(array_info.elem_type) == _const_v__ast__string_type_idx && v__ast__Type_nr_muls(array_info.elem_type) == 0; if (needs_clone) { v__gen__c__Gen_write(g, _SLIT("string_clone(")); } @@ -79907,7 +80067,7 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_str_val(v__gen__c__Gen* g, v__ast__StringInt if (g->comptime_var_type_map.len > 0 || g->comptime_for_method.len > 0) { exp_typ = (*(*expr._v__ast__Ident).obj._v__ast__Var).typ; } else if ((*(*expr._v__ast__Ident).obj._v__ast__Var).smartcasts.len > 0) { - exp_typ = (*(v__ast__Type*)array_last((*(*expr._v__ast__Ident).obj._v__ast__Var).smartcasts)); + exp_typ = v__gen__c__Gen_unwrap_generic(g, (*(v__ast__Type*)array_last((*(*expr._v__ast__Ident).obj._v__ast__Var).smartcasts))); v__ast__TypeSymbol* cast_sym = v__ast__Table_sym(g->table, exp_typ); if ((cast_sym->info)._typ == 429 /* v.ast.Aggregate */) { exp_typ = (*(v__ast__Type*)/*ee elem_sym */array_get((*cast_sym->info._v__ast__Aggregate).types, g->aggregate_type_idx)); @@ -79972,9 +80132,9 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_string_inter_literal(v__gen__c__Gen* g, v__a v__gen__c__Gen_write(g, _SLIT("0, { .d_c = 0 }}")); break; } - multi_return_u64_string mr_5665 = v__gen__c__Gen_str_format(g, node, i); - u64 ft_u64 = mr_5665.arg0; - string ft_str = mr_5665.arg1; + multi_return_u64_string mr_5683 = v__gen__c__Gen_str_format(g, node, i); + u64 ft_u64 = mr_5683.arg0; + string ft_str = mr_5683.arg1; v__gen__c__Gen_write(g, str_intp(3, _MOV((StrIntpData[]){{_SLIT("0x"), 0xfe10, {.d_s = u64_hex(ft_u64)}}, {_SLIT(", {.d_"), 0xfe10, {.d_s = ft_str}}, {_SLIT(" = "), 0, { .d_c = 0 }}}))); if (ft_str.str[0] == 'p') { v__gen__c__Gen_write(g, _SLIT("(void*)(")); @@ -81784,7 +81944,7 @@ VV_LOCAL_SYMBOL string v__scanner__Scanner_ident_char(v__scanner__Scanner* s) { } else { Array_int escapes_pos = __new_array_with_default(0, 0, sizeof(int), 0); for (int i = 0; i < c.len; ++i) { - byte v = c.str[i]; + u8 v = c.str[i]; if (v == '\\') { array_push((array*)&escapes_pos, _MOV((int[]){ i })); } @@ -84690,7 +84850,8 @@ VV_LOCAL_SYMBOL multi_return_Array_v__ast__Param_bool_bool v__parser__Parser_fn_ Array_v__ast__Param args = __new_array_with_default(0, 0, sizeof(v__ast__Param), 0); bool is_variadic = false; string argname = (p->tok.kind == v__token__Kind__name && p->tok.lit.len > 0 && u8_is_capital(string_at(p->tok.lit, 0)) ? (v__parser__Parser_prepend_mod(p, p->tok.lit)) : (p->tok.lit)); - bool types_only = (p->tok.kind == v__token__Kind__amp || p->tok.kind == v__token__Kind__ellipsis || p->tok.kind == v__token__Kind__key_fn || p->tok.kind == v__token__Kind__lsbr) || (p->peek_tok.kind == v__token__Kind__comma && v__ast__Table_known_type(p->table, argname)) || p->peek_tok.kind == v__token__Kind__dot || p->peek_tok.kind == v__token__Kind__rpar || (p->tok.kind == v__token__Kind__key_mut && (v__parser__Parser_peek_token(p, 2).kind == v__token__Kind__comma || v__parser__Parser_peek_token(p, 2).kind == v__token__Kind__rpar || (p->peek_tok.kind == v__token__Kind__name && v__parser__Parser_peek_token(p, 2).kind == v__token__Kind__dot))); + bool is_generic_type = p->tok.kind == v__token__Kind__name && p->tok.lit.len == 1 && u8_is_capital(string_at(p->tok.lit, 0)); + bool types_only = (p->tok.kind == v__token__Kind__amp || p->tok.kind == v__token__Kind__ellipsis || p->tok.kind == v__token__Kind__key_fn || p->tok.kind == v__token__Kind__lsbr) || (p->peek_tok.kind == v__token__Kind__comma && (v__ast__Table_known_type(p->table, argname) || is_generic_type)) || p->peek_tok.kind == v__token__Kind__dot || p->peek_tok.kind == v__token__Kind__rpar || (p->tok.kind == v__token__Kind__key_mut && (v__parser__Parser_peek_token(p, 2).kind == v__token__Kind__comma || v__parser__Parser_peek_token(p, 2).kind == v__token__Kind__rpar || (p->peek_tok.kind == v__token__Kind__name && v__parser__Parser_peek_token(p, 2).kind == v__token__Kind__dot))); if (types_only) { int arg_no = 1; for (;;) { @@ -87501,7 +87662,8 @@ v__ast__Stmt v__parser__Parser_stmt(v__parser__Parser* p, bool is_top_level) { v__token__Pos spos = v__token__Token_pos(&p->tok); string name = v__parser__Parser_check_name(p); if (Array_string_contains(p->label_names, name)) { - v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("duplicate label `"), 0xfe10, {.d_s = name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), spos); + v__ast__Stmt _t5 = v__ast__NodeError_to_sumtype_v__ast__Stmt(ADDR(v__ast__NodeError, (v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("duplicate label `"), 0xfe10, {.d_s = name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), spos)))); + return _t5; } array_push((array*)&p->label_names, _MOV((string[]){ string_clone(name) })); v__parser__Parser_next(p); @@ -87510,52 +87672,53 @@ v__ast__Stmt v__parser__Parser_stmt(v__parser__Parser* p, bool is_top_level) { v__ast__Stmt stmt = v__parser__Parser_stmt(p, is_top_level); if (stmt._typ == 309 /* v.ast.ForStmt */) { (*stmt._v__ast__ForStmt).label = name; - v__ast__Stmt _t6 = v__ast__ForStmt_to_sumtype_v__ast__Stmt(&(*stmt._v__ast__ForStmt)); - return _t6; + v__ast__Stmt _t7 = v__ast__ForStmt_to_sumtype_v__ast__Stmt(&(*stmt._v__ast__ForStmt)); + return _t7; } else if (stmt._typ == 308 /* v.ast.ForInStmt */) { (*stmt._v__ast__ForInStmt).label = name; - v__ast__Stmt _t7 = v__ast__ForInStmt_to_sumtype_v__ast__Stmt(&(*stmt._v__ast__ForInStmt)); - return _t7; + v__ast__Stmt _t8 = v__ast__ForInStmt_to_sumtype_v__ast__Stmt(&(*stmt._v__ast__ForInStmt)); + return _t8; } else if (stmt._typ == 307 /* v.ast.ForCStmt */) { (*stmt._v__ast__ForCStmt).label = name; - v__ast__Stmt _t8 = v__ast__ForCStmt_to_sumtype_v__ast__Stmt(&(*stmt._v__ast__ForCStmt)); - return _t8; + v__ast__Stmt _t9 = v__ast__ForCStmt_to_sumtype_v__ast__Stmt(&(*stmt._v__ast__ForCStmt)); + return _t9; } else { - v__parser__Parser_error_with_pos(p, _SLIT("unknown kind of For statement"), for_pos); + v__ast__Stmt _t10 = v__ast__NodeError_to_sumtype_v__ast__Stmt(ADDR(v__ast__NodeError, (v__parser__Parser_error_with_pos(p, _SLIT("unknown kind of For statement"), for_pos)))); + return _t10; } ; } - v__ast__Stmt _t9 = v__ast__GotoLabel_to_sumtype_v__ast__Stmt(ADDR(v__ast__GotoLabel, (((v__ast__GotoLabel){.name = name,.pos = v__token__Pos_extend(spos, v__token__Token_pos(&p->tok)),})))); - return _t9; - } else if (p->peek_tok.kind == v__token__Kind__name) { - v__ast__Stmt _t10 = v__ast__NodeError_to_sumtype_v__ast__Stmt(ADDR(v__ast__NodeError, (v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("unexpected name `"), 0xfe10, {.d_s = p->tok.lit}}, {_SLIT("`"), 0, { .d_c = 0 }}})), v__token__Token_pos(&p->tok))))); - return _t10; - } else if (!p->inside_if_expr && !p->inside_match_body && !p->inside_or_expr && (p->peek_tok.kind == v__token__Kind__rcbr || p->peek_tok.kind == v__token__Kind__eof) && !v__parser__Parser_mark_var_as_used(p, p->tok.lit)) { - v__ast__Stmt _t11 = v__ast__NodeError_to_sumtype_v__ast__Stmt(ADDR(v__ast__NodeError, (v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("`"), 0xfe10, {.d_s = p->tok.lit}}, {_SLIT("` evaluated but not used"), 0, { .d_c = 0 }}})), v__token__Token_pos(&p->tok))))); + v__ast__Stmt _t11 = v__ast__GotoLabel_to_sumtype_v__ast__Stmt(ADDR(v__ast__GotoLabel, (((v__ast__GotoLabel){.name = name,.pos = v__token__Pos_extend(spos, v__token__Token_pos(&p->tok)),})))); return _t11; + } else if (p->peek_tok.kind == v__token__Kind__name) { + v__ast__Stmt _t12 = v__ast__NodeError_to_sumtype_v__ast__Stmt(ADDR(v__ast__NodeError, (v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("unexpected name `"), 0xfe10, {.d_s = p->tok.lit}}, {_SLIT("`"), 0, { .d_c = 0 }}})), v__token__Token_pos(&p->tok))))); + return _t12; + } else if (!p->inside_if_expr && !p->inside_match_body && !p->inside_or_expr && (p->peek_tok.kind == v__token__Kind__rcbr || p->peek_tok.kind == v__token__Kind__eof) && !v__parser__Parser_mark_var_as_used(p, p->tok.lit)) { + v__ast__Stmt _t13 = v__ast__NodeError_to_sumtype_v__ast__Stmt(ADDR(v__ast__NodeError, (v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("`"), 0xfe10, {.d_s = p->tok.lit}}, {_SLIT("` evaluated but not used"), 0, { .d_c = 0 }}})), v__token__Token_pos(&p->tok))))); + return _t13; } - v__ast__Stmt _t12 = v__parser__Parser_parse_multi_expr(p, is_top_level); - return _t12; + v__ast__Stmt _t14 = v__parser__Parser_parse_multi_expr(p, is_top_level); + return _t14; break; } case v__token__Kind__comment: { - v__ast__Stmt _t13 = v__ast__ExprStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__ExprStmt, (v__parser__Parser_comment_stmt(p)))); - return _t13; + v__ast__Stmt _t15 = v__ast__ExprStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__ExprStmt, (v__parser__Parser_comment_stmt(p)))); + return _t15; break; } case v__token__Kind__key_return: { if (p->inside_defer) { - v__ast__Stmt _t14 = v__ast__NodeError_to_sumtype_v__ast__Stmt(ADDR(v__ast__NodeError, (v__parser__Parser_error_with_pos(p, _SLIT("`return` not allowed inside `defer` block"), v__token__Token_pos(&p->tok))))); - return _t14; + v__ast__Stmt _t16 = v__ast__NodeError_to_sumtype_v__ast__Stmt(ADDR(v__ast__NodeError, (v__parser__Parser_error_with_pos(p, _SLIT("`return` not allowed inside `defer` block"), v__token__Token_pos(&p->tok))))); + return _t16; } else { - v__ast__Stmt _t15 = v__ast__Return_to_sumtype_v__ast__Stmt(ADDR(v__ast__Return, (v__parser__Parser_return_stmt(p)))); - return _t15; + v__ast__Stmt _t17 = v__ast__Return_to_sumtype_v__ast__Stmt(ADDR(v__ast__Return, (v__parser__Parser_return_stmt(p)))); + return _t17; } break; } @@ -87566,23 +87729,23 @@ v__ast__Stmt v__parser__Parser_stmt(v__parser__Parser* p, bool is_top_level) { v__token__Pos pos = v__token__Token_pos(&p->tok); v__ast__IfExpr expr = v__parser__Parser_if_expr(p, true); v__token__Pos_update_last_line(&pos, p->prev_tok.line_nr); - v__ast__Stmt _t16 = v__ast__ExprStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__ExprStmt, (((v__ast__ExprStmt){.pos = pos,.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.expr = v__ast__IfExpr_to_sumtype_v__ast__Expr(&expr),.is_expr = 0,.typ = 0,})))); - return _t16; + v__ast__Stmt _t18 = v__ast__ExprStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__ExprStmt, (((v__ast__ExprStmt){.pos = pos,.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.expr = v__ast__IfExpr_to_sumtype_v__ast__Expr(&expr),.is_expr = 0,.typ = 0,})))); + return _t18; } else if (p->peek_tok.kind == (v__token__Kind__key_for)) { - v__ast__Stmt _t17 = v__ast__ComptimeFor_to_sumtype_v__ast__Stmt(ADDR(v__ast__ComptimeFor, (v__parser__Parser_comptime_for(p)))); - return _t17; + v__ast__Stmt _t19 = v__ast__ComptimeFor_to_sumtype_v__ast__Stmt(ADDR(v__ast__ComptimeFor, (v__parser__Parser_comptime_for(p)))); + return _t19; } else if (p->peek_tok.kind == (v__token__Kind__name)) { v__token__Pos pos = v__token__Token_pos(&p->tok); v__ast__ComptimeCall *expr = HEAP(v__ast__ComptimeCall, (v__parser__Parser_comptime_call(p))); v__token__Pos_update_last_line(&pos, p->prev_tok.line_nr); - v__ast__Stmt _t18 = v__ast__ExprStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__ExprStmt, (((v__ast__ExprStmt){.pos = pos,.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.expr = v__ast__ComptimeCall_to_sumtype_v__ast__Expr(&(*(expr))),.is_expr = 0,.typ = 0,})))); - return _t18; + v__ast__Stmt _t20 = v__ast__ExprStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__ExprStmt, (((v__ast__ExprStmt){.pos = pos,.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.expr = v__ast__ComptimeCall_to_sumtype_v__ast__Expr(&(*(expr))),.is_expr = 0,.typ = 0,})))); + return _t20; } else { - v__ast__Stmt _t19 = v__ast__NodeError_to_sumtype_v__ast__Stmt(ADDR(v__ast__NodeError, (v__parser__Parser_error_with_pos(p, _SLIT("unexpected $"), v__token__Token_pos(&p->tok))))); - return _t19; + v__ast__Stmt _t21 = v__ast__NodeError_to_sumtype_v__ast__Stmt(ADDR(v__ast__NodeError, (v__parser__Parser_error_with_pos(p, _SLIT("unexpected $"), v__token__Token_pos(&p->tok))))); + return _t21; }; break; } @@ -87596,27 +87759,27 @@ v__ast__Stmt v__parser__Parser_stmt(v__parser__Parser* p, bool is_top_level) { if (p->tok.line_nr == line && p->tok.kind == v__token__Kind__name) { label = v__parser__Parser_check_name(p); } - v__ast__Stmt _t20 = v__ast__BranchStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__BranchStmt, (((v__ast__BranchStmt){.kind = tok.kind,.label = label,.pos = v__token__Token_pos(&tok),})))); - return _t20; + v__ast__Stmt _t22 = v__ast__BranchStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__BranchStmt, (((v__ast__BranchStmt){.kind = tok.kind,.label = label,.pos = v__token__Token_pos(&tok),})))); + return _t22; break; } case v__token__Kind__key_unsafe: { - v__ast__Stmt _t21 = v__parser__Parser_unsafe_stmt(p); - return _t21; + v__ast__Stmt _t23 = v__parser__Parser_unsafe_stmt(p); + return _t23; break; } case v__token__Kind__hash: { - v__ast__Stmt _t22 = v__ast__HashStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__HashStmt, (v__parser__Parser_hash(p)))); - return _t22; + v__ast__Stmt _t24 = v__ast__HashStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__HashStmt, (v__parser__Parser_hash(p)))); + return _t24; break; } case v__token__Kind__key_defer: { if (p->inside_defer) { - v__ast__Stmt _t23 = v__ast__NodeError_to_sumtype_v__ast__Stmt(ADDR(v__ast__NodeError, (v__parser__Parser_error_with_pos(p, _SLIT("`defer` blocks cannot be nested"), v__token__Token_pos(&p->tok))))); - return _t23; + v__ast__Stmt _t25 = v__ast__NodeError_to_sumtype_v__ast__Stmt(ADDR(v__ast__NodeError, (v__parser__Parser_error_with_pos(p, _SLIT("`defer` blocks cannot be nested"), v__token__Token_pos(&p->tok))))); + return _t25; } else { v__parser__Parser_next(p); v__token__Pos spos = v__token__Token_pos(&p->tok); @@ -87624,16 +87787,16 @@ v__ast__Stmt v__parser__Parser_stmt(v__parser__Parser* p, bool is_top_level) { p->defer_vars = __new_array_with_default(0, 0, sizeof(v__ast__Ident), 0); Array_v__ast__Stmt stmts = v__parser__Parser_parse_block(p); p->inside_defer = false; - v__ast__Stmt _t24 = v__ast__DeferStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__DeferStmt, (((v__ast__DeferStmt){.stmts = stmts,.pos = v__token__Pos_extend_with_last_line(spos, v__token__Token_pos(&p->tok), p->prev_tok.line_nr),.defer_vars = array_clone_to_depth(&p->defer_vars, 0),.ifdef = (string){.str=(byteptr)"", .is_lit=1},.idx_in_fn = -1,})))); - return _t24; + v__ast__Stmt _t26 = v__ast__DeferStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__DeferStmt, (((v__ast__DeferStmt){.stmts = stmts,.pos = v__token__Pos_extend_with_last_line(spos, v__token__Token_pos(&p->tok), p->prev_tok.line_nr),.defer_vars = array_clone_to_depth(&p->defer_vars, 0),.ifdef = (string){.str=(byteptr)"", .is_lit=1},.idx_in_fn = -1,})))); + return _t26; } break; } case v__token__Kind__key_go: { v__ast__GoExpr go_expr = v__parser__Parser_go_expr(p); - v__ast__Stmt _t25 = v__ast__ExprStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__ExprStmt, (((v__ast__ExprStmt){.pos = go_expr.pos,.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.expr = v__ast__GoExpr_to_sumtype_v__ast__Expr(&go_expr),.is_expr = 0,.typ = 0,})))); - return _t25; + v__ast__Stmt _t27 = v__ast__ExprStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__ExprStmt, (((v__ast__ExprStmt){.pos = go_expr.pos,.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.expr = v__ast__GoExpr_to_sumtype_v__ast__Expr(&go_expr),.is_expr = 0,.typ = 0,})))); + return _t27; break; } case v__token__Kind__key_goto: @@ -87641,20 +87804,20 @@ v__ast__Stmt v__parser__Parser_stmt(v__parser__Parser* p, bool is_top_level) { v__parser__Parser_next(p); v__token__Pos spos = v__token__Token_pos(&p->tok); string name = v__parser__Parser_check_name(p); - v__ast__Stmt _t26 = v__ast__GotoStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__GotoStmt, (((v__ast__GotoStmt){.name = name,.pos = spos,})))); - return _t26; + v__ast__Stmt _t28 = v__ast__GotoStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__GotoStmt, (((v__ast__GotoStmt){.name = name,.pos = spos,})))); + return _t28; break; } case v__token__Kind__key_const: { - v__ast__Stmt _t27 = v__ast__NodeError_to_sumtype_v__ast__Stmt(ADDR(v__ast__NodeError, (v__parser__Parser_error_with_pos(p, _SLIT("const can only be defined at the top level (outside of functions)"), v__token__Token_pos(&p->tok))))); - return _t27; + v__ast__Stmt _t29 = v__ast__NodeError_to_sumtype_v__ast__Stmt(ADDR(v__ast__NodeError, (v__parser__Parser_error_with_pos(p, _SLIT("const can only be defined at the top level (outside of functions)"), v__token__Token_pos(&p->tok))))); + return _t29; break; } case v__token__Kind__key_asm: { - v__ast__Stmt _t28 = v__ast__AsmStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__AsmStmt, (v__parser__Parser_asm_stmt(p, false)))); - return _t28; + v__ast__Stmt _t30 = v__ast__AsmStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__AsmStmt, (v__parser__Parser_asm_stmt(p, false)))); + return _t30; break; } case v__token__Kind__unknown: @@ -87758,8 +87921,8 @@ v__ast__Stmt v__parser__Parser_stmt(v__parser__Parser* p, bool is_top_level) { case v__token__Kind___end_: default: { - v__ast__Stmt _t29 = v__parser__Parser_parse_multi_expr(p, is_top_level); - return _t29; + v__ast__Stmt _t31 = v__parser__Parser_parse_multi_expr(p, is_top_level); + return _t31; break; } } @@ -88562,9 +88725,9 @@ VV_LOCAL_SYMBOL v__ast__Stmt v__parser__Parser_parse_multi_expr(v__parser__Parse v__token__Pos pos = v__token__Token_pos(&tok); Array_v__ast__Ident defer_vars = p->defer_vars; p->defer_vars = __new_array_with_default(0, 0, sizeof(v__ast__Ident), 0); - multi_return_Array_v__ast__Expr_Array_v__ast__Comment mr_47732 = v__parser__Parser_expr_list(p); - Array_v__ast__Expr left = mr_47732.arg0; - Array_v__ast__Comment left_comments = mr_47732.arg1; + multi_return_Array_v__ast__Expr_Array_v__ast__Comment mr_47746 = v__parser__Parser_expr_list(p); + Array_v__ast__Expr left = mr_47746.arg0; + Array_v__ast__Comment left_comments = mr_47746.arg1; if (!(p->inside_defer && p->tok.kind == v__token__Kind__decl_assign)) { _PUSH_MANY(&defer_vars, (p->defer_vars), _t1, Array_v__ast__Ident); } @@ -88958,6 +89121,13 @@ v__ast__Expr v__parser__Parser_name_expr(v__parser__Parser* p) { v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("unexpected "), 0xfe10, {.d_s = v__token__Token_str(p->prev_tok)}}, {_SLIT0, 0, { .d_c = 0 }}})), v__token__Token_pos(&p->prev_tok)); } node = v__ast__CallExpr_to_sumtype_v__ast__Expr(ADDR(v__ast__CallExpr, (v__parser__Parser_call_expr(p, language, mod)))); + if (p->tok.kind == v__token__Kind__lpar && p->prev_tok.line_nr == p->tok.line_nr) { + v__parser__Parser_next(p); + v__token__Pos pos = v__token__Token_pos(&p->tok); + Array_v__ast__CallArg args = v__parser__Parser_call_args(p); + v__parser__Parser_check(p, v__token__Kind__rpar); + node = v__ast__CallExpr_to_sumtype_v__ast__Expr(ADDR(v__ast__CallExpr, (((v__ast__CallExpr){.pos = pos,.name_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mod = (string){.str=(byteptr)"", .is_lit=1},.name = (string){.str=(byteptr)"", .is_lit=1},.is_method = 0,.is_field = 0,.is_fn_var = 0,.is_keep_alive = 0,.is_noreturn = 0,.is_ctor_new = 0,.args = args,.expected_arg_types = __new_array(0, 0, sizeof(v__ast__Type)),.language = 0,.or_block = (v__ast__OrExpr){.stmts = __new_array(0, 0, sizeof(v__ast__Stmt)),.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},},.left = node,.left_type = 0,.receiver_type = 0,.return_type = 0,.fn_var_type = 0,.should_be_skipped = 0,.concrete_types = __new_array(0, 0, sizeof(v__ast__Type)),.concrete_list_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.raw_concrete_types = __new_array(0, 0, sizeof(v__ast__Type)),.free_receiver = 0,.scope = p->scope,.from_embed_types = __new_array(0, 0, sizeof(v__ast__Type)),.comments = __new_array(0, 0, sizeof(v__ast__Comment)),})))); + } } } else if ((p->peek_tok.kind == v__token__Kind__lcbr || (p->peek_tok.kind == v__token__Kind__lt && lit0_is_capital)) && (!p->inside_match || (p->inside_select && prev_tok_kind == v__token__Kind__arrow && lit0_is_capital)) && !p->inside_match_case && (!p->inside_if || p->inside_select) && (!p->inside_for || p->inside_select) && !known_var) { v__ast__Expr _t19 = v__ast__StructInit_to_sumtype_v__ast__Expr(ADDR(v__ast__StructInit, (v__parser__Parser_struct_init(p, string__plus(string__plus(p->mod, _SLIT(".")), p->tok.lit), false)))); @@ -89834,9 +90004,9 @@ VV_LOCAL_SYMBOL v__ast__Return v__parser__Parser_return_stmt(v__parser__Parser* v__ast__Return _t1 = ((v__ast__Return){.pos = first_pos,.comments = comments,.exprs = __new_array(0, 0, sizeof(v__ast__Expr)),.types = __new_array(0, 0, sizeof(v__ast__Type)),}); return _t1; } - multi_return_Array_v__ast__Expr_Array_v__ast__Comment mr_84043 = v__parser__Parser_expr_list(p); - Array_v__ast__Expr exprs = mr_84043.arg0; - Array_v__ast__Comment comments2 = mr_84043.arg1; + multi_return_Array_v__ast__Expr_Array_v__ast__Comment mr_84307 = v__parser__Parser_expr_list(p); + Array_v__ast__Expr exprs = mr_84307.arg0; + Array_v__ast__Comment comments2 = mr_84307.arg1; _PUSH_MANY(&comments, (comments2), _t2, Array_v__ast__Comment); v__token__Pos end_pos = v__ast__Expr_pos((*(v__ast__Expr*)array_last(exprs))); v__ast__Return _t3 = ((v__ast__Return){.pos = v__token__Pos_extend(first_pos, end_pos),.comments = comments,.exprs = exprs,.types = __new_array(0, 0, sizeof(v__ast__Type)),}); @@ -90090,8 +90260,8 @@ VV_LOCAL_SYMBOL v__ast__TypeDecl v__parser__Parser_type_decl(v__parser__Parser* return _t2; } Array_v__ast__TypeNode sum_variants = __new_array_with_default(0, 0, sizeof(v__ast__TypeNode), 0); - multi_return_Array_v__ast__Type_Array_string mr_90240 = v__parser__Parser_parse_generic_types(p); - Array_v__ast__Type generic_types = mr_90240.arg0; + multi_return_Array_v__ast__Type_Array_string mr_90504 = v__parser__Parser_parse_generic_types(p); + Array_v__ast__Type generic_types = mr_90504.arg0; v__token__Pos decl_pos_with_generics = v__token__Pos_extend(decl_pos, v__token__Token_pos(&p->prev_tok)); v__parser__Parser_check(p, v__token__Kind__assign); v__token__Pos type_pos = v__token__Token_pos(&p->tok); @@ -91706,27 +91876,24 @@ string v__parser__Parser_compile_template_file(v__parser__Parser* p, string temp } if (state == (v__parser__State__html)) { - if (string_starts_with(line, _SLIT("span.")) && string_ends_with(line, _SLIT("{"))) { + string line_t = string_trim_space(line); + if (string_starts_with(line_t, _SLIT("span.")) && string_ends_with(line, _SLIT("{"))) { string _v_class = string_trim_space(string_find_between(line, _SLIT("span."), _SLIT("{"))); strings__Builder_writeln(&source, str_intp(2, _MOV((StrIntpData[]){{_SLIT(""), 0, { .d_c = 0 }}}))); in_span = true; continue; - } - if (string_starts_with(string_trim_space(line), _SLIT(".")) && string_ends_with(line, _SLIT("{"))) { + } else if (string_starts_with(line_t, _SLIT(".")) && string_ends_with(line, _SLIT("{"))) { string _v_class = string_trim_space(string_find_between(line, _SLIT("."), _SLIT("{"))); string trimmed = string_trim_space(line); strings__Builder_write_string(&source, strings__repeat('\t', line.len - trimmed.len)); strings__Builder_writeln(&source, str_intp(2, _MOV((StrIntpData[]){{_SLIT("
"), 0, { .d_c = 0 }}}))); continue; - } - if (string_starts_with(line, _SLIT("#")) && string_ends_with(line, _SLIT("{"))) { + } else if (string_starts_with(line_t, _SLIT("#")) && string_ends_with(line, _SLIT("{"))) { string _v_class = string_trim_space(string_find_between(line, _SLIT("#"), _SLIT("{"))); strings__Builder_writeln(&source, str_intp(2, _MOV((StrIntpData[]){{_SLIT("
"), 0, { .d_c = 0 }}}))); continue; - } - if (string__eq(string_trim_space(line), _SLIT("}"))) { - string trimmed = string_trim_space(line); - strings__Builder_write_string(&source, strings__repeat('\t', line.len - trimmed.len)); + } else if (string__eq(line_t, _SLIT("}"))) { + strings__Builder_write_string(&source, strings__repeat('\t', line.len - line_t.len)); if (in_span) { strings__Builder_writeln(&source, _SLIT("")); in_span = false; @@ -92549,6 +92716,16 @@ VV_LOCAL_SYMBOL void v__builder__Builder_setup_ccompiler_options(v__builder__Bui if (v->pref->os == v__pref__OS__macos && os__exists(_SLIT("/opt/procursus"))) { array_push((array*)&ccoptions.linker_flags, _MOV((string[]){ string_clone(_SLIT("-Wl,-rpath,/opt/procursus/lib")) })); } + int user_darwin_version = 999999999; + bool user_darwin_ppc = false; + #if defined(__APPLE__) + { + user_darwin_version = string_int((*(string*)/*ee elem_sym */array_get(string_split(os__uname().release, _SLIT(".")), 0))); + if (string__eq(os__uname().machine, _SLIT("Power Macintosh"))) { + user_darwin_ppc = true; + } + } + #endif ccoptions.debug_mode = v->pref->is_debug; ccoptions.guessed_compiler = v->pref->ccompiler; if (string__eq(ccoptions.guessed_compiler, _SLIT("cc")) && v->pref->is_prod) { @@ -92588,18 +92765,21 @@ VV_LOCAL_SYMBOL void v__builder__Builder_setup_ccompiler_options(v__builder__Bui } if (ccoptions.is_cc_gcc) { if (ccoptions.debug_mode) { - debug_options = new_array_from_c_array(2, 2, sizeof(string), _MOV((string[2]){_SLIT("-g"), _SLIT("-no-pie")})); + debug_options = new_array_from_c_array(1, 1, sizeof(string), _MOV((string[1]){_SLIT("-g")})); + if (user_darwin_version > 9) { + array_push((array*)&debug_options, _MOV((string[]){ string_clone(_SLIT("-no-pie")) })); + } } optimization_options = new_array_from_c_array(3, 3, sizeof(string), _MOV((string[3]){_SLIT("-O3"), _SLIT("-fno-strict-aliasing"), _SLIT("-flto")})); } if (ccoptions.debug_mode) { - _PUSH_MANY(&ccoptions.args, (debug_options), _t9, Array_string); + _PUSH_MANY(&ccoptions.args, (debug_options), _t10, Array_string); } if (v->pref->is_prod) { if (ccoptions.is_cc_tcc && !(v->parsed_files.len > 0 && string_contains((*(v__ast__File**)array_last(v->parsed_files))->path, _SLIT("vlib")))) { eprintln(_SLIT("Note: tcc is not recommended for -prod builds")); } - _PUSH_MANY(&ccoptions.args, (optimization_options), _t10, Array_string); + _PUSH_MANY(&ccoptions.args, (optimization_options), _t11, Array_string); } if (v->pref->is_prod && !ccoptions.debug_mode) { array_push((array*)&ccoptions.args, _MOV((string[]){ string_clone(_SLIT("-DNDEBUG")) })); @@ -92661,7 +92841,7 @@ VV_LOCAL_SYMBOL void v__builder__Builder_setup_ccompiler_options(v__builder__Bui } } if (v->pref->os == v__pref__OS__macos || v->pref->os == v__pref__OS__ios) { - if (!ccoptions.is_cc_tcc) { + if (!ccoptions.is_cc_tcc && !user_darwin_ppc) { array_push((array*)&ccoptions.source_args, _MOV((string[]){ string_clone(_SLIT("-x objective-c")) })); } } @@ -92683,15 +92863,15 @@ VV_LOCAL_SYMBOL void v__builder__Builder_setup_ccompiler_options(v__builder__Bui Array_v__cflag__CFlag cflags = v__builder__Builder_get_os_cflags(v); if (v->pref->build_mode != v__pref__BuildMode__build_module) { Array_string only_o_files = Array_v__cflag__CFlag_c_options_only_object_files(cflags); - _PUSH_MANY(&ccoptions.o_args, (only_o_files), _t39, Array_string); + _PUSH_MANY(&ccoptions.o_args, (only_o_files), _t40, Array_string); } - multi_return_Array_string_Array_string_Array_string mr_11425 = Array_v__cflag__CFlag_defines_others_libs(cflags); - Array_string defines = mr_11425.arg0; - Array_string others = mr_11425.arg1; - Array_string libs = mr_11425.arg2; - _PUSH_MANY(&ccoptions.pre_args, (defines), _t40, Array_string); - _PUSH_MANY(&ccoptions.pre_args, (others), _t41, Array_string); - _PUSH_MANY(&ccoptions.linker_flags, (libs), _t42, Array_string); + multi_return_Array_string_Array_string_Array_string mr_11728 = Array_v__cflag__CFlag_defines_others_libs(cflags); + Array_string defines = mr_11728.arg0; + Array_string others = mr_11728.arg1; + Array_string libs = mr_11728.arg2; + _PUSH_MANY(&ccoptions.pre_args, (defines), _t41, Array_string); + _PUSH_MANY(&ccoptions.pre_args, (others), _t42, Array_string); + _PUSH_MANY(&ccoptions.linker_flags, (libs), _t43, Array_string); if (v->pref->use_cache && v->pref->build_mode != v__pref__BuildMode__build_module) { if (!ccoptions.is_cc_tcc) { #if defined(__linux__) @@ -93113,10 +93293,10 @@ VV_LOCAL_SYMBOL void v__builder__Builder_cc_linux_cross(v__builder__Builder* b) v__builder__Builder_ensure_linuxroot_exists(b, sysroot); string obj_file = string__plus(b->out_name_c, _SLIT(".o")); Array_v__cflag__CFlag cflags = v__builder__Builder_get_os_cflags(b); - multi_return_Array_string_Array_string_Array_string mr_22460 = Array_v__cflag__CFlag_defines_others_libs(cflags); - Array_string defines = mr_22460.arg0; - Array_string others = mr_22460.arg1; - Array_string libs = mr_22460.arg2; + multi_return_Array_string_Array_string_Array_string mr_22763 = Array_v__cflag__CFlag_defines_others_libs(cflags); + Array_string defines = mr_22763.arg0; + Array_string others = mr_22763.arg1; + Array_string libs = mr_22763.arg2; Array_string cc_args = __new_array_with_default(0, 0, sizeof(string), 0); array_push((array*)&cc_args, _MOV((string[]){ string_clone(_SLIT("-w")) })); array_push((array*)&cc_args, _MOV((string[]){ string_clone(_SLIT("-fPIC")) })); diff --git a/v_win.c b/v_win.c index 596094d..b288ec0 100644 --- a/v_win.c +++ b/v_win.c @@ -1,11 +1,11 @@ -#define V_COMMIT_HASH "9d764cd25" +#define V_COMMIT_HASH "b81f06e36" #ifndef V_COMMIT_HASH - #define V_COMMIT_HASH "5e8c4a3" + #define V_COMMIT_HASH "9d764cd25" #endif #ifndef V_CURRENT_COMMIT_HASH - #define V_CURRENT_COMMIT_HASH "9d764cd" + #define V_CURRENT_COMMIT_HASH "b81f06e" #endif // V comptime_definitions: @@ -8967,6 +8967,7 @@ Option_void v__checker__Checker_check_expected(v__checker__Checker* c, v__ast__T VV_LOCAL_SYMBOL string v__checker__Checker_expected_msg(v__checker__Checker* c, v__ast__Type got, v__ast__Type expected); bool v__checker__Checker_symmetric_check(v__checker__Checker* c, v__ast__Type left, v__ast__Type right); void v__checker__Checker_infer_fn_generic_types(v__checker__Checker* c, v__ast__Fn func, v__ast__CallExpr* node); +int v__checker__Checker_sizeof_integer(v__checker__Checker* c, v__ast__Type a); int _const_v__checker__int_min; // inited later int _const_v__checker__int_max = 2147483647; // precomputed #define _const_v__checker__expr_level_cutoff_limit 40 @@ -12942,12 +12943,12 @@ int strings__levenshtein_distance(string a, string b) { array_set(&f, j, &(int[]) { j }); } for (int _t1 = 0; _t1 < a.len; ++_t1) { - byte ca = a.str[_t1]; + u8 ca = a.str[_t1]; int j = 1; int fj1 = (*(int*)/*ee elem_sym */array_get(f, 0)); (*(int*)/*ee elem_sym */array_get(f, 0))++; for (int _t2 = 0; _t2 < b.len; ++_t2) { - byte cb = b.str[_t2]; + u8 cb = b.str[_t2]; int mn = ((*(int*)/*ee elem_sym */array_get(f, j)) + 1 <= (*(int*)/*ee elem_sym */array_get(f, j - 1)) + 1 ? ((*(int*)/*ee elem_sym */array_get(f, j)) + 1) : ((*(int*)/*ee elem_sym */array_get(f, j - 1)) + 1)); if (cb != ca) { mn = (mn <= fj1 + 1 ? (mn) : (fj1 + 1)); @@ -13035,7 +13036,7 @@ string strings__find_between_pair_u8(string input, u8 start, u8 end) { int marks = 0; int start_index = -1; for (int i = 0; i < input.len; ++i) { - byte b = input.str[i]; + u8 b = input.str[i]; if (b == start) { if (start_index == -1) { start_index = i + 1; @@ -14796,7 +14797,7 @@ string strconv__f64_to_str_lnd1(f64 f, int dec_digit) { int exp_sgn = 1; int dot_res_sp = -1; for (int _t2 = 0; _t2 < s.len; ++_t2) { - byte c = s.str[_t2]; + u8 c = s.str[_t2]; if (c == ('-')) { sgn = -1; @@ -15254,7 +15255,7 @@ string strconv__fxx_to_str_l_parse(string s) { int exp = 0; int exp_sgn = 1; for (int _t2 = 0; _t2 < s.len; ++_t2) { - byte c = s.str[_t2]; + u8 c = s.str[_t2]; if (c == '-') { sgn = -1; i++; @@ -15363,7 +15364,7 @@ string strconv__fxx_to_str_l_parse_no_dot(string s) { int exp = 0; int exp_sgn = 1; for (int _t2 = 0; _t2 < s.len; ++_t2) { - byte c = s.str[_t2]; + u8 c = s.str[_t2]; if (c == '-') { sgn = -1; i++; @@ -20106,9 +20107,9 @@ Array_string string_split_any(string s, string delim) { return string_split(s, _SLIT("")); } for (int index = 0; index < s.len; ++index) { - byte ch = s.str[index]; + u8 ch = s.str[index]; for (int _t2 = 0; _t2 < delim.len; ++_t2) { - byte delim_ch = delim.str[_t2]; + u8 delim_ch = delim.str[_t2]; if (ch == delim_ch) { array_push((array*)&res, _MOV((string[]){ string_substr(s, i, index) })); i = index + 1; @@ -20135,7 +20136,7 @@ Array_string string_split_nth(string s, string delim, int nth) { if (delim.len == (0)) { i = 1; for (int _t1 = 0; _t1 < s.len; ++_t1) { - byte ch = s.str[_t1]; + u8 ch = s.str[_t1]; if (nth > 0 && i >= nth) { array_push((array*)&res, _MOV((string[]){ string_substr(s, i, (s).len) })); break; @@ -20395,9 +20396,9 @@ Array_int prefix; int string_index_any(string s, string chars) { for (int i = 0; i < s.len; ++i) { - byte ss = s.str[i]; + u8 ss = s.str[i]; for (int _t1 = 0; _t1 < chars.len; ++_t1) { - byte c = chars.str[_t1]; + u8 c = chars.str[_t1]; if (c == ss) { return i; } @@ -20499,7 +20500,7 @@ int string_count(string s, string substr) { if (substr.len == 1) { u8 target = substr.str[ 0]; for (int _t3 = 0; _t3 < s.len; ++_t3) { - byte letter = s.str[_t3]; + u8 letter = s.str[_t3]; if (letter == target) { n++; } @@ -20530,7 +20531,7 @@ bool string_contains(string s, string substr) { bool string_contains_any(string s, string chars) { for (int _t1 = 0; _t1 < chars.len; ++_t1) { - byte c = chars.str[_t1]; + u8 c = chars.str[_t1]; if (string_contains(s, u8_ascii_str(c))) { return true; } @@ -20719,7 +20720,7 @@ string string_trim(string s, string cutset) { if (!(pos_left <= s.len && pos_right >= -1 && cs_match)) break; cs_match = false; for (int _t2 = 0; _t2 < cutset.len; ++_t2) { - byte cs = cutset.str[_t2]; + u8 cs = cutset.str[_t2]; if (s.str[ pos_left] == cs) { pos_left++; cs_match = true; @@ -20727,7 +20728,7 @@ string string_trim(string s, string cutset) { } } for (int _t3 = 0; _t3 < cutset.len; ++_t3) { - byte cs = cutset.str[_t3]; + u8 cs = cutset.str[_t3]; if (s.str[ pos_right] == cs) { pos_right--; cs_match = true; @@ -20751,7 +20752,7 @@ string string_trim_left(string s, string cutset) { if (!(pos < s.len)) break; bool found = false; for (int _t2 = 0; _t2 < cutset.len; ++_t2) { - byte cs = cutset.str[_t2]; + u8 cs = cutset.str[_t2]; if (s.str[ pos] == cs) { found = true; break; @@ -20775,7 +20776,7 @@ string string_trim_right(string s, string cutset) { if (!(pos >= 0)) break; bool found = false; for (int _t2 = 0; _t2 < cutset.len; ++_t2) { - byte cs = cutset.str[_t2]; + u8 cs = cutset.str[_t2]; if (s.str[ pos] == cs) { found = true; } @@ -20987,7 +20988,7 @@ string string_after(string s, string sub) { string string_after_char(string s, u8 sub) { int pos = -1; for (int i = 0; i < s.len; ++i) { - byte c = s.str[i]; + u8 c = s.str[i]; if (c == sub) { pos = i; break; @@ -21062,7 +21063,7 @@ int string_hash(string s) { u32 h = ((u32)(0U)); if (h == 0U && s.len > 0) { for (int _t1 = 0; _t1 < s.len; ++_t1) { - byte c = s.str[_t1]; + u8 c = s.str[_t1]; h = h * 31U + ((u32)(c)); } } @@ -21109,7 +21110,7 @@ Array_string string_fields(string s) { bool is_in_word = false; bool is_space = false; for (int i = 0; i < s.len; ++i) { - byte c = s.str[i]; + u8 c = s.str[i]; is_space = (c == 32 || c == 9 || c == 10); if (!is_space) { word_len++; @@ -26590,7 +26591,7 @@ inline VV_LOCAL_SYMBOL semver__Version semver__increment_version(semver__Version VV_LOCAL_SYMBOL bool semver__is_valid_string(string input) { for (int _t1 = 0; _t1 < input.len; ++_t1) { - byte c = input.str[_t1]; + u8 c = input.str[_t1]; if (!(u8_is_letter(c) || u8_is_digit(c) || c == '.' || c == '-')) { bool _t2 = false; return _t2; @@ -26602,7 +26603,7 @@ VV_LOCAL_SYMBOL bool semver__is_valid_string(string input) { VV_LOCAL_SYMBOL bool semver__is_valid_number(string input) { for (int _t1 = 0; _t1 < input.len; ++_t1) { - byte c = input.str[_t1]; + u8 c = input.str[_t1]; if (!u8_is_digit(c)) { bool _t2 = false; return _t2; @@ -26900,7 +26901,7 @@ multi_return_string_int os__fd_read(int fd, int maxbytes) { Option_os__File os__open_file(string path, string mode, Array_int options) { int flags = 0; for (int _t1 = 0; _t1 < mode.len; ++_t1) { - byte m = mode.str[_t1]; + u8 m = mode.str[_t1]; if (m == ('w')) { flags |= (_const_os__o_create | _const_os__o_trunc); @@ -33631,7 +33632,7 @@ void v__pref__Preferences_fill_with_defaults(v__pref__Preferences* p) { if ((p->third_party_option).len == 0) { p->third_party_option = p->cflags; } - string vhash = _SLIT("5e8c4a3"); + string vhash = _SLIT("9d764cd25"); p->cache_manager = v__vcache__new_cache_manager(new_array_from_c_array(7, 7, sizeof(string), _MOV((string[7]){string_clone(vhash), str_intp(6, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = v__pref__Backend_str(p->backend)}}, {_SLIT(" | "), 0xfe10, {.d_s = v__pref__OS_str(p->os)}}, {_SLIT(" | "), 0xfe10, {.d_s = p->ccompiler}}, {_SLIT(" | "), 0xfe10, {.d_s = p->is_prod ? _SLIT("true") : _SLIT("false")}}, {_SLIT(" | "), 0xfe10, {.d_s = p->sanitize ? _SLIT("true") : _SLIT("false")}}, {_SLIT0, 0, { .d_c = 0 }}})), string_clone(string_trim_space(p->cflags)), string_clone(string_trim_space(p->third_party_option)), string_clone(Array_string_str(p->compile_defines_all)), string_clone(Array_string_str(p->compile_defines)), string_clone(Array_string_str(p->lookup_path))}))); if (string__eq(os__user_os(), _SLIT("windows"))) { p->use_cache = false; @@ -36018,7 +36019,7 @@ void help__print_and_exit(string topic) { string vroot = os__dir(vexe); string topicdir = os__join_path(vroot, new_array_from_c_array(3, 3, sizeof(string), _MOV((string[3]){_SLIT("cmd"), _SLIT("v"), _SLIT("help")}))); for (int _t1 = 0; _t1 < topic.len; ++_t1) { - byte b = topic.str[_t1]; + u8 b = topic.str[_t1]; if ((b >= 'a' && b <= 'z') || b == '-' || (b >= '0' && b <= '9')) { continue; } @@ -36501,7 +36502,7 @@ inline bool v__util__is_func_char(u8 c) { bool v__util__contains_capital(string s) { for (int _t1 = 0; _t1 < s.len; ++_t1) { - byte c = s.str[_t1]; + u8 c = s.str[_t1]; if (c >= 'A' && c <= 'Z') { bool _t2 = true; return _t2; @@ -38010,6 +38011,15 @@ Option_void v__ast__Stmt_check_c_expr(v__ast__Stmt stmt) { if (stmt._typ == 337 /* v.ast.AssignStmt */) { return (Option_void){0}; } + else if (stmt._typ == 346 /* v.ast.ForCStmt */) { + return (Option_void){0}; + } + else if (stmt._typ == 347 /* v.ast.ForInStmt */) { + return (Option_void){0}; + } + else if (stmt._typ == 348 /* v.ast.ForStmt */) { + return (Option_void){0}; + } else if (stmt._typ == 345 /* v.ast.ExprStmt */) { if (v__ast__Expr_is_expr((*stmt._v__ast__ExprStmt).expr)) { return (Option_void){0}; @@ -45380,7 +45390,7 @@ bool v__checker__Checker_assign_stmt_defer_0 = false; v__ast__Type left_elem_type = v__ast__Table_unaliased_type(c->table, left_info.elem_type); v__ast__Array right_info = /* as */ *(v__ast__Array*)__as_cast((right_sym->info)._v__ast__Array,(right_sym->info)._typ, 450) /*expected idx: 450, name: v.ast.Array */ ; v__ast__Type right_elem_type = v__ast__Table_unaliased_type(c->table, right_info.elem_type); - if (left_info.nr_dims == right_info.nr_dims && v__ast__Type_alias_eq(left_elem_type, right_elem_type)) { + if (v__ast__Type_nr_muls(left_type_unwrapped) == v__ast__Type_nr_muls(right_type_unwrapped) && left_info.nr_dims == right_info.nr_dims && v__ast__Type_alias_eq(left_elem_type, right_elem_type)) { continue; } } @@ -45790,7 +45800,10 @@ Option_void v__checker__Checker_check_expected_call_arg(v__checker__Checker* c, } return (Option_void){0}; } - return (Option_void){ .state=2, .err=_v_error( str_intp(3, _MOV((StrIntpData[]){{_SLIT("cannot use `"), 0xfe10, {.d_s = got_typ_str}}, {_SLIT("` as `"), 0xfe10, {.d_s = expected_typ_str}}, {_SLIT("`"), 0, { .d_c = 0 }}}))), .data={EMPTY_STRUCT_INITIALIZATION} }; + if (!v__ast__Type_alias_eq(got, _const_v__ast__void_type)) { + return (Option_void){ .state=2, .err=_v_error( str_intp(3, _MOV((StrIntpData[]){{_SLIT("cannot use `"), 0xfe10, {.d_s = got_typ_str}}, {_SLIT("` as `"), 0xfe10, {.d_s = expected_typ_str}}, {_SLIT("`"), 0, { .d_c = 0 }}}))), .data={EMPTY_STRUCT_INITIALIZATION} }; + } + return (Option_void){0}; } VV_LOCAL_SYMBOL bool v__checker__Checker_check_same_module(v__checker__Checker _v_toheap_c, v__ast__Type got, v__ast__Type expected) { @@ -46038,10 +46051,10 @@ VV_LOCAL_SYMBOL v__ast__Type v__checker__Checker_promote_num(v__checker__Checker v__ast__Type type_hi = left_type; v__ast__Type type_lo = right_type; if (v__ast__Type_idx(type_hi) < v__ast__Type_idx(type_lo)) { - v__ast__Type _var_16285 = type_hi; - v__ast__Type _var_16294 = type_lo; - type_hi = _var_16294; - type_lo = _var_16285; + v__ast__Type _var_16316 = type_hi; + v__ast__Type _var_16325 = type_lo; + type_hi = _var_16325; + type_lo = _var_16316; } int idx_hi = v__ast__Type_idx(type_hi); int idx_lo = v__ast__Type_idx(type_lo); @@ -46347,6 +46360,44 @@ void v__checker__Checker_infer_fn_generic_types(v__checker__Checker* c, v__ast__ } } +int v__checker__Checker_sizeof_integer(v__checker__Checker* c, v__ast__Type a) { + v__ast__Type t = (Array_int_contains(_const_v__ast__unsigned_integer_type_idxs, a) ? (v__ast__Type_flip_signedness(a)) : (a)); + int_literal _t1 = 0; + + if (t == (_const_v__ast__char_type_idx) || t == (_const_v__ast__i8_type_idx)) { + _t1 = 1; + } + else if (t == (_const_v__ast__i16_type_idx)) { + _t1 = 2; + } + else if (t == (_const_v__ast__int_type_idx)) { + _t1 = 4; + } + else if (t == (_const_v__ast__rune_type_idx)) { + _t1 = 4; + } + else if (t == (_const_v__ast__i64_type_idx)) { + _t1 = 8; + } + else if (t == (_const_v__ast__isize_type_idx)) { + _t1 = (c->pref->m64 ? (8) : (4)); + } + else if (t == (_const_v__ast__int_literal_type)) { + string s = v__ast__Table_type_to_str(c->table, a); + _v_panic( str_intp(2, _MOV((StrIntpData[]){{_SLIT("`"), 0xfe10, {.d_s = s}}, {_SLIT("` has unknown size"), 0, { .d_c = 0 }}}))); + VUNREACHABLE(); + _t1 = 0; + } + else { + string s = v__ast__Table_type_to_str(c->table, a); + _v_panic( str_intp(2, _MOV((StrIntpData[]){{_SLIT("`"), 0xfe10, {.d_s = s}}, {_SLIT("` is not an integer"), 0, { .d_c = 0 }}}))); + VUNREACHABLE(); + _t1 = 0; + }int r = _t1; + int _t2 = r; + return _t2; +} + VV_LOCAL_SYMBOL Array_string v__checker__all_valid_comptime_idents(void) { Array_string res = __new_array_with_default(0, 0, sizeof(string), 0); _PUSH_MANY(&res, (_const_v__checker__valid_comptime_if_os), _t1, Array_string); @@ -46956,6 +47007,14 @@ v__ast__Type former_expected_type; string rt = v__ast__Table_sym(c->table, right_type)->name; v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("negative value cannot be compared with `"), 0xfe10, {.d_s = rt}}, {_SLIT("`"), 0, { .d_c = 0 }}})), (*node->left._v__ast__IntegerLiteral).pos); } + } else if (is_left_type_signed != is_right_type_signed && left_type != _const_v__ast__int_literal_type_idx && right_type != _const_v__ast__int_literal_type_idx) { + int ls = v__checker__Checker_sizeof_integer(c, left_type); + int rs = v__checker__Checker_sizeof_integer(c, right_type); + if ((is_left_type_signed && ls < rs) || (is_right_type_signed && rs < ls)) { + string lt = v__ast__Table_sym(c->table, left_type)->name; + string rt = v__ast__Table_sym(c->table, right_type)->name; + v__checker__Checker_error(c, str_intp(3, _MOV((StrIntpData[]){{_SLIT("`"), 0xfe10, {.d_s = lt}}, {_SLIT("` cannot be compared with `"), 0xfe10, {.d_s = rt}}, {_SLIT("`"), 0, { .d_c = 0 }}})), node->pos); + } } } break; @@ -47221,8 +47280,8 @@ v__ast__Type former_expected_type; v__checker__Checker_error(c, _SLIT("array append cannot be used in an expression"), node->pos); } v__checker__Checker_check_expr_opt_call(c, node->right, right_type); - multi_return_string_v__token__Pos mr_33156 = v__checker__Checker_fail_if_immutable(c, node->left); - node->auto_locked = mr_33156.arg0; + multi_return_string_v__token__Pos mr_33737 = v__checker__Checker_fail_if_immutable(c, node->left); + node->auto_locked = mr_33737.arg0; v__ast__Type left_value_type = v__ast__Table_value_type(c->table, v__checker__Checker_unwrap_generic(c, left_type)); v__ast__TypeSymbol* left_value_sym = v__ast__Table_sym(c->table, v__checker__Checker_unwrap_generic(c, left_value_type)); if (left_value_sym->kind == v__ast__Kind__interface_) { @@ -47658,19 +47717,19 @@ VV_LOCAL_SYMBOL multi_return_string_v__token__Pos v__checker__Checker_fail_if_im if (v__ast__Type_has_flag(elem_type, v__ast__TypeFlag__shared_f)) { v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("you have to create a handle and `lock` it to modify `shared` "), 0xfe10, {.d_s = kind}}, {_SLIT(" element"), 0, { .d_c = 0 }}})), v__token__Pos_extend(v__ast__Expr_pos((*expr._v__ast__IndexExpr).left), (*expr._v__ast__IndexExpr).pos)); } - multi_return_string_v__token__Pos mr_43532 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__IndexExpr).left); - to_lock = mr_43532.arg0; - pos = mr_43532.arg1; + multi_return_string_v__token__Pos mr_44113 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__IndexExpr).left); + to_lock = mr_44113.arg0; + pos = mr_44113.arg1; } else if (expr._typ == 320 /* v.ast.ParExpr */) { - multi_return_string_v__token__Pos mr_43601 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__ParExpr).expr); - to_lock = mr_43601.arg0; - pos = mr_43601.arg1; + multi_return_string_v__token__Pos mr_44182 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__ParExpr).expr); + to_lock = mr_44182.arg0; + pos = mr_44182.arg1; } else if (expr._typ == 322 /* v.ast.PrefixExpr */) { - multi_return_string_v__token__Pos mr_43673 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__PrefixExpr).right); - to_lock = mr_43673.arg0; - pos = mr_43673.arg1; + multi_return_string_v__token__Pos mr_44254 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__PrefixExpr).right); + to_lock = mr_44254.arg0; + pos = mr_44254.arg1; } else if (expr._typ == 325 /* v.ast.SelectorExpr */) { if ((*expr._v__ast__SelectorExpr).expr_type == 0) { @@ -47720,9 +47779,9 @@ VV_LOCAL_SYMBOL multi_return_string_v__token__Pos v__checker__Checker_fail_if_im string type_str = v__ast__Table_type_to_str(c->table, (*expr._v__ast__SelectorExpr).expr_type); v__checker__Checker_error(c, str_intp(3, _MOV((StrIntpData[]){{_SLIT("field `"), 0xfe10, {.d_s = (*expr._v__ast__SelectorExpr).field_name}}, {_SLIT("` of struct `"), 0xfe10, {.d_s = type_str}}, {_SLIT("` is immutable"), 0, { .d_c = 0 }}})), (*expr._v__ast__SelectorExpr).pos); } - multi_return_string_v__token__Pos mr_45137 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__SelectorExpr).expr); - to_lock = mr_45137.arg0; - pos = mr_45137.arg1; + multi_return_string_v__token__Pos mr_45718 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__SelectorExpr).expr); + to_lock = mr_45718.arg0; + pos = mr_45718.arg1; } if ((to_lock).len != 0) { explicit_lock_needed = true; @@ -47828,9 +47887,9 @@ VV_LOCAL_SYMBOL multi_return_string_v__token__Pos v__checker__Checker_fail_if_im } else if (expr._typ == 291 /* v.ast.CallExpr */) { if (string__eq((*expr._v__ast__CallExpr).name, _SLIT("slice"))) { - multi_return_string_v__token__Pos mr_46960 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__CallExpr).left); - to_lock = mr_46960.arg0; - pos = mr_46960.arg1; + multi_return_string_v__token__Pos mr_47541 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__CallExpr).left); + to_lock = mr_47541.arg0; + pos = mr_47541.arg1; if ((to_lock).len != 0) { explicit_lock_needed = true; } @@ -48171,7 +48230,6 @@ v__ast__Type v__checker__Checker_selector_expr(v__checker__Checker* c, v__ast__S c->inside_selector_expr = old_selector_expr; c->using_new_err_struct = using_new_err_struct_save; if (typ == _const_v__ast__void_type_idx) { - v__checker__Checker_error(c, _SLIT("`void` type has no fields"), node->pos); v__ast__Type _t6 = _const_v__ast__void_type; return _t6; } @@ -48230,9 +48288,9 @@ v__ast__Type v__checker__Checker_selector_expr(v__checker__Checker* c, v__ast__S *(multi_return_v__ast__StructField_Array_v__ast__Type*) _t13.data = (multi_return_v__ast__StructField_Array_v__ast__Type){.arg0=((v__ast__StructField){.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.type_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.has_default_expr = 0,.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.is_pub = 0,.default_val = (string){.str=(byteptr)"", .is_lit=1},.is_mut = 0,.is_global = 0,.is_volatile = 0,.default_expr = {0},.default_expr_typ = 0,.name = (string){.str=(byteptr)"", .is_lit=1},.typ = 0,}),.arg1=__new_array_with_default(0, 0, sizeof(v__ast__Type), 0)}; } - multi_return_v__ast__StructField_Array_v__ast__Type mr_60068 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t13.data); - field = mr_60068.arg0; - embed_types = mr_60068.arg1; + multi_return_v__ast__StructField_Array_v__ast__Type mr_60742 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t13.data); + field = mr_60742.arg0; + embed_types = mr_60742.arg1; node->from_embed_types = embed_types; if (sym->kind == v__ast__Kind__aggregate || sym->kind == v__ast__Kind__sum_type) { unknown_field_msg = IError_name_table[err._typ]._method_msg(err._object); @@ -48266,9 +48324,9 @@ v__ast__Type v__checker__Checker_selector_expr(v__checker__Checker* c, v__ast__S *(multi_return_v__ast__StructField_Array_v__ast__Type*) _t15.data = (multi_return_v__ast__StructField_Array_v__ast__Type){.arg0=((v__ast__StructField){.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.type_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.has_default_expr = 0,.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.is_pub = 0,.default_val = (string){.str=(byteptr)"", .is_lit=1},.is_mut = 0,.is_global = 0,.is_volatile = 0,.default_expr = {0},.default_expr_typ = 0,.name = (string){.str=(byteptr)"", .is_lit=1},.typ = 0,}),.arg1=__new_array_with_default(0, 0, sizeof(v__ast__Type), 0)}; } - multi_return_v__ast__StructField_Array_v__ast__Type mr_60899 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t15.data); - field = mr_60899.arg0; - embed_types = mr_60899.arg1; + multi_return_v__ast__StructField_Array_v__ast__Type mr_61573 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t15.data); + field = mr_61573.arg0; + embed_types = mr_61573.arg1; node->from_embed_types = embed_types; } } @@ -50492,8 +50550,8 @@ v__ast__Type v__checker__Checker_postfix_expr(v__checker__Checker* c, v__ast__Po string typ_str = v__ast__Table_type_to_str(c->table, typ); v__checker__Checker_error(c, str_intp(3, _MOV((StrIntpData[]){{_SLIT("invalid operation: "), 0xfe10, {.d_s = v__token__Kind_str(node->op)}}, {_SLIT(" (non-numeric type `"), 0xfe10, {.d_s = typ_str}}, {_SLIT("`)"), 0, { .d_c = 0 }}})), node->pos); } else { - multi_return_string_v__token__Pos mr_115132 = v__checker__Checker_fail_if_immutable(c, node->expr); - node->auto_locked = mr_115132.arg0; + multi_return_string_v__token__Pos mr_115806 = v__checker__Checker_fail_if_immutable(c, node->expr); + node->auto_locked = mr_115806.arg0; } v__ast__Type _t1 = typ; return _t1; @@ -53864,6 +53922,17 @@ v__ast__Type v__checker__Checker_fn_call(v__checker__Checker* c, v__ast__CallExp v__ast__Type _t15 = _const_v__ast__string_type; return _t15; } + if (!found && (node->left)._typ == 291 /* v.ast.CallExpr */) { + v__checker__Checker_expr(c, node->left); + v__ast__CallExpr expr = /* as */ *(v__ast__CallExpr*)__as_cast((node->left)._v__ast__CallExpr,(node->left)._typ, 291) /*expected idx: 291, name: v.ast.CallExpr */ ; + v__ast__TypeSymbol* sym = v__ast__Table_sym(c->table, expr.return_type); + if (sym->kind == v__ast__Kind__function) { + v__ast__FnType info = /* as */ *(v__ast__FnType*)__as_cast((sym->info)._v__ast__FnType,(sym->info)._typ, 482) /*expected idx: 482, name: v.ast.FnType */ ; + node->return_type = info.func.return_type; + found = true; + func = info.func; + } + } if (!found) { Option_v__ast__Fn _t16; if (_t16 = v__ast__Table_find_fn(c->table, fn_name), _t16.state == 0) { @@ -54116,9 +54185,9 @@ v__ast__Type v__checker__Checker_fn_call(v__checker__Checker* c, v__ast__CallExp v__checker__Checker_error(c, _SLIT("function with `shared` arguments cannot be called inside `lock`/`rlock` block"), call_arg->pos); } if (call_arg->is_mut) { - multi_return_string_v__token__Pos mr_28526 = v__checker__Checker_fail_if_immutable(c, call_arg->expr); - string to_lock = mr_28526.arg0; - v__token__Pos pos = mr_28526.arg1; + multi_return_string_v__token__Pos mr_28813 = v__checker__Checker_fail_if_immutable(c, call_arg->expr); + string to_lock = mr_28813.arg0; + v__token__Pos pos = mr_28813.arg1; if (!v__ast__Expr_is_lvalue(call_arg->expr)) { v__checker__Checker_error(c, _SLIT("cannot pass expression as `mut`"), v__ast__Expr_pos(call_arg->expr)); } @@ -54167,6 +54236,15 @@ v__ast__Type v__checker__Checker_fn_call(v__checker__Checker* c, v__ast__CallExp if (v__ast__Type_has_flag(param.typ, v__ast__TypeFlag__generic)) { continue; } + if (param_typ_sym->kind == v__ast__Kind__array && arg_typ_sym->kind == v__ast__Kind__array) { + v__ast__Array param_info = /* as */ *(v__ast__Array*)__as_cast((param_typ_sym->info)._v__ast__Array,(param_typ_sym->info)._typ, 450) /*expected idx: 450, name: v.ast.Array */ ; + v__ast__Type param_elem_type = v__ast__Table_unaliased_type(c->table, param_info.elem_type); + v__ast__Array arg_info = /* as */ *(v__ast__Array*)__as_cast((arg_typ_sym->info)._v__ast__Array,(arg_typ_sym->info)._typ, 450) /*expected idx: 450, name: v.ast.Array */ ; + v__ast__Type arg_elem_type = v__ast__Table_unaliased_type(c->table, arg_info.elem_type); + if (v__ast__Type_nr_muls(param.typ) == v__ast__Type_nr_muls(arg_typ) && param_info.nr_dims == arg_info.nr_dims && v__ast__Type_alias_eq(param_elem_type, arg_elem_type)) { + continue; + } + } if (c->pref->translated || c->file->is_translated) { if (v__ast__Type_alias_eq(param.typ, _const_v__ast__int_type) && arg_typ_sym->kind == v__ast__Kind__enum_) { continue; @@ -54461,9 +54539,9 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal *(multi_return_v__ast__Fn_Array_v__ast__Type*) _t22.data = (multi_return_v__ast__Fn_Array_v__ast__Type){.arg0=((v__ast__Fn){.is_variadic = 0,.language = 0,.is_pub = 0,.is_ctor_new = 0,.is_deprecated = 0,.is_noreturn = 0,.is_unsafe = 0,.is_placeholder = 0,.is_main = 0,.is_test = 0,.is_keep_alive = 0,.is_method = 0,.no_body = 0,.mod = (string){.str=(byteptr)"", .is_lit=1},.file = (string){.str=(byteptr)"", .is_lit=1},.file_mode = 0,.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.return_type_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.return_type = 0,.receiver_type = 0,.name = (string){.str=(byteptr)"", .is_lit=1},.params = __new_array(0, 0, sizeof(v__ast__Param)),.source_fn = 0,.usages = 0,.generic_names = __new_array(0, 0, sizeof(string)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.is_conditional = 0,.ctdefine_idx = 0,}),.arg1=__new_array_with_default(0, 0, sizeof(v__ast__Type), 0)}; } - multi_return_v__ast__Fn_Array_v__ast__Type mr_41745 = (*(multi_return_v__ast__Fn_Array_v__ast__Type*)_t22.data); - method = mr_41745.arg0; - embed_types = mr_41745.arg1; + multi_return_v__ast__Fn_Array_v__ast__Type mr_42485 = (*(multi_return_v__ast__Fn_Array_v__ast__Type*)_t22.data); + method = mr_42485.arg0; + embed_types = mr_42485.arg1; if (embed_types.len != 0) { is_method_from_embed = true; node->from_embed_types = embed_types; @@ -54484,9 +54562,9 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal v__checker__Checker_error(c, _SLIT("method with `shared` receiver cannot be called inside `lock`/`rlock` block"), node->pos); } if ((*(v__ast__Param*)/*ee elem_sym */array_get(method.params, 0)).is_mut) { - multi_return_string_v__token__Pos mr_42876 = v__checker__Checker_fail_if_immutable(c, node->left); - string to_lock = mr_42876.arg0; - v__token__Pos pos = mr_42876.arg1; + multi_return_string_v__token__Pos mr_43616 = v__checker__Checker_fail_if_immutable(c, node->left); + string to_lock = mr_43616.arg0; + v__token__Pos pos = mr_43616.arg1; if (!v__ast__Expr_is_lvalue(node->left)) { v__checker__Checker_error(c, _SLIT("cannot pass expression as `mut`"), v__ast__Expr_pos(node->left)); } @@ -54588,9 +54666,9 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal v__checker__Checker_error(c, _SLIT("method with `shared` arguments cannot be called inside `lock`/`rlock` block"), arg->pos); } if (arg->is_mut) { - multi_return_string_v__token__Pos mr_46845 = v__checker__Checker_fail_if_immutable(c, arg->expr); - string to_lock = mr_46845.arg0; - v__token__Pos pos = mr_46845.arg1; + multi_return_string_v__token__Pos mr_47585 = v__checker__Checker_fail_if_immutable(c, arg->expr); + string to_lock = mr_47585.arg0; + v__token__Pos pos = mr_47585.arg1; if (!param_is_mut) { string tok = v__ast__ShareType_str(arg->share); v__checker__Checker_error(c, str_intp(5, _MOV((StrIntpData[]){{_SLIT("`"), 0xfe10, {.d_s = node->name}}, {_SLIT("` parameter `"), 0xfe10, {.d_s = param.name}}, {_SLIT("` is not `"), 0xfe10, {.d_s = tok}}, {_SLIT("`, `"), 0xfe10, {.d_s = tok}}, {_SLIT("` is not needed`"), 0, { .d_c = 0 }}})), v__ast__Expr_pos(arg->expr)); @@ -54644,6 +54722,17 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal Option_void _t29 = v__checker__Checker_check_expected_call_arg(c, got_arg_typ, exp_arg_typ, node->language, *arg); if (_t29.state != 0 && _t29.err._typ != _IError_None___index) { IError err = _t29.err; + v__ast__TypeSymbol* param_typ_sym = v__ast__Table_sym(c->table, exp_arg_typ); + v__ast__TypeSymbol* arg_typ_sym = v__ast__Table_sym(c->table, got_arg_typ); + if (param_typ_sym->kind == v__ast__Kind__array && arg_typ_sym->kind == v__ast__Kind__array) { + v__ast__Array param_info = /* as */ *(v__ast__Array*)__as_cast((param_typ_sym->info)._v__ast__Array,(param_typ_sym->info)._typ, 450) /*expected idx: 450, name: v.ast.Array */ ; + v__ast__Type param_elem_type = v__ast__Table_unaliased_type(c->table, param_info.elem_type); + v__ast__Array arg_info = /* as */ *(v__ast__Array*)__as_cast((arg_typ_sym->info)._v__ast__Array,(arg_typ_sym->info)._typ, 450) /*expected idx: 450, name: v.ast.Array */ ; + v__ast__Type arg_elem_type = v__ast__Table_unaliased_type(c->table, arg_info.elem_type); + if (v__ast__Type_nr_muls(exp_arg_typ) == v__ast__Type_nr_muls(got_arg_typ) && param_info.nr_dims == arg_info.nr_dims && v__ast__Type_alias_eq(param_elem_type, arg_elem_type)) { + continue; + } + } if (!v__ast__Type_alias_eq(got_arg_typ, _const_v__ast__void_type)) { v__checker__Checker_error(c, str_intp(5, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = IError_name_table[err._typ]._method_msg(err._object)}}, {_SLIT(" in argument "), 0xfe07, {.d_i32 = i + 1}}, {_SLIT(" to `"), 0xfe10, {.d_s = left_sym->name}}, {_SLIT("."), 0xfe10, {.d_s = method_name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), arg->pos); } @@ -54772,8 +54861,8 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal return _t43; } - multi_return_v__ast__StructField_Array_v__ast__Type mr_53745 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t42.data); - node->from_embed_types = mr_53745.arg1; + multi_return_v__ast__StructField_Array_v__ast__Type mr_55050 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t42.data); + node->from_embed_types = mr_55050.arg1; v__ast__Type _t44 = info.func.return_type; return _t44; } @@ -55008,6 +55097,9 @@ VV_LOCAL_SYMBOL v__ast__Type v__checker__Checker_map_builtin_method_call(v__chec v__ast__Type ret_type = _const_v__ast__void_type; if (string__eq(method_name, _SLIT("clone")) || string__eq(method_name, _SLIT("move"))) { + if (node->args.len != 0) { + v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("`."), 0xfe10, {.d_s = method_name}}, {_SLIT("()` does not have any arguments"), 0, { .d_c = 0 }}})), (*(v__ast__CallArg*)/*ee elem_sym */array_get(node->args, 0)).pos); + } if (string_at(method_name, 0) == 'm') { v__checker__Checker_fail_if_immutable(c, node->left); } @@ -55019,6 +55111,9 @@ VV_LOCAL_SYMBOL v__ast__Type v__checker__Checker_map_builtin_method_call(v__chec ret_type = v__ast__Type_clear_flag(ret_type, v__ast__TypeFlag__shared_f); } else if (string__eq(method_name, _SLIT("keys"))) { + if (node->args.len != 0) { + v__checker__Checker_error(c, _SLIT("`.keys()` does not have any arguments"), (*(v__ast__CallArg*)/*ee elem_sym */array_get(node->args, 0)).pos); + } v__ast__Map info = /* as */ *(v__ast__Map*)__as_cast((left_sym.info)._v__ast__Map,(left_sym.info)._typ, 451) /*expected idx: 451, name: v.ast.Map */ ; int typ = v__ast__Table_find_or_register_array(c->table, info.key_type); ret_type = ((typ)); @@ -55127,6 +55222,9 @@ VV_LOCAL_SYMBOL v__ast__Type v__checker__Checker_array_builtin_method_call(v__ch v__checker__Checker_check_map_and_filter(c, false, elem_typ, *node); node->return_type = _const_v__ast__bool_type; } else if (string__eq(method_name, _SLIT("clone"))) { + if (node->args.len != 0) { + v__checker__Checker_error(c, _SLIT("`.clone()` does not have any arguments"), (*(v__ast__CallArg*)/*ee elem_sym */array_get(node->args, 0)).pos); + } node->receiver_type = v__ast__Type_ref(left_type); if (v__ast__Expr_is_auto_deref_var(node->left)) { node->return_type = v__ast__Type_deref(left_type); @@ -55141,18 +55239,37 @@ VV_LOCAL_SYMBOL v__ast__Type v__checker__Checker_array_builtin_method_call(v__ch } else if (string__eq(method_name, _SLIT("contains"))) { if (node->args.len != 1) { v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("`.contains()` expected 1 argument, but got "), 0xfe07, {.d_i32 = node->args.len}}, {_SLIT0, 0, { .d_c = 0 }}})), node->pos); - } else { - v__ast__Type arg_typ = v__ast__mktyp(v__checker__Checker_expr(c, (*(v__ast__CallArg*)/*ee elem_sym */array_get(node->args, 0)).expr)); - string elem_typ_str = v__ast__Table_type_to_str(c->table, elem_typ); - string arg_typ_str = v__ast__Table_type_to_str(c->table, arg_typ); - if (!v__ast__TypeSymbol_has_method(&left_sym, _SLIT("contains")) && !string__eq(elem_typ_str, arg_typ_str)) { - v__checker__Checker_error(c, str_intp(3, _MOV((StrIntpData[]){{_SLIT("`.contains()` expected `"), 0xfe10, {.d_s = elem_typ_str}}, {_SLIT("` argument, but got `"), 0xfe10, {.d_s = arg_typ_str}}, {_SLIT("`"), 0, { .d_c = 0 }}})), node->pos); + } else if (!v__ast__TypeSymbol_has_method(&left_sym, _SLIT("contains"))) { + v__ast__Type arg_typ = v__checker__Checker_expr(c, (*(v__ast__CallArg*)/*ee elem_sym */array_get(node->args, 0)).expr); + Option_void _t2 = v__checker__Checker_check_expected_call_arg(c, arg_typ, elem_typ, node->language, (*(v__ast__CallArg*)/*ee elem_sym */array_get(node->args, 0))); + if (_t2.state != 0 && _t2.err._typ != _IError_None___index) { + IError err = _t2.err; + v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = IError_name_table[err._typ]._method_msg(err._object)}}, {_SLIT(" in argument 1 to `.contains()`"), 0, { .d_c = 0 }}})), (*(v__ast__CallArg*)/*ee elem_sym */array_get(node->args, 0)).pos); + ; } + + ; } node->return_type = _const_v__ast__bool_type; } else if (string__eq(method_name, _SLIT("index"))) { + if (node->args.len != 1) { + v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("`.index()` expected 1 argument, but got "), 0xfe07, {.d_i32 = node->args.len}}, {_SLIT0, 0, { .d_c = 0 }}})), node->pos); + } else if (!v__ast__TypeSymbol_has_method(&left_sym, _SLIT("index"))) { + v__ast__Type arg_typ = v__checker__Checker_expr(c, (*(v__ast__CallArg*)/*ee elem_sym */array_get(node->args, 0)).expr); + Option_void _t3 = v__checker__Checker_check_expected_call_arg(c, arg_typ, elem_typ, node->language, (*(v__ast__CallArg*)/*ee elem_sym */array_get(node->args, 0))); + if (_t3.state != 0 && _t3.err._typ != _IError_None___index) { + IError err = _t3.err; + v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = IError_name_table[err._typ]._method_msg(err._object)}}, {_SLIT(" in argument 1 to `.index()`"), 0, { .d_c = 0 }}})), (*(v__ast__CallArg*)/*ee elem_sym */array_get(node->args, 0)).pos); + ; + } + + ; + } node->return_type = _const_v__ast__int_type; } else if (string__eq(method_name, _SLIT("first")) || string__eq(method_name, _SLIT("last")) || string__eq(method_name, _SLIT("pop"))) { + if (node->args.len != 0) { + v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("`."), 0xfe10, {.d_s = method_name}}, {_SLIT("()` does not have any arguments"), 0, { .d_c = 0 }}})), (*(v__ast__CallArg*)/*ee elem_sym */array_get(node->args, 0)).pos); + } node->return_type = array_info.elem_type; if (string__eq(method_name, _SLIT("pop"))) { v__checker__Checker_fail_if_immutable(c, node->left); @@ -55161,8 +55278,8 @@ VV_LOCAL_SYMBOL v__ast__Type v__checker__Checker_array_builtin_method_call(v__ch node->receiver_type = left_type; } } - v__ast__Type _t2 = node->return_type; - return _t2; + v__ast__Type _t4 = node->return_type; + return _t4; } VV_LOCAL_SYMBOL void v__checker__scope_register_it(v__ast__Scope* s, v__token__Pos pos, v__ast__Type typ) { @@ -55261,6 +55378,9 @@ VV_LOCAL_SYMBOL void v__checker__Checker_for_in_stmt(v__checker__Checker* c, v__ v__ast__Scope_update_var_type(node->scope, node->key_var, key_type); } v__ast__Type value_type = v__ast__Table_value_type(c->table, typ); + if (sym->kind == v__ast__Kind__string) { + value_type = _const_v__ast__byte_type; + } if (v__ast__Type_alias_eq(value_type, _const_v__ast__void_type) || v__ast__Type_has_flag(typ, v__ast__TypeFlag__optional)) { if (!v__ast__Type_alias_eq(typ, _const_v__ast__void_type)) { v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("for in: cannot index `"), 0xfe10, {.d_s = v__ast__Table_type_to_str(c->table, typ)}}, {_SLIT("`"), 0, { .d_c = 0 }}})), v__ast__Expr_pos(node->cond)); @@ -55648,11 +55768,10 @@ VV_LOCAL_SYMBOL void v__checker__Checker_smartcast_if_conds(v__checker__Checker* _t1 = ((v__ast__Type)(0)); } v__ast__Type right_type = _t1; - right_type = v__checker__Checker_unwrap_generic(c, right_type); if (!v__ast__Type_alias_eq(right_type, ((v__ast__Type)(0)))) { v__ast__TypeSymbol* left_sym = v__ast__Table_sym(c->table, (*node._v__ast__InfixExpr).left_type); v__ast__TypeSymbol* right_sym = v__ast__Table_sym(c->table, right_type); - v__ast__Type expr_type = v__checker__Checker_unwrap_generic(c, v__checker__Checker_expr(c, (*node._v__ast__InfixExpr).left)); + v__ast__Type expr_type = v__checker__Checker_expr(c, (*node._v__ast__InfixExpr).left); if (left_sym->kind == v__ast__Kind__aggregate) { expr_type = (/* as */ *(v__ast__Aggregate*)__as_cast((left_sym->info)._v__ast__Aggregate,(left_sym->info)._typ, 468) /*expected idx: 468, name: v.ast.Aggregate */ ).sum_type; } @@ -55662,7 +55781,7 @@ VV_LOCAL_SYMBOL void v__checker__Checker_smartcast_if_conds(v__checker__Checker* } else { return; } - } else if (!v__checker__Checker_check_types(c, right_type, expr_type)) { + } else if (!v__checker__Checker_check_types(c, right_type, expr_type) && left_sym->kind != v__ast__Kind__sum_type) { string expect_str = v__ast__Table_type_to_str(c->table, right_type); string expr_str = v__ast__Table_type_to_str(c->table, expr_type); v__checker__Checker_error(c, str_intp(3, _MOV((StrIntpData[]){{_SLIT("cannot use type `"), 0xfe10, {.d_s = expect_str}}, {_SLIT("` as type `"), 0xfe10, {.d_s = expr_str}}, {_SLIT("`"), 0, { .d_c = 0 }}})), (*node._v__ast__InfixExpr).pos); @@ -56180,8 +56299,9 @@ VV_LOCAL_SYMBOL void v__checker__Checker_match_exprs(v__checker__Checker* c, v__ c->expected_type = node->expected_type; v__ast__Expr low_expr = (*expr._v__ast__RangeExpr).low; v__ast__Expr high_expr = (*expr._v__ast__RangeExpr).high; + v__ast__TypeSymbol* final_cond_sym = v__ast__Table_final_sym(c->table, node->cond_type); if ((low_expr)._typ == 310 /* v.ast.IntegerLiteral */) { - if ((high_expr)._typ == 310 /* v.ast.IntegerLiteral */ && (v__ast__TypeSymbol_is_int(&cond_type_sym) || (cond_type_sym.info)._typ == 484 /* v.ast.Enum */)) { + if ((high_expr)._typ == 310 /* v.ast.IntegerLiteral */ && (v__ast__TypeSymbol_is_int(final_cond_sym) || (final_cond_sym->info)._typ == 484 /* v.ast.Enum */)) { low = string_i64((*low_expr._v__ast__IntegerLiteral).val); high = string_i64((*high_expr._v__ast__IntegerLiteral).val); if (low > high) { @@ -56191,7 +56311,7 @@ VV_LOCAL_SYMBOL void v__checker__Checker_match_exprs(v__checker__Checker* c, v__ v__checker__Checker_error(c, _SLIT("mismatched range types"), (*low_expr._v__ast__IntegerLiteral).pos); } } else if ((low_expr)._typ == 294 /* v.ast.CharLiteral */) { - if ((high_expr)._typ == 294 /* v.ast.CharLiteral */ && (cond_type_sym.kind == v__ast__Kind__u8 || cond_type_sym.kind == v__ast__Kind__char || cond_type_sym.kind == v__ast__Kind__rune)) { + if ((high_expr)._typ == 294 /* v.ast.CharLiteral */ && (final_cond_sym->kind == v__ast__Kind__u8 || final_cond_sym->kind == v__ast__Kind__char || final_cond_sym->kind == v__ast__Kind__rune)) { low = string_at((*low_expr._v__ast__CharLiteral).val, 0); high = string_at((*high_expr._v__ast__CharLiteral).val, 0); if (low > high) { @@ -56703,6 +56823,13 @@ void v__checker__Checker_return_stmt(v__checker__Checker* c, v__ast__Return* nod array_push((array*)&expr_idxs, _MOV((int[]){ i })); } } else { + if ((expr)._typ == 305 /* v.ast.Ident */) { + if (((*expr._v__ast__Ident).obj)._typ == 363 /* v.ast.Var */) { + if ((*(*expr._v__ast__Ident).obj._v__ast__Var).smartcasts.len > 0) { + typ = v__checker__Checker_unwrap_generic(c, (*(v__ast__Type*)array_last((*(*expr._v__ast__Ident).obj._v__ast__Var).smartcasts))); + } + } + } array_push((array*)&got_types, _MOV((v__ast__Type[]){ typ })); array_push((array*)&expr_idxs, _MOV((int[]){ i })); } @@ -57149,7 +57276,7 @@ v__ast__Type v__checker__Checker_int_lit(v__checker__Checker* c, v__ast__Integer v__checker__Checker_error(c, message, node->pos); } else if (lit.len == limit.len) { for (int i = 0; i < lit.len; ++i) { - byte digit = lit.str[i]; + u8 digit = lit.str[i]; if (digit > string_at(limit, i)) { v__checker__Checker_error(c, message, node->pos); } else if (digit < string_at(limit, i)) { @@ -60082,7 +60209,7 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_array_init(v__gen__c__Gen* g, v__ast__ArrayI g->inside_lambda = false; return; } - bool need_tmp_var = g->inside_call && !g->inside_struct_init; + bool need_tmp_var = g->inside_call && !g->inside_struct_init && node.exprs.len == 0; string stmt_str = _SLIT(""); string tmp_var = _SLIT(""); if (need_tmp_var) { @@ -61509,11 +61636,27 @@ string sref_name; } v__ast__FnType func = /* as */ *(v__ast__FnType*)__as_cast((right_sym->info)._v__ast__FnType,(right_sym->info)._typ, 482) /*expected idx: 482, name: v.ast.FnType */ ; string ret_styp = v__gen__c__Gen_typ(g, func.func.return_type); - v__gen__c__Gen_write(g, str_intp(3, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = ret_styp}}, {_SLIT(" (*"), 0xfe10, {.d_s = v__gen__c__Gen_get_ternary_name(g, ident.name)}}, {_SLIT(") ("), 0, { .d_c = 0 }}}))); + string call_conv = _SLIT(""); + string msvc_call_conv = _SLIT(""); + for (int _t8 = 0; _t8 < func.func.attrs.len; ++_t8) { + v__ast__Attr attr = ((v__ast__Attr*)func.func.attrs.data)[_t8]; + + if (string__eq(attr.name, _SLIT("callconv"))) { + if (g->is_cc_msvc) { + msvc_call_conv = str_intp(2, _MOV((StrIntpData[]){{_SLIT("__"), 0xfe10, {.d_s = attr.arg}}, {_SLIT(" "), 0, { .d_c = 0 }}})); + } else { + call_conv = str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = attr.arg}}, {_SLIT0, 0, { .d_c = 0 }}})); + } + } + else { + }; + } + string call_conv_attribute_suffix = (call_conv.len != 0 ? ( str_intp(2, _MOV((StrIntpData[]){{_SLIT("__attribute__(("), 0xfe10, {.d_s = call_conv}}, {_SLIT("))"), 0, { .d_c = 0 }}}))) : (_SLIT(""))); + v__gen__c__Gen_write(g, str_intp(4, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = ret_styp}}, {_SLIT(" ("), 0xfe10, {.d_s = msvc_call_conv}}, {_SLIT("*"), 0xfe10, {.d_s = v__gen__c__Gen_get_ternary_name(g, ident.name)}}, {_SLIT(") ("), 0, { .d_c = 0 }}}))); int def_pos = g->definitions.len; v__gen__c__Gen_fn_decl_params(g, func.func.params, ((voidptr)(0)), false); strings__Builder_go_back(&g->definitions, g->definitions.len - def_pos); - v__gen__c__Gen_write(g, _SLIT(")")); + v__gen__c__Gen_write(g, str_intp(2, _MOV((StrIntpData[]){{_SLIT(")"), 0xfe10, {.d_s = call_conv_attribute_suffix}}, {_SLIT0, 0, { .d_c = 0 }}}))); } else { if (is_decl) { if (is_inside_ternary) { @@ -66220,7 +66363,7 @@ VV_LOCAL_SYMBOL void v__gen__c__write_octal_escape(strings__Builder* b, u8 c) { VV_LOCAL_SYMBOL string v__gen__c__cescape_nonascii(string original) { strings__Builder b = strings__new_builder(original.len); for (int _t1 = 0; _t1 < original.len; ++_t1) { - byte c = original.str[_t1]; + u8 c = original.str[_t1]; if (c < 32 || c > 126) { v__gen__c__write_octal_escape((voidptr)&/*qq*/b, c); continue; @@ -67290,7 +67433,7 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_selector_expr(v__gen__c__Gen* g, v__ast__Sel if (field_sym->kind == v__ast__Kind__sum_type) { v__gen__c__Gen_write(g, _SLIT("*")); } - v__ast__TypeSymbol* cast_sym = v__ast__Table_sym(g->table, typ); + v__ast__TypeSymbol* cast_sym = v__ast__Table_sym(g->table, v__gen__c__Gen_unwrap_generic(g, typ)); if (i != 0) { string dot = (v__ast__Type_is_ptr(field.typ) ? (_SLIT("->")) : (_SLIT("."))); sum_type_deref_field = /*f*/string__plus(sum_type_deref_field, str_intp(2, _MOV((StrIntpData[]){{_SLIT(")"), 0xfe10, {.d_s = dot}}, {_SLIT0, 0, { .d_c = 0 }}}))); @@ -67480,11 +67623,11 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_map_init(v__gen__c__Gen* g, v__ast__MapInit string value_typ_str = v__gen__c__Gen_typ(g, unwrap_val_typ); v__ast__TypeSymbol* value_sym = v__ast__Table_sym(g->table, unwrap_val_typ); v__ast__TypeSymbol* key_sym = v__ast__Table_final_sym(g->table, unwrap_key_typ); - multi_return_string_string_string_string mr_105072 = v__gen__c__Gen_map_fn_ptrs(g, *key_sym); - string hash_fn = mr_105072.arg0; - string key_eq_fn = mr_105072.arg1; - string clone_fn = mr_105072.arg2; - string free_fn = mr_105072.arg3; + multi_return_string_string_string_string mr_105090 = v__gen__c__Gen_map_fn_ptrs(g, *key_sym); + string hash_fn = mr_105090.arg0; + string key_eq_fn = mr_105090.arg1; + string clone_fn = mr_105090.arg2; + string free_fn = mr_105090.arg3; int size = node.vals.len; string shared_styp = _SLIT(""); string styp = _SLIT(""); @@ -68639,9 +68782,9 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_write_types(v__gen__c__Gen* g, Array_v__ast_ for (int _t3 = 0; _t3 < (*sym->info._v__ast__Struct).fields.len; ++_t3) { v__ast__StructField field = ((v__ast__StructField*)(*sym->info._v__ast__Struct).fields.data)[_t3]; if (v__ast__Type_has_flag(field.typ, v__ast__TypeFlag__optional)) { - multi_return_string_string mr_142140 = v__gen__c__Gen_optional_type_name(g, field.typ); - string styp = mr_142140.arg0; - string base = mr_142140.arg1; + multi_return_string_string mr_142158 = v__gen__c__Gen_optional_type_name(g, field.typ); + string styp = mr_142158.arg0; + string base = mr_142158.arg1; sync__RwMutex_lock(&g->done_optionals->mtx); /*lock*/ { if (!Array_string_contains(g->done_optionals->val, base)) { @@ -68912,11 +69055,11 @@ bool v__gen__c__Gen_or_block_defer_0 = false; if (string__eq(g->file->mod.name, _SLIT("main")) && (isnil(g->fn_decl) || g->fn_decl->is_main)) { string err_msg = str_intp(3, _MOV((StrIntpData[]){{_SLIT("IError_name_table["), 0xfe10, {.d_s = cvar_name}}, {_SLIT(".err._typ]._method_msg("), 0xfe10, {.d_s = cvar_name}}, {_SLIT(".err._object)"), 0, { .d_c = 0 }}})); if (g->pref->is_debug) { - multi_return_int_string_string_string mr_151194 = v__gen__c__Gen_panic_debug_info(g, or_block.pos); - int paline = mr_151194.arg0; - string pafile = mr_151194.arg1; - string pamod = mr_151194.arg2; - string pafn = mr_151194.arg3; + multi_return_int_string_string_string mr_151212 = v__gen__c__Gen_panic_debug_info(g, or_block.pos); + int paline = mr_151212.arg0; + string pafile = mr_151212.arg1; + string pamod = mr_151212.arg2; + string pafn = mr_151212.arg3; v__gen__c__Gen_writeln(g, str_intp(6, _MOV((StrIntpData[]){{_SLIT("panic_debug("), 0xfe07, {.d_i32 = paline}}, {_SLIT(", tos3(\""), 0xfe10, {.d_s = pafile}}, {_SLIT("\"), tos3(\""), 0xfe10, {.d_s = pamod}}, {_SLIT("\"), tos3(\""), 0xfe10, {.d_s = pafn}}, {_SLIT("\"), "), 0xfe10, {.d_s = err_msg}}, {_SLIT(" );"), 0, { .d_c = 0 }}}))); } else { v__gen__c__Gen_writeln(g, str_intp(2, _MOV((StrIntpData[]){{_SLIT("\tpanic_optional_not_set( "), 0xfe10, {.d_s = err_msg}}, {_SLIT(" );"), 0, { .d_c = 0 }}}))); @@ -69026,11 +69169,11 @@ VV_LOCAL_SYMBOL string v__gen__c__Gen_type_default(v__gen__c__Gen* g, v__ast__Ty { v__ast__Map info = v__ast__TypeSymbol_map_info(sym); v__ast__TypeSymbol* key_typ = v__ast__Table_sym(g->table, info.key_type); - multi_return_string_string_string_string mr_153776 = v__gen__c__Gen_map_fn_ptrs(g, *key_typ); - string hash_fn = mr_153776.arg0; - string key_eq_fn = mr_153776.arg1; - string clone_fn = mr_153776.arg2; - string free_fn = mr_153776.arg3; + multi_return_string_string_string_string mr_153794 = v__gen__c__Gen_map_fn_ptrs(g, *key_typ); + string hash_fn = mr_153794.arg0; + string key_eq_fn = mr_153794.arg1; + string clone_fn = mr_153794.arg2; + string free_fn = mr_153794.arg3; string noscan_key = v__gen__c__Gen_check_noscan(g, info.key_type); string noscan_value = v__gen__c__Gen_check_noscan(g, info.value_type); string noscan = (noscan_key.len != 0 || noscan_value.len != 0 ? (_SLIT("_noscan")) : (_SLIT(""))); @@ -69202,9 +69345,11 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_size_of(v__gen__c__Gen* g, v__ast__SizeOf no VV_LOCAL_SYMBOL void v__gen__c__Gen_enum_val(v__gen__c__Gen* g, v__ast__EnumVal node) { string styp = v__gen__c__Gen_typ(g, v__ast__Table_unaliased_type(g->table, node.typ)); - if (v__ast__Type_is_number(node.typ)) { + if (g->pref->translated && v__ast__Type_is_number(node.typ)) { + v__gen__c__Gen_write(g, str_intp(4, _MOV((StrIntpData[]){{_SLIT("/*enum val is_number "), 0xfe10, {.d_s = node.mod}}, {_SLIT(" styp="), 0xfe10, {.d_s = styp}}, {_SLIT("*/_const_main__"), 0xfe10, {.d_s = node.val}}, {_SLIT0, 0, { .d_c = 0 }}}))); + } else { + v__gen__c__Gen_write(g, str_intp(3, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = styp}}, {_SLIT("__"), 0xfe10, {.d_s = node.val}}, {_SLIT0, 0, { .d_c = 0 }}}))); } - v__gen__c__Gen_write(g, str_intp(3, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = styp}}, {_SLIT("__"), 0xfe10, {.d_s = node.val}}, {_SLIT0, 0, { .d_c = 0 }}}))); } VV_LOCAL_SYMBOL void v__gen__c__Gen_as_cast(v__gen__c__Gen* g, v__ast__AsCast node) { @@ -69553,8 +69698,8 @@ VV_LOCAL_SYMBOL string v__gen__c__Gen_interface_table(v__gen__c__Gen* g) { int params_start_pos = g->out.len; Array_v__ast__Param params = array_clone_to_depth(&method.params, 0); array_set(¶ms, 0, &(v__ast__Param[]) { ((v__ast__Param){(*(v__ast__Param*)/*ee elem_sym */array_get(params, 0)).pos,(*(v__ast__Param*)/*ee elem_sym */array_get(params, 0)).name,(*(v__ast__Param*)/*ee elem_sym */array_get(params, 0)).is_mut,(*(v__ast__Param*)/*ee elem_sym */array_get(params, 0)).is_auto_rec,(*(v__ast__Param*)/*ee elem_sym */array_get(params, 0)).type_pos,(*(v__ast__Param*)/*ee elem_sym */array_get(params, 0)).is_hidden,.typ = v__ast__Type_set_nr_muls(st, 1),}) }); - multi_return_Array_string_Array_string_Array_bool mr_168066 = v__gen__c__Gen_fn_decl_params(g, params, ((voidptr)(0)), false); - Array_string fargs = mr_168066.arg0; + multi_return_Array_string_Array_string_Array_bool mr_168158 = v__gen__c__Gen_fn_decl_params(g, params, ((voidptr)(0)), false); + Array_string fargs = mr_168158.arg0; string parameter_name = strings__Builder_cut_last(&g->out, g->out.len - params_start_pos); if (v__ast__Type_is_ptr(st)) { parameter_name = string_trim_string_left(parameter_name, _SLIT("__shared__")); @@ -69571,8 +69716,8 @@ VV_LOCAL_SYMBOL string v__gen__c__Gen_interface_table(v__gen__c__Gen* g) { *(multi_return_v__ast__Fn_Array_v__ast__Type*) _t26.data = (multi_return_v__ast__Fn_Array_v__ast__Type){.arg0=((v__ast__Fn){.is_variadic = 0,.language = 0,.is_pub = 0,.is_ctor_new = 0,.is_deprecated = 0,.is_noreturn = 0,.is_unsafe = 0,.is_placeholder = 0,.is_main = 0,.is_test = 0,.is_keep_alive = 0,.is_method = 0,.no_body = 0,.mod = (string){.str=(byteptr)"", .is_lit=1},.file = (string){.str=(byteptr)"", .is_lit=1},.file_mode = 0,.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.return_type_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.return_type = 0,.receiver_type = 0,.name = (string){.str=(byteptr)"", .is_lit=1},.params = __new_array(0, 0, sizeof(v__ast__Param)),.source_fn = 0,.usages = 0,.generic_names = __new_array(0, 0, sizeof(string)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.is_conditional = 0,.ctdefine_idx = 0,}),.arg1=__new_array_with_default(0, 0, sizeof(v__ast__Type), 0)}; } - multi_return_v__ast__Fn_Array_v__ast__Type mr_168530 = (*(multi_return_v__ast__Fn_Array_v__ast__Type*)_t26.data); - Array_v__ast__Type embed_types = mr_168530.arg1; + multi_return_v__ast__Fn_Array_v__ast__Type mr_168622 = (*(multi_return_v__ast__Fn_Array_v__ast__Type*)_t26.data); + Array_v__ast__Type embed_types = mr_168622.arg1; if (embed_types.len > 0 && !Array_string_contains(method_names, method.name)) { v__ast__TypeSymbol* embed_sym = v__ast__Table_sym(g->table, (*(v__ast__Type*)array_last(embed_types))); string method_name = str_intp(3, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = embed_sym->cname}}, {_SLIT("_"), 0xfe10, {.d_s = method.name}}, {_SLIT0, 0, { .d_c = 0 }}})); @@ -71644,7 +71789,10 @@ int ctmp; ctmp = g->tmp_count; g->tmp_count = 0; v__gen__c__Gen_gen_fn_decl_defer_5 = true; + int prev_inside_ternary = g->inside_ternary; + g->inside_ternary = 0; v__gen__c__Gen_stmts(g, node->stmts); + g->inside_ternary = prev_inside_ternary; if (node->is_noreturn) { v__gen__c__Gen_writeln(g, _SLIT("\twhile(1);")); } @@ -71900,11 +72048,12 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_call_expr(v__gen__c__Gen* g, v__ast__CallExp bool v__gen__c__Gen_call_expr_defer_0 = false; if ((node.left)._typ == 283 /* v.ast.AnonFn */) { v__gen__c__Gen_expr(g, node.left); - } - if ((node.left)._typ == 308 /* v.ast.IndexExpr */ && (node.name).len == 0) { + } else if ((node.left)._typ == 308 /* v.ast.IndexExpr */ && (node.name).len == 0) { g->is_fn_index_call = true; v__gen__c__Gen_expr(g, node.left); g->is_fn_index_call = false; + } else if ((node.left)._typ == 291 /* v.ast.CallExpr */ && (node.name).len == 0) { + v__gen__c__Gen_expr(g, node.left); } if (node.should_be_skipped) { return; @@ -72246,7 +72395,7 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_method_call(v__gen__c__Gen* g, v__ast__CallE v__gen__c__Gen_gen_expr_to_string(g, node.left, rec_type); return; } else if ((*(*node.left._v__ast__Ident).obj._v__ast__Var).smartcasts.len > 0) { - rec_type = (*(v__ast__Type*)array_last((*(*node.left._v__ast__Ident).obj._v__ast__Var).smartcasts)); + rec_type = v__gen__c__Gen_unwrap_generic(g, (*(v__ast__Type*)array_last((*(*node.left._v__ast__Ident).obj._v__ast__Var).smartcasts))); v__ast__TypeSymbol* cast_sym = v__ast__Table_sym(g->table, rec_type); if ((cast_sym->info)._typ == 468 /* v.ast.Aggregate */) { rec_type = (*(v__ast__Type*)/*ee elem_sym */array_get((*cast_sym->info._v__ast__Aggregate).types, g->aggregate_type_idx)); @@ -72614,7 +72763,7 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_fn_call(v__gen__c__Gen* g, v__ast__CallExpr if (((*expr._v__ast__Ident).obj)._typ == 363 /* v.ast.Var */) { typ = (*(*expr._v__ast__Ident).obj._v__ast__Var).typ; if ((*(*expr._v__ast__Ident).obj._v__ast__Var).smartcasts.len > 0) { - typ = (*(v__ast__Type*)array_last((*(*expr._v__ast__Ident).obj._v__ast__Var).smartcasts)); + typ = v__gen__c__Gen_unwrap_generic(g, (*(v__ast__Type*)array_last((*(*expr._v__ast__Ident).obj._v__ast__Var).smartcasts))); v__ast__TypeSymbol* cast_sym = v__ast__Table_sym(g->table, typ); if ((cast_sym->info)._typ == 468 /* v.ast.Aggregate */) { typ = (*(v__ast__Type*)/*ee elem_sym */array_get((*cast_sym->info._v__ast__Aggregate).types, g->aggregate_type_idx)); @@ -72630,11 +72779,11 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_fn_call(v__gen__c__Gen* g, v__ast__CallExpr } if (!print_auto_str) { if (g->pref->is_debug && string__eq(node.name, _SLIT("panic"))) { - multi_return_int_string_string_string mr_40302 = v__gen__c__Gen_panic_debug_info(g, node.pos); - int paline = mr_40302.arg0; - string pafile = mr_40302.arg1; - string pamod = mr_40302.arg2; - string pafn = mr_40302.arg3; + multi_return_int_string_string_string mr_40523 = v__gen__c__Gen_panic_debug_info(g, node.pos); + int paline = mr_40523.arg0; + string pafile = mr_40523.arg1; + string pamod = mr_40523.arg2; + string pafn = mr_40523.arg3; v__gen__c__Gen_write(g, str_intp(5, _MOV((StrIntpData[]){{_SLIT("panic_debug("), 0xfe07, {.d_i32 = paline}}, {_SLIT(", tos3(\""), 0xfe10, {.d_s = pafile}}, {_SLIT("\"), tos3(\""), 0xfe10, {.d_s = pamod}}, {_SLIT("\"), tos3(\""), 0xfe10, {.d_s = pafn}}, {_SLIT("\"), "), 0, { .d_c = 0 }}}))); v__gen__c__Gen_call_args(g, node); v__gen__c__Gen_write(g, _SLIT(")")); @@ -73284,6 +73433,12 @@ inline VV_LOCAL_SYMBOL void v__gen__c__Gen_ref_or_deref_arg(v__gen__c__Gen* g, v v__gen__c__Gen_expr(g, arg.expr); v__gen__c__Gen_write(g, _SLIT("->val")); return; + } else if ((arg.expr)._typ == 285 /* v.ast.ArrayInit */) { + if ((*arg.expr._v__ast__ArrayInit).is_fixed) { + if (!(*arg.expr._v__ast__ArrayInit).has_it) { + v__gen__c__Gen_write(g, str_intp(2, _MOV((StrIntpData[]){{_SLIT("("), 0xfe10, {.d_s = v__gen__c__Gen_typ(g, (*arg.expr._v__ast__ArrayInit).typ)}}, {_SLIT(")"), 0, { .d_c = 0 }}}))); + } + } } v__gen__c__Gen_expr_with_cast(g, arg.expr, arg_typ, expected_type); if (needs_closing) { @@ -73654,14 +73809,15 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_for_in_stmt(v__gen__c__Gen* g, v__ast__ForIn g->indent--; } else if (node.kind == v__ast__Kind__string) { v__ast__Expr cond = ((node.cond)._typ == 329 /* v.ast.StringLiteral */ || (node.cond)._typ == 328 /* v.ast.StringInterLiteral */ ? (v__ast__CTempVar_to_sumtype_v__ast__Expr(ADDR(v__ast__CTempVar, (v__gen__c__Gen_new_ctemp_var_then_gen(g, node.cond, _const_v__ast__string_type))))) : (node.cond)); + string field_accessor = (v__ast__Type_is_ptr(node.cond_type) ? (_SLIT("->")) : (_SLIT("."))); string i = ((string__eq(node.key_var, _SLIT("")) || string__eq(node.key_var, _SLIT("_"))) ? (v__gen__c__Gen_new_tmp_var(g)) : (node.key_var)); v__gen__c__Gen_write(g, str_intp(3, _MOV((StrIntpData[]){{_SLIT("for (int "), 0xfe10, {.d_s = i}}, {_SLIT(" = 0; "), 0xfe10, {.d_s = i}}, {_SLIT(" < "), 0, { .d_c = 0 }}}))); v__gen__c__Gen_expr(g, cond); - v__gen__c__Gen_writeln(g, str_intp(2, _MOV((StrIntpData[]){{_SLIT(".len; ++"), 0xfe10, {.d_s = i}}, {_SLIT(") {"), 0, { .d_c = 0 }}}))); + v__gen__c__Gen_writeln(g, str_intp(3, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = field_accessor}}, {_SLIT("len; ++"), 0xfe10, {.d_s = i}}, {_SLIT(") {"), 0, { .d_c = 0 }}}))); if (!string__eq(node.val_var, _SLIT("_"))) { - v__gen__c__Gen_write(g, str_intp(2, _MOV((StrIntpData[]){{_SLIT("\tbyte "), 0xfe10, {.d_s = v__gen__c__c_name(node.val_var)}}, {_SLIT(" = "), 0, { .d_c = 0 }}}))); + v__gen__c__Gen_write(g, str_intp(2, _MOV((StrIntpData[]){{_SLIT("\tu8 "), 0xfe10, {.d_s = v__gen__c__c_name(node.val_var)}}, {_SLIT(" = "), 0, { .d_c = 0 }}}))); v__gen__c__Gen_expr(g, cond); - v__gen__c__Gen_writeln(g, str_intp(2, _MOV((StrIntpData[]){{_SLIT(".str["), 0xfe10, {.d_s = i}}, {_SLIT("];"), 0, { .d_c = 0 }}}))); + v__gen__c__Gen_writeln(g, str_intp(3, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = field_accessor}}, {_SLIT("str["), 0xfe10, {.d_s = i}}, {_SLIT("];"), 0, { .d_c = 0 }}}))); } } else if (node.kind == v__ast__Kind__struct_) { v__ast__TypeSymbol* cond_type_sym = v__ast__Table_sym(g->table, node.cond_type); @@ -73744,24 +73900,28 @@ VV_LOCAL_SYMBOL bool v__gen__c__Gen_need_tmp_var_in_if(v__gen__c__Gen* g, v__ast bool _t4 = true; return _t4; } + if ((stmt.expr)._typ == 315 /* v.ast.MatchExpr */) { + bool _t5 = true; + return _t5; + } if ((stmt.expr)._typ == 291 /* v.ast.CallExpr */) { if ((*stmt.expr._v__ast__CallExpr).is_method) { v__ast__TypeSymbol* left_sym = v__ast__Table_sym(g->table, (*stmt.expr._v__ast__CallExpr).receiver_type); if (left_sym->kind == v__ast__Kind__array || left_sym->kind == v__ast__Kind__array_fixed || left_sym->kind == v__ast__Kind__map) { - bool _t5 = true; - return _t5; + bool _t6 = true; + return _t6; } } else if ((*stmt.expr._v__ast__CallExpr).or_block.kind != v__ast__OrKind__absent) { - bool _t6 = true; - return _t6; + bool _t7 = true; + return _t7; } } } } } } - bool _t7 = false; - return _t7; + bool _t8 = false; + return _t8; } VV_LOCAL_SYMBOL void v__gen__c__Gen_if_expr(v__gen__c__Gen* g, v__ast__IfExpr node) { @@ -75241,7 +75401,7 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_infix_expr_left_shift_op(v__gen__c__Gen* g, } else { v__gen__c__Gen_write(g, str_intp(2, _MOV((StrIntpData[]){{_SLIT(", _MOV(("), 0xfe10, {.d_s = elem_type_str}}, {_SLIT("[]){ "), 0, { .d_c = 0 }}}))); } - bool needs_clone = v__ast__Type_idx(array_info.elem_type) == _const_v__ast__string_type_idx && !g->is_builtin_mod; + bool needs_clone = !g->is_builtin_mod && v__ast__Type_idx(array_info.elem_type) == _const_v__ast__string_type_idx && v__ast__Type_nr_muls(array_info.elem_type) == 0; if (needs_clone) { v__gen__c__Gen_write(g, _SLIT("string_clone(")); } @@ -77653,7 +77813,7 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_str_val(v__gen__c__Gen* g, v__ast__StringInt if (g->comptime_var_type_map.len > 0 || g->comptime_for_method.len > 0) { exp_typ = (*(*expr._v__ast__Ident).obj._v__ast__Var).typ; } else if ((*(*expr._v__ast__Ident).obj._v__ast__Var).smartcasts.len > 0) { - exp_typ = (*(v__ast__Type*)array_last((*(*expr._v__ast__Ident).obj._v__ast__Var).smartcasts)); + exp_typ = v__gen__c__Gen_unwrap_generic(g, (*(v__ast__Type*)array_last((*(*expr._v__ast__Ident).obj._v__ast__Var).smartcasts))); v__ast__TypeSymbol* cast_sym = v__ast__Table_sym(g->table, exp_typ); if ((cast_sym->info)._typ == 468 /* v.ast.Aggregate */) { exp_typ = (*(v__ast__Type*)/*ee elem_sym */array_get((*cast_sym->info._v__ast__Aggregate).types, g->aggregate_type_idx)); @@ -77718,9 +77878,9 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_string_inter_literal(v__gen__c__Gen* g, v__a v__gen__c__Gen_write(g, _SLIT("0, { .d_c = 0 }}")); break; } - multi_return_u64_string mr_5665 = v__gen__c__Gen_str_format(g, node, i); - u64 ft_u64 = mr_5665.arg0; - string ft_str = mr_5665.arg1; + multi_return_u64_string mr_5683 = v__gen__c__Gen_str_format(g, node, i); + u64 ft_u64 = mr_5683.arg0; + string ft_str = mr_5683.arg1; v__gen__c__Gen_write(g, str_intp(3, _MOV((StrIntpData[]){{_SLIT("0x"), 0xfe10, {.d_s = u64_hex(ft_u64)}}, {_SLIT(", {.d_"), 0xfe10, {.d_s = ft_str}}, {_SLIT(" = "), 0, { .d_c = 0 }}}))); if (ft_str.str[0] == 'p') { v__gen__c__Gen_write(g, _SLIT("(void*)(")); @@ -79518,7 +79678,7 @@ VV_LOCAL_SYMBOL string v__scanner__Scanner_ident_char(v__scanner__Scanner* s) { } else { Array_int escapes_pos = __new_array_with_default(0, 0, sizeof(int), 0); for (int i = 0; i < c.len; ++i) { - byte v = c.str[i]; + u8 v = c.str[i]; if (v == '\\') { array_push((array*)&escapes_pos, _MOV((int[]){ i })); } @@ -82394,7 +82554,8 @@ VV_LOCAL_SYMBOL multi_return_Array_v__ast__Param_bool_bool v__parser__Parser_fn_ Array_v__ast__Param args = __new_array_with_default(0, 0, sizeof(v__ast__Param), 0); bool is_variadic = false; string argname = (p->tok.kind == v__token__Kind__name && p->tok.lit.len > 0 && u8_is_capital(string_at(p->tok.lit, 0)) ? (v__parser__Parser_prepend_mod(p, p->tok.lit)) : (p->tok.lit)); - bool types_only = (p->tok.kind == v__token__Kind__amp || p->tok.kind == v__token__Kind__ellipsis || p->tok.kind == v__token__Kind__key_fn || p->tok.kind == v__token__Kind__lsbr) || (p->peek_tok.kind == v__token__Kind__comma && v__ast__Table_known_type(p->table, argname)) || p->peek_tok.kind == v__token__Kind__dot || p->peek_tok.kind == v__token__Kind__rpar || (p->tok.kind == v__token__Kind__key_mut && (v__parser__Parser_peek_token(p, 2).kind == v__token__Kind__comma || v__parser__Parser_peek_token(p, 2).kind == v__token__Kind__rpar || (p->peek_tok.kind == v__token__Kind__name && v__parser__Parser_peek_token(p, 2).kind == v__token__Kind__dot))); + bool is_generic_type = p->tok.kind == v__token__Kind__name && p->tok.lit.len == 1 && u8_is_capital(string_at(p->tok.lit, 0)); + bool types_only = (p->tok.kind == v__token__Kind__amp || p->tok.kind == v__token__Kind__ellipsis || p->tok.kind == v__token__Kind__key_fn || p->tok.kind == v__token__Kind__lsbr) || (p->peek_tok.kind == v__token__Kind__comma && (v__ast__Table_known_type(p->table, argname) || is_generic_type)) || p->peek_tok.kind == v__token__Kind__dot || p->peek_tok.kind == v__token__Kind__rpar || (p->tok.kind == v__token__Kind__key_mut && (v__parser__Parser_peek_token(p, 2).kind == v__token__Kind__comma || v__parser__Parser_peek_token(p, 2).kind == v__token__Kind__rpar || (p->peek_tok.kind == v__token__Kind__name && v__parser__Parser_peek_token(p, 2).kind == v__token__Kind__dot))); if (types_only) { int arg_no = 1; for (;;) { @@ -85170,7 +85331,8 @@ v__ast__Stmt v__parser__Parser_stmt(v__parser__Parser* p, bool is_top_level) { v__token__Pos spos = v__token__Token_pos(&p->tok); string name = v__parser__Parser_check_name(p); if (Array_string_contains(p->label_names, name)) { - v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("duplicate label `"), 0xfe10, {.d_s = name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), spos); + v__ast__Stmt _t5 = v__ast__NodeError_to_sumtype_v__ast__Stmt(ADDR(v__ast__NodeError, (v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("duplicate label `"), 0xfe10, {.d_s = name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), spos)))); + return _t5; } array_push((array*)&p->label_names, _MOV((string[]){ string_clone(name) })); v__parser__Parser_next(p); @@ -85179,52 +85341,53 @@ v__ast__Stmt v__parser__Parser_stmt(v__parser__Parser* p, bool is_top_level) { v__ast__Stmt stmt = v__parser__Parser_stmt(p, is_top_level); if (stmt._typ == 348 /* v.ast.ForStmt */) { (*stmt._v__ast__ForStmt).label = name; - v__ast__Stmt _t6 = v__ast__ForStmt_to_sumtype_v__ast__Stmt(&(*stmt._v__ast__ForStmt)); - return _t6; + v__ast__Stmt _t7 = v__ast__ForStmt_to_sumtype_v__ast__Stmt(&(*stmt._v__ast__ForStmt)); + return _t7; } else if (stmt._typ == 347 /* v.ast.ForInStmt */) { (*stmt._v__ast__ForInStmt).label = name; - v__ast__Stmt _t7 = v__ast__ForInStmt_to_sumtype_v__ast__Stmt(&(*stmt._v__ast__ForInStmt)); - return _t7; + v__ast__Stmt _t8 = v__ast__ForInStmt_to_sumtype_v__ast__Stmt(&(*stmt._v__ast__ForInStmt)); + return _t8; } else if (stmt._typ == 346 /* v.ast.ForCStmt */) { (*stmt._v__ast__ForCStmt).label = name; - v__ast__Stmt _t8 = v__ast__ForCStmt_to_sumtype_v__ast__Stmt(&(*stmt._v__ast__ForCStmt)); - return _t8; + v__ast__Stmt _t9 = v__ast__ForCStmt_to_sumtype_v__ast__Stmt(&(*stmt._v__ast__ForCStmt)); + return _t9; } else { - v__parser__Parser_error_with_pos(p, _SLIT("unknown kind of For statement"), for_pos); + v__ast__Stmt _t10 = v__ast__NodeError_to_sumtype_v__ast__Stmt(ADDR(v__ast__NodeError, (v__parser__Parser_error_with_pos(p, _SLIT("unknown kind of For statement"), for_pos)))); + return _t10; } ; } - v__ast__Stmt _t9 = v__ast__GotoLabel_to_sumtype_v__ast__Stmt(ADDR(v__ast__GotoLabel, (((v__ast__GotoLabel){.name = name,.pos = v__token__Pos_extend(spos, v__token__Token_pos(&p->tok)),})))); - return _t9; - } else if (p->peek_tok.kind == v__token__Kind__name) { - v__ast__Stmt _t10 = v__ast__NodeError_to_sumtype_v__ast__Stmt(ADDR(v__ast__NodeError, (v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("unexpected name `"), 0xfe10, {.d_s = p->tok.lit}}, {_SLIT("`"), 0, { .d_c = 0 }}})), v__token__Token_pos(&p->tok))))); - return _t10; - } else if (!p->inside_if_expr && !p->inside_match_body && !p->inside_or_expr && (p->peek_tok.kind == v__token__Kind__rcbr || p->peek_tok.kind == v__token__Kind__eof) && !v__parser__Parser_mark_var_as_used(p, p->tok.lit)) { - v__ast__Stmt _t11 = v__ast__NodeError_to_sumtype_v__ast__Stmt(ADDR(v__ast__NodeError, (v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("`"), 0xfe10, {.d_s = p->tok.lit}}, {_SLIT("` evaluated but not used"), 0, { .d_c = 0 }}})), v__token__Token_pos(&p->tok))))); + v__ast__Stmt _t11 = v__ast__GotoLabel_to_sumtype_v__ast__Stmt(ADDR(v__ast__GotoLabel, (((v__ast__GotoLabel){.name = name,.pos = v__token__Pos_extend(spos, v__token__Token_pos(&p->tok)),})))); return _t11; + } else if (p->peek_tok.kind == v__token__Kind__name) { + v__ast__Stmt _t12 = v__ast__NodeError_to_sumtype_v__ast__Stmt(ADDR(v__ast__NodeError, (v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("unexpected name `"), 0xfe10, {.d_s = p->tok.lit}}, {_SLIT("`"), 0, { .d_c = 0 }}})), v__token__Token_pos(&p->tok))))); + return _t12; + } else if (!p->inside_if_expr && !p->inside_match_body && !p->inside_or_expr && (p->peek_tok.kind == v__token__Kind__rcbr || p->peek_tok.kind == v__token__Kind__eof) && !v__parser__Parser_mark_var_as_used(p, p->tok.lit)) { + v__ast__Stmt _t13 = v__ast__NodeError_to_sumtype_v__ast__Stmt(ADDR(v__ast__NodeError, (v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("`"), 0xfe10, {.d_s = p->tok.lit}}, {_SLIT("` evaluated but not used"), 0, { .d_c = 0 }}})), v__token__Token_pos(&p->tok))))); + return _t13; } - v__ast__Stmt _t12 = v__parser__Parser_parse_multi_expr(p, is_top_level); - return _t12; + v__ast__Stmt _t14 = v__parser__Parser_parse_multi_expr(p, is_top_level); + return _t14; break; } case v__token__Kind__comment: { - v__ast__Stmt _t13 = v__ast__ExprStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__ExprStmt, (v__parser__Parser_comment_stmt(p)))); - return _t13; + v__ast__Stmt _t15 = v__ast__ExprStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__ExprStmt, (v__parser__Parser_comment_stmt(p)))); + return _t15; break; } case v__token__Kind__key_return: { if (p->inside_defer) { - v__ast__Stmt _t14 = v__ast__NodeError_to_sumtype_v__ast__Stmt(ADDR(v__ast__NodeError, (v__parser__Parser_error_with_pos(p, _SLIT("`return` not allowed inside `defer` block"), v__token__Token_pos(&p->tok))))); - return _t14; + v__ast__Stmt _t16 = v__ast__NodeError_to_sumtype_v__ast__Stmt(ADDR(v__ast__NodeError, (v__parser__Parser_error_with_pos(p, _SLIT("`return` not allowed inside `defer` block"), v__token__Token_pos(&p->tok))))); + return _t16; } else { - v__ast__Stmt _t15 = v__ast__Return_to_sumtype_v__ast__Stmt(ADDR(v__ast__Return, (v__parser__Parser_return_stmt(p)))); - return _t15; + v__ast__Stmt _t17 = v__ast__Return_to_sumtype_v__ast__Stmt(ADDR(v__ast__Return, (v__parser__Parser_return_stmt(p)))); + return _t17; } break; } @@ -85235,23 +85398,23 @@ v__ast__Stmt v__parser__Parser_stmt(v__parser__Parser* p, bool is_top_level) { v__token__Pos pos = v__token__Token_pos(&p->tok); v__ast__IfExpr expr = v__parser__Parser_if_expr(p, true); v__token__Pos_update_last_line(&pos, p->prev_tok.line_nr); - v__ast__Stmt _t16 = v__ast__ExprStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__ExprStmt, (((v__ast__ExprStmt){.pos = pos,.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.expr = v__ast__IfExpr_to_sumtype_v__ast__Expr(&expr),.is_expr = 0,.typ = 0,})))); - return _t16; + v__ast__Stmt _t18 = v__ast__ExprStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__ExprStmt, (((v__ast__ExprStmt){.pos = pos,.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.expr = v__ast__IfExpr_to_sumtype_v__ast__Expr(&expr),.is_expr = 0,.typ = 0,})))); + return _t18; } else if (p->peek_tok.kind == (v__token__Kind__key_for)) { - v__ast__Stmt _t17 = v__ast__ComptimeFor_to_sumtype_v__ast__Stmt(ADDR(v__ast__ComptimeFor, (v__parser__Parser_comptime_for(p)))); - return _t17; + v__ast__Stmt _t19 = v__ast__ComptimeFor_to_sumtype_v__ast__Stmt(ADDR(v__ast__ComptimeFor, (v__parser__Parser_comptime_for(p)))); + return _t19; } else if (p->peek_tok.kind == (v__token__Kind__name)) { v__token__Pos pos = v__token__Token_pos(&p->tok); v__ast__ComptimeCall *expr = HEAP(v__ast__ComptimeCall, (v__parser__Parser_comptime_call(p))); v__token__Pos_update_last_line(&pos, p->prev_tok.line_nr); - v__ast__Stmt _t18 = v__ast__ExprStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__ExprStmt, (((v__ast__ExprStmt){.pos = pos,.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.expr = v__ast__ComptimeCall_to_sumtype_v__ast__Expr(&(*(expr))),.is_expr = 0,.typ = 0,})))); - return _t18; + v__ast__Stmt _t20 = v__ast__ExprStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__ExprStmt, (((v__ast__ExprStmt){.pos = pos,.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.expr = v__ast__ComptimeCall_to_sumtype_v__ast__Expr(&(*(expr))),.is_expr = 0,.typ = 0,})))); + return _t20; } else { - v__ast__Stmt _t19 = v__ast__NodeError_to_sumtype_v__ast__Stmt(ADDR(v__ast__NodeError, (v__parser__Parser_error_with_pos(p, _SLIT("unexpected $"), v__token__Token_pos(&p->tok))))); - return _t19; + v__ast__Stmt _t21 = v__ast__NodeError_to_sumtype_v__ast__Stmt(ADDR(v__ast__NodeError, (v__parser__Parser_error_with_pos(p, _SLIT("unexpected $"), v__token__Token_pos(&p->tok))))); + return _t21; }; break; } @@ -85265,27 +85428,27 @@ v__ast__Stmt v__parser__Parser_stmt(v__parser__Parser* p, bool is_top_level) { if (p->tok.line_nr == line && p->tok.kind == v__token__Kind__name) { label = v__parser__Parser_check_name(p); } - v__ast__Stmt _t20 = v__ast__BranchStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__BranchStmt, (((v__ast__BranchStmt){.kind = tok.kind,.label = label,.pos = v__token__Token_pos(&tok),})))); - return _t20; + v__ast__Stmt _t22 = v__ast__BranchStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__BranchStmt, (((v__ast__BranchStmt){.kind = tok.kind,.label = label,.pos = v__token__Token_pos(&tok),})))); + return _t22; break; } case v__token__Kind__key_unsafe: { - v__ast__Stmt _t21 = v__parser__Parser_unsafe_stmt(p); - return _t21; + v__ast__Stmt _t23 = v__parser__Parser_unsafe_stmt(p); + return _t23; break; } case v__token__Kind__hash: { - v__ast__Stmt _t22 = v__ast__HashStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__HashStmt, (v__parser__Parser_hash(p)))); - return _t22; + v__ast__Stmt _t24 = v__ast__HashStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__HashStmt, (v__parser__Parser_hash(p)))); + return _t24; break; } case v__token__Kind__key_defer: { if (p->inside_defer) { - v__ast__Stmt _t23 = v__ast__NodeError_to_sumtype_v__ast__Stmt(ADDR(v__ast__NodeError, (v__parser__Parser_error_with_pos(p, _SLIT("`defer` blocks cannot be nested"), v__token__Token_pos(&p->tok))))); - return _t23; + v__ast__Stmt _t25 = v__ast__NodeError_to_sumtype_v__ast__Stmt(ADDR(v__ast__NodeError, (v__parser__Parser_error_with_pos(p, _SLIT("`defer` blocks cannot be nested"), v__token__Token_pos(&p->tok))))); + return _t25; } else { v__parser__Parser_next(p); v__token__Pos spos = v__token__Token_pos(&p->tok); @@ -85293,16 +85456,16 @@ v__ast__Stmt v__parser__Parser_stmt(v__parser__Parser* p, bool is_top_level) { p->defer_vars = __new_array_with_default(0, 0, sizeof(v__ast__Ident), 0); Array_v__ast__Stmt stmts = v__parser__Parser_parse_block(p); p->inside_defer = false; - v__ast__Stmt _t24 = v__ast__DeferStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__DeferStmt, (((v__ast__DeferStmt){.stmts = stmts,.pos = v__token__Pos_extend_with_last_line(spos, v__token__Token_pos(&p->tok), p->prev_tok.line_nr),.defer_vars = array_clone_to_depth(&p->defer_vars, 0),.ifdef = (string){.str=(byteptr)"", .is_lit=1},.idx_in_fn = -1,})))); - return _t24; + v__ast__Stmt _t26 = v__ast__DeferStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__DeferStmt, (((v__ast__DeferStmt){.stmts = stmts,.pos = v__token__Pos_extend_with_last_line(spos, v__token__Token_pos(&p->tok), p->prev_tok.line_nr),.defer_vars = array_clone_to_depth(&p->defer_vars, 0),.ifdef = (string){.str=(byteptr)"", .is_lit=1},.idx_in_fn = -1,})))); + return _t26; } break; } case v__token__Kind__key_go: { v__ast__GoExpr go_expr = v__parser__Parser_go_expr(p); - v__ast__Stmt _t25 = v__ast__ExprStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__ExprStmt, (((v__ast__ExprStmt){.pos = go_expr.pos,.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.expr = v__ast__GoExpr_to_sumtype_v__ast__Expr(&go_expr),.is_expr = 0,.typ = 0,})))); - return _t25; + v__ast__Stmt _t27 = v__ast__ExprStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__ExprStmt, (((v__ast__ExprStmt){.pos = go_expr.pos,.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.expr = v__ast__GoExpr_to_sumtype_v__ast__Expr(&go_expr),.is_expr = 0,.typ = 0,})))); + return _t27; break; } case v__token__Kind__key_goto: @@ -85310,20 +85473,20 @@ v__ast__Stmt v__parser__Parser_stmt(v__parser__Parser* p, bool is_top_level) { v__parser__Parser_next(p); v__token__Pos spos = v__token__Token_pos(&p->tok); string name = v__parser__Parser_check_name(p); - v__ast__Stmt _t26 = v__ast__GotoStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__GotoStmt, (((v__ast__GotoStmt){.name = name,.pos = spos,})))); - return _t26; + v__ast__Stmt _t28 = v__ast__GotoStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__GotoStmt, (((v__ast__GotoStmt){.name = name,.pos = spos,})))); + return _t28; break; } case v__token__Kind__key_const: { - v__ast__Stmt _t27 = v__ast__NodeError_to_sumtype_v__ast__Stmt(ADDR(v__ast__NodeError, (v__parser__Parser_error_with_pos(p, _SLIT("const can only be defined at the top level (outside of functions)"), v__token__Token_pos(&p->tok))))); - return _t27; + v__ast__Stmt _t29 = v__ast__NodeError_to_sumtype_v__ast__Stmt(ADDR(v__ast__NodeError, (v__parser__Parser_error_with_pos(p, _SLIT("const can only be defined at the top level (outside of functions)"), v__token__Token_pos(&p->tok))))); + return _t29; break; } case v__token__Kind__key_asm: { - v__ast__Stmt _t28 = v__ast__AsmStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__AsmStmt, (v__parser__Parser_asm_stmt(p, false)))); - return _t28; + v__ast__Stmt _t30 = v__ast__AsmStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__AsmStmt, (v__parser__Parser_asm_stmt(p, false)))); + return _t30; break; } case v__token__Kind__unknown: @@ -85427,8 +85590,8 @@ v__ast__Stmt v__parser__Parser_stmt(v__parser__Parser* p, bool is_top_level) { case v__token__Kind___end_: default: { - v__ast__Stmt _t29 = v__parser__Parser_parse_multi_expr(p, is_top_level); - return _t29; + v__ast__Stmt _t31 = v__parser__Parser_parse_multi_expr(p, is_top_level); + return _t31; break; } } @@ -86231,9 +86394,9 @@ VV_LOCAL_SYMBOL v__ast__Stmt v__parser__Parser_parse_multi_expr(v__parser__Parse v__token__Pos pos = v__token__Token_pos(&tok); Array_v__ast__Ident defer_vars = p->defer_vars; p->defer_vars = __new_array_with_default(0, 0, sizeof(v__ast__Ident), 0); - multi_return_Array_v__ast__Expr_Array_v__ast__Comment mr_47732 = v__parser__Parser_expr_list(p); - Array_v__ast__Expr left = mr_47732.arg0; - Array_v__ast__Comment left_comments = mr_47732.arg1; + multi_return_Array_v__ast__Expr_Array_v__ast__Comment mr_47746 = v__parser__Parser_expr_list(p); + Array_v__ast__Expr left = mr_47746.arg0; + Array_v__ast__Comment left_comments = mr_47746.arg1; if (!(p->inside_defer && p->tok.kind == v__token__Kind__decl_assign)) { _PUSH_MANY(&defer_vars, (p->defer_vars), _t1, Array_v__ast__Ident); } @@ -86627,6 +86790,13 @@ v__ast__Expr v__parser__Parser_name_expr(v__parser__Parser* p) { v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("unexpected "), 0xfe10, {.d_s = v__token__Token_str(p->prev_tok)}}, {_SLIT0, 0, { .d_c = 0 }}})), v__token__Token_pos(&p->prev_tok)); } node = v__ast__CallExpr_to_sumtype_v__ast__Expr(ADDR(v__ast__CallExpr, (v__parser__Parser_call_expr(p, language, mod)))); + if (p->tok.kind == v__token__Kind__lpar && p->prev_tok.line_nr == p->tok.line_nr) { + v__parser__Parser_next(p); + v__token__Pos pos = v__token__Token_pos(&p->tok); + Array_v__ast__CallArg args = v__parser__Parser_call_args(p); + v__parser__Parser_check(p, v__token__Kind__rpar); + node = v__ast__CallExpr_to_sumtype_v__ast__Expr(ADDR(v__ast__CallExpr, (((v__ast__CallExpr){.pos = pos,.name_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mod = (string){.str=(byteptr)"", .is_lit=1},.name = (string){.str=(byteptr)"", .is_lit=1},.is_method = 0,.is_field = 0,.is_fn_var = 0,.is_keep_alive = 0,.is_noreturn = 0,.is_ctor_new = 0,.args = args,.expected_arg_types = __new_array(0, 0, sizeof(v__ast__Type)),.language = 0,.or_block = (v__ast__OrExpr){.stmts = __new_array(0, 0, sizeof(v__ast__Stmt)),.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},},.left = node,.left_type = 0,.receiver_type = 0,.return_type = 0,.fn_var_type = 0,.should_be_skipped = 0,.concrete_types = __new_array(0, 0, sizeof(v__ast__Type)),.concrete_list_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.raw_concrete_types = __new_array(0, 0, sizeof(v__ast__Type)),.free_receiver = 0,.scope = p->scope,.from_embed_types = __new_array(0, 0, sizeof(v__ast__Type)),.comments = __new_array(0, 0, sizeof(v__ast__Comment)),})))); + } } } else if ((p->peek_tok.kind == v__token__Kind__lcbr || (p->peek_tok.kind == v__token__Kind__lt && lit0_is_capital)) && (!p->inside_match || (p->inside_select && prev_tok_kind == v__token__Kind__arrow && lit0_is_capital)) && !p->inside_match_case && (!p->inside_if || p->inside_select) && (!p->inside_for || p->inside_select) && !known_var) { v__ast__Expr _t19 = v__ast__StructInit_to_sumtype_v__ast__Expr(ADDR(v__ast__StructInit, (v__parser__Parser_struct_init(p, string__plus(string__plus(p->mod, _SLIT(".")), p->tok.lit), false)))); @@ -87503,9 +87673,9 @@ VV_LOCAL_SYMBOL v__ast__Return v__parser__Parser_return_stmt(v__parser__Parser* v__ast__Return _t1 = ((v__ast__Return){.pos = first_pos,.comments = comments,.exprs = __new_array(0, 0, sizeof(v__ast__Expr)),.types = __new_array(0, 0, sizeof(v__ast__Type)),}); return _t1; } - multi_return_Array_v__ast__Expr_Array_v__ast__Comment mr_84043 = v__parser__Parser_expr_list(p); - Array_v__ast__Expr exprs = mr_84043.arg0; - Array_v__ast__Comment comments2 = mr_84043.arg1; + multi_return_Array_v__ast__Expr_Array_v__ast__Comment mr_84307 = v__parser__Parser_expr_list(p); + Array_v__ast__Expr exprs = mr_84307.arg0; + Array_v__ast__Comment comments2 = mr_84307.arg1; _PUSH_MANY(&comments, (comments2), _t2, Array_v__ast__Comment); v__token__Pos end_pos = v__ast__Expr_pos((*(v__ast__Expr*)array_last(exprs))); v__ast__Return _t3 = ((v__ast__Return){.pos = v__token__Pos_extend(first_pos, end_pos),.comments = comments,.exprs = exprs,.types = __new_array(0, 0, sizeof(v__ast__Type)),}); @@ -87759,8 +87929,8 @@ VV_LOCAL_SYMBOL v__ast__TypeDecl v__parser__Parser_type_decl(v__parser__Parser* return _t2; } Array_v__ast__TypeNode sum_variants = __new_array_with_default(0, 0, sizeof(v__ast__TypeNode), 0); - multi_return_Array_v__ast__Type_Array_string mr_90240 = v__parser__Parser_parse_generic_types(p); - Array_v__ast__Type generic_types = mr_90240.arg0; + multi_return_Array_v__ast__Type_Array_string mr_90504 = v__parser__Parser_parse_generic_types(p); + Array_v__ast__Type generic_types = mr_90504.arg0; v__token__Pos decl_pos_with_generics = v__token__Pos_extend(decl_pos, v__token__Token_pos(&p->prev_tok)); v__parser__Parser_check(p, v__token__Kind__assign); v__token__Pos type_pos = v__token__Token_pos(&p->tok); @@ -89355,27 +89525,24 @@ string v__parser__Parser_compile_template_file(v__parser__Parser* p, string temp } if (state == (v__parser__State__html)) { - if (string_starts_with(line, _SLIT("span.")) && string_ends_with(line, _SLIT("{"))) { + string line_t = string_trim_space(line); + if (string_starts_with(line_t, _SLIT("span.")) && string_ends_with(line, _SLIT("{"))) { string _v_class = string_trim_space(string_find_between(line, _SLIT("span."), _SLIT("{"))); strings__Builder_writeln(&source, str_intp(2, _MOV((StrIntpData[]){{_SLIT(""), 0, { .d_c = 0 }}}))); in_span = true; continue; - } - if (string_starts_with(string_trim_space(line), _SLIT(".")) && string_ends_with(line, _SLIT("{"))) { + } else if (string_starts_with(line_t, _SLIT(".")) && string_ends_with(line, _SLIT("{"))) { string _v_class = string_trim_space(string_find_between(line, _SLIT("."), _SLIT("{"))); string trimmed = string_trim_space(line); strings__Builder_write_string(&source, strings__repeat('\t', line.len - trimmed.len)); strings__Builder_writeln(&source, str_intp(2, _MOV((StrIntpData[]){{_SLIT("
"), 0, { .d_c = 0 }}}))); continue; - } - if (string_starts_with(line, _SLIT("#")) && string_ends_with(line, _SLIT("{"))) { + } else if (string_starts_with(line_t, _SLIT("#")) && string_ends_with(line, _SLIT("{"))) { string _v_class = string_trim_space(string_find_between(line, _SLIT("#"), _SLIT("{"))); strings__Builder_writeln(&source, str_intp(2, _MOV((StrIntpData[]){{_SLIT("
"), 0, { .d_c = 0 }}}))); continue; - } - if (string__eq(string_trim_space(line), _SLIT("}"))) { - string trimmed = string_trim_space(line); - strings__Builder_write_string(&source, strings__repeat('\t', line.len - trimmed.len)); + } else if (string__eq(line_t, _SLIT("}"))) { + strings__Builder_write_string(&source, strings__repeat('\t', line.len - line_t.len)); if (in_span) { strings__Builder_writeln(&source, _SLIT("")); in_span = false; @@ -90181,6 +90348,8 @@ VV_LOCAL_SYMBOL void v__builder__Builder_setup_ccompiler_options(v__builder__Bui if (v->pref->os == v__pref__OS__macos && os__exists(_SLIT("/opt/procursus"))) { array_push((array*)&ccoptions.linker_flags, _MOV((string[]){ string_clone(_SLIT("-Wl,-rpath,/opt/procursus/lib")) })); } + int user_darwin_version = 999999999; + bool user_darwin_ppc = false; ccoptions.debug_mode = v->pref->is_debug; ccoptions.guessed_compiler = v->pref->ccompiler; if (string__eq(ccoptions.guessed_compiler, _SLIT("cc")) && v->pref->is_prod) { @@ -90220,18 +90389,21 @@ VV_LOCAL_SYMBOL void v__builder__Builder_setup_ccompiler_options(v__builder__Bui } if (ccoptions.is_cc_gcc) { if (ccoptions.debug_mode) { - debug_options = new_array_from_c_array(2, 2, sizeof(string), _MOV((string[2]){_SLIT("-g"), _SLIT("-no-pie")})); + debug_options = new_array_from_c_array(1, 1, sizeof(string), _MOV((string[1]){_SLIT("-g")})); + if (user_darwin_version > 9) { + array_push((array*)&debug_options, _MOV((string[]){ string_clone(_SLIT("-no-pie")) })); + } } optimization_options = new_array_from_c_array(3, 3, sizeof(string), _MOV((string[3]){_SLIT("-O3"), _SLIT("-fno-strict-aliasing"), _SLIT("-flto")})); } if (ccoptions.debug_mode) { - _PUSH_MANY(&ccoptions.args, (debug_options), _t9, Array_string); + _PUSH_MANY(&ccoptions.args, (debug_options), _t10, Array_string); } if (v->pref->is_prod) { if (ccoptions.is_cc_tcc && !(v->parsed_files.len > 0 && string_contains((*(v__ast__File**)array_last(v->parsed_files))->path, _SLIT("vlib")))) { eprintln(_SLIT("Note: tcc is not recommended for -prod builds")); } - _PUSH_MANY(&ccoptions.args, (optimization_options), _t10, Array_string); + _PUSH_MANY(&ccoptions.args, (optimization_options), _t11, Array_string); } if (v->pref->is_prod && !ccoptions.debug_mode) { array_push((array*)&ccoptions.args, _MOV((string[]){ string_clone(_SLIT("-DNDEBUG")) })); @@ -90287,7 +90459,7 @@ VV_LOCAL_SYMBOL void v__builder__Builder_setup_ccompiler_options(v__builder__Bui } } if (v->pref->os == v__pref__OS__macos || v->pref->os == v__pref__OS__ios) { - if (!ccoptions.is_cc_tcc) { + if (!ccoptions.is_cc_tcc && !user_darwin_ppc) { array_push((array*)&ccoptions.source_args, _MOV((string[]){ string_clone(_SLIT("-x objective-c")) })); } } @@ -90309,15 +90481,15 @@ VV_LOCAL_SYMBOL void v__builder__Builder_setup_ccompiler_options(v__builder__Bui Array_v__cflag__CFlag cflags = v__builder__Builder_get_os_cflags(v); if (v->pref->build_mode != v__pref__BuildMode__build_module) { Array_string only_o_files = Array_v__cflag__CFlag_c_options_only_object_files(cflags); - _PUSH_MANY(&ccoptions.o_args, (only_o_files), _t38, Array_string); + _PUSH_MANY(&ccoptions.o_args, (only_o_files), _t39, Array_string); } - multi_return_Array_string_Array_string_Array_string mr_11425 = Array_v__cflag__CFlag_defines_others_libs(cflags); - Array_string defines = mr_11425.arg0; - Array_string others = mr_11425.arg1; - Array_string libs = mr_11425.arg2; - _PUSH_MANY(&ccoptions.pre_args, (defines), _t39, Array_string); - _PUSH_MANY(&ccoptions.pre_args, (others), _t40, Array_string); - _PUSH_MANY(&ccoptions.linker_flags, (libs), _t41, Array_string); + multi_return_Array_string_Array_string_Array_string mr_11728 = Array_v__cflag__CFlag_defines_others_libs(cflags); + Array_string defines = mr_11728.arg0; + Array_string others = mr_11728.arg1; + Array_string libs = mr_11728.arg2; + _PUSH_MANY(&ccoptions.pre_args, (defines), _t40, Array_string); + _PUSH_MANY(&ccoptions.pre_args, (others), _t41, Array_string); + _PUSH_MANY(&ccoptions.linker_flags, (libs), _t42, Array_string); if (v->pref->use_cache && v->pref->build_mode != v__pref__BuildMode__build_module) { if (!ccoptions.is_cc_tcc) { } @@ -90698,10 +90870,10 @@ VV_LOCAL_SYMBOL void v__builder__Builder_cc_linux_cross(v__builder__Builder* b) v__builder__Builder_ensure_linuxroot_exists(b, sysroot); string obj_file = string__plus(b->out_name_c, _SLIT(".o")); Array_v__cflag__CFlag cflags = v__builder__Builder_get_os_cflags(b); - multi_return_Array_string_Array_string_Array_string mr_22460 = Array_v__cflag__CFlag_defines_others_libs(cflags); - Array_string defines = mr_22460.arg0; - Array_string others = mr_22460.arg1; - Array_string libs = mr_22460.arg2; + multi_return_Array_string_Array_string_Array_string mr_22763 = Array_v__cflag__CFlag_defines_others_libs(cflags); + Array_string defines = mr_22763.arg0; + Array_string others = mr_22763.arg1; + Array_string libs = mr_22763.arg2; Array_string cc_args = __new_array_with_default(0, 0, sizeof(string), 0); array_push((array*)&cc_args, _MOV((string[]){ string_clone(_SLIT("-w")) })); array_push((array*)&cc_args, _MOV((string[]){ string_clone(_SLIT("-fPIC")) }));