chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] keyword args not assigned in program.


From: Alan Post
Subject: [Chicken-users] keyword args not assigned in program.
Date: Sat, 20 Nov 2010 06:59:38 -0700

I'm dealing with a frustrating bug--I haven't been able to turn it
into a simple test case.  Will you let me explain what is going on,
why I haven't been able to make a test case, and then offer advice?

I have a compiler to convert a PEG grammar to scheme.  In my test
suite, I have a line:

<++> tests/run.scm
  (set! compiler (eval (compile "test.peg")))
<-->

The test.peg file references a symbol defined in tests/run.scm, and
I run the compiler with some sample data:

<++> tests/run.scm # this test fails!
  (define (transform #!rest rest #!key key0)
    (pretty-print rest)
    key0)

  (set! compiler (eval (compile "test.peg")))

  (compiler "a")
<-->

The compiler works, it calls |transform|, but the #!key arguments to
transform are not properly mapped.  |rest| is:

  (key0: 0 key1: 1)

but |key0| is:

  #f

So my #!rest arguments are seeing the tagged values, but the tagged
values aren't being assigned to #!key arguments.

That is simple enough to diagnose.  I've made my |test.peg| file,
the one I'm compiling, as simple as possible.  I want to remove the
compiler, because it is hands down the largest part of the test.

I run |(compile "teg.peg")| and save the output to |"out.scm"|,
converting my test to this:

<++> tests/run.scm # this test works!
  (define (transform #!rest rest #!key key0)
    (pretty-print rest)
    key0)

  (call-with-output-file "out.scm"
    (lambda (port)
      (write (compile "test.peg") port)))
  (set! compiler (eval (call-with-input-file "out.scm" read)))

  (compiler "a")
<-->

I have a temporary file that I write and then read.  The output of
the compiler is the same, but the method that the sexpr is evaluated
changes to have an intermediate file.

Suddenly, my test works and |key0| receives the correct value.

It appears that directly evaluating the result of the compiler causes
#!key arguments not to be assigned, but if I save that same result
and read it back in, things work fine.

What is going on?!  My closest guess is that I have some kind of gc
problem that I only trigger with a program of a particular size.  I'm
not sure where to go from here, as the test case is still a few
thousand lines of code, given that the compiler seems integral to
the test case.

-Alan
-- 
.i ko djuno fi le do sevzi



reply via email to

[Prev in Thread] Current Thread [Next in Thread]