mirror of
https://github.com/carp-lang/Carp.git
synced 2024-09-17 08:27:45 +03:00
Fixed copy function for generic types.
This commit is contained in:
parent
73b120bd53
commit
026251a241
@ -25,15 +25,11 @@
|
||||
;; &(str
|
||||
;; &(Pair.init 5.6 true))))
|
||||
|
||||
(deftype Inner [])
|
||||
(deftype Outer [stuff Inner])
|
||||
(defn f []
|
||||
(let [b (Outer.init (Inner.init))]
|
||||
(IO.println (ref (Outer.str &b)))))
|
||||
(deftype (Trivial t) [x t])
|
||||
|
||||
(deftype (Gen t) [x t])
|
||||
(defn g []
|
||||
(IO.println (ref (Gen.str &(Gen.init (Gen.init [true false]))))))
|
||||
(defn construct-from-ref [r]
|
||||
(Trivial.init @r))
|
||||
|
||||
(defn main []
|
||||
(do (f) (g)))
|
||||
(defn-do main []
|
||||
(println* &(Array.repeat-indexed 5 Trivial.init))
|
||||
(println* &(Array.copy-map construct-from-ref &(Array.repeat-indexed 5 Trivial.init))))
|
||||
|
@ -132,7 +132,7 @@ templateForDelete _ _ _ _ _ = Nothing
|
||||
templateForCopy :: TypeEnv -> Env -> [String] -> Ty -> [XObj] -> Maybe ((String, Binder), [XObj])
|
||||
templateForCopy typeEnv env insidePath structTy@(StructTy typeName _) [XObj (Arr membersXObjs) _ _] =
|
||||
Just (instanceBinderWithDeps (SymPath insidePath "copy")
|
||||
(FuncTy [RefTy structTy] (StructTy typeName []))
|
||||
(FuncTy [RefTy structTy] structTy)
|
||||
(templateCopy typeEnv env (memberXObjsToPairs membersXObjs)))
|
||||
templateForCopy _ _ _ _ _ = Nothing
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user