From c22816de08fc1682ea2f3d48b5167c141608a92a Mon Sep 17 00:00:00 2001 From: Markus Triska Date: Mon, 8 Jun 2020 00:07:24 +0200 Subject: [PATCH] type check for ~d and ~D specifiers --- src/prolog/lib/format.pl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/prolog/lib/format.pl b/src/prolog/lib/format.pl index d91fdc91..e8be4df3 100644 --- a/src/prolog/lib/format.pl +++ b/src/prolog/lib/format.pl @@ -172,9 +172,11 @@ cells([~,a|Fs], [Arg|Args], Tab, Es) --> !, { atom_chars(Arg, Chars) }, cells(Fs, Args, Tab, [chars(Chars)|Es]). cells([~|Fs0], Args0, Tab, Es) --> - { numeric_argument(Fs0, Num, [d|Fs], Args0, [Arg|Args]) }, + { numeric_argument(Fs0, Num, [d|Fs], Args0, [Arg0|Args]) }, !, - { format_number_chars(Arg, Cs0) }, + { Arg is Arg0, % evaluate compound expression + must_be(integer, Arg), + number_chars(Arg, Cs0) }, ( { Num =:= 0 } -> { Cs = Cs0 } ; { length(Cs0, L), ( L =< Num -> -- 2.54.0