Skip to content

Commit

Permalink
Fix typo and accounting of var sets.
Browse files Browse the repository at this point in the history
  • Loading branch information
stamourv committed Oct 8, 2015
1 parent 068e348 commit 9649e12
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
6 changes: 4 additions & 2 deletions compiler/ast.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
(var-id var)))
(set-var-refs! var (remq r refs)))
(define (discard-set s)
(define var (ref-var s))
(define var (set-var s))
(define sets (var-sets var))
(unless (memq s sets)
(compiler-error "discard-set: set is not in the variable's sets"
Expand Down Expand Up @@ -157,7 +157,9 @@
[(def _ _ var) ; only at the top-level, makes no sense to copy
(compiler-error "copying the definition of" (var-id var))]
[(set _ _ var) ; as above
(make-set #f '() (maybe-substitute-var var))]
(define res (make-set #f '() (maybe-substitute-var var)))
(set-var-sets! var (cons res (var-sets var)))
res]
[(if* _ _)
(make-if* #f '())]
[(prc _ _ params rest? entry)
Expand Down
1 change: 1 addition & 0 deletions tests/succeed/set-global.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
12 changes: 12 additions & 0 deletions tests/succeed/set-global.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(define *x* 0)

; Any one of the following crashes the picobit compiler:

(let ((x 1)) (set! *x* x))

((lambda () (set! *x* 1)))

(define (picobit-crashes) (set! *x* 1))
(picobit-crashes)

*x*

0 comments on commit 9649e12

Please sign in to comment.