justinethier / cyclone

:cyclone: A brand-new compiler that allows practical application development using R7RS Scheme. We provide modern features and a stable system capable of generating fast native binaries.
http://justinethier.github.io/cyclone/
MIT License
823 stars 42 forks source link

Bugs with vector literals in compiled code #462

Closed justinethier closed 3 years ago

justinethier commented 3 years ago

For example the following prints #(a b) instead of `#("string 1" "string 2"):

(import (scheme base) (scheme write))                                            

(define a "string 1")                                                            
(define b "string 2")                                                            
(define vec #(1 2))                                                              

(write #(a b))                                                                   
(newline)  

Even more concerning:

(import (scheme base) (scheme write))                                            

(define a "string 1")                                                            
(define b "string 2")                                                            
(define vec #(1 2))                                                              

(write vec)                                                                   
(newline)  

This program throws a runtime error:

#(Cyc_display: bad tag x=30

justinethier commented 3 years ago

The first case is handled how we would expect in R7RS, it defines a literal.

The second case has now been fixed, there was an issue with how top-level vector literals were being compiled.