From: Mark Thom Date: Tue, 4 Aug 2020 01:29:53 +0000 (-0600) Subject: unify '[]' with proper [] in atom_chars/2 (#569) X-Git-Tag: v0.9.0~174^2~19 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=d57a5922730b4a7a95776744dc0dcfdddcdf3036;p=scryer-prolog.git unify '[]' with proper [] in atom_chars/2 (#569) --- diff --git a/Cargo.lock b/Cargo.lock index 531d0e50..526b9644 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -905,9 +905,9 @@ dependencies = [ [[package]] name = "prolog_parser" -version = "0.8.65" +version = "0.8.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdcfe8260335a150812e36b171ff985ce88f02de16c05f4a13fe4f10e8c247f8" +checksum = "e35f5db0eb6725d00be12f3c9550de0dce0a43a1fa25a873f879613d63fcbbd5" dependencies = [ "lexical", "num-rug-adapter", diff --git a/Cargo.toml b/Cargo.toml index c359e1ba..4b4bc1bf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,7 @@ libc = "0.2.62" nix = "0.15.0" num-rug-adapter = { optional = true, version = "0.1.3" } ordered-float = "0.5.0" -prolog_parser = { version = "0.8.65", default-features = false } +prolog_parser = { version = "0.8.66", default-features = false } ref_thread_local = "0.0.0" rug = { version = "1.4.0", optional = true } rustyline = "6.0.0" diff --git a/src/machine/system_calls.rs b/src/machine/system_calls.rs index 644f8296..ada49a0f 100644 --- a/src/machine/system_calls.rs +++ b/src/machine/system_calls.rs @@ -1029,20 +1029,24 @@ impl MachineState { match iter.focus() { Addr::EmptyList => { - let chars = clause_name!(string, indices.atom_tbl); - let atom = self.heap.to_unifiable( - HeapCellValue::Atom(chars, None) - ); + if &string == "[]" { + self.unify(addr, Addr::EmptyList); + } else { + let chars = clause_name!(string, indices.atom_tbl); + let atom = self.heap.to_unifiable( + HeapCellValue::Atom(chars, None) + ); - self.unify(addr, atom); + self.unify(addr, atom); + } } focus => { - let stub = MachineError::functor_stub( - clause_name!("atom_chars"), - 2, - ); - if let Addr::Lis(l) = focus { + let stub = MachineError::functor_stub( + clause_name!("atom_chars"), + 2, + ); + let err = MachineError::type_error( self.heap.h(), ValidType::Character,