Skip to content

fix(coverage): break import cycle with debug#3491

Merged
bobzhang merged 2 commits intomainfrom
fix/coverage-debug-cycle
Apr 27, 2026
Merged

fix(coverage): break import cycle with debug#3491
bobzhang merged 2 commits intomainfrom
fix/coverage-debug-cycle

Conversation

@bobzhang
Copy link
Copy Markdown
Contributor

@bobzhang bobzhang commented Apr 27, 2026

Summary

coverage/debug.mbt (added in #3482) introduced a Debug impl for CoverageCounter, which made coverage import debug. With --enable-coverage, the toolchain implicitly injects coverage into every package — including debug itself — producing the cycle:

abort -> prelude -> coverage -> debug -> coverage

This causes moon test --enable-coverage (and the misc-check CI job) to fail with Import loop detected.

Fix

  • Delete coverage/debug.mbt.
  • Remove "moonbitlang/core/debug" from coverage/moon.pkg.

The only observable API change is that CoverageCounter no longer has a Debug impl — it's an internal counter type that callers shouldn't be debug-printing in normal code.

Repro

$ git checkout origin/main
$ moon test --enable-coverage
Error: Failed to solve package relationship
Caused by:
    Error 1: Import loop detected: moonbitlang/core/abort -> moonbitlang/core/prelude -> moonbitlang/core/coverage -> moonbitlang/core/debug -> moonbitlang/core/coverage

Test plan

  • moon test --enable-coverage — 6369/6369 pass after the fix.
  • moon test — 6364/6364 pass.

mbti diff (coverage)

< import { "moonbitlang/core/debug" }
< pub impl @debug.Debug for CoverageCounter

🤖 Generated with Claude Code


Open in Devin Review

`coverage/debug.mbt` (added in #3482) introduced a `Debug` impl for
`CoverageCounter`, which made `coverage` import `debug`. With
`--enable-coverage`, the toolchain implicitly injects coverage into
every package — including `debug` itself — producing the cycle:

    abort -> prelude -> coverage -> debug -> coverage

This causes `moon test --enable-coverage` (and the misc-check CI job)
to fail with "Import loop detected".

Removes `coverage/debug.mbt` and the `debug` import from
`coverage/moon.pkg`. The only observable API change is that
`CoverageCounter` no longer has a `Debug` impl — it's an internal
counter type that callers shouldn't be debug-printing in normal code.

After this change `moon test --enable-coverage` runs clean (6369/6369).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

@bobzhang bobzhang enabled auto-merge (squash) April 27, 2026 08:37
@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented Apr 27, 2026

Coverage Report for CI Build 4042

Warning

No base build found for commit bf02241 on main.
Coverage changes can't be calculated without a base build.
If a base build is processing, this comment will update automatically when it completes.

Coverage: 94.817%

Details

  • Patch coverage: No coverable lines changed in this PR.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

Requires a base build to compare against. How to fix this →


Coverage Stats

Coverage Status
Relevant Lines: 15589
Covered Lines: 14781
Line Coverage: 94.82%
Coverage Strength: 220117.59 hits per line

💛 - Coveralls

@bobzhang bobzhang merged commit 797ddb4 into main Apr 27, 2026
12 of 19 checks passed
@bobzhang bobzhang deleted the fix/coverage-debug-cycle branch April 27, 2026 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants