Skip to content

Instantly share code, notes, and snippets.

@frenchy64
Created April 12, 2014 15:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frenchy64/10542732 to your computer and use it in GitHub Desktop.
Save frenchy64/10542732 to your computer and use it in GitHub Desktop.
(ns clojure.core.typed.test.unsound-record
(:require [clojure.core.typed :as t]))
(t/ann-record Foo [a :- Number])
(defrecord Foo [a])
(t/ann unsound [(t/Map Any Any) -> Number])
(defn unsound [r]
(let [r (assoc r :a nil)]
(assert (instance? Foo r))
(inc (:a r))))
; NPE at runtime
(fn []
(unsound (->Foo 1)))
; check-ns
; ...
; :ok
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment