diff options
-rw-r--r-- | mu.arc | 6 | ||||
-rw-r--r-- | mu.arc.t | 15 |
2 files changed, 18 insertions, 3 deletions
diff --git a/mu.arc b/mu.arc index 64f63218..384316a4 100644 --- a/mu.arc +++ b/mu.arc @@ -151,8 +151,10 @@ (def addr (loc) (ret result v.loc (whenlet base rep.routine*!default-scope - (++ result base)) - (if (pos 'deref metadata.loc) + (if (< result memory*.base) + (++ result base) + (die "addr: no room for var @result"))) + (when (pos 'deref metadata.loc) (zap memory* result)))) (def addrs (n sz) diff --git a/mu.arc.t b/mu.arc.t index 8fbbf7ad..a715b76b 100644 --- a/mu.arc.t +++ b/mu.arc.t @@ -1384,7 +1384,7 @@ (new-trace "set-default-scope") (add-fns '((main - ((default-scope scope-address) <- new (scope type) (1 literal)) + ((default-scope scope-address) <- new (scope type) (2 literal)) ((1 integer) <- copy (23 literal))))) (let before Memory-in-use-until ;? (set dump-trace*) @@ -1394,4 +1394,17 @@ (is 23 (memory* (+ before 1)))) (prn "F - default-scope implicitly modifies variable locations"))) +(reset) +(new-trace "default-scope-bounds-check") +(add-fns + '((main + ((default-scope scope-address) <- new (scope type) (2 literal)) + ((2 integer) <- copy (23 literal))))) +;? (set dump-trace*) +(run 'main) +;? (prn memory*) +(let last-routine (deq completed-routines*) + (if (no rep.last-routine!error) + (prn "F - default-scope checks bounds"))) + (reset) ; end file with this to persist the trace for the final test |