take an unnamed closure parameter, and refuse a variadic one
The closure's type was built from each parameter's second element, so a type alone, or the ..., crashed sexc. A variadic closure cannot work: its call helper would have to forward what C cannot.
This commit is contained in:
@@ -433,6 +433,18 @@
|
||||
(test-assert "while a block inside may shadow it"
|
||||
(emits? (in-fn "(var c (closure () int) (closure () int (a) (do (var a int 5) (g a)) (return a)))")
|
||||
"int a = 5;"))
|
||||
;; the closure's type was built from each parameter's second element,
|
||||
;; which a type alone has none of
|
||||
(test-assert "a parameter may name nothing"
|
||||
(emits? (in-fn "(var c (closure ((int) (int)) int) (closure ((int) (b int)) int () (return b)))")
|
||||
"struct ƛint__int"))
|
||||
(test-assert "and its code names it, a definition needing one before C23"
|
||||
(emits? (in-fn "(var c (closure ((int) (int)) int) (closure ((int) (b int)) int () (return b)))")
|
||||
"int ƛu0, int b)"))
|
||||
;; the call helper would have to forward the rest, which C cannot
|
||||
(test-assert "a closure cannot be variadic"
|
||||
(reports? (in-fn "(var c _ (closure ((n int) ...) int () (return n)))")
|
||||
"a closure cannot be variadic; a lambda can"))
|
||||
;; The environment is one shared union, declared in the prelude --
|
||||
;; its layout is part of the ABI two units agree on, so it cannot
|
||||
;; depend on what either file contains. `sex->c' has no prelude, so
|
||||
|
||||
Reference in New Issue
Block a user