fix: float wire precision, native stack safety, refs diagnostics and fixtures
Findings from the conformance corpus workstream, all fixed at the source: - value/wire: enable serde_json's float_roundtrip so typed wire floats keep their exact digits across foreign/plugin boundaries (Python pi*9 now stays 28.274333882308138). - host: default interpreter stack budget lowered to 128 frames so deeply recursive documents hit a structured resource.exhausted instead of exhausting the native debug-build Rust stack; --stack remains available. - frontend/map: calling an external HTTP(S) link is reported as ref.unresolved (consistent with other unresolvable call targets) instead of math.unsupported. - frontend/analyze: invalid front matter emits a single frontmatter.invalid diagnostic (the YAML error is not repeated by the imports pass). - spec/mapping: clarify that would-be execution nodes outside any function body are inert with a markdown.inert_executable warning (no "return outside a function" hard-error claim). - tests: add the conformance corpus and harness (150 AST goldens, 36 semantic goldens, 48 hard-error + 6 warning + 10 runtime-error negatives, CLI/module/ plugin integration tests, prose-invariance properties) and update the three reported observations to the fixed behaviour.
This commit is contained in:
1 parent
33341a0e92
commit
847c2c1580
511 files changed
+11678
-26
No files matched your search
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"args": {},
|
||||
"function": "main",
|
||||
"stdout": "",
|
||||
"value": {
|
||||
"decimal": "3",
|
||||
"type": "int"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
## main
|
||||
|
||||
*1 + 2*
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"args": {},
|
||||
"function": "main",
|
||||
"stdout": "",
|
||||
"value": {
|
||||
"type": "text",
|
||||
"value": "你好,Marqdo"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
## main
|
||||
|
||||
*"你好,Marqdo"*
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"args": {},
|
||||
"function": "main",
|
||||
"stdout": "",
|
||||
"value": {
|
||||
"type": "float",
|
||||
"value": 3.0
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
## main
|
||||
|
||||
*1.5 * 2.0*
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"args": {},
|
||||
"function": "main",
|
||||
"stdout": "",
|
||||
"value": {
|
||||
"decimal": "1234567890123456789012345678900",
|
||||
"type": "int"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
## main
|
||||
|
||||
*123456789012345678901234567890 * 10*
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"args": {
|
||||
"n": {
|
||||
"decimal": "5",
|
||||
"type": "int"
|
||||
}
|
||||
},
|
||||
"function": "阶乘",
|
||||
"stdout": "",
|
||||
"value": {
|
||||
"decimal": "120",
|
||||
"type": "int"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
# 数学
|
||||
|
||||
## 阶乘
|
||||
|
||||
1. `n <= 1`
|
||||
|
||||
*1*
|
||||
|
||||
2. `n > 1`
|
||||
|
||||
**结果 = n * 阶乘(n=n-1)**
|
||||
|
||||
*结果*
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"args": {
|
||||
"n": {
|
||||
"decimal": "8",
|
||||
"type": "int"
|
||||
}
|
||||
},
|
||||
"function": "斐波那契",
|
||||
"stdout": "",
|
||||
"value": {
|
||||
"decimal": "21",
|
||||
"type": "int"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
## 斐波那契
|
||||
|
||||
1. `n < 2`
|
||||
|
||||
*n*
|
||||
|
||||
2. `n >= 2`
|
||||
|
||||
**结果 = 斐波那契(n=n-1) + 斐波那契(n=n-2)**
|
||||
|
||||
*结果*
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"args": {
|
||||
"乙": {
|
||||
"decimal": "36",
|
||||
"type": "int"
|
||||
},
|
||||
"甲": {
|
||||
"decimal": "48",
|
||||
"type": "int"
|
||||
}
|
||||
},
|
||||
"function": "最大公约数",
|
||||
"stdout": "",
|
||||
"value": {
|
||||
"decimal": "12",
|
||||
"type": "int"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
## 最大公约数
|
||||
|
||||
**a = 甲**
|
||||
|
||||
**b = 乙**
|
||||
|
||||
- `b > 0`
|
||||
|
||||
**t = b**
|
||||
|
||||
**b = a % b**
|
||||
|
||||
**a = t**
|
||||
|
||||
*a*
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"args": {
|
||||
"n": {
|
||||
"decimal": "10",
|
||||
"type": "int"
|
||||
}
|
||||
},
|
||||
"function": "求和",
|
||||
"stdout": "",
|
||||
"value": {
|
||||
"decimal": "55",
|
||||
"type": "int"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
## 求和
|
||||
|
||||
**i = 1**
|
||||
|
||||
**total = 0**
|
||||
|
||||
- `i <= n`
|
||||
|
||||
**total = total + i**
|
||||
|
||||
**i = i + 1**
|
||||
|
||||
*total*
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"args": {
|
||||
"n": {
|
||||
"decimal": "2",
|
||||
"type": "int"
|
||||
}
|
||||
},
|
||||
"function": "嵌套",
|
||||
"stdout": "",
|
||||
"value": {
|
||||
"decimal": "6",
|
||||
"type": "int"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
## 嵌套
|
||||
|
||||
**total = 0**
|
||||
|
||||
1. `n > 0`
|
||||
|
||||
**m = 3**
|
||||
|
||||
- `m > 0`
|
||||
|
||||
**total = total + m**
|
||||
|
||||
**m = m - 1**
|
||||
|
||||
2. `n <= 0`
|
||||
|
||||
**total = 0**
|
||||
|
||||
*total*
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"args": {},
|
||||
"function": "main",
|
||||
"stdout": "",
|
||||
"value": {
|
||||
"decimal": "5",
|
||||
"type": "int"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
## 加法
|
||||
|
||||
`(a: Int, b: Int)`
|
||||
|
||||
*a + b*
|
||||
|
||||
## main
|
||||
|
||||
*加法(2, 3)*
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"args": {},
|
||||
"function": "main",
|
||||
"stdout": "",
|
||||
"value": {
|
||||
"decimal": "12",
|
||||
"type": "int"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
## 默认
|
||||
|
||||
`(x: Int, y: Int = 10)`
|
||||
|
||||
*x + y*
|
||||
|
||||
## main
|
||||
|
||||
*默认(x=2)*
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"args": {},
|
||||
"function": "main",
|
||||
"stdout": "",
|
||||
"value": {
|
||||
"decimal": "7",
|
||||
"type": "int"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
## 减法
|
||||
|
||||
`(a: Int, b: Int)`
|
||||
|
||||
*a - b*
|
||||
|
||||
## main
|
||||
|
||||
*减法(b=3, a=10)*
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"args": {},
|
||||
"function": "main",
|
||||
"stdout": "",
|
||||
"value": {
|
||||
"decimal": "42",
|
||||
"type": "int"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
## 加一
|
||||
|
||||
**n = n + 1**
|
||||
|
||||
*n*
|
||||
|
||||
## main
|
||||
|
||||
**f = ref("#加一")**
|
||||
|
||||
*f(n=41)*
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"args": {},
|
||||
"function": "main",
|
||||
"stdout": "",
|
||||
"value": {
|
||||
"module": "index.mq.md",
|
||||
"name": "加一",
|
||||
"type": "function_ref"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
## 加一
|
||||
|
||||
**n = n + 1**
|
||||
|
||||
*n*
|
||||
|
||||
## main
|
||||
|
||||
*ref("#加一")*
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"args": {},
|
||||
"function": "main",
|
||||
"stdout": "",
|
||||
"value": {
|
||||
"entries": {
|
||||
"文本": {
|
||||
"type": "text",
|
||||
"value": "42"
|
||||
},
|
||||
"长度": {
|
||||
"decimal": "2",
|
||||
"type": "int"
|
||||
}
|
||||
},
|
||||
"type": "map"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
## main
|
||||
|
||||
*{"长度": 长度("你好"), "文本": 文本(42)}*
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"args": {},
|
||||
"function": "main",
|
||||
"stdout": "",
|
||||
"value": {
|
||||
"decimal": "42",
|
||||
"type": "int"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
## main
|
||||
|
||||
*整数("40") + 整数(2.0)*
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"args": {},
|
||||
"function": "main",
|
||||
"stdout": "",
|
||||
"value": {
|
||||
"type": "float",
|
||||
"value": 3.0
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
## main
|
||||
|
||||
*小数("1.5") * 小数("2")*
|
||||
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"args": {},
|
||||
"function": "main",
|
||||
"stdout": "",
|
||||
"value": {
|
||||
"header": [
|
||||
"名称",
|
||||
"数量"
|
||||
],
|
||||
"rows": [
|
||||
[
|
||||
{
|
||||
"type": "text",
|
||||
"value": "苹果"
|
||||
},
|
||||
{
|
||||
"decimal": "42",
|
||||
"type": "int"
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"type": "text",
|
||||
"value": "梨"
|
||||
},
|
||||
{
|
||||
"decimal": "7",
|
||||
"type": "int"
|
||||
}
|
||||
]
|
||||
],
|
||||
"type": "table"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
## main
|
||||
|
||||
*表(["名称", "数量"], [["苹果", 42], ["梨", 7]])*
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"args": {},
|
||||
"function": "main",
|
||||
"stdout": "",
|
||||
"value": {
|
||||
"entries": {
|
||||
"a": {
|
||||
"type": "text",
|
||||
"value": "Int"
|
||||
},
|
||||
"b": {
|
||||
"type": "text",
|
||||
"value": "Text"
|
||||
},
|
||||
"c": {
|
||||
"type": "text",
|
||||
"value": "None"
|
||||
},
|
||||
"d": {
|
||||
"type": "text",
|
||||
"value": "Float"
|
||||
}
|
||||
},
|
||||
"type": "map"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
## main
|
||||
|
||||
*{"a": 类型(1), "b": 类型("x"), "c": 类型(None), "d": 类型(1.5)}*
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"args": {},
|
||||
"function": "main",
|
||||
"stdout": "",
|
||||
"value": {
|
||||
"type": "float",
|
||||
"value": 12.566370614359172
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
## 公式
|
||||
|
||||
$$
|
||||
A = \pi r^2
|
||||
$$
|
||||
|
||||
## main
|
||||
|
||||
*math.eval(ref("#公式"), {"r": 2}, target="A")*
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"args": {},
|
||||
"function": "main",
|
||||
"stdout": "",
|
||||
"value": {
|
||||
"decimal": "3",
|
||||
"type": "int"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
## 公式
|
||||
|
||||
$$
|
||||
A = r + 1
|
||||
$$
|
||||
|
||||
## main
|
||||
|
||||
*math.eval(ref("#公式"), {"r": 2}, target="A")*
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"args": {},
|
||||
"function": "main",
|
||||
"stdout": "你好\n42\n2.5\n",
|
||||
"value": {
|
||||
"type": "none"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
## main
|
||||
|
||||
> 打印("你好")
|
||||
|
||||
> 打印(42)
|
||||
|
||||
> 打印(2.5)
|
||||
|
||||
*None*
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"args": {},
|
||||
"function": "main",
|
||||
"stdout": "1\n",
|
||||
"value": {
|
||||
"type": "unit"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
## main
|
||||
|
||||
**x = 1**
|
||||
|
||||
> 打印(x)
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"args": {},
|
||||
"function": "main",
|
||||
"stdout": "",
|
||||
"value": {
|
||||
"type": "none"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
## main
|
||||
|
||||
*None*
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"args": {},
|
||||
"function": "main",
|
||||
"stdout": "",
|
||||
"value": {
|
||||
"type": "bool",
|
||||
"value": true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
## main
|
||||
|
||||
*(true and false) or (not false)*
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"args": {},
|
||||
"function": "main",
|
||||
"stdout": "",
|
||||
"value": {
|
||||
"type": "bool",
|
||||
"value": true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
## main
|
||||
|
||||
*(1 < 1.5) and (2.0 == 2) and not (1 != 1)*
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"args": {},
|
||||
"function": "main",
|
||||
"stdout": "",
|
||||
"value": {
|
||||
"decimal": "31",
|
||||
"type": "int"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
## main
|
||||
|
||||
*7 // 2 * 10 + 7 % 2*
|
||||
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"args": {},
|
||||
"function": "main",
|
||||
"stdout": "",
|
||||
"value": {
|
||||
"entries": {
|
||||
"first": {
|
||||
"decimal": "10",
|
||||
"type": "int"
|
||||
},
|
||||
"key": {
|
||||
"decimal": "2",
|
||||
"type": "int"
|
||||
},
|
||||
"last": {
|
||||
"decimal": "30",
|
||||
"type": "int"
|
||||
},
|
||||
"member": {
|
||||
"decimal": "42",
|
||||
"type": "int"
|
||||
},
|
||||
"text": {
|
||||
"type": "text",
|
||||
"value": "好"
|
||||
}
|
||||
},
|
||||
"type": "map"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
## main
|
||||
|
||||
*{"first": [10, 20, 30][0], "last": [10, 20, 30][-1], "text": "你好"[1], "member": {"a": 42}.a, "key": {"b": 2}["b"]}*
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"args": {},
|
||||
"function": "main",
|
||||
"stdout": "",
|
||||
"value": {
|
||||
"entries": {
|
||||
"a": {
|
||||
"decimal": "1",
|
||||
"type": "int"
|
||||
},
|
||||
"b": {
|
||||
"items": [
|
||||
{
|
||||
"type": "bool",
|
||||
"value": true
|
||||
},
|
||||
{
|
||||
"type": "none"
|
||||
}
|
||||
],
|
||||
"type": "list"
|
||||
}
|
||||
},
|
||||
"type": "map"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
## main
|
||||
|
||||
*{"a": 1, "b": [true, None]}*
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"args": {},
|
||||
"function": "main",
|
||||
"stdout": "[1, 2, 3]\n{a: 1}\n",
|
||||
"value": {
|
||||
"type": "none"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
## main
|
||||
|
||||
> 打印([1, 2, 3])
|
||||
|
||||
> 打印({"a": 1})
|
||||
|
||||
*None*
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"args": {},
|
||||
"function": "main",
|
||||
"stdout": "",
|
||||
"value": {
|
||||
"type": "text",
|
||||
"value": "你好,世界"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
## main
|
||||
|
||||
*"你好" + "," + "世界"*
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"args": {
|
||||
"n": {
|
||||
"decimal": "5",
|
||||
"type": "int"
|
||||
}
|
||||
},
|
||||
"function": "递归和",
|
||||
"stdout": "",
|
||||
"value": {
|
||||
"decimal": "15",
|
||||
"type": "int"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
## 递归和
|
||||
|
||||
1. `n <= 0`
|
||||
|
||||
*0*
|
||||
|
||||
2. `n > 0`
|
||||
|
||||
**结果 = n + 递归和(n=n-1)**
|
||||
|
||||
*结果*
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"args": {
|
||||
"target": {
|
||||
"decimal": "10",
|
||||
"type": "int"
|
||||
}
|
||||
},
|
||||
"function": "找平方",
|
||||
"stdout": "",
|
||||
"value": {
|
||||
"decimal": "16",
|
||||
"type": "int"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
## 找平方
|
||||
|
||||
**i = 0**
|
||||
|
||||
- `i * i < target`
|
||||
|
||||
**i = i + 1**
|
||||
|
||||
*i * i*
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"args": {
|
||||
"n": {
|
||||
"decimal": "-5",
|
||||
"type": "int"
|
||||
}
|
||||
},
|
||||
"function": "符号",
|
||||
"stdout": "",
|
||||
"value": {
|
||||
"decimal": "-1",
|
||||
"type": "int"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
## 符号
|
||||
|
||||
1. `n < 0`
|
||||
|
||||
*-1*
|
||||
|
||||
2. `n == 0`
|
||||
|
||||
*0*
|
||||
|
||||
3. `n > 0`
|
||||
|
||||
*1*
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"args": {},
|
||||
"function": "main",
|
||||
"stdout": "",
|
||||
"value": {
|
||||
"decimal": "13",
|
||||
"type": "int"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
## 混合
|
||||
|
||||
`(x: Int, y: Int = 5, z: Int = 1)`
|
||||
|
||||
*x * y + z*
|
||||
|
||||
## main
|
||||
|
||||
*混合(x=2, z=3)*
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"args": {},
|
||||
"function": "main",
|
||||
"grants": [
|
||||
"foreign"
|
||||
],
|
||||
"stdout": "",
|
||||
"value": {
|
||||
"type": "float",
|
||||
"value": 28.274333882308138
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
## Python 校验
|
||||
|
||||
```python
|
||||
import json, math, sys
|
||||
|
||||
envelope = json.load(sys.stdin)
|
||||
r = int(envelope["input"]["entries"]["r"]["decimal"])
|
||||
area = math.pi * r ** 2
|
||||
print(json.dumps({"type": "map", "entries": {"area": {"type": "float", "value": area}}}))
|
||||
```
|
||||
|
||||
## main
|
||||
|
||||
**结果 = foreign.call(ref("#python-校验"), {"r": 3})**
|
||||
|
||||
*结果.area*
|
||||
Reference in new issue
Block a user