forked from alex-eg/sex
read an array's length as types does
Inference took only an integer for a length, and read a name there as part of the element type: [_ N] did not solve, and an array of [int N] decayed to int N *.
This commit is contained in:
@@ -678,6 +678,15 @@
|
||||
(emits? "(typedef count int) (fn g () count (return 0))
|
||||
(fn f () void (var x _ (g)))"
|
||||
"count x = g()"))
|
||||
;; only an integer was taken for a length; a name was read as part
|
||||
;; of the element's
|
||||
(test-assert "of a named length"
|
||||
(emits? "(define N 3) (fn f () void (var t [_ N] #(1 2 3)))" "int t[N]"))
|
||||
(test-assert "which an array of decays from as any other"
|
||||
(emits? "(define N 3) (fn f () void (var a [int N]) (var p _ (+ a 1)))"
|
||||
"int * p = a + 1"))
|
||||
(test-assert "while a length left to work out is not one"
|
||||
(reports? (in-fn "(var t [_ _] #(1 2))") "cannot infer"))
|
||||
;; a variable had nowhere to keep a qualifier written on it, and
|
||||
;; what it was solved to came out without
|
||||
(test-assert "a qualified wildcard keeps its qualifier"
|
||||
|
||||
Reference in New Issue
Block a user