diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2014-11-28 18:58:38 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2014-11-28 18:58:38 -0800 |
commit | 878f57a6dbdc20631ac945a3311131a8c076c2ee (patch) | |
tree | 4c762d450737fec3a36d63e95bd2c8472049d710 | |
parent | c6278ca5bc1c2287f34ed84bf98e947c9720491d (diff) | |
download | mu-878f57a6dbdc20631ac945a3311131a8c076c2ee.tar.gz |
372 - size check for arrays
-rw-r--r-- | mu.arc | 7 | ||||
-rw-r--r-- | mu.arc.t | 5 |
2 files changed, 10 insertions, 2 deletions
diff --git a/mu.arc b/mu.arc index 73c9e92e..e22dec52 100644 --- a/mu.arc +++ b/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) diff --git a/mu.arc.t b/mu.arc.t index fdd30e4a..1b9eedb6 100644 --- a/mu.arc.t +++ b/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 |