Skip to content

Conversation

@jjtolton
Copy link

Closes: #3138

@jjtolton jjtolton marked this pull request as ready for review October 26, 2025 15:50
@UWN
Copy link

UWN commented Oct 26, 2025

Can you give an example where (( is involved in an incomplete reduction?

@UWN
Copy link

UWN commented Oct 26, 2025

... and where is a problem with the comma?

% Test that (( produces syntax error
test("(( should produce syntax_error", (
catch(
(read_from_chars("((}.", _), false),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example is not very convincing, since it always produced a syntax error (for whatever reason). So what is its point?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

multitasking error, stand by

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(... divergent branches, git status says I should do git pull)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps looking at the combined testing branch would be better:

https://github.com/jjtolton/scryer-prolog/tree/combined-testing

That has digits, this, and double bars

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(... divergent branches, git status says I should do git pull)

Forget it, your combined branch is it!

% Test that {( produces syntax error (already tested in ISO conformity)
test("{( should produce syntax_error", (
catch(
(read_from_chars("{(}.", _), false),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idem

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes mthom#3138

The parser was incorrectly accepting expressions like ([ and ({
as valid syntax, parsing them as atoms instead of rejecting them as
incomplete reductions.

This fix adds checks in reduce_brackets() to reject when an opening
parenthesis is followed by:
- Opening bracket [
- Opening curly brace {

Note: (, and (( were already correctly rejected by existing checks.

This brings the behavior in line with how curly braces work, where
{[ and {( correctly produce syntax errors.

Added tests in src/tests/syntax_errors.pl to verify the fix and
prevent regressions.
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.

Syntax: unexpected extension

2 participants