diff --git a/App/lib/core/Gen/Call/CallGenCtor.vp b/App/lib/core/Gen/Call/CallGenCtor.vp index cd08561..ab45293 100644 --- a/App/lib/core/Gen/Call/CallGenCtor.vp +++ b/App/lib/core/Gen/Call/CallGenCtor.vp @@ -322,6 +322,10 @@ novirtual class CallGenCtor(CallGenBase.CallGenBase): if pool is None or builder is None or new_node is None or trans is None: return None src: int = new_node.Source life: int = new_node.Life + # 缺省规则(§3.2 / D3):来源缺省 = heap;生命期缺省由来源决定 + # stack → slife(帧生命期;故 `new stack T(...)` 不写 slife 也等效) + # heap / memgr → hlife(自由生命期) + # 生命期在 life_of_expr 里按同一张表落地(LIFE_FRAME / LIFE_HEAP),此处只管存储。 # §2.4-3:stack 不可能超帧 if src == ast.NEW_SRC_STACK and life == ast.NEW_LIFE_HLIFE: self.Gen.TypeGenErr.fatal_error(new_node, "`new stack hlife` is contradictory: a stack allocation can never outlive its frame; use `new stack slife` (the default for stack), or `heap`/`memgr(x)` for a longer lifetime", "LifetimeError")