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

+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();