Formatter silently changes whitespace and operators inside multiline string literals
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 84/100
Research direction
Start in src/fmt.c around lines 333–344 and inspect how fix_spacing handles physical lines, then review multiline literal handling in src/lexer.c around line 485. Extend tests/test_fmt.sh with the reproducer, blank lines, operator/comment-like text, and a single-line control. Done means formatted output preserves literal bytes and ordinary source whitespace normalization still works through the shared formatting path.
Written by the indexing model from the issue text.
Description
The formatter edits the contents of a valid multiline string: it changes indentation, removes trailing spaces, and inserts spaces around apparent operators inside the literal. The resulting program still exits successfully but produces different data. --fmt --write persists that corruption; LSP formatting uses the same function.
Exact reproduction
Create a fixture with literal newlines inside its quoted string. The middle line has two leading and two trailing spaces:
python3 - <<'PYFIXTURE'
from pathlib import Path
Path('multiline.eigs').write_text('value is "start\n a+b \nend"\nprint of value\n')
PYFIXTURE
eigenscript multiline.eigs
eigenscript --fmt multiline.eigs > formatted.eigs
eigenscript formatted.eigs
Both executions and formatting exit 0. Exact stdout, shown as escaped strings:
before: "start\n a+b \nend\n"
after: "start\n a + b\nend\n"
The formatter emits this source:
value is "start
a + b
end"
print of value
Cause
The lexer accepts the multiline literal and retains these bytes. src/fmt.c:333–344 strips leading/trailing whitespace from every physical line before knowing whether it is inside a string. fix_spacing also starts each physical line with string state cleared, so a+b is treated as source code.
This breaks the formatter's string-preservation behavior already checked for single-line strings by tests/test_fmt.sh (string content not modified). The existing corpus parseability check cannot detect this case: both programs parse.
Regression acceptance
- The formatted reproducer's exact stdout equals the original, including leading/trailing spaces and newlines inside the literal.
- Cover blank lines and operator/comment-looking text inside multiline strings, alongside a normal single-line string control.
- Keep ordinary source whitespace normalization working outside literals; verify the shared formatting path preserves literal data.
Distinct from the operator-table fixes in #729/#750.
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.
- Dominant language
- C
- Stars
- 3
- Forks
- 7
- Avg merge
- 4h 5m
- Merged PRs (30d)
- 116
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from InauguralSystems/EigenScript
-
area:docs good first issue kind:docs-drift
Difficulty 1/5 Under an hour Newbie friendliness 92/100
InauguralSystems/EigenScript#1400 ·
Maintainers usually reply within 1 day
-
area:docs good first issue kind:docs-drift
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
InauguralSystems/EigenScript#1396 ·
Maintainers usually reply within 1 day
-
docs/BUILTINS.md: task_spawn row says task_yield/task_join 'land in a later increment'; both existOpenarea:docs good first issue kind:docs-drift
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
InauguralSystems/EigenScript#1392 ·
Maintainers usually reply within 1 day
-
area:embed kind:silent-wrong
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
InauguralSystems/EigenScript#1387 ·
Maintainers usually reply within 1 day
-
area:stdlib kind:silent-wrong
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
InauguralSystems/EigenScript#1378 ·
Maintainers usually reply within 1 day
All issues in InauguralSystems/EigenScript
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
fastfetch-cli/fastfetch#2628 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
FujiNetWIFI/fujinet-firmware#1736 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100