hashtables: Enforce shape on hashtable literals. Fixes #568.
parent
17008536a6
commit
8637c1c012
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue