Skip to content

Fix two test-compile failures: String.write and String self-aliasing - #5

Merged
conorbronsdon merged 2 commits into
mainfrom
fix-string-write
Jul 31, 2026
Merged

Fix two test-compile failures: String.write and String self-aliasing#5
conorbronsdon merged 2 commits into
mainfrom
fix-string-write

Conversation

@conorbronsdon

@conorbronsdon conorbronsdon commented Jul 31, 2026

Copy link
Copy Markdown
Owner

Two independent failures, both blocking the test workflow. mojo-xml is the only repo in the suite with more than one.

1. String.write is no longer a static method (shared with mojo-feed, -html, -markdown, -template, -url)

The stdlib made it an instance method, so both overloads take mut self and the old static call stopped resolving. String.__init__ takes a variadic pack of Writable args and Error conforms to Writable, so String(e) is the direct replacement. Verified green in CI on conorbronsdon/mojo-feed#5 first.

2. test/anchor_dump.mojo:18 — self-aliasing in the String initializer (mojo-xml only)

error: aliasing values passed immutably to 'args' argument and constructed as a result in 'String' initializer call

s = String(s.strip()) borrows s for the argument while s is also the construction target. Building into a temporary and moving it in separates the two.

This second one is why mojo-xml's conformance job was already red on 7/29, before the nightly bump that broke the other five — so this repo was never actually green after publish.

🤖 Generated with Claude Code

conorbronsdon and others added 2 commits July 31, 2026 14:31
Mojo's stdlib made String.write an instance method -- both overloads now take
`mut self` -- so the old static form no longer resolves and the test module
fails to parse. String.__init__ takes a variadic pack of Writable arguments and
Error conforms to Writable, so String(e) is the direct replacement.

Test-only; nothing in src/ used the static form.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
s.strip() borrows s while the String initializer is constructing s as its
result, which the compiler now rejects:

  error: aliasing values passed immutably to 'args' argument and constructed
  as a result in 'String' initializer call

Constructing into a temporary and moving it in separates the borrow from the
assignment. This is why mojo-xml's conformance job was already red on 7/29,
before the String.write breakage in the previous commit.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@conorbronsdon conorbronsdon changed the title Fix test compile: String.write is no longer a static method Fix two test-compile failures: String.write and String self-aliasing Jul 31, 2026
@conorbronsdon
conorbronsdon merged commit 2667703 into main Jul 31, 2026
1 check passed
@conorbronsdon
conorbronsdon deleted the fix-string-write branch July 31, 2026 21:37
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