Skip to content

fix: zero fix --apply writes combined-source buffer to original file#21

Open
mkitsugi wants to merge 1 commit into
vercel-labs:mainfrom
mkitsugi:fix-fix-apply-writes-combined-buffer
Open

fix: zero fix --apply writes combined-source buffer to original file#21
mkitsugi wants to merge 1 commit into
vercel-labs:mainfrom
mkitsugi:fix-fix-apply-writes-combined-buffer

Conversation

@mkitsugi
Copy link
Copy Markdown

print_or_apply_fix_json was scanning and writing input->source — the import-resolved combined buffer that fs.c::append_source_without_imports prefixes each file with // file: <path>. For --apply this injected the prefix as the first line of the user's file; for --patch it shifted reported line numbers by one. Re-read input->source_file from disk before applying the line edit.

Repro on the existing fixture:

cp conformance/native/fail/mem-copy-immutable-dst.0 /tmp/x.0
bin/zero fix --apply /tmp/x.0
head -1 /tmp/x.0   # before: "// file: /tmp/x.0"

The conformance assertion for --apply was a regex match (/let mut dst/) which the injected header passed through; tightened to full-content equality, and added an explicit patches[0].line check for --patch.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 16, 2026

@mkitsugi is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

print_or_apply_fix_json was scanning and writing input->source, the
import-resolved combined buffer that fs.c::append_source_without_imports
prefixes each file with `// file: <path>`. For --apply this injected
the prefix as the first line of the user's file; for --patch it shifted
line numbers by one. Re-read input->source_file from disk before
applying the line edit.

The conformance assertion for --apply was a regex match (/let mut dst/)
which the injected header passed through; tightened to full-content
equality, and added an explicit patches[0].line check for --patch.
@mkitsugi mkitsugi force-pushed the fix-fix-apply-writes-combined-buffer branch from 1cbca6f to bb618ce Compare May 16, 2026 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant