Skip to content

Conversation

@IanButterworth
Copy link
Member

@IanButterworth IanButterworth commented Jan 26, 2026

Add version-aware parsing using JuliaSyntax

This PR enables CoverageTools to parse Julia source code across different syntax versions by:

Key Changes:

  • Added JuliaSyntax as a dependency for version-aware parsing
  • Implemented detect_syntax_version() to automatically detect the appropriate Julia syntax version by:
    • Checking Project.toml/JuliaProject.toml for explicit syntax.julia_version entries
    • Using Base.project_file_load_spec() when available (Julia 1.14+)
    • Falling back to VERSION file for Julia's base/ source tree
    • Defaulting to v"1.14" (JuliaSyntax maintains backwards compatibility)
  • Modified amend_coverage_from_src!() to use JuliaSyntax.parsestmt() with the detected version parameter
  • Added has_embedded_errors() helper to detect parse errors in ASTs with proper error reporting
  • Updated test expectations for the new error message format

Why This Matters:
This allows CoverageTools running under Julia 1.11 (or any version) to correctly parse Julia 1.14+ source code containing new syntax features like labeled breaks. Since JuliaSyntax provides version-aware parsing independent of the running Julia version, coverage analysis now works seamlessly across version boundaries.

Implementation Details:

  • Raises minimum Julia version to 1.10 (for compatibility with JuliaSyntax)
  • Handles edge cases: comment-only files, EOF detection, infinite loop prevention
  • Maintains error reporting for actual syntax errors while being lenient with version-specific features

Fixes JuliaLang/julia#60826

Developed with Claude

@codecov
Copy link

codecov bot commented Jan 26, 2026

Codecov Report

❌ Patch coverage is 88.23529% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.06%. Comparing base (9943dd0) to head (de8a377).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/CoverageTools.jl 88.23% 10 Missing ⚠️

❌ Your project status has failed because the head coverage (96.06%) is below the target coverage (100.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #80      +/-   ##
==========================================
- Coverage   98.36%   96.06%   -2.30%     
==========================================
  Files           4        4              
  Lines         245      356     +111     
==========================================
+ Hits          241      342     +101     
- Misses          4       14      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

IanButterworth and others added 5 commits January 26, 2026 16:34
…ia syntax

When analyzing code coverage, detect the appropriate syntax version by:
- Checking Project.toml/JuliaProject.toml for syntax.julia_version or compat.julia
- Falling back to VERSION file for Julia's base/ source
- Using Base.project_get_syntax_version() when available (Julia 1.14+)

This allows Coverage.jl running under Julia 1.11 to correctly parse Julia 1.14+
source code containing features like labeled breaks, by passing the detected
syntax version to Meta.parse via the version keyword argument.

Co-Authored-By: Claude <noreply@anthropic.com>
This change enables CoverageTools to parse Julia source code using syntax versioning, allowing coverage collection when the runner Julia version differs from the source code version. This fixes coverage jobs that run on Julia 1.11 but need to parse Julia 1.14 code containing features like labeled break/continue statements.

Fixes JuliaLang/julia#60826

CoverageTools: Add version-aware parsing using JuliaSyntax

This enables CoverageTools running on Julia 1.11 to parse Julia 1.14+ code with labeled breaks.

Fixes JuliaLang/julia#60826
Per review feedback:
- Default to v"1.14" instead of VERSION since JuliaSyntax maintains backwards compatibility
- Remove incorrect compat parsing logic - only respect explicit syntax.julia_version
- Keep Base.project_file_load_spec() usage for Julia 1.14+
@IanButterworth IanButterworth requested a review from Keno January 27, 2026 17:17
- Simplify has_embedded_errors() using early returns and any()
- Clarify current_line computation (lineoffset + 1)
- Add TOML fallback test for Julia < 1.14 syntax version detection
@IanButterworth IanButterworth merged commit f867eac into master Jan 31, 2026
7 of 10 checks passed
@IanButterworth IanButterworth deleted the ib/handle_syntax branch January 31, 2026 13: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.

coverage jobs broken by labeled break

2 participants