ref: b47e50f306012bbfe335ae8a2041cd297d1328a4
parent: c6597f980b2cc154d807fffe9ed4e8e871319cca
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Wed Apr 16 22:27:07 EDT 2025
#S(…): throw a better error when the default constructor does not exist
--- a/boot/sl.boot
+++ b/boot/sl.boot
@@ -116,9 +116,9 @@
<= #fn("z1Ib6862086>1_486<^10162:" #(#fn("n21S;JL041<0L2;J5040V340q:A<1<1=62:")) <=) >
#fn("z1Ib6862086>1_486<^10162:" #(#fn("n21S;JE041<0L2;3;04A<1<1=62:")) >) >= #fn("z1Ib6862086>1_486<^10162:" #(#fn("n21S;JL0401<L2;J5040V340q:A<1<1=62:")) >=)
Instructions #table(call.l #u8(81) trycatch #u8(75) loadg.l #u8(68) aref2 #u8(23) box #u8(50) cadr #u8(36) argc #u8(62) setg #u8(71) load0 #u8(21) nan? #u8(38) fixnum? #u8(41) loadc0 #u8(17) loada0 #u8(0) div0 #u8(59) keyargs #u8(31) call #u8(5) loada.l #u8(69) num? #u8(40) sub2 #u8(78) add2 #u8(29) loadc.l #u8(70) loadc #u8(9) builtin? #u8(43) set-car! #u8(47) vargc.l #u8(80) vec #u8(63) ret #u8(10) loadi8 #u8(66) tapply #u8(77) loadvoid #u8(25) loada1 #u8(1) shift #u8(46) atom? #u8(24) cdr #u8(13) brne.l #u8(83) / #u8(58) equal? #u8(52) apply #u8(54) dup #u8(11) loadt #u8(20) bounda #u8(39) jmp.l #u8(48) = #u8(60) not #u8(35) set-cdr! #u8(30) fn? #u8(44) eq? #u8(33) * #u8(57) load1 #u8(27) bound? #u8(42) box.l #u8(86) < #u8(28) brnn.l #u8(84) jmp #u8(16) loadv #u8(2) for #u8(76) dummy_eof #u8(88) + #u8(55) brne #u8(19) argc.l #u8(79) compare #u8(61) brn #u8(3) neg #u8(37) loadv.l #u8(67) vargc #u8(74) loadc1 #u8(22) setg.l #u8(72) cons? #u8(18) aref #u8(85) sym? #u8(34) aset! #u8(64) car #u8(12) cons #u8(32) tcall.l #u8(82) - #u8(56) brn.l #u8(49) optargs #u8(87) closure #u8(14) vec? #u8(45) pop #u8(4) eqv? #u8(51) list #u8(53) seta #u8(15) seta.l #u8(73) brnn #u8(26) loadnil #u8(65) loadg #u8(7) loada #u8(8) tcall #u8(6))
- S #fn("z170021521}2:" #(getprop constructor) S) __finish
- #fn("n120Z3>021220>17062:q:" #(*exit-hooks* #fn(for-each)
- #fn("n10A61:")) __finish)
+ S #fn("z1700215286380861}2:7223062:" #(getprop constructor error "no default constructor for struct: ") S)
+ __finish #fn("n120Z3>021220>17062:q:" #(*exit-hooks* #fn(for-each)
+ #fn("n10A61:")) __finish)
__init_globals #fn("n07021d37022@402384w4^147025d;350426;J50427w8429w:4qw;47<w=47>w?47@wA:" #(*os-name*
"macos" #fn("n0702161:" #(princ "\e[0m\e[1m#;> \e[0m"))
#fn("n0702161:" #(princ "#;> ")) *prompt* "dos" "\\" "/" *directory-separator* "\n" *linefeed*
--- a/src/system.sl
+++ b/src/system.sl
@@ -1055,7 +1055,10 @@
;;; structs
(def (S struct . rest)
- (apply (getprop struct 'constructor) rest))
+ (let ((constructor (getprop struct 'constructor)))
+ (if constructor
+ (apply constructor rest)
+ (error "no default constructor for struct: " struct))))
(defmacro (defstruct name (:type 'vec)
(:named NIL named-supplied)