diff --git a/core/hashtables/hashtables-tests.factor b/core/hashtables/hashtables-tests.factor index a238eef90d..92295244bd 100644 --- a/core/hashtables/hashtables-tests.factor +++ b/core/hashtables/hashtables-tests.factor @@ -1,5 +1,5 @@ USING: accessors assocs continuations fry hashtables kernel make -math namespaces sequences tools.test ; +math namespaces sequences tools.test eval ; { H{ } } [ { } [ dup ] H{ } map>assoc ] unit-test @@ -125,6 +125,9 @@ H{ } "x" set ! non-integer capacity not allowed [ 0.75 ] must-fail +[ "H{ 1 }" eval( str -- obj ) ] must-fail +[ "H{ 1 2 -- 3 }" eval( str -- obj ) ] must-fail + ! Another crash discovered by erg { } [ H{ } clone diff --git a/core/hashtables/hashtables.factor b/core/hashtables/hashtables.factor index 05e6a9e34b..c00b4fbe87 100644 --- a/core/hashtables/hashtables.factor +++ b/core/hashtables/hashtables.factor @@ -194,7 +194,13 @@ M: hashtable assoc-like ERROR: malformed-hashtable-pair seq pair ; : check-hashtable ( seq -- seq ) - dup [ dup length 2 = [ drop ] [ malformed-hashtable-pair ] if ] each ; + dup [ + dup sequence? [ + dup length 2 = [ drop ] [ malformed-hashtable-pair ] if + ] [ + malformed-hashtable-pair + ] if + ] each ; : parse-hashtable ( seq -- hashtable ) check-hashtable H{ } assoc-clone-like ;