Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Formatter collapses unequal legal indentation levels and emits unparseable source

未关闭
#1,246 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
74/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
c
领域
compilers

调研方向

Start with src/fmt.c:352–382 and docs/SPEC.md:69, then run the supplied indent.eigs commands after a fresh default make build. Exercise the reproducer and the listed unequal-increment, sibling, dedent, and 2-/4-space cases; done means formatted programs remain parseable, preserve execution output, and satisfy the stated regression checks.

由索引模型根据 Issue 内容生成。

描述

area:lint-tooling bug found-by:code-review

Formatting a valid nested block can collapse two different indentation levels and make the program fail to parse. --fmt returns success; --fmt --write would replace the working source with that result. The LSP formatting handler uses the same formatter.

Reproduction

Save this as indent.eigs. The two indented lines use four and six spaces, respectively:

if 1:
    if 1:
      print of 7
print of 9
eigenscript indent.eigs
eigenscript --fmt indent.eigs > formatted.eigs
eigenscript formatted.eigs

Original: exit 0, stdout 7\n9\n. Formatter: exit 0, but emits:

if 1:
    if 1:
    print of 7
print of 9

The result exits 1 with Parse error line 3:5: expected indent, got identifier ('print').

Cause and contract

docs/SPEC.md:69 requires consistent indentation within a block, not equal increments between blocks. The original program executes successfully.

src/fmt.c:352–382 finds the smallest positive indentation (4 here), then computes level = indents[i] / min_indent. Integer division maps both 4 and 6 to depth 1. Formatting needs to preserve the actual nesting/dedent structure instead of deriving it from one global width.

Regression acceptance

  • Formatting the reproducer preserves successful execution and its exact output.
  • Cover unequal indentation increments, sibling blocks, dedents, and ordinary 2-/4-space inputs.
  • Assert parseability and output after applying the formatter; idempotence alone cannot detect this corruption.

Distinct from #729/#750, which address splitting operators and keeping the operator table synchronized.

Verification

Confirmed with a fresh default make build of b91768e23c5a874a64e76e4af9ab291e6aa49983 in a clean isolated worktree. The original, formatter, and transformed program were executed separately with inherited EIGS_* variables removed; exit status and output were captured for each.

主要语言
C
星标
3
派生
7
平均合并
3 小时 58 分钟
30 天内合并 PR
105

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

InauguralSystems/EigenScript 的其他 Issue

查看 InauguralSystems/EigenScript 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。