give a better error message when an invalid slot name is used in a tuple/struct literal

db4
Joe Groff 2009-09-16 18:07:39 -05:00
parent d1c69efc0f
commit 748ba4b833
2 changed files with 11 additions and 1 deletions

View File

@ -174,6 +174,8 @@ M: no-method error.
M: bad-slot-value summary drop "Bad store to specialized slot" ;
M: bad-slot-name summary drop "Bad slot name in object literal" ;
M: no-math-method summary
drop "No suitable arithmetic method" ;

View File

@ -99,9 +99,17 @@ GENERIC# boa>object 1 ( class slots -- tuple )
M: tuple-class boa>object
swap prefix >tuple ;
ERROR: bad-slot-name class slot ;
: check-slot-exists ( class initials slot-spec/f index/f name -- class initials slot-spec index )
over [ drop ] [ nip nip nip bad-slot-name ] if ;
: slot-named-checked ( class initials name slots -- class initials slot-spec )
over [ slot-named* ] dip check-slot-exists drop ;
: assoc>object ( class slots values -- tuple )
[ [ [ initial>> ] map ] keep ] dip
swap [ [ slot-named* drop ] curry dip ] curry assoc-map
swap [ [ slot-named-checked ] curry dip ] curry assoc-map
[ dup <enum> ] dip update boa>object ;
: parse-tuple-literal-slots ( class slots -- tuple )