Skip to content

Conversation

@fglock
Copy link
Owner

@fglock fglock commented Oct 29, 2025

The parser was incorrectly treating 'and', 'or', and 'xor' as list terminators even when they appeared before '=>' in hash literals. This caused syntax errors in valid Perl code like:

my %h = ( and => 1, or => 2, xor => 3 );

The fix adds special handling in:

  1. ListParser.isListTerminator() - checks if and/or/xor are followed by '=>' and if so, doesn't treat them as terminators
  2. ParsePrimary.parseOperator() - handles autoquoting when these keywords appear as OPERATOR tokens before '=>'
  3. ParsePrimary.parseIdentifier() - already handled autoquoting for IDENTIFIER tokens (unchanged)

This allows these keywords to be used as hash keys with fat comma syntax while still functioning as operators in other contexts.

The parser was incorrectly treating 'and', 'or', and 'xor' as list
terminators even when they appeared before '=>' in hash literals.
This caused syntax errors in valid Perl code like:

  my %h = ( and => 1, or => 2, xor => 3 );

The fix adds special handling in:
1. ListParser.isListTerminator() - checks if and/or/xor are followed
   by '=>' and if so, doesn't treat them as terminators
2. ParsePrimary.parseOperator() - handles autoquoting when these
   keywords appear as OPERATOR tokens before '=>'
3. ParsePrimary.parseIdentifier() - already handled autoquoting for
   IDENTIFIER tokens (unchanged)

This allows these keywords to be used as hash keys with fat comma
syntax while still functioning as operators in other contexts.
@fglock fglock merged commit 055561a into master Oct 29, 2025
2 checks passed
@fglock fglock deleted the fix-bop-parser branch October 29, 2025 12:42
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