Skip to content

test(fmt): cover baml.spawn paths in type positions - #4415

Closed
sxlijin wants to merge 1 commit into
canaryfrom
sxlijin/B-1509-fmt-spawn-type-position
Closed

test(fmt): cover baml.spawn paths in type positions#4415
sxlijin wants to merge 1 commit into
canaryfrom
sxlijin/B-1509-fmt-spawn-type-position

Conversation

@sxlijin

@sxlijin sxlijin commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add B-1509 regression coverage for baml.spawn.CancelToken in parameter, return, class-field, and generic-argument type positions
  • document that formatter contextual identifiers cover both expression and type path segments
  • keep the existing B-258 expression-position behavior covered alongside the new cases

Root cause

spawn is lexed as KW_SPAWN even when it appears as a namespace segment. The formatter previously expected a plain WORD in type paths. The shared contextual-keyword handling now accepts this valid parser output, but type-position coverage was missing.

Impact

Files with signatures such as tok: baml.spawn.CancelToken remain formatable and formatter behavior stays aligned with the parser across all reported type positions.

Validation

  • cargo test -p baml_fmt --lib (125 passed)
  • cargo fmt --all -- --check
  • git diff --check

Linear: B-1509

Summary by CodeRabbit

  • Bug Fixes

    • Improved formatting support for qualified type paths containing keyword-like segments, such as baml.spawn.CancelToken.
    • Ensured these paths remain intact across parameters, return types, class fields, and generic types.
  • Tests

    • Added regression coverage verifying formatting succeeds and produces consistent, repeatable output.

@linear

linear Bot commented Aug 13, 2026

Copy link
Copy Markdown

B-1509

@vercel

vercel Bot commented Aug 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
beps Ready Ready Preview Aug 13, 2026 11:34pm
promptfiddle2 Ready Ready Preview Aug 13, 2026 11:34pm

Request Review

@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a86f5a5e-ec43-40a8-bb06-ebd5781c0294

📥 Commits

Reviewing files that changed from the base of the PR and between 077ad42 and f58bb5b.

📒 Files selected for processing (2)
  • baml_language/crates/baml_fmt/src/ast/tokens.rs
  • baml_language/crates/baml_fmt/src/lib.rs

📝 Walkthrough

Walkthrough

The formatter documentation now describes keyword-like path segments in expressions and types. A regression test verifies that baml.spawn.CancelToken formats correctly in several type positions and remains idempotent.

Changes

Formatter contextual paths

Layer / File(s) Summary
Document and test contextual type paths
baml_language/crates/baml_fmt/src/ast/tokens.rs, baml_language/crates/baml_fmt/src/lib.rs
The Word documentation covers contextual path segments. A regression test checks baml.spawn.CancelToken in parameter types, return types, class fields, and generic map values.

Estimated code review effort: 2 (Simple) | ~10 minutes

Mergeability Score: ⚪ Minimal · up to f58bb

The PR preserves formatting for spawn namespace paths in type positions while keeping existing expression behavior covered; no actionable merge-blocking risk remains beyond normal checks.

Possibly related PRs

Suggested reviewers: codeshaunted, aaronvg

Poem

I hop through paths where keywords grow,
baml.spawn.CancelToken now formats so.
Types stay clear, each test runs bright,
Twice the same output, neat and right.
A tidy burrow for every byte.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the regression test for baml.spawn paths in type positions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sxlijin/B-1509-fmt-spawn-type-position

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sxlijin
sxlijin marked this pull request as ready for review August 13, 2026 23:27
@github-actions

Copy link
Copy Markdown

⏭️ Performance benchmarks were skipped

Perf benchmarks (CodSpeed) are opt-in on pull requests — they no longer run on every push. They always run automatically after merge to canary/main.

To run them on this PR, do any of the following, then push a commit (or re-run CI):

  • Add RUN_CODSPEED=1 to the PR description, or
  • Include run-perf or /perf in the PR title or any commit message.

@vercel
vercel Bot temporarily deployed to Preview – beps August 13, 2026 23:27 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 August 13, 2026 23:34 Inactive
@github-actions

Copy link
Copy Markdown

Binary size checks passed

7 passed

Artifact Platform File Gzip Gated on Baseline Delta Status
baml-cli Linux 🔒 26.2 MB 11.1 MB file 27.4 MB -1.2 MB (-4.4%) OK
packed-program Linux 🔒 16.9 MB 6.8 MB file 18.6 MB -1.7 MB (-8.9%) OK
baml-cli macOS 🔒 20.4 MB 9.7 MB file 21.3 MB -913.9 KB (-4.3%) OK
packed-program macOS 🔒 13.3 MB 6.0 MB file 14.5 MB -1.2 MB (-8.1%) OK
baml-cli Windows 🔒 21.9 MB 9.9 MB file 23.0 MB -1.1 MB (-4.6%) OK
packed-program Windows 🔒 14.1 MB 6.1 MB file 15.5 MB -1.4 MB (-9.1%) OK
bridge_wasm WASM 15.5 MB 🔒 4.2 MB gzip 4.6 MB -437.3 KB (-9.5%) OK

🔒 = the size this artifact is GATED on (ceiling + delta). Binaries gate on file size (installed binary); WASM gates on gzip (download size). The other size is shown for information only.


Generated by cargo size-gate · workflow run

sxlijin commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

Closing as redundant: the reported formatter behavior was already fixed by #4341 (fix(fmt): accept contextual keywords as identifiers in name positions), merged as 061b224ea4. B-1509 now links that original fix; this PR only added explicit regression coverage for behavior already present on canary.

@sxlijin sxlijin closed this Aug 14, 2026
@sxlijin
sxlijin deleted the sxlijin/B-1509-fmt-spawn-type-position branch August 14, 2026 17:22
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