Opened 10 years ago
Last modified 8 years ago
#1145 assigned defect
Issue with matchable and the module system
Reported by: | Mario Domenech Goulart | Owned by: | sjamaan |
---|---|---|---|
Priority: | major | Milestone: | someday |
Component: | extensions | Version: | 4.9.x |
Keywords: | matchable, module system | Cc: | Alex Shinn |
Estimated difficulty: | hard |
Description
Here are some cases that illustrate the problem: http://paste.call-cc.org/paste?id=4d676dd966a3e3c5b5a3d216014d07a7fa746c6f
Change History (14)
comment:1 Changed 10 years ago by
comment:2 Changed 10 years ago by
Owner: | set to Alex Shinn |
---|---|
Status: | new → assigned |
I believe this is an issue in the expansion of the matchable macro. ie, it's a bug in the egg, not in the expander or module system.
comment:3 Changed 10 years ago by
Component: | unknown → extensions |
---|
comment:4 Changed 10 years ago by
The problem is unlikely directly in matchable, since it works on many other implementations.
comment:5 Changed 10 years ago by
Have you tested my trivial test under other implementations? It's the following:
(match 'some-form ((or ('x a) ('y b)) 'a-macro) (else #f))
comment:6 Changed 10 years ago by
Yes, I test that and variations under chibi and scheme48 (which is
about as strict as you get), and couldn't find any errors. The test
suite also already has similar cases.
Mario's example that fails depending on the imports suggests it's
definitely an interaction with Chicken's module system and/or
expander.
comment:7 Changed 10 years ago by
Owner: | changed from Alex Shinn to sjamaan |
---|
OK, thanks. I'll take a another, closer look then!
comment:8 Changed 10 years ago by
Component: | extensions → expander |
---|
comment:9 Changed 9 years ago by
Milestone: | someday → 4.11.0 |
---|
OK, I never took a look at it; let's move it up to the 4.11 milestone
comment:10 Changed 9 years ago by
Alex, I tried it under Chibi just now, and it seems to indicate the bug really is in matchable:
$ ./chibi-scheme > (import (chibi match)) > (match 'some-form ((or ('x a) ('y b)) 'a-macro) (else #f)) WARNING: reference to undefined variable: a WARNING: reference to undefined variable: b #f
So this seems exactly the same message that CHICKEN gives, except in CHICKEN, a module can't be resolved when you have undefined variables.
comment:12 Changed 9 years ago by
If you want to debug this, see the generated source, you can try putting the match expression outside of a module, and then compile with csc -debug 2 test.scm
. It will output something like:
[canonicalized] (##core#callunit "library") (##core#callunit "eval") (##core#callunit "chicken_2dsyntax") (##core#undefined) (let ((t11 (let ((t10 (##sys#require 'matchable))) (##core#undefined)))) (##core#undefined)) (let ((v1316 'some-form)) (let ((failure1927 (##core#lambda () (let ((failure3038 (##core#lambda () (error 'match '"no matching pattern")))) (let ((else97 v1316)) '#f))))) (let ((sk2587591 (##core#lambda (b592 a593) 'a-macro))) (let ((fk2595599 (##core#lambda () (if (pair? v1316) (let ((w680687 (car v1316)) (x682688 (cdr v1316))) (if (equal? w680687 'y) (if (if (pair? x682688) (null? (cdr x682688)) '#f) (let ((w770775 (car x682688))) ;; The "a" in the expression below is clearly unbound (let ((b831 w770775)) (sk2587591 b831 a))) (failure1927)) (failure1927))) (failure1927))))) (if (pair? v1316) (let ((w911918 (car v1316)) (x913919 (cdr v1316))) (if (equal? w911918 'x) (if (if (pair? x913919) (null? (cdr x913919)) '#f) (let ((w10011006 (car x913919))) ;; The "b" in the expression below is clearly unbound (let ((a1062 w10011006)) (sk2587591 b a1062))) (fk2595599)) (fk2595599))) (fk2595599)))))) ((##sys#implicit-exit-handler)) (##core#undefined)
There's a bit of a problem with CHICKEN in that it bails out early when a module is unresolved, so you can't see exactly how it's compiled inside a module, but I think the problem is clear in the code above, where I put the comments.
comment:13 Changed 9 years ago by
Component: | expander → extensions |
---|---|
Milestone: | 4.11.0 → someday |
After pointing this out to Alex on IRC, he agreed that it's a problem with the code emitted by matchable, not so much with CHICKEN itself. Moving this to "someday" and "extensions".
comment:14 Changed 8 years ago by
Estimated difficulty: | → hard |
---|
Peter commented on IRC: