[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-janitors] #1437: csi needs double imports
From: |
Chicken Trac |
Subject: |
Re: [Chicken-janitors] #1437: csi needs double imports |
Date: |
Sat, 28 Apr 2018 09:48:44 -0000 |
#1437: csi needs double imports
---------------------------------+---------------------------
Reporter: mario | Owner:
Type: defect | Status: new
Priority: major | Milestone: 5.0
Component: expander | Version: 5.0
Resolution: | Keywords: double import
Estimated difficulty: |
---------------------------------+---------------------------
Comment (by sjamaan):
Looks like this will also fail when using the compiler:
{{{
(begin
(import srfi-1)
(print (assoc 'a '((a . 1)) eq?)))
}}}
When compiling this:
{{{
Warning: at toplevel:
(test.scm:3) in procedure call to `scheme#assoc', expected 2 arguments
but was given 3 arguments
}}}
And when run, it will fail too.
The reason is that in the compiler, we walk the toplevel using `map`,
which calls `canonicalize-expression` on each toplevel expression. This
in turn accesses `(##sys#current-environment)` once at the start and then
passes this on as the syntax environment (`se`), which gets passed along.
When expanding an import, we update `##sys#current-environment`, but this
won't affect `se` because that's another list (at best, it's the tail of
the new `##sys#current-environment`).
In the evaluator, the same happens. So you'd have to map `eval` over the
"toplevel" expressions, instead.
--
Ticket URL: <https://bugs.call-cc.org/ticket/1437#comment:9>
CHICKEN Scheme <https://www.call-cc.org/>
CHICKEN Scheme is a compiler for the Scheme programming language.