larcenists / larceny

Larceny Scheme implementation
Other
202 stars 32 forks source link

Compiler produces invalid tokens in .slfasl.<number>-files #770

Closed mnieper closed 8 years ago

mnieper commented 8 years ago

When I try to compile the library

(define-library (mylib)
  (import (scheme base))
  (begin
    (define-record-type <record>
      (make-record syntax foo)
      #f
      (syntax syntax)
      (foo foo)))

with (compile-stale-libraries) from (larceny compiler), I get the following error:

Compiling mylib.sld

Error: no handler for exception #<record &compound-condition>
Compound condition has these components: 
#<record &lexical>
#<record &who>
    who : get-datum
#<record &message>
    message : "lexical error: incomplete or illegal token in line 1: ## "
#<record &irritants>
    irritants : ("#" "#" #<INPUT PORT mylib.slfasl.55286>)

Terminating program execution.

The error does not show up if I change the name of the field syntax to something different, or if I remove the second field foo, or if I add a third field bar.

WillClinger commented 8 years ago

This is a rather interesting bug in Larceny's write procedures.

The vector of field names is written to an intermediate file, which is later read back. If the first field name is syntax, and the second is any other symbol, say foo, then the vector of field names should be written as #(syntax foo).

Unfortunately, Larceny's write procedures write a vector v by writing # followed by the usual printed representation of (vector->list v). In R6RS, (syntax foo) is abbreviated #'foo, so the vector gets written as ##'foo instead of #(syntax foo).

Fixing Larceny's write procedures to print vectors correctly should fix this.

WillClinger commented 8 years ago

Fixed by changeset af93e654deaaa3f0600a8c02abf4fabe2b818c33