Skip to content

Improve Diagnostic Source Locations and Enable Recursion Regression Coverage #44

@SizzleUnrlsd

Description

@SizzleUnrlsd

Summary

Some warnings were missing source locations (line/column), which made diagnostics less actionable and left recursion tests effectively unvalidated (no expectations found, skipping).

Problems

  • NeverInitialized local variable warnings sometimes had no line/column.
  • Recursion warnings (recursive or mutually recursive, unconditional self recursion) had no line/column in human output.
  • The test harness parity logic could miss recursion flags when diagnostics were preceded by at line ....
  • Recursion test files had no expectations, so they were skipped.

Implemented Changes

  • Added robust location recovery for uninitialized local variables in src/analysis/UninitializedVarAnalysis.cpp.
  • Added recursion warning locations (function-level) in src/StackUsageAnalyzer.cpp.
  • Updated human-vs-JSON parity parsing in run_test.py so recursion flags are detected even when location lines are present.
  • Added concrete expectations to recursion tests:
    • test/recursion/c/infinite-recursion.c
    • test/recursion/c/limited-recursion.c
    • test/recursion/cpp/infinite-recursion.cpp
    • test/recursion/cpp/limited-recursion.cpp
  • Added/updated expectation for uninitialized variable location:
    • test/uninitialized-variable/uninitialized-local-argument-never-used.c

Architecture Rationale

  • Kept fixes local to diagnostics production rather than changing the global debug pipeline.
  • Reused existing aux.locations as the single source of truth for function-level locations.
  • Used layered fallbacks for declaration recovery (debug metadata first, source-text fallback last) to improve robustness without broad side effects.

Result

  • Human output now includes at line X, column Y for recursion warnings.
  • Recursion tests are no longer skipped and now assert expected diagnostics.
  • Full test suite passes: 157/157.

Suggested Conventional Commits

  • fix(uninitialized): recover declaration line/column for never-initialized locals
  • feat(recursion): add source line and column to recursion diagnostics
  • test(recursion): add expectations for recursion diagnostics with locations
  • fix(test-runner): detect recursion flags in human output with location-prefixed diagnostics

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingenhancementNew feature or request

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions