Skip to content

Commit

Permalink
delay instantiation errors on lists in phrase/3 until runtime (#1665, #…
Browse files Browse the repository at this point in the history
  • Loading branch information
mthom committed Apr 29, 2024
1 parent bcfa021 commit f3eea63
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/lib/dcgs.pl
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@
Cs0 = Cs.
... --> [] | [_], ... .

% defer instantiation errors until runtime. instantiations may be made
% then.
error_goal(error(instantiation_error, _Context), _).
error_goal(error(E, must_be/2), error(E, must_be/2)).
error_goal(error(E, (=..)/2), error(E, (=..)/2)).
error_goal(error(representation_error(dcg_body), Context),
Expand All @@ -259,7 +262,11 @@
E,
dcgs:error_goal(E, GRBody1)
),
( GRBody = (_:_) ->
( E = error(instantiation_error, _),
GRBody0 = [T|Ts] ->
GRBody2 = (error:must_be(list, [T|Ts]),
lists:append([T|Ts], S0, S))
; GRBody = (_:_) ->
GRBody2 = M:GRBody1
; GRBody2 = GRBody1
).
Expand Down

0 comments on commit f3eea63

Please sign in to comment.