Skip to content

Conversation

@fglock
Copy link
Owner

@fglock fglock commented Jan 28, 2026

Summary

Fixed two failing parser tests in perl5_t/t/comp/parser.t:

Test 14: backslash-c without character

  • Problem: Missing control character after backslash-c should generate an error
  • Solution: Added proper error handling in StringDoubleQuoted.handleControlCharacter() and StringSegmentParser.handleControlCharacter()
  • Result: Now throws the correct error message when control character is missing

Test 15: dollar at end of string

  • Problem: dollar at the end of double-quoted string should generate Final dollar should be backslash-dollar or dollarname error
  • Solution: Added check for empty identifier in parseSimpleVariableInterpolation() when dollar sigil is at EOF
  • Result: Now generates the exact expected error message

Changes Made

  1. StringDoubleQuoted.java:

    • Added PerlCompilerException import
    • Modified handleControlCharacter() to throw proper error when character is missing
  2. StringSegmentParser.java:

    • Modified handleControlCharacter() to throw proper error when character is missing
    • Added targeted EOF check in shouldInterpolateVariable() for dollar sigil in double-quoted strings
    • Added check for empty identifier in parseSimpleVariableInterpolation() to handle dollar at end of string
    • Added getter method for originalStringContent

Test Results

  • Test 14: backslash-c string - PASSED
  • Test 15: dollar at end of string - PASSED
  • make build: HEALTHY
  • All other tests: PASSING (no regressions)

Verification

Both tests now pass with the exact expected error messages:

  • Test 14: Handles missing control character after backslash-c
  • Test 15: Generates Final dollar should be backslash-dollar or dollarname for dollar at end of string

The fixes are minimal and targeted, only affecting the specific error cases without breaking existing functionality.

- Add proper error handling for missing control character after \c
- Update StringDoubleQuoted.java to inline control character logic with error checking
- Update StringSegmentParser.java handleControlCharacter method to throw proper error
- Test 14 in parser.t now passes

Test 15 ($ at end of string) still needs work.
- Add very specific check in shouldInterpolateVariable for $ at EOF
- Only applies to double-quoted string context (not regex)
- Test 14 still working, test 15 still needs work
- Build is healthy
- Add check for empty identifier in parseSimpleVariableInterpolation
- When $ sigil has empty identifier and we're at EOF, generate proper error
- Both test 14 and test 15 now pass
- Error message: 'Final $ should be $ or $name' matches expected output
@fglock fglock merged commit a10c0af into master Jan 28, 2026
2 checks passed
@fglock fglock deleted the fix-parser-make branch January 28, 2026 15:47
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.

2 participants