diff --git a/lib/prelude.ml b/lib/prelude.ml index 36cc40de..52db7810 100644 --- a/lib/prelude.ml +++ b/lib/prelude.ml @@ -554,11 +554,11 @@ let source = {flan| ;; in. Owned by the caller: (free v), or let a (free-all a) take the region. ;; ;; This is the one that proves the containers and the generics compose. It -;; allocates — (vec-new t), push, returns (Vec t) — and the type-erased Vec +;; allocates — (vec-new $t), push, returns (Vec $t) — and the type-erased Vec ;; runtime needed no change at all, because SizeOf and AlignOf are computed at ;; the instantiation site, where the element type is concrete. (defn filter [s [const $t] keep? (Fn [$t] bool)] (Vec $t) - (let [v (vec-new t)] + (let [v (vec-new $t)] (dotimes [i (length s)] (when (keep? (at s i)) (push v (at s i)))) @@ -570,7 +570,7 @@ let source = {flan| ;; the map's own key bytes and is good for as long as they are. (defn map-keys [m (Map $k $v)] (Vec $k) {:where (hashable? $k)} - (let [out (vec-new k) + (let [out (vec-new $k) cur (i64 0) key (the $k (zeroed)) val (the $v (zeroed))] @@ -580,7 +580,7 @@ let source = {flan| (defn map-values [m (Map $k $v)] (Vec $v) {:where (hashable? $k)} - (let [out (vec-new v) + (let [out (vec-new $v) cur (i64 0) key (the $k (zeroed)) val (the $v (zeroed))] diff --git a/test/programs/map-keys.flan b/test/programs/map-keys.flan index 6bd61733..7e9baf81 100644 --- a/test/programs/map-keys.flan +++ b/test/programs/map-keys.flan @@ -1,5 +1,12 @@ ;; map-keys and map-values: the prelude's two generic walks over a map. Block ;; order is the hash's, so what comes back is sorted before it is printed. +;; +;; The three globals are named after the prelude's type variables. A generic's +;; body names its element type as $t, $k or $v, never bare, because a bare +;; name there is an expression and would find these. +(defonce t i32 0) +(defonce k i32 0) +(defonce v i32 0) (defn main [] i32 (let [m (map-new i32 i64)]