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:
@@ -735,6 +735,15 @@ whitespace aside, THEN?"
|
||||
"struct p* x = &s"))
|
||||
(test-assert "a wildcard inside an array"
|
||||
(emits? (in-fn "(var t [_ 3] #([int 3] : 1 2 3))") "int t[3]"))
|
||||
;; 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