1
0
forked from alex-eg/sex

refuse _ in a function's signature

Nothing solves it there, and it reached the C as _.
This commit is contained in:
2026-10-18 22:02:55 +03:00
parent 0a0a3f6b25
commit e0ecde6517
2 changed files with 19 additions and 0 deletions

View File

@@ -696,6 +696,17 @@
(test-assert "and a field"
(emits? "(struct h ((xs [int 4]))) (fn f ((v (struct h))) void (var p _ (. v xs)))"
"int * p = v.xs"))
;; nothing solves a `_' in a signature: it reached C as one
(test-assert "a parameter's type is written out"
(reports? "(fn id ((x _)) int (return x))" "a function's types are written out"))
(test-assert "and so is the return type"
(reports? "(fn id ((x int)) _ (return x))" "a function's types are written out"))
(test-assert "a lambda's as well"
(reports? (in-fn "(var l (fn ((int)) int) (lambda ((x _)) int (return x)))")
"a function's types are written out"))
(test-assert "and a closure's"
(reports? (in-fn "(var c (closure ((int)) int) (closure ((x int)) _ () (return x)))")
"a function's types are written out"))
(test-assert "while a function is the pointer it already is"
(emits? "(fn g ((n int)) int (return n)) (fn f () void (var p _ g))"
"int (*p)(int) = g"))