Skip to content

Conversation

@jjtolton
Copy link
Contributor

@jjtolton jjtolton commented Dec 6, 2025

Summary

  • Fix bug where [|] inside expressions like 1*[|] incorrectly parsed when | is defined as an operator (e.g., via library(dcgs))
  • The | with XFY spec was being treated as a term in compute_arity_in_list(), causing it to steal terms from before the [ bracket

Bug Report

jjtolton#5

Test Cases

All should throw syntax_error when | is operator (1105 xfy):

"{1*[|]. }."         % space before }
"{ ! * [ | ] * ! }." % spaces throughout  
"{!*[|]*!}."         % no spaces
"!*[|]*!."           % without braces
"(!*[|]*!)."         % with parens
"!*[|]*1."           % ending with number
"!*[|]*A."           % ending with variable

Fix

Explicitly reject HeadTailSeparator at term positions in compute_arity_in_list(), since [|...] with nothing before | is always invalid.

When | is defined as an operator (e.g., via dcgs), expressions like
1*[|] incorrectly parsed because the | was treated as a term due to
its operator spec. This caused compute_arity_in_list() to steal terms
from before the [ bracket.

The fix explicitly rejects HeadTailSeparator at term positions in
compute_arity_in_list(), since [|...] with nothing before | is always
invalid regardless of whether | is an operator.

Fixes: #5
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