123-scratch-reset-intern.scm (730B)
1 ; Newly interned symbol names must not live in scratch. If they do, a 2 ; scratch reset can let a later symbol overwrite an earlier symtab name, 3 ; causing lookup to return the wrong global. 4 5 (define-record-type cell 6 (mk-cell head tail) 7 cell? 8 (head cell-head cell-head-set!)) 9 10 (use-scratch-heap!) 11 (define s-pair (cons 1 2)) 12 (reset-scratch-heap!) 13 (define s-cell (mk-cell 10 20)) 14 15 ;; Before the fix, parsing/evaluating s-cell here found the earlier 16 ;; s-pair symtab entry after its scratch-resident name bytes had been 17 ;; overwritten with "s-cell", so record? received the pair. 18 (if (record? s-cell) 0 (sys-exit 1)) 19 (if (cell? s-cell) 0 (sys-exit 2)) 20 (if (= 10 (cell-head s-cell)) 0 (sys-exit 3)) 21 22 (use-main-heap!) 23 (sys-exit 42)