mirror of
https://github.com/carp-lang/Carp.git
synced 2024-10-12 04:58:18 +03:00
41 lines
918 B
Plaintext
41 lines
918 B
Plaintext
;; This file contains examples of unsolved bugs
|
|
|
|
(load "Debug.carp")
|
|
(Debug.sanitize-addresses)
|
|
(project-set! "printAST" "true")
|
|
|
|
;; This shouldn't compile:
|
|
;; (defn faulty-repeat [n inpt]
|
|
;; (let [str ""]
|
|
;; (do
|
|
;; (for [i 0 n]
|
|
;; (set! str &(append @str @inpt)))
|
|
;; @str)))
|
|
;; (defn main []
|
|
;; (let [strings (faulty-repeat 20 "x")]
|
|
;; (IO.println &strings)))
|
|
|
|
;; ;; Dangling reference to member variable.
|
|
;; (deftype S [f String])
|
|
;; (defn main []
|
|
;; (let [s (S.init @"hello")
|
|
;; r (S.f &s)
|
|
;; _ (S.set-f s @"bye")]
|
|
;; (IO.println r)))
|
|
|
|
;; ;; Dangling reference to variable.
|
|
;; (defn main []
|
|
;; (let [s @"hello"
|
|
;; r &s]
|
|
;; (do (String.delete s)
|
|
;; (IO.println r))))
|
|
|
|
;; Problem with string deallocation in branches.
|
|
(deftype Foo [])
|
|
(defn f [x] (let [_ (the &Foo x)] ()))
|
|
|
|
(defn ifmem []
|
|
(if false
|
|
(f &(Foo.init))
|
|
()))
|