372 - size check for arrays
This commit is contained in:
parent
c6278ca5bc
commit
878f57a6db
7
mu.arc
7
mu.arc
|
@ -576,8 +576,11 @@
|
|||
(do (assert (~isa val 'record) "setm: record of size 1 @(tostring prn.val)")
|
||||
(trace "setm" loc ": setting " addr " to " val)
|
||||
(= memory*.addr val))
|
||||
(do (assert (isa val 'record) "setm: non-record of size >1 @val")
|
||||
(unless ((types* typeof.loc) 'array)
|
||||
(do (if ((types* typeof.loc) 'array)
|
||||
; size check for arrays
|
||||
(when (~is rep.val.0 (- n 1))
|
||||
(die "writing invalid array @(tostring prn.val)"))
|
||||
; size check for non-arrays
|
||||
(when (~is sizeof.loc n)
|
||||
(die "writing to incorrect size @(tostring prn.val) => @loc")))
|
||||
(let addrs (addrs addr n)
|
||||
|
|
5
mu.arc.t
5
mu.arc.t
|
@ -888,6 +888,11 @@
|
|||
(~is memory*.5 41)
|
||||
(~is memory*.6 42))
|
||||
(prn "F - 'setm' supports indirect writes to arrays"))
|
||||
(= routine* make-routine!foo)
|
||||
(setm '(4 integer-array) (annotate 'record '(2 31 32 33)))
|
||||
(if (~posmatch "invalid array" rep.routine*!error)
|
||||
(prn "F - 'setm' checks that array written is well-formed"))
|
||||
(wipe routine*)
|
||||
|
||||
; back to top level tests
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user