fix(parse): allow unbound GFM tables as discarded values

Bare tables in a function body evaluate as collections without requiring
a name bind; restores welcome-page install tables.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-09-17 10:29:13 +08:00
1 parent e848306187
commit d1e2f0ced0
7 files changed
+53 -13

No files matched your search

+1
View File
@@ -5,6 +5,7 @@
### Added
### Fixed
- 未绑定的 GFM 表格不再报 `unrecognized statement`:作为集合值求值后丢弃(文档中可写表)。
### Changed
+1 -1
View File
@@ -211,7 +211,7 @@ v0.3:
| 体内 `1.` `2.` … | 分支 |
| 体内 `-` | 循环 |
| `N. *` | else 臂(此处 `*` 仍是「空条件」标记,**不是**返回值;见 §7.3) |
| GFM 表格 | 集合(不变) |
| GFM 表格 | 集合;`` `名` = `` 后绑定,或**未绑定**时求值后丢弃(文档中可写表) |
| 表达式 `[键](集合)` | **取元**(与 foreach 同形;见 [collection-access-link.md](collection-access-link.md)) |
| `修饰… [函数名] 实参…` | **方括号标记调用**(前置修饰 → `名=True`;见 [bracket-call-modifiers.md](bracket-call-modifiers.md)) |
| `` 集合[^键] `` | **过渡**:旧脚注取元(仍可用) |
+6 -6
View File
@@ -15,13 +15,13 @@ The language is still young: structure markers, bilingual core names (`print` /
## Install
Pick one way to get the CLI (not a Markdown table — tables are collections in Marqdo):
Pick one way to get the CLI:
Ubuntu PPA — `sudo add-apt-repository ppa:cflmy/marqdo` then `sudo apt install marqdo`.
GitHub Releases — prebuilt Windows / Linux zips at [releases](https://github.com/cflmy/marqdo/releases).
From source — `cargo build --release` (needs Rust).
| Method | Notes |
|--------|-------|
| Ubuntu PPA | `sudo add-apt-repository ppa:cflmy/marqdo` then `sudo apt install marqdo` |
| GitHub Releases | Prebuilt Windows / Linux zips at [releases](https://github.com/cflmy/marqdo/releases) |
| From source | `cargo build --release` (needs Rust) |
Official extensions version independently of the CLI:
+6 -6
View File
@@ -15,13 +15,13 @@ AI 偏爱 Markdown结构的输出。作者的念头是:何必再把文档和
## 安装
解释器(CLI)任选其一(不用 Markdown 表格——在 Marqdo 里表格是集合):
解释器(CLI)任选其一:
Ubuntu PPA — `sudo add-apt-repository ppa:cflmy/marqdo` 后 `sudo apt install marqdo`。
GitHub Releases — [releases](https://github.com/cflmy/marqdo/releases) 下载 Windows / Linux 预编译包。
源码 — `cargo build --release`(需本机 Rust)。
| 方式 | 说明 |
|------|------|
| Ubuntu PPA | `sudo add-apt-repository ppa:cflmy/marqdo` 后 `sudo apt install marqdo` |
| GitHub Releases | [releases](https://github.com/cflmy/marqdo/releases) 下载 Windows / Linux 预编译包 |
| 源码 | `cargo build --release`(需本机 Rust) |
官方扩展与 CLI 可分开更新。安装扩展:
+19
View File
@@ -323,6 +323,16 @@ impl<'a> Cursor<'a> {
fun.body.push(self.parse_loop_or_err()?);
continue;
}
// Unbound GFM table = collection value (not assigned); evaluate and discard.
if trimmed.starts_with('|') {
let span = Span {
line: l.line_no,
col: 1,
};
let value = self.consume_table()?;
fun.body.push(Stmt::Expr { value, span });
continue;
}
let stmt = self.parse_simple_stmt()?;
let end_body = matches!(stmt, Stmt::Return { .. }) && level >= 2;
@@ -382,6 +392,13 @@ impl<'a> Cursor<'a> {
return Ok(Stmt::Call { call, span });
}
// Unbound GFM table (header already consumed by bump above).
if trimmed.starts_with('|') {
self.i -= 1;
let value = self.consume_table()?;
return Ok(Stmt::Expr { value, span });
}
// Bare assign `` `x` = … ``
if trimmed.starts_with('`') {
if let Some(stmt) = self.parse_backtick_assign(trimmed, span.clone())? {
@@ -695,6 +712,8 @@ impl<'a> Cursor<'a> {
/// - first header `@` / `行` / `row` → List of row Maps (marker col excluded)
/// - else ≥2-col → Map (column-oriented)
///
/// Also used for **unbound** tables in a function body (value computed, not stored).
///
/// Data cells are expressions ([`parse_call_arg_value`]); headers stay key text.
fn consume_table(&mut self) -> Result<Expr> {
self.skip_noise();
+5
View File
@@ -132,6 +132,11 @@ fn structure_hello() {
assert_out("tests/structure/hello.mq.md", "Hello World!");
}
#[test]
fn structure_unbound_table() {
assert_out("tests/structure/unbound-table.mq.md", "ok");
}
#[test]
fn structure_object_handle() {
assert_out("tests/structure/object-handle.mq.md", "counter\n3\n4");
+15
View File
@@ -0,0 +1,15 @@
---
title: Unbound GFM table is a discarded value
---
# main
Documentation may include a table that is not bound to a name. It is still a
collection value; evaluating it must not error.
| Method | Notes |
|--------|-------|
| PPA | apt |
| Source | cargo |
> print text=ok