From 09b5bf5ac34205318472f26a51f308d7a18ed4fd Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Thu, 8 Oct 2026 18:21:00 +0800 Subject: [PATCH] =?UTF-8?q?docs(gen):=20=5Ftranslate=5Fnew=5Fexpr=20?= =?UTF-8?q?=E6=B3=A8=E6=98=8E=E7=BC=BA=E7=9C=81=E8=A7=84=E5=88=99=EF=BC=88?= =?UTF-8?q?stack=20=E9=BB=98=E8=AE=A4=20slife=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 缺省规则(§3.2 / D3):来源缺省 = heap;生命期缺省由来源决定——stack → slife(故 new stack T(...) 不写 slife 也等效),heap/memgr → hlife。生命期在 life_of_expr 按同一张表落地(LIFE_FRAME / LIFE_HEAP)。 --- App/lib/core/Gen/Call/CallGenCtor.vp | 4 ++++ 1 file changed, 4 insertions(+) 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")