]> Repositorios git - scryer-prolog.git/commitdiff
FIXED: instantiation and type check for string arguments
authorMarkus Triska <[email protected]>
Thu, 23 Jan 2025 19:18:55 +0000 (20:18 +0100)
committerMarkus Triska <[email protected]>
Thu, 23 Jan 2025 19:18:55 +0000 (20:18 +0100)
This addresses #2790.

The issue first appeared in an example reported by @ak-1 in #2788, and
was successfully analyzed by @flexoron. Many thanks!

src/lib/format.pl

index 2ac4744b8bd9c0ff99c12d06d81d44a315f08a31..96266c5dfa122273fee089d32640aba1a10b5d36 100644 (file)
@@ -1,5 +1,5 @@
 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-   Written 2020-2024 by Markus Triska ([email protected])
+   Written 2020-2025 by Markus Triska ([email protected])
    Part of Scryer Prolog.
    I place this code in the public domain. Use it in any way you want.
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
@@ -187,7 +187,8 @@ elements_gluevars([E|Es], N0, N) -->
         elements_gluevars(Es, N1, N).
 
 element_gluevar(chars(Cs), N0, N) -->
-        { length(Cs, L),
+        { must_be(chars, Cs),
+          length(Cs, L),
           N is N0 + L }.
 element_gluevar(glue(_,V), N, N) --> [V].
 element_gluevar(goal(G), N, N)   --> { G }.