stage1 指针计算类型的错误修复 as运算符优先级的修改 ir2vm的bug修复

This commit is contained in:
zzy committed 2026-09-15 21:24:58 +08:00
1 parent 06f3884c30
commit 09d05e3a34
10 files changed
+191 -60

No files matched your search

+6 -3
View File
@@ -651,9 +651,11 @@ static spl_lang_type_id_t sema_coerce(spl_sema_t *sema, spl_ast_node_ref_t ref,
switch (n->kind) {
case SPL_AST_EXPR_UNARY: {
/* & 与 .* 的结果类型由操作数决定,不能靠 expected 反向定型 */
/* ADDRESS / DEREF 的结果类型由操作数决定,不能用 expected 反向定型。
* 但不能直接 return ——— 那会绕过 expected 兼容性检查。
* 走 break 落到兜底:infer 后做 is_subtype / comptime 判定。 */
if (n->unary.op == SPL_UNARY_OP_ADDRESS || n->unary.op == SPL_UNARY_OP_DEREF)
return sema_infer(sema, ref);
break;
if (!sema_coerce(sema, n->unary.operand, expected))
return 0;
n->resolved_lang_tid = expected;
@@ -1213,7 +1215,8 @@ static spl_lang_type_id_t sema_infer(spl_sema_t *sema, spl_ast_node_ref_t ref) {
for (usize i = 0; i < nargs && i < fixed; ++i) {
spl_lang_type_id_t pt =
vec_at(spl_lang_type_node(sema->type, callee_tid)->extra.fn.params, i);
sema_coerce(sema, vec_at(n->call.args, i), pt);
if (!sema_coerce(sema, vec_at(n->call.args, i), pt))
return 0;
}
/* varargs:默认提升到 isize */
if (has_varargs) {