| 1 | module scheme |
| 2 | |
| 3 | fn test_nested_macro_freezing_keeps_same_spelled_private_names_in_distinct_libraries() { |
| 4 | mut vm := new() |
| 5 | value := vm.eval('(define-library (edge a) (export emit-a) (import (scheme base)) |
| 6 | (begin (define x 10) |
| 7 | (define-syntax emit-a (syntax-rules () ((_ k out) (k out x)))))) |
| 8 | (define-library (edge b) (export emit-b) (import (scheme base)) |
| 9 | (begin (define x 20) |
| 10 | (define-syntax emit-b (syntax-rules () ((_ k out a) (k out a x)))))) |
| 11 | (import (edge a) (edge b)) |
| 12 | (define-syntax build (syntax-rules () ((_ out a b) |
| 13 | (define-syntax out (syntax-rules () ((_ ) (list a b))))))) |
| 14 | (define-syntax step (syntax-rules () ((_ out a) (emit-b build out a)))) |
| 15 | (emit-a step output) (output)') or { panic(err.msg()) } |
| 16 | assert write(value) or { panic(err.msg()) } == '(10 20)' |
| 17 | gc_collect() |
| 18 | assert write(vm.eval('(output)') or { panic(err.msg()) }) or { panic(err.msg()) } == '(10 20)' |
| 19 | } |
| 20 | |