Fix invalid (|) parsing when | is operator#3208
Open
jjtolton wants to merge 1 commit intomthom:masterfrom
Open
Fix invalid (|) parsing when | is operator#3208jjtolton wants to merge 1 commit intomthom:masterfrom
jjtolton wants to merge 1 commit intomthom:masterfrom
Conversation
Two fixes for (|) handling: 1. In compute_arity_in_brackets(): Reject HeadTailSeparator at term positions, since (|...) with nothing before | is invalid regardless of whether | is an operator. 2. In reduce_brackets(): Reject HeadTailSeparator in bracket reduction, since (|) must NEVER be converted to the atom | per ISO s#360. 3. In builtins.pl: Use quoted '|' instead of (|) to reference the bar operator, since (|) is no longer valid syntax. Fixes: #7
jjtolton
commented
Dec 8, 2025
| ( Priority >= 1001 ; Priority == 0 ) | ||
| -> '$op'(Priority, OpSpec, Op) | ||
| ; throw(error(permission_error(create, operator, (|)), op/3))) % www.complang.tuwien.ac.at/ulrich/iso-prolog/conformity_testing#72 | ||
| ; throw(error(permission_error(create, operator, '|'), op/3))) % www.complang.tuwien.ac.at/ulrich/iso-prolog/conformity_testing#72 |
Contributor
Author
There was a problem hiding this comment.
Note that this is properly fixed in a different PR addressing this syntax specifically, but a naked (|) is technically always invalid syntax and so must be changed. I need to change it here also for testing purposes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
(|)incorrectly parsed when|is defined as an operator (e.g., vialibrary(dcgs))compute_arity_in_brackets()andreduce_brackets()builtins.plto use quoted'|'instead of(|)Bug Report
jjtolton#7
Test Cases
All should throw
syntax_errorwhen|is operator (1105 xfy):Fix Details
compute_arity_in_brackets(): RejectHeadTailSeparatorat term positionsreduce_brackets(): RejectHeadTailSeparatorin bracket reduction per ISO s#360builtins.pl: Use'|'instead of(|)to reference bar operatorRelated: PR #3206 (similar fix for
[|]in lists)