fix(批8 (甲) 批1 刀1): unify_types 的 T? 模式规则——修 S1-ARG 恒报 + 同基点上的 TF01 硬错(判据 C1–C7 两向钉子 + 突变自证) - #133
Merged
Merged
Conversation
根因(实测):unify_types 三条规则外的 `T?`(TYP_OPTIONAL,内层泛型参数)落兜底 type_compat_strict(concrete, pattern) ⇒ 内层**不代入、不绑定、恒假** ⇒ 泛型调用里 `T?` 形参的实参既不绑定也不校验,且 [S1-ARG] report-only 打点对 `T?` **恒报**(含已正确编译的 合法调用 —— 它们此前靠 ir_gen 旧路径恰好正确)。 修复:新增 `pk == TYP_OPTIONAL` 分支(① concrete 亦 optional ⇒ 内层对内层;② 否则裸值入 T? ⇒ 内层对 concrete),内层是泛型参数时由既有 TYP_GENERIC_PARAM 分支绑定/比对。 **既有三条规则逐字未动;不改任何调用点。** 判据(tests/selfhost/test_topt_pattern.py,已挂 src/ci/run.sh selfhost-tests;**两向钉子**): C1 五例合法调用(C6 g(d,d) / C7 g2(d) / J / K / M)[S1-ARG] 由 1 → **0**; C2 g(1,d) 真错仍**恰 1** 条(防「一律不报」);C3 实例键与调用点转换不变 (g[dex] / g2[dex] / call g2[dex](_dxsc));C5 槽型直读 slot=8;C4 非泛型面零足迹对照。 批次判据(与当批起点读数相同):check src/compiler rc=0 · ^error[ = 0(起点 0)· selftest-types 415/415(起点 415/415)· canary 5/5 且五值逐字节同改前 · 停条件六套件全绿(test_optional 80/80 · test_arg_inference_gap 全绿 · test_generic_constr 15/15 · test_generic_param_erasure ALL PASS · test_cache_identity 6/6 · test_cir_warm_path 19/19)。 行为变更(显式登记):`T?` 的 S1-ARG 误报消失(诊断面)+ 该模式下的泛型绑定由「不绑定」 变为「绑定」;产物面零足迹(canary 五值 + 六套件均同改前)。
…+ 排除法成因,明写机制未查明 实测三读数(同一批探针跨基点):41a51d8d = check rc=0 + 1 条 [S1-ARG] · 965052b(2(a) 后)= rc=1 error[TF01] (g2(d)/g2(x:int)/g2(Some(3))/return g2(x)/f := g2(x);return f 五项全 rc=1)· 批 1 修后五项全 rc=0。 成因 = 排除法定位到 #132(区间内 #129/#130/#131 皆文档面,唯一代码提交是 2(a))。 **机制未查明**(不得据本条推断机理;先例 = #2026-09-17-5 的读码机理被 T0 推翻并带下游判据作废)。 方法学(供后续批次照做):「批声明的范围」≠「批的实际影响面」⇒ 凡改 checker.cr 的批,收尾宜对已知敏感面 跨基点复测同类案例。状态 = 已消解(判据 = tests/selfhost/test_topt_pattern.py C7)。 (映射表行 + ### 段两处齐备;test_todo_id_migration 全绿:J3 新 id 139 / 标题 139)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
本批是什么
批 8 (甲)批 1 · 刀 1 =
unify_types的T?模式规则(独立小批;计划 =docs/superpowers/plans/2026-09-18-b8-e1-arg-check.md§3 刀 1,冻结版76ce7023)。只加一个分支、不改既有三条规则的语义、不改任何调用点(+24 行,含注释)。
根因(实读 + 实测)
unify_types原只有三条规则(pattern == concrete/TYP_GENERIC_PARAM/TYP_GENERIC_APPLY),T?(TYP_OPTIONAL,内层泛型参数)落兜底type_compat_strict(concrete, pattern)⇒ 内层不代入、不绑定、恒假。后果两层:
[S1-ARG]report-only 打点对T?恒报(含已正确编译的合法调用g(d,d)/g2(d));T?形参的单泛型调用在当前基点965052b5(2(a) 合并后)本就是硬错error[TF01](rc=1)——g2(d)/g2(x:int)/g2(Some(3))/return g2(x)/f := g2(x); return f均 rc=1;根因同一条:
unify不绑定 ⇒ 调用结果型解不出 ⇒ 调用者被判「返回型不符」。(旧基点
41a51d8d上它们是 rc=0 + 1 条打点 ⇒ 2(a) 合并后升级成硬错。)修法
pk == TYP_OPTIONAL⇒ ① concrete 亦 optional ⇒ 内层对内层递归;② 否则(裸值入T?,T ⊆ T?,与type_compat_strict的可选目标分支同语义)⇒ 内层对 concrete 递归。内层是泛型参数时,由既有
TYP_GENERIC_PARAM分支绑定/比对。判据(
tests/selfhost/test_topt_pattern.py,已挂src/ci/run.sh的selfhost-tests;两向钉子)g(d,d)/g2(d)/J/K/M:合法调用check rc=0·[S1-ARG]0 条g2(d)/M回rc=1)g(1, d)(apx):真错check rc=0·[S1-ARG]恰 1 条g2(Some(3))/f := g2(x); return f/return g2(x)(对照f := g2(x); return 0)error[TF01])g[dex]/g2[dex]/call g2[dex](_dxsc)/--dump-paramsslot=8g12(1,d)[S1-ARG]0(改前亦 0)突变自证(配方可复跑):独立工作区删回该分支 → 重建 →
COREC_BIN=<变异二进制> python3 tests/selfhost/test_topt_pattern.py⇒ 8 项红(C1 五 + C7 三),C2/C3/C4/C5 全绿 —— 判据命中目标、且未把「产物面」与「诊断面」混在一根钉子上。
批次判据(判据 = 与当批起点读数相同,非写死数)
./build/corec check src/compiler^error[= 0^error[= 0selftest-typestools/baseline/canary_check.sh)canary_elf f1137275…·pa_ccr f06bf45b…·pa_static_ccr 76df0adf…·gt_ccr edfd8e98…·gt_static_ccr bbfe4789…)test_optional80/80 ·test_arg_inference_gap全绿 ·test_generic_constr15/15 ·test_generic_param_erasureALL PASS ·test_cache_identity6/6 ·test_cir_warm_path19/19行为变更(显式登记,本批不是「零行为变化」)
T?的[S1-ARG]误报消失;T?形参单泛型调用在当前基点上的error[TF01](rc=1)被修好(= T0 报告登记的「同族相邻缺陷、未定位根因」三例,根因即本刀);不做 / 不确定
@raw_int((i) 小批已派plan-optdex;两个写者不同时改checker.cr);diag.cr的 TF07 build 豁免(归刀 4);(甲) 主体(实参校验硬错)归批 2;tests/suite/*.cr语料不在门内)。