Carp/examples/bugs.carp

41 lines
918 B
Plaintext
Raw Normal View History

2017-10-10 14:50:47 +03:00
;; This file contains examples of unsolved bugs
(load "Debug.carp")
(Debug.sanitize-addresses)
2017-12-15 17:31:56 +03:00
(project-set! "printAST" "true")
2018-01-28 08:17:23 +03:00
;; This shouldn't compile:
;; (defn faulty-repeat [n inpt]
;; (let [str ""]
;; (do
;; (for [i 0 n]
;; (set! str &(append @str @inpt)))
;; @str)))
;; (defn main []
2018-01-28 08:17:23 +03:00
;; (let [strings (faulty-repeat 20 "x")]
;; (IO.println &strings)))
2018-01-30 17:22:07 +03:00
2018-02-05 10:03:36 +03:00
;; ;; Dangling reference to member variable.
;; (deftype S [f String])
;; (defn main []
2018-02-05 10:03:36 +03:00
;; (let [s (S.init @"hello")
;; r (S.f &s)
;; _ (S.set-f s @"bye")]
;; (IO.println r)))
2018-02-05 10:03:36 +03:00
;; ;; Dangling reference to variable.
;; (defn main []
;; (let [s @"hello"
;; r &s]
;; (do (String.delete s)
;; (IO.println r))))
2018-02-05 10:03:36 +03:00
;; Problem with string deallocation in branches.
2018-02-05 10:17:09 +03:00
(deftype Foo [])
(defn f [x] (let [_ (the &Foo x)] ()))
2018-02-05 10:03:36 +03:00
(defn ifmem []
2018-02-05 10:17:09 +03:00
(if false
(f &(Foo.init))
2018-02-05 10:03:36 +03:00
()))