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

Multiline string literals shift source-line identities and make temporal queries return the wrong value

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

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

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

调研方向

Start in src/lexer.c at the ordinary-string scanner around line 485 and the f-string literal scanner around line 455; compare their position handling with the source-line contracts in docs/SPEC.md. Run the listed multiline and escaped-newline reproducers, then add regression coverage for both string forms, multiple literal newlines, temporal queries, and caught runtime errors. Done means physical lines and error.line are correct while literal values and source spans remain unchanged.

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

描述

area:observer area:runtime-vm bug found-by:code-review kind:silent-wrong

Physical newlines inside a string literal do not advance the lexer's line counter. Later assignments are recorded under the wrong source lines, so temporal queries can return the wrong value with exit 0. Runtime error locations shift too. Ordinary strings and literal text in f-strings both exhibit the defect.

Reproduce

Save and run this exact five-line program:

s is "a
b"
x is 10
x is 20
print of (what is x at 3)

Actual: exit 0, stdout 20\n, empty stderr. Expected: 10\n; physical line 3 assigns 10.

Paired control: replace the first two physical lines with an escaped newline followed by a blank line. The assignments retain exactly the same physical line numbers:

s is "a\nb"

x is 10
x is 20
print of (what is x at 3)

The control exits 0 and prints 10\n. Prefixing either literal with f reproduces the same failure/control pair, so that sibling belongs in this fix.

A second reproducer keeps only the first two physical lines above, followed by:

try:
    q is 1 / 0
catch e:
    print of e.line

With the physical multiline literal, it prints 3; the division is on physical line 4. The escaped-newline/blank-line control prints 4. Both exit 0; the builtin error is caught.

Cause and contract

The ordinary-string scanner advances p and col through literal newlines without advancing line. The f-string literal scanner does the same. Tokens after the literal inherit this shifted position.

The spec explicitly defines at <line> as a source-line query and error.line as the 1-based source line. Fix physical position accounting while retaining string bytes and the token's opening position.

Regression acceptance

  • Both ordinary-string and f-string reproducers return 10 at physical line 3.
  • Caught runtime errors report their physical source line after these literals.
  • Cover multiple literal newlines and escaped \n controls; escapes must not advance the physical line counter.
  • Preserve the original literal values and source spans.

Distinct from #1245 (the formatter changes string contents) and #1244 (f-string interpolation token positions are discarded during splicing).

Verification

Confirmed on a fresh default release build of b91768e23c5a874a64e76e4af9ab291e6aa49983, with inherited EIGS_* variables cleared. Each reproducer and paired control was executed; no runtime or test source was changed. This is a current correctness defect, not a proposed v1 language restriction.

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

环境准备

在 Codespaces 中打开

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

从这里开始

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

InauguralSystems/EigenScript 的其他 Issue

查看 InauguralSystems/EigenScript 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

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