Opened 10 years ago

Closed 10 years ago

#1154 closed defect (fixed)

error using 'bindings' egg from an 'included' script

Reported by: John Foerch Owned by: sjamaan
Priority: major Milestone: someday
Component: unknown Version: 4.9.x
Keywords: Cc: John Foerch
Estimated difficulty:

Description

The setup for this error is to have one script that includes another script, and the second script has (use bindings) and some use of the forms provided by the bindings egg. For example:

######### test-case.scm

(import chicken scheme)

(use extras)

(include "script-that-uses-bindings.scm")

######### script-that-uses-bindings.scm

(use bindings)

(pp (bind (a b c) (list 1 2 3) (list c b a)))

run with: csi -s test-case.scm

This resulted in the following error:

Error: during expansion of (dbind21 ...) - unbound variable: macro-helpers#seq-destruc

Call history:

<syntax> (##core#require-extension (bindings) #t)
<syntax> (##core#begin (##core#begin (##core#begin (##sys#require (quote bindings))) (import bindings)) (##co......
<syntax> (##core#begin (##core#begin (##sys#require (quote bindings))) (import bindings))
<syntax> (##core#begin (##sys#require (quote bindings)))
<syntax> (##sys#require (quote bindings))
<syntax> (quote bindings)
<syntax> (##core#quote bindings)
<syntax> (import bindings)
<syntax> (import scheme (only macro-helpers define-syntax-rule replace* seq-length seq-ref seq-tail bind-exce......
<syntax> (import scheme (only chicken receive case-lambda define-values let-values make-parameter error signa......
<syntax> (##core#undefined)
<syntax> (##core#undefined)
<syntax> (##core#undefined)
<syntax> (##core#undefined)
<syntax> (pp (bind (a b c) (list 1 2 3) (list c b a)))
<syntax> (bind (a b c) (list 1 2 3) (list c b a)) <--

If you use 'load' instead of 'include', there is no error. Also if the first script (test-case.scm) does (use bindings) there is no error.

I tested this with Chicken 4.8.0.3 and bindings egg version 3.1. Another person reported that they could reproduce the error with Chicken 4.9 as well.

Attachments (1)

fix-bindings-for-compilation.diff (1.2 KB) - added by Moritz Heidkamp 10 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 Changed 10 years ago by John Foerch

I receive the same error if I try to use the bindings egg inside of a module. Here is a test case for that:

######### bindings-egg-inside-of-module.scm

(module bindings-in-a-module-test-case

*

(import chicken scheme)

(use bindings

extras)

(pp (bind (a b c) (list 1 2 3) (list c b a)))

)

comment:2 Changed 10 years ago by John Foerch

Cc: John Foerch added

comment:3 in reply to:  2 ; Changed 10 years ago by juergen

Resolution: fixed
Status: newclosed

Replying to retroj:

This is neither a bug of Chicken nor of the bindings egg.

Chicken needs the library bindings to do its work.

So the following will do in

test-case.scm:


(require-library bindings)
(import scheme chicken extras)
(include "script-that-uses-bindings.scm")

and in

script-that-uses-bindings.scm:


(import bindings)
(pp (bind (a b c) (list 1 2 3) (list c b a)))

as well as in

binding-egg-inside-of-module.scm:


(module bindings-in-a-module-test-case *

(import chicken scheme bindings extras)
(pp (bind (a b c) (list 1 2 3) (list b c a))))

comment:4 in reply to:  3 Changed 10 years ago by juergen

Replying to juergen:

Replying to retroj:

This is neither a bug of Chicken nor of the bindings egg.

Chicken needs the library bindings to do its work.

So the following will do in

test-case.scm:


(require-library bindings)
(import scheme chicken extras)
(include "script-that-uses-bindings.scm")

and in

script-that-uses-bindings.scm:


(import bindings)
(pp (bind (a b c) (list 1 2 3) (list c b a)))

as well as in

binding-egg-inside-of-module.scm:


(module bindings-in-a-module-test-case *

(import chicken scheme bindings extras)
(pp (bind (a b c) (list 1 2 3) (list b c a))))

Of course, the first line in the last file should be

(require-library bindings)

I forgot that, sorry!

comment:5 Changed 10 years ago by sjamaan

Resolution: fixed
Status: closedreopened

Hey Juergen,

I would like to look into this. I agree with John that it's a bit weird how this works. Possibly it's a bug in core, or simply a misunderstanding of how it's supposed to work on our side. Either way, I'd prefer to look into it to clarify the issue.

comment:6 Changed 10 years ago by sjamaan

Owner: set to sjamaan
Status: reopenedassigned

comment:7 Changed 10 years ago by Moritz Heidkamp

There was a bug in the bindings module which made it impossible to use in compiled code: The binding syntax would sometimes expand to raw procedures rather than identifiers naming these procedures. This works in the interpreter but not in the compiler. Attaching a patch that fixes this issue at least for the case I found.

Changed 10 years ago by Moritz Heidkamp

comment:8 Changed 10 years ago by juergen

Resolution: fixed
Status: assignedclosed

Version 3.3 is now available, which fixes the reported problem (albeit a bit differently than in the patch above). Moreover, in this version the helper module macro-helpers is extracted into its own library. That simplifies matters a bit.
Juergen

Note: See TracTickets for help on using tickets.