Skip to content

Update error! macros to allow spanned hints as: hint[span]: "..." - #8052

Merged
laurmaedje merged 1 commit into
typst:mainfrom
isuffix:spans-on-hints
Apr 2, 2026
Merged

laurmaedje merged 1 commit into
typst:mainfrom
isuffix:spans-on-hints

Conversation

@isuffix

@isuffix isuffix commented Mar 31, 2026

Copy link
Copy Markdown
Collaborator

This adds syntax to the error!, bail!, and warning! macros for spanned hints.

I had to reconfigure the macro internals a bit to allow for a recursive macro call --- moving from .with_hint() taking the diagnostic by value to mutating the diagnostic --- but the result should be the same.

I also updated the three cases of manual calls that were able to use the spanned hint macro plus a single warning that didn't need the new syntax, but could still use the warning! macro.

@isuffix isuffix added the internals About internal changes to the codebase. label Mar 31, 2026
Comment thread crates/typst-library/src/diag.rs Resolved
@laurmaedje laurmaedje added waiting-on-author Pull request waits on author and removed waiting-on-author Pull request waits on author labels Apr 1, 2026
@laurmaedje
laurmaedje added this pull request to the merge queue Apr 2, 2026
@laurmaedje

Copy link
Copy Markdown
Member

Thanks!

Merged via the queue into typst:main with commit 6ecf521 Apr 2, 2026
8 checks passed
vlad2305m added a commit to vlad2305m/typst that referenced this pull request Apr 3, 2026
# *   65a9626 2026-04-03 17:26 vlad2305m Merge branch 'typst:main' into main  HEAD, origin/main, origin/HEAD
# |\  
# | * d6848a8 2026-04-02 17:27 Laurenz Lowercase error message (typst#8059)  
# | * 6ecf521 2026-04-02 07:48 Ian Update `error!` macros to allow spanned hints as: `hint[span]: "..."` (typst#8052)  
# | * b772964 2026-03-24 16:51 Ian Wrzesinski Escape emitted (not annotated) newlines in test error messages
@isuffix
isuffix deleted the spans-on-hints branch April 3, 2026 18:06
jassielof pushed a commit to jassielof/typst that referenced this pull request Apr 7, 2026
ParaN3xus added a commit to ParaN3xus/tinymist that referenced this pull request May 15, 2026
ParaN3xus added a commit to ParaN3xus/typst.ts that referenced this pull request May 15, 2026
ParaN3xus added a commit to ParaN3xus/typst.ts that referenced this pull request May 15, 2026
ParaN3xus added a commit to ParaN3xus/tinymist that referenced this pull request May 24, 2026
ParaN3xus added a commit to ParaN3xus/tinymist that referenced this pull request Jun 1, 2026
Myriad-Dreamin pushed a commit to Myriad-Dreamin/tinymist that referenced this pull request Jun 13, 2026
Myriad-Dreamin pushed a commit to Myriad-Dreamin/tinymist that referenced this pull request Jun 13, 2026
Myriad-Dreamin pushed a commit to Myriad-Dreamin/tinymist that referenced this pull request Jun 13, 2026
Myriad-Dreamin added a commit to Myriad-Dreamin/tinymist that referenced this pull request Jun 15, 2026
Part of the Typst 0.15 cleanup stack. This slice covers diagnostics/span
migration and the minimal query prerequisites needed before the later
export and text accessor slices.

## Upstream Typst Changes

- [`typst/typst#8052`](typst/typst#8052) makes
diagnostic hints carry span metadata. Tinymist renders the hint message
payload instead of formatting the whole spanned wrapper.
- [`typst/typst#8254`](typst/typst#8254) changes
diagnostic, user-action, and test-range span handling. Tinymist updates
LSP diagnostics, user-action conversion, and range-sensitive tests for
the new span shape.
- [`typst/typst#8188`](typst/typst#8188) changes
syntax diagnostics. Tinymist updates syntax matchers and diagnostics
conversion paths that inspect syntax-side errors.
- [`typst/typst#8307`](typst/typst#8307) changes
bibliography lookup. Tinymist now finds bibliography elements through
the document introspector and packs them back to `BibliographyElem`.
- Typst 0.15 deprecates rooted virtual-path access through
`as_rooted_path`; diagnostics now use the slash-form virtual path
accessor for extension checks.

## Tinymist Changes

- Updates `tinymist-world` diagnostic rendering for spanned hint values.
- Updates `tinymist-query`, `tinymist-analysis`, `tinymist-lint`, and
debug-facing syntax diagnostics for the new span and syntax diagnostic
APIs.
- Updates user-action span conversion and affected test ranges.
- Updates code-context path evaluation to construct `RangeMapper` from
an iterator, matching the lint expectations of the current toolchain.
- Carries the small bibliography lookup prerequisite in this slice so
later query-oriented slices build on the updated Typst API.

---------

Co-authored-by: paran3xus <[email protected]>
Myriad-Dreamin pushed a commit to Myriad-Dreamin/typst.ts that referenced this pull request Jun 15, 2026
Myriad-Dreamin pushed a commit to Myriad-Dreamin/typst.ts that referenced this pull request Jun 15, 2026
Myriad-Dreamin added a commit to Myriad-Dreamin/tinymist that referenced this pull request Jun 15, 2026
Part of the Typst 0.15 cleanup stack. This slice covers diagnostics/span
migration and the minimal query prerequisites needed before the later
export and text accessor slices.

## Upstream Typst Changes

- [`typst/typst#8052`](typst/typst#8052) makes
diagnostic hints carry span metadata. Tinymist renders the hint message
payload instead of formatting the whole spanned wrapper.
- [`typst/typst#8254`](typst/typst#8254) changes
diagnostic, user-action, and test-range span handling. Tinymist updates
LSP diagnostics, user-action conversion, and range-sensitive tests for
the new span shape.
- [`typst/typst#8188`](typst/typst#8188) changes
syntax diagnostics. Tinymist updates syntax matchers and diagnostics
conversion paths that inspect syntax-side errors.
- [`typst/typst#8307`](typst/typst#8307) changes
bibliography lookup. Tinymist now finds bibliography elements through
the document introspector and packs them back to `BibliographyElem`.
- Typst 0.15 deprecates rooted virtual-path access through
`as_rooted_path`; diagnostics now use the slash-form virtual path
accessor for extension checks.

## Tinymist Changes

- Updates `tinymist-world` diagnostic rendering for spanned hint values.
- Updates `tinymist-query`, `tinymist-analysis`, `tinymist-lint`, and
debug-facing syntax diagnostics for the new span and syntax diagnostic
APIs.
- Updates user-action span conversion and affected test ranges.
- Updates code-context path evaluation to construct `RangeMapper` from
an iterator, matching the lint expectations of the current toolchain.
- Carries the small bibliography lookup prerequisite in this slice so
later query-oriented slices build on the updated Typst API.

---------

Co-authored-by: paran3xus <[email protected]>
Myriad-Dreamin added a commit to Myriad-Dreamin/tinymist that referenced this pull request Jun 15, 2026
Part of the Typst 0.15 cleanup stack. This slice covers diagnostics/span
migration and the minimal query prerequisites needed before the later
export and text accessor slices.

## Upstream Typst Changes

- [`typst/typst#8052`](typst/typst#8052) makes
diagnostic hints carry span metadata. Tinymist renders the hint message
payload instead of formatting the whole spanned wrapper.
- [`typst/typst#8254`](typst/typst#8254) changes
diagnostic, user-action, and test-range span handling. Tinymist updates
LSP diagnostics, user-action conversion, and range-sensitive tests for
the new span shape.
- [`typst/typst#8188`](typst/typst#8188) changes
syntax diagnostics. Tinymist updates syntax matchers and diagnostics
conversion paths that inspect syntax-side errors.
- [`typst/typst#8307`](typst/typst#8307) changes
bibliography lookup. Tinymist now finds bibliography elements through
the document introspector and packs them back to `BibliographyElem`.
- Typst 0.15 deprecates rooted virtual-path access through
`as_rooted_path`; diagnostics now use the slash-form virtual path
accessor for extension checks.

## Tinymist Changes

- Updates `tinymist-world` diagnostic rendering for spanned hint values.
- Updates `tinymist-query`, `tinymist-analysis`, `tinymist-lint`, and
debug-facing syntax diagnostics for the new span and syntax diagnostic
APIs.
- Updates user-action span conversion and affected test ranges.
- Updates code-context path evaluation to construct `RangeMapper` from
an iterator, matching the lint expectations of the current toolchain.
- Carries the small bibliography lookup prerequisite in this slice so
later query-oriented slices build on the updated Typst API.

---------

Co-authored-by: paran3xus <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internals About internal changes to the codebase.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants