]> Repositorios git - scryer-prolog.git/commitdiff
correct bad atom_length/2, atom_chars/2 error reporting
authorMark Thom <[email protected]>
Sat, 6 Apr 2019 06:13:52 +0000 (00:13 -0600)
committerMark Thom <[email protected]>
Sat, 6 Apr 2019 06:13:52 +0000 (00:13 -0600)
Cargo.toml
src/prolog/lib/builtins.pl

index 48ee5cc484ad3890a93a7778756a42c13113d7d5..9351316b811710b74c45e1d3982883668228580d 100644 (file)
@@ -1,6 +1,6 @@
 [package]
 name = "scryer-prolog"
-version = "0.8.43"
+version = "0.8.44"
 authors = ["Mark Thom <[email protected]>"]
 repository = "https://github.com/mthom/scryer-prolog"
 description = "A modern Prolog implementation written mostly in Rust."
@@ -14,7 +14,7 @@ cfg-if = "0.1.7"
 downcast = "0.10.0"
 num = "0.2"
 ordered-float = "0.5.0"
-prolog_parser = "0.8.16"
+prolog_parser = { version = "0.8.17", path = "../prolog_parser" }
 readline_rs_compat = { version = "0.1.7", optional = true }
 ref_thread_local = "0.0.0"
 
index c8bece283b2eaecffc54fbaaa3b47f0fbd816c60..6417ac83fe3d96f63be68a0a03dfc2c486206f76 100644 (file)
@@ -766,7 +766,7 @@ op(Priority, OpSpec, Op) :-
     ;  var(OpSpec)   -> throw(error(instantiation_error, op/3)) % 8.14.3.3 b)
     ;  var(Op)       -> throw(error(instantiation_error, op/3)) % 8.14.3.3 c)
     ;  Op == '|'     -> (  op_priority(Priority), op_specifier(OpSpec),
-                          lists:member(OpSpec, [xfx, xfy, yfx]), Priority >= 1001
+                          lists:member(OpSpec, [xfx, xfy, yfx]), ( Priority >= 1001 ; Priority == 0 )
                        -> '$op'(Priority, OpSpec, Op)
                        ;  throw(error(permission_error(create, operator, (|)), op/3))) % www.complang.tuwien.ac.at/ulrich/iso-prolog/conformity_testing#72
     ;  valid_op(Op), op_priority(Priority), op_specifier(OpSpec) ->
@@ -800,7 +800,7 @@ atom_length(Atom, Length) :-
     (  var(Atom)  -> throw(error(instantiation_error, atom_length/2)) % 8.16.1.3 a)
     ;  atom(Atom) -> (  var(Length) -> '$atom_length'(Atom, Length)
                     ;  integer(Length), Length >= 0 -> '$atom_length'(Atom, Length)
-                    ;  integer(Length) -> throw(domain_error(not_less_than_zero, Length), atom_length/2) % 8.16.1.3 d)
+                    ;  integer(Length) -> throw(error(domain_error(not_less_than_zero, Length), atom_length/2)) % 8.16.1.3 d)
                     ;  throw(error(type_error(integer, Length), atom_length/2)) % 8.16.1.3 c)
                     )
     ;  throw(error(type_error(atom, Atom), atom_length/2)) % 8.16.1.3 b)
@@ -811,13 +811,10 @@ no_var_in_list([X|Xs]) :- var(X), !, '$fail'.
 no_var_in_list([_|Xs]) :- no_var_in_list(Xs).
 
 atom_chars(Atom, List) :-
-    (  var(Atom), '$skip_max_list'(_, -1, List, Xs) ->
-       (  var(Xs) -> throw(error(instantiation_error, atom_chars/2))
-       ;  Xs == [] ->
-         (  no_var_in_list(List) -> '$atom_chars'(Atom, List)
-         ;  throw(error(instantiation_error, atom_chars/2))
-         )
-       ;  throw(error(type_error(list, List), atom_chars/2))
+    error:can_be(list, List),
+    (  var(Atom) ->
+       (  var(List) -> throw(error(instantiation_error, atom_chars/2))
+       ;  no_var_in_list(List) -> '$atom_chars'(Atom, List)
        )
     ;  atom(Atom) -> '$atom_chars'(Atom, List)
     ;  Atom == [] -> '$atom_chars'(Atom, List)
@@ -825,13 +822,10 @@ atom_chars(Atom, List) :-
     ).
 
 atom_codes(Atom, List) :-
-    (  var(Atom), '$skip_max_list'(_, -1, List, Xs) ->
-       (  var(Xs) -> throw(error(instantiation_error, atom_codes/2))
-       ;  Xs == [] ->
-         (  no_var_in_list(List) -> '$atom_codes'(Atom, List)
-         ;  throw(error(instantiation_error, atom_codes/2))
-         )
-       ;  throw(error(type_error(list, List), atom_codes/2))
+    error:can_be(list, List),
+    (  var(Atom) ->
+       (  var(List) -> throw(error(instantiation_error, atom_codes/2))
+       ;  no_var_in_list(List) -> '$atom_codes'(Atom, List)
        )
     ;  atom(Atom) -> '$atom_codes'(Atom, List)
     ;  Atom == [] -> '$atom_codes'(Atom, List)