Formatter silently changes whitespace and operators inside multiline string literals
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 84/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- C
- Estrellas
- 3
- Forks
- 7
- Merge medio
- 3 h 58 min
- PR fusionados (30 d)
- 105
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Incluye un Dockerfile o un archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de InauguralSystems/EigenScript
-
area:lint-tooling bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
InauguralSystems/EigenScript#1340 ·
Los mantenedores suelen responder en 1 día
-
area:stdlib found-by:code-review kind:silent-wrong
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
InauguralSystems/EigenScript#1338 ·
Los mantenedores suelen responder en 1 día
-
area:lint-tooling found-by:critic kind:docs-drift
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
InauguralSystems/EigenScript#1335 ·
Los mantenedores suelen responder en 1 día
-
area:ci found-by:critic kind:gate-defect
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
InauguralSystems/EigenScript#1311 ·
Los mantenedores suelen responder en 1 día
-
enrolment: decide test_gc_runner_controls.py (exempt vs enrol) and whether floors need a ratchetAbiertoarea:gates found-by:critic kind:decision
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
InauguralSystems/EigenScript#1280 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de InauguralSystems/EigenScript
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 75/100
NabuCasa/silabs-firmware-builder#231 · 1 comentario ·
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 88/100
ClickHouse/pg_clickhouse#383 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
johnsonjh/emu2-cpm86#68 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día