correct bad atom_length/2, atom_chars/2 error reporting

This commit is contained in:
Mark Thom
2019-04-06 00:13:52 -06:00
parent 3aa8d11a98
commit 7a497fd4e1
2 changed files with 12 additions and 18 deletions

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "scryer-prolog" name = "scryer-prolog"
version = "0.8.43" version = "0.8.44"
authors = ["Mark Thom <markjordanthom@gmail.com>"] authors = ["Mark Thom <markjordanthom@gmail.com>"]
repository = "https://github.com/mthom/scryer-prolog" repository = "https://github.com/mthom/scryer-prolog"
description = "A modern Prolog implementation written mostly in Rust." description = "A modern Prolog implementation written mostly in Rust."
@@ -14,7 +14,7 @@ cfg-if = "0.1.7"
downcast = "0.10.0" downcast = "0.10.0"
num = "0.2" num = "0.2"
ordered-float = "0.5.0" 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 } readline_rs_compat = { version = "0.1.7", optional = true }
ref_thread_local = "0.0.0" ref_thread_local = "0.0.0"

View File

@@ -766,7 +766,7 @@ op(Priority, OpSpec, Op) :-
; var(OpSpec) -> throw(error(instantiation_error, op/3)) % 8.14.3.3 b) ; 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) ; var(Op) -> throw(error(instantiation_error, op/3)) % 8.14.3.3 c)
; Op == '|' -> ( op_priority(Priority), op_specifier(OpSpec), ; 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) -> '$op'(Priority, OpSpec, Op)
; throw(error(permission_error(create, operator, (|)), op/3))) % www.complang.tuwien.ac.at/ulrich/iso-prolog/conformity_testing#72 ; 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) -> ; 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) ( var(Atom) -> throw(error(instantiation_error, atom_length/2)) % 8.16.1.3 a)
; atom(Atom) -> ( var(Length) -> '$atom_length'(Atom, Length) ; atom(Atom) -> ( var(Length) -> '$atom_length'(Atom, Length)
; integer(Length), Length >= 0 -> '$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(integer, Length), atom_length/2)) % 8.16.1.3 c)
) )
; throw(error(type_error(atom, Atom), atom_length/2)) % 8.16.1.3 b) ; 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). no_var_in_list([_|Xs]) :- no_var_in_list(Xs).
atom_chars(Atom, List) :- atom_chars(Atom, List) :-
( var(Atom), '$skip_max_list'(_, -1, List, Xs) -> error:can_be(list, List),
( var(Xs) -> throw(error(instantiation_error, atom_chars/2)) ( var(Atom) ->
; Xs == [] -> ( var(List) -> throw(error(instantiation_error, atom_chars/2))
( no_var_in_list(List) -> '$atom_chars'(Atom, List) ; 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))
) )
; atom(Atom) -> '$atom_chars'(Atom, List) ; atom(Atom) -> '$atom_chars'(Atom, List)
; Atom == [] -> '$atom_chars'(Atom, List) ; Atom == [] -> '$atom_chars'(Atom, List)
@@ -825,13 +822,10 @@ atom_chars(Atom, List) :-
). ).
atom_codes(Atom, List) :- atom_codes(Atom, List) :-
( var(Atom), '$skip_max_list'(_, -1, List, Xs) -> error:can_be(list, List),
( var(Xs) -> throw(error(instantiation_error, atom_codes/2)) ( var(Atom) ->
; Xs == [] -> ( var(List) -> throw(error(instantiation_error, atom_codes/2))
( no_var_in_list(List) -> '$atom_codes'(Atom, List) ; 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))
) )
; atom(Atom) -> '$atom_codes'(Atom, List) ; atom(Atom) -> '$atom_codes'(Atom, List)
; Atom == [] -> '$atom_codes'(Atom, List) ; Atom == [] -> '$atom_codes'(Atom, List)