refuse a closure capturing one name twice

check-capture-names held captures against the parameters and the body,
not against each other: (n n) gave C two members and two parameters n.
This commit is contained in:
2026-10-27 22:41:06 +03:00
parent acbd4928f5
commit 28aaaf637c
2 changed files with 8 additions and 0 deletions

View File

@@ -2031,6 +2031,11 @@
(when (memq name parameters)
(sex-error form "a capture and a parameter share a name" name)))
names)
(let twice ((names names))
(when (pair? names)
(when (memq (car names) (cdr names))
(sex-error form "two captures share a name" (car names)))
(twice (cdr names))))
(for-each (lambda (statement)
(match statement
(('var (? symbol? name) . _)