Hi folks,
I wrote a small piece of Clojure code of which I thought it would use the
ClojureScript subset of Clojure, so that it could be compiled to JavaScript.
But when I compile it (successfully) I get invalid JavaScript and I get an
exception when running it in the browser.
This seems to occur only when I use object destructuring within deftype. A
small sample:
(ns test)
(defprotocol Test
(foo [this data]))
(deftype Foo []
Test
(foo [this {:keys [bar a b c] :as d}]
(.log js/console bar)))
This compiles down to:
// ...
/**
* @constructor
*/
test.Foo = (function (){
})
test.Foo.cljs$core$IPrintable$_pr_seq = (function (this__262__auto__){
return cljs.core.list.call(null,"test.Foo");
});
test.Foo.prototype.test$Test$ = true;
// The next line isn't valid javascript it still contains the :keys keyword!
test.Foo.prototype.test$Test$foo = (function (this$,{:keys [bar a b c],
_COLON_as d_RBRACE_){
var this__2633 = this;
return console.log(test.bar);
});
test.Foo;
I tested destructuring in normal fns, which worked fine.
Is there something wrong with my snippet or could this be a bug?
I'm using the latest version of cljsc from github
(1028ca12f169322e31d7967d8c385165cf773665)
Best regards
Ben
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en