Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove DCGs that have thrown an exception during term expansion #2681

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/lib/dcgs.pl
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,13 @@
dcg_body(GRIf, S0, S1, If),
dcg_body(GRThen, S1, S, Then).


% When DCG expansion throws an exception – remove offending term and rethrow.
user:term_expansion(throw_dcg_expansion_error(E), _) :-
throw(E).
user:term_expansion(Term0, Term) :-
nonvar(Term0),
dcg_rule(Term0, Term).

catch(dcg_rule(Term0, Term), E, Term = throw_dcg_expansion_error(E)).

%% seq(Seq)//
%
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
:- use_module(library(dcgs)).

d -->
( { true } -> []
; { true } -> []
).
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
error(representation_error(dcg_body),[culprit-({true}->[])]).
7 changes: 7 additions & 0 deletions tests/scryer/cli/issues/not_supported_dcg_constructs.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# issue 2675
args = [
"-f",
"--no-add-history",
"-g", "halt",
"main.pl"
]
Loading