Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
adcdd9e
layout: struct 声明语法 + kindexpr structref(#199,WIP 落盘)
miaobyte Sep 3, 2026
058e25b
runtime: struct·new 内建 + cpTree 造实例(#199 依赖 #200,WIP 落盘)
miaobyte Sep 3, 2026
4709a9f
tutorial: 12-struct 重写为 struct 教程 00-07 + README 措辞(#199,WIP 落盘)
miaobyte Sep 3, 2026
ae4ebe8
fix: 12-struct 教程语法迁移 #→//(rebase 后对齐 master #219 语法)
miaobyte Sep 5, 2026
cfb44ed
struct: 实例复制 cpdir/cpTree 深拷 → cplist/CpList 浅拷(#199)
miaobyte Sep 5, 2026
94dea4d
mkindex: 加 capacity 参数(kv·mkindex(path,cap))+ 新教程 kv_mkindex_cap
miaobyte Sep 6, 2026
e142dbe
docs: 生态架构图迁入 + stdlib/kvlang 增 reference(五语言)与 spec(kvlang 规范)
miaobyte Sep 6, 2026
4a9e141
chore: reference 材料不入库(gitignore,本地查阅用)
miaobyte Sep 6, 2026
02569d6
layout/runtime: spec 驱动修正——ndim==1 判定、null 非合法字面量等
miaobyte Sep 7, 2026
2dc73a0
stdlib: deepdive → spec 迁移(deepdive 删,spec 卷扩写为唯一规范事实源)
miaobyte Sep 7, 2026
fe61c1e
spec: 卷结构重组(合并小章、重构目录层级)
miaobyte Sep 7, 2026
fde2376
spec(类型系统): 新增「字符串编码」章——存储默认 utf8 / 用户代码 utf32 / string 包定宽
miaobyte Sep 7, 2026
59a8112
spec: 删除 `<-` 赋值记号——`=` 与 `->` 双记号(`<-` 与 `=` 重复)
miaobyte Sep 7, 2026
37bc03c
spec: 字符串编码章归位编号(→ 26-字符串编码)
miaobyte Sep 7, 2026
cdece1a
test: error_cases 目录从 tutorial/ 迁至仓库根
miaobyte Sep 7, 2026
d2d95e5
cleanup: defrwfunc 关键词移除(highlight/教程)+ 陈旧 agent_eval/benchmark.csv 清理
miaobyte Sep 7, 2026
54b510c
cleanup: 删陈旧 tutorial/questions(Q&A 习题)、error_test.py、issue116_exp.py
miaobyte Sep 7, 2026
296ce28
runtime: 条件取值去 AsBool,改 AsInt64 != 0(bool 即 0/1 整数)
miaobyte Sep 7, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,6 @@ kvlanglayout
silent*
dumptest*
d[0-9][0-9][0-9][0-9][0-9][0-9][0-9]

# 五语言对齐 reference 材料(本地查阅用,不入库)
stdlib/kvlang/reference/
4 changes: 2 additions & 2 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ kvspace 是核心的寻址空间与内存空间;语言本体是小核心 runti
![kvlang 生态架构](docs/kvlang-ecosystem-architecture.png)

- **kvspace** — 一套 C ABI(`kvspace_*`,24 符号),由 DSN 选择两种实现:`kvspace-c`(C,`shm://`,链接 `blockmalloc` + `slotsboxmalloc`)与 `kvspace-durable`(Rust,`redis://` / `fs://`,s3/tikv 规划中)。
- **kvlang** — `layout`(Rust,编译)与 `runtime`(C,执行),二者都只依赖 `kvspace_*` C ABI。
- **kvlang** — `layout`(Rust,语法检查+布局)与 `runtime`(C,执行),二者都只依赖 `kvspace_*` C ABI。
- **rwirext** — 构建在 runtime 之上的扩展。嵌入式(Rust `term`,经 `kvlang_rwirext.h` 链接 `libkvlang_runtime`)或独立进程 handoff(Go `json`、Python `numpy`)。`term` / `json` 只是基础示例扩展,不是招牌能力。

---
Expand Down Expand Up @@ -191,7 +191,7 @@ if (sum > 50) { println("big") } else { println("small") }
for (x in [7, 2, 9, 4]) { println(x) }
```

条件支持复合表达式:`if (7 % 2 != 0)`、`while (i < string.len(s))` 均可(编译期自动展平为临时槽)。
条件支持复合表达式:`if (7 % 2 != 0)`、`while (i < string.len(s))` 均可(布局期自动展平为临时槽)。

### 操作符

Expand Down
169 changes: 169 additions & 0 deletions docs/kvlang-ecosystem-architecture.drawio
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
<?xml version="1.0" encoding="UTF-8"?>
<mxfile host="drawio" version="26.0.0">
<diagram name="kvlang-ecosystem">
<mxGraphModel dx="1400" dy="900" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1300" pageHeight="1150" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />

<mxCell id="title" value="kvlang / kvspace 生态架构" style="text;html=1;align=left;verticalAlign=middle;fontSize=20;fontStyle=1;" vertex="1" parent="1">
<mxGeometry x="40" y="20" width="600" height="34" as="geometry" />
</mxCell>

<mxCell id="tierA" value="上层 · rwirext 扩展运行时" style="swimlane;startSize=34;html=1;fillColor=#ffffff;swimlaneFillColor=#ffffff;strokeColor=#999999;fontSize=14;fontStyle=1;verticalAlign=top;" vertex="1" parent="1">
<mxGeometry x="40" y="70" width="1200" height="150" as="geometry" />
</mxCell>
<mxCell id="n_term" value="term&#xa;(Rust)&#xa;print / println / cerr / input" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=13;" vertex="1" parent="tierA">
<mxGeometry x="60" y="55" width="280" height="76" as="geometry" />
</mxCell>
<mxCell id="n_json" value="json&#xa;(Go)&#xa;json.to / json.from" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#b0e3e6;strokeColor=#0e8088;fontSize=13;" vertex="1" parent="tierA">
<mxGeometry x="460" y="55" width="280" height="76" as="geometry" />
</mxCell>
<mxCell id="n_numpy" value="numpy / op-gpu&#xa;(Python)&#xa;tensor 算子" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=13;" vertex="1" parent="tierA">
<mxGeometry x="860" y="55" width="280" height="76" as="geometry" />
</mxCell>

<mxCell id="tierB" value="中层 · kvlang(VM)" style="swimlane;startSize=34;html=1;fillColor=#ffffff;swimlaneFillColor=#ffffff;strokeColor=#999999;fontSize=14;fontStyle=1;verticalAlign=top;" vertex="1" parent="1">
<mxGeometry x="40" y="290" width="1200" height="150" as="geometry" />
</mxCell>
<mxCell id="n_layout" value="layout&#xa;(Rust)&#xa;编译期:parser / lower / layoutcode" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=13;" vertex="1" parent="tierB">
<mxGeometry x="160" y="55" width="360" height="76" as="geometry" />
</mxCell>
<mxCell id="n_runtime" value="runtime&#xa;(C)&#xa;执行期:fetch-decode-execute&#xa;对外暴露 kvlang_runtime.h + kvlang_rwirext.h" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=13;" vertex="1" parent="tierB">
<mxGeometry x="680" y="45" width="360" height="90" as="geometry" />
</mxCell>

<mxCell id="tierC" value="核心 · kvspace(统一 KV 存储契约)" style="swimlane;startSize=34;html=1;fillColor=#ffffff;swimlaneFillColor=#ffffff;strokeColor=#999999;fontSize=14;fontStyle=1;verticalAlign=top;" vertex="1" parent="1">
<mxGeometry x="40" y="510" width="1200" height="200" as="geometry" />
</mxCell>
<mxCell id="n_kvc" value="kvspace-c&#xa;(C)&#xa;实现 kvspace_* C ABI" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=13;fontStyle=1;" vertex="1" parent="tierC">
<mxGeometry x="160" y="50" width="360" height="90" as="geometry" />
</mxCell>
<mxCell id="n_kvd" value="kvspace-durable&#xa;(Rust · cdylib)&#xa;实现 kvspace_* C ABI" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=13;fontStyle=1;" vertex="1" parent="tierC">
<mxGeometry x="680" y="50" width="360" height="90" as="geometry" />
</mxCell>
<mxCell id="note_abi" value="kvspace-c 与 kvspace-durable 实现同一 kvspace_* C ABI(24 符号);运行时按 DSN 选择后端:shm:// → kvspace-c,redis:// / fs:// → kvspace-durable" style="text;html=1;align=center;verticalAlign=middle;fontSize=11;fontColor=#555555;" vertex="1" parent="tierC">
<mxGeometry x="80" y="152" width="1040" height="36" as="geometry" />
</mxCell>

<mxCell id="tierD" value="底层 · 依赖与后端" style="swimlane;startSize=34;html=1;fillColor=#ffffff;swimlaneFillColor=#ffffff;strokeColor=#999999;fontSize=14;fontStyle=1;verticalAlign=top;" vertex="1" parent="1">
<mxGeometry x="40" y="750" width="1200" height="170" as="geometry" />
</mxCell>
<mxCell id="lbl_dep" value="kvspace-c 依赖库" style="text;html=1;align=left;verticalAlign=middle;fontSize=12;fontStyle=2;fontColor=#555555;" vertex="1" parent="tierD">
<mxGeometry x="120" y="42" width="440" height="20" as="geometry" />
</mxCell>
<mxCell id="lbl_be" value="kvspace-durable 后端" style="text;html=1;align=left;verticalAlign=middle;fontSize=12;fontStyle=2;fontColor=#555555;" vertex="1" parent="tierD">
<mxGeometry x="690" y="42" width="470" height="20" as="geometry" />
</mxCell>
<mxCell id="n_block" value="blockmalloc&#xa;(C)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="tierD">
<mxGeometry x="120" y="72" width="200" height="70" as="geometry" />
</mxCell>
<mxCell id="n_slots" value="slotsboxmalloc&#xa;(C)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="tierD">
<mxGeometry x="340" y="72" width="230" height="70" as="geometry" />
</mxCell>
<mxCell id="n_redis" value="redis" style="shape=cylinder3;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;" vertex="1" parent="tierD">
<mxGeometry x="690" y="72" width="120" height="70" as="geometry" />
</mxCell>
<mxCell id="n_fs" value="fs" style="shape=cylinder3;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;" vertex="1" parent="tierD">
<mxGeometry x="830" y="72" width="110" height="70" as="geometry" />
</mxCell>
<mxCell id="n_s3" value="s3 / tikv …&#xa;(未来)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#999999;dashed=1;fontSize=12;fontColor=#777777;" vertex="1" parent="tierD">
<mxGeometry x="960" y="72" width="200" height="70" as="geometry" />
</mxCell>

<mxCell id="e_term" value="C ABI · kvlang_rwirext.h&#xa;link libkvlang_runtime.so&#xa;(嵌入式 KVMODE_RETURN)" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.15;entryY=0;entryDx=0;entryDy=0;labelBackgroundColor=#ffffff;fontSize=11;" edge="1" parent="1" source="n_term" target="n_runtime">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="e_json" value="handoff · KV .todo/.done" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;dashed=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;labelBackgroundColor=#ffffff;fontSize=11;" edge="1" parent="1" source="n_json" target="n_runtime">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="e_numpy" value="handoff · KV .todo/.done" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;dashed=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.85;entryY=0;entryDx=0;entryDy=0;labelBackgroundColor=#ffffff;fontSize=11;" edge="1" parent="1" source="n_numpy" target="n_runtime">
<mxGeometry relative="1" as="geometry" />
</mxCell>

<mxCell id="e_layout" value="C ABI · kvspace_*&#xa;extern &quot;C&quot;(24 符号)" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.28;entryY=0;entryDx=0;entryDy=0;labelBackgroundColor=#ffffff;fontSize=11;" edge="1" parent="1" source="n_layout" target="tierC">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="e_runtime" value="C ABI · kvspace_*(24 符号)" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.72;entryY=0;entryDx=0;entryDy=0;labelBackgroundColor=#ffffff;fontSize=11;" edge="1" parent="1" source="n_runtime" target="tierC">
<mxGeometry relative="1" as="geometry" />
</mxCell>

<mxCell id="e_block" value="库链接" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.3;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;labelBackgroundColor=#ffffff;fontSize=11;" edge="1" parent="1" source="n_kvc" target="n_block">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="e_slots" value="库链接" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.6;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;labelBackgroundColor=#ffffff;fontSize=11;" edge="1" parent="1" source="n_kvc" target="n_slots">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="e_redis" value="backend" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.25;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;labelBackgroundColor=#ffffff;fontSize=11;" edge="1" parent="1" source="n_kvd" target="n_redis">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="e_fs" value="backend" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;labelBackgroundColor=#ffffff;fontSize=11;" edge="1" parent="1" source="n_kvd" target="n_fs">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="e_s3" value="未来" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;dashed=1;exitX=0.75;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;strokeColor=#999999;fontColor=#777777;labelBackgroundColor=#ffffff;fontSize=11;" edge="1" parent="1" source="n_kvd" target="n_s3">
<mxGeometry relative="1" as="geometry" />
</mxCell>

<mxCell id="legLang" value="实现语言(配色)" style="rounded=0;whiteSpace=wrap;html=1;fillColor=none;strokeColor=#666666;verticalAlign=top;fontStyle=1;fontSize=12;align=left;spacingLeft=8;" vertex="1" parent="1">
<mxGeometry x="40" y="960" width="560" height="150" as="geometry" />
</mxCell>
<mxCell id="ll1" value="" style="rounded=1;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;" vertex="1" parent="legLang">
<mxGeometry x="12" y="34" width="34" height="16" as="geometry" />
</mxCell>
<mxCell id="ll1t" value="Rust(term / layout / kvspace-durable)" style="text;html=1;align=left;verticalAlign=middle;fontSize=12;" vertex="1" parent="legLang">
<mxGeometry x="54" y="32" width="490" height="20" as="geometry" />
</mxCell>
<mxCell id="ll2" value="" style="rounded=1;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="legLang">
<mxGeometry x="12" y="60" width="34" height="16" as="geometry" />
</mxCell>
<mxCell id="ll2t" value="C(runtime / kvspace-c / blockmalloc / slotsboxmalloc)" style="text;html=1;align=left;verticalAlign=middle;fontSize=12;" vertex="1" parent="legLang">
<mxGeometry x="54" y="58" width="490" height="20" as="geometry" />
</mxCell>
<mxCell id="ll3" value="" style="rounded=1;html=1;fillColor=#b0e3e6;strokeColor=#0e8088;" vertex="1" parent="legLang">
<mxGeometry x="12" y="86" width="34" height="16" as="geometry" />
</mxCell>
<mxCell id="ll3t" value="Go(json 扩展)" style="text;html=1;align=left;verticalAlign=middle;fontSize=12;" vertex="1" parent="legLang">
<mxGeometry x="54" y="84" width="490" height="20" as="geometry" />
</mxCell>
<mxCell id="ll4" value="" style="rounded=1;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="legLang">
<mxGeometry x="12" y="112" width="34" height="16" as="geometry" />
</mxCell>
<mxCell id="ll4t" value="Python(numpy / op-gpu 扩展)" style="text;html=1;align=left;verticalAlign=middle;fontSize=12;" vertex="1" parent="legLang">
<mxGeometry x="54" y="110" width="490" height="20" as="geometry" />
</mxCell>

<mxCell id="legEdge" value="依赖类型(连线)" style="rounded=0;whiteSpace=wrap;html=1;fillColor=none;strokeColor=#666666;verticalAlign=top;fontStyle=1;fontSize=12;align=left;spacingLeft=8;" vertex="1" parent="1">
<mxGeometry x="680" y="960" width="560" height="150" as="geometry" />
</mxCell>
<mxCell id="le1" value="" style="endArrow=classic;html=1;rounded=0;strokeColor=#333333;" edge="1" parent="legEdge">
<mxGeometry relative="1" as="geometry">
<mxPoint x="12" y="42" as="sourcePoint" />
<mxPoint x="60" y="42" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="le1t" value="实线 = C ABI / 直接链接(编译期链接、同/跨语言 FFI)" style="text;html=1;align=left;verticalAlign=middle;fontSize=12;" vertex="1" parent="legEdge">
<mxGeometry x="72" y="32" width="480" height="20" as="geometry" />
</mxCell>
<mxCell id="le2" value="" style="endArrow=classic;html=1;rounded=0;dashed=1;strokeColor=#333333;" edge="1" parent="legEdge">
<mxGeometry relative="1" as="geometry">
<mxPoint x="12" y="76" as="sourcePoint" />
<mxPoint x="60" y="76" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="le2t" value="虚线 = handoff:KV .todo/.done 协议(独立进程扩展)" style="text;html=1;align=left;verticalAlign=middle;fontSize=12;" vertex="1" parent="legEdge">
<mxGeometry x="72" y="66" width="480" height="20" as="geometry" />
</mxCell>
<mxCell id="le3" value="" style="endArrow=classic;html=1;rounded=0;dashed=1;strokeColor=#999999;" edge="1" parent="legEdge">
<mxGeometry relative="1" as="geometry">
<mxPoint x="12" y="110" as="sourcePoint" />
<mxPoint x="60" y="110" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="le3t" value="灰虚线 = 未来实现(尚未落地)" style="text;html=1;align=left;verticalAlign=middle;fontSize=12;fontColor=#777777;" vertex="1" parent="legEdge">
<mxGeometry x="72" y="100" width="480" height="20" as="geometry" />
</mxCell>

</root>
</mxGraphModel>
</diagram>
</mxfile>
10 changes: 2 additions & 8 deletions tutorial/error_test.py → error_cases/error_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
用法: python3 tutorial/error_test.py
"""
from __future__ import annotations
import os, re, subprocess, sys
import os, subprocess, sys
from pathlib import Path

ROOT = Path(__file__).resolve().parent.parent
Expand Down Expand Up @@ -44,11 +44,6 @@ def _unescape_logx(stderr: str) -> str:
"""logx msg= 域为 JSON-style 引号串,\" → " 以利子串匹配。"""
return stderr.replace('\\"', '"')

def _detect_entry(out: str) -> str:
m = re.search(r"ENTRY=(\S+)", out)
return m.group(1) if m else "init"


def collect_errors(rel: str) -> str:
"""layout(编译期诊断)+ run(运行时诊断),收集 stderr 合并。"""
# 用 kvspace clear 隔离各 case
Expand All @@ -58,8 +53,7 @@ def collect_errors(rel: str) -> str:
text=True, timeout=60, cwd=str(ROOT))
stderr += _unescape_logx(layout.stderr)
if layout.returncode == 0:
entry = _detect_entry(layout.stdout)
crun = subprocess.run([TERM_BIN, entry], capture_output=True,
crun = subprocess.run([TERM_BIN, "test"], capture_output=True,
text=True, timeout=120, cwd=str(ROOT),
env={**os.environ, "KVSPACE": _C_DSN})
stderr += "\n" + _unescape_logx(crun.stderr)
Expand Down
6 changes: 6 additions & 0 deletions error_cases/type_error/bool_branch.kv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// expected
// TypeError: branch condition must be bool, got int64
// 修复: B2 铁律 — 分支条件必须是 bool,禁止 int 隐式真值化(用 != 0)
rwfunc test() -> () {
if (int64(1)) { }
}
6 changes: 6 additions & 0 deletions error_cases/type_error/bool_logic.kv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// expected
// TypeError: && requires bool, got int64
// 修复: B2 铁律 — 逻辑运算只接受 bool,禁止 int 隐式真值化(用 != 0)
rwfunc test() -> () {
int64(1) && true -> x
}
2 changes: 1 addition & 1 deletion layout/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "kvlang-layout"
version = "0.1.0"
edition = "2021"
license = "MIT"
description = "kvlang 编译期(parser/lower/layoutcode),只依赖 kvspace-durable 的 C ABI"
description = "kvlang 语法检查 + 布局工具(parser/lower/layoutcode),只依赖 kvspace-durable 的 C ABI"

[lib]
name = "kvlanglayout"
Expand Down
Loading
Loading