refuse a malformed closure capture

((+ a 1)) was a capture named `+' holding a.
This commit is contained in:
2026-10-19 10:23:59 +03:00
parent 784250d061
commit 6e9b70e7f1
2 changed files with 7 additions and 2 deletions

View File

@@ -539,6 +539,10 @@ whitespace aside, THEN?"
;; captures are a closure's other parameters, under C's rule for
;; those: no two alike, and none redeclared at the body's top level.
;; Both were C's redefinition errors
;; ((+ a 1)) was a capture named `+', holding a
(test-assert "a capture is a name, or a name and a value"
(reports? (in-fn "(var c (closure () int) (closure () int ((+ a 1)) (return 1)))")
"a capture is a name, or (name value)"))
(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"))