diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-01-27 20:50:21 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-01-27 20:50:21 -0800 |
commit | 4270ca61d70311230f22a718090423f5e0bdc91b (patch) | |
tree | 03e5a0c689702319edd04172986dda90c073105c | |
parent | 1724312ec9d096a9ce89352b2e8da12d558f2f62 (diff) | |
download | mu-4270ca61d70311230f22a718090423f5e0bdc91b.tar.gz |
643 - bug in use-before-set logic
Ran into this in color-repl.mu: I wasn't checking struct variables in 'get' operations. Still no way to test for use-before-set logic. But we'll fix it when we leave arc behind.
-rw-r--r-- | color-repl.mu | 7 | ||||
-rw-r--r-- | mu.arc | 19 |
2 files changed, 10 insertions, 16 deletions
diff --git a/color-repl.mu b/color-repl.mu index e6f52503..d733b8f8 100644 --- a/color-repl.mu +++ b/color-repl.mu @@ -96,13 +96,6 @@ { begin (backspace?:boolean <- equal c:character ((#\backspace literal))) (break-unless backspace?:boolean) - (len:integer-address <- get-address result:buffer-address/deref length:offset) - ; but only if we need to - { begin - (zero?:boolean <- lesser-or-equal len:integer-address/deref 0:literal) - (break-if zero?:boolean) - (len:integer-address/deref <- subtract len:integer-address/deref 1:literal) - } (loop 2:blocks) } (newline?:boolean <- equal c:character ((#\newline literal))) diff --git a/mu.arc b/mu.arc index 5de3f75d..38dc0999 100644 --- a/mu.arc +++ b/mu.arc @@ -1250,7 +1250,7 @@ (trace "cn0" instr " " canon.location " " canon.isa-field) (let (oargs op args) (parse-instr instr) ;? (tr "about to rename args: @op") - (if (in op 'get 'get-address) + (when (in op 'get 'get-address) ; special case: map field offset by looking up type table (with (basetype (typeof args.0) field (v args.1)) @@ -1269,14 +1269,15 @@ (do (set isa-field.field) (trace "cn0" "field location @idx") (= location.field idx)) - (assert nil "couldn't find field in @instr"))))) - ; map args to location indices - (each arg args - (trace "cn0" "checking arg " arg) - (when (and nondummy.arg not-raw-string.arg) - (assert (~isa-field v.arg) "arg @arg is also a field name") - (when (maybe-add arg location idx) - (err "use before set: @arg"))))) + (assert nil "couldn't find field in @instr")))))) + ; map args to location indices + (each arg args + (trace "cn0" "checking arg " arg) + (when (and nondummy.arg not-raw-string.arg (~literal? arg)) + (assert (~isa-field v.arg) "arg @arg is also a field name") + (when (maybe-add arg location idx) + ; todo: test this + (err "use before set: @arg")))) ;? (tr "about to rename oargs") ; map oargs to location indices (each arg oargs |