hashtables: Enforce shape on hashtable literals. Fixes #568.

db4
Doug Coleman 2012-08-24 15:00:33 -07:00
parent 17008536a6
commit 8637c1c012
2 changed files with 9 additions and 1 deletions

View File

@ -181,4 +181,12 @@ M: hashtable assoc-like
[ hashcode 0x13c6ef37 + ] dip
[ 6 shift ] [ -2 shift ] bi + + ;
ERROR: malformed-hashtable-pair seq pair ;
: check-hashtable ( seq -- seq )
dup [ dup length 2 = [ drop ] [ malformed-hashtable-pair ] if ] each ;
: parse-hashtable ( seq -- hashtable )
check-hashtable H{ } assoc-clone-like ;
INSTANCE: hashtable assoc

View File

@ -97,7 +97,7 @@ IN: bootstrap.syntax
"V{" [ \ } [ >vector ] parse-literal ] define-core-syntax
"B{" [ \ } [ >byte-array ] parse-literal ] define-core-syntax
"BV{" [ \ } [ >byte-vector ] parse-literal ] define-core-syntax
"H{" [ \ } [ >hashtable ] parse-literal ] define-core-syntax
"H{" [ \ } [ parse-hashtable ] parse-literal ] define-core-syntax
"T{" [ parse-tuple-literal suffix! ] define-core-syntax
"W{" [ \ } [ first <wrapper> ] parse-literal ] define-core-syntax
"HS{" [ \ } [ >hash-set ] parse-literal ] define-core-syntax