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

@@ -498,6 +498,9 @@
(test-assert "a capture named like a parameter is refused"
(reports? (in-fn "(var c (closure ((int)) int) (closure ((a int)) int (a) (return a)))")
"a capture and a parameter share a name"))
(test-assert "so is one captured twice"
(reports? (in-fn "(var c (closure () int) (closure () int (a a) (return a)))")
"two captures share a name"))
(test-assert "so is one redeclared at the top of the body"
(reports? (in-fn "(var c (closure () int) (closure () int (a) (var a int 5) (return a)))")
"the body redeclares a capture"))