Skip to content

Fix #3156: Reject bracketed terms as functors#3203

Open
jjtolton wants to merge 1 commit intomthom:masterfrom
jjtolton:fix-issue-3156
Open

Fix #3156: Reject bracketed terms as functors#3203
jjtolton wants to merge 1 commit intomthom:masterfrom
jjtolton:fix-issue-3156

Conversation

@jjtolton
Copy link
Contributor

@jjtolton jjtolton commented Dec 6, 2025

Summary

Fixes #3156 - Prevents patterns like ((>)(1) from incorrectly parsing as >(1).

A bracketed term (BTERM) cannot be used as a functor name - only atoms can be functors per ISO Prolog syntax rules.

Changes

  • Added check in reduce_term() to reject BTERM as functor
  • Added 6 tests covering the bug cases and valid syntax

Test Cases

Input Expected Before Fix After Fix
((>)(1). syntax_error >(1) syntax_error ✓
((a)(b). syntax_error a(b) syntax_error ✓
(a) (b). syntax_error syntax_error ✓ syntax_error ✓
a(b). a(b) a(b) a(b)
(a). a a a
((>)). (>) (>) (>)

Testing

All 36 tests pass.

Prevents patterns like ((>)(1) from incorrectly parsing as >(1).
A bracketed term (BTERM) cannot be used as a functor name - only
atoms can be functors per ISO Prolog syntax rules.
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.

Unexpected syntax extention

1 participant