Skip to content

Fix #line directive to support unquoted filenames#325

Merged
fglock merged 2 commits into
masterfrom
fix/line-directive-unquoted
Mar 17, 2026
Merged

Fix #line directive to support unquoted filenames#325
fglock merged 2 commits into
masterfrom
fix/line-directive-unquoted

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Mar 16, 2026

Summary

  • Perl allows both quoted and unquoted filenames in #line directives:
    • #line N "filename" (quoted - already worked)
    • #line N filename (unquoted bareword - now fixed)
  • Added support for unquoted filenames in ErrorMessageUtil.getSourceLocationAccurate()

Impact

  • Moo croak-locations.t: 29 failures → 3 failures (26 tests fixed)
  • Remaining 3 failures are complex nested eval cases related to Carp stack walking

Test Plan

  • Unit tests pass (make)
  • Moo tests: 64/71 passing (90%), 795/829 subtests (96%)
  • Mo tests: 27/28 passing (99.3%)

Generated with Devin

fglock and others added 2 commits March 16, 2026 23:34
Perl allows both quoted and unquoted filenames in #line directives:
- #line N "filename"  (quoted - already worked)
- #line N filename    (unquoted bareword - now fixed)

The fix adds an else clause in ErrorMessageUtil.getSourceLocationAccurate()
to also handle IDENTIFIER tokens as unquoted filenames.

This fixes Moo croak-locations.t: 29 failures -> 3 failures.
The remaining 3 are complex nested eval cases related to Carp stack walking.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <noreply@cognition.ai>
Problem: caller() was returning empty/wrong package for subroutine stack
frames because saveSourceLocation() was only called during parsing, when
subroutines don't yet have their own class context.

Solution: Modified setDebugInfoLineNumber() to also call saveSourceLocation()
during bytecode emission. This ensures source locations are saved with the
correct package context from the subroutine's symbol table.

- ByteCodeSourceMapper.java: Added saveSourceLocation() call to setDebugInfoLineNumber()
- Added dev/design/caller_package_context.md with detailed analysis
- Updated dev/design/moo_support.md with Phase 28 entry

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <noreply@cognition.ai>
@fglock fglock merged commit 15ef2a0 into master Mar 17, 2026
2 checks passed
@fglock fglock deleted the fix/line-directive-unquoted branch March 17, 2026 11:51
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