mirror of
https://github.com/carp-lang/Carp.git
synced 2024-10-11 12:37:32 +03:00
57 lines
1.3 KiB
Plaintext
57 lines
1.3 KiB
Plaintext
;; This file contains examples of unsolved bugs
|
|
|
|
(Debug.sanitize-addresses)
|
|
(Project.config "print-ast" 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))))
|
|
|
|
;; ;; This crashes the compiler:
|
|
;; (defn x [a] (the Inthdfdf a))
|
|
|
|
;; ;; The error message for this is really bad:
|
|
;; (defn f []
|
|
;; (let [s @"hej"]
|
|
;; (do (delete s)
|
|
;; s)))
|
|
|
|
;; Setting ref to value in short-lived scope
|
|
;; (defn main []
|
|
;; (let-do [r &[1 2 3]]
|
|
;; (let [xs [4 5 6]]
|
|
;; (set! r &xs))
|
|
;; (println* r)))
|
|
|
|
;; '=' resolves to wrong thing
|
|
(deftype (Foo t) [x t])
|
|
(defmodule Foo
|
|
(defn = [a b]
|
|
(= (Foo.x a) (Foo.x b))))
|
|
|
|
(defn main []
|
|
(do (println* (= &(Foo.init 123) &(Foo.init 666)))
|
|
(println* (= &(Foo.init 123) &(Foo.init 123)))))
|