Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

alet with interop forms produces invalid JavaScript #48

Closed
Peeja opened this issue Jun 4, 2017 · 3 comments
Closed

alet with interop forms produces invalid JavaScript #48

Peeja opened this issue Jun 4, 2017 · 3 comments
Assignees
Labels

Comments

@Peeja
Copy link

Peeja commented Jun 4, 2017

With

[org.clojure/clojurescript "1.9.562"]
[funcool/promesa "1.8.1"]

The CLJS

(ns promesabug.core
  (:require [promesa.core :as p :include-macros true]))

(p/alet [a-binding (.aJSMethod (js-obj))]
  nil)

produces

// Compiled by ClojureScript 1.9.562 {:target :nodejs}
goog.provide('promesabug.core');
goog.require('cljs.core');
goog.require('promesa.core');
if(cljs.core._EQ_.call(null,promesa.core.await$,.aJSMethod)){
promesa.core.bind.call(null,{},(function (a_binding){
return promesa.core.promise.call(null,null);
}));
} else {
var a_binding_8847 = {}.aJSMethod();
promesa.core.promise.call(null,null);
}

//# sourceMappingURL=core.js.map

which includes cljs.core._EQ_.call(null,promesa.core.await$,.aJSMethod). .aJSMethod is nonsense JS here.

This appears to be what happens when you take the value of an interop symbol in ClojureScript; for instance, (println .aJSMethod) becomes cljs.core.println.call(null,.aJSMethod);. I'd call that a bug in ClojureScript, but until and unless that's changed, it would be nice to avoid causing the problem.

(A decent workaround for the current version of Promesa, incidentally, is to wrap the right-hand-side of the binding in (p/await …).)

@Peeja
Copy link
Author

Peeja commented Jun 4, 2017

(Bug filed against ClojureScript, but the correct compiler behavior here would be to throw a compiler error and stop building, so Promesa still needs to do something differently to make this work.)

@niwinz
Copy link
Member

niwinz commented Jul 20, 2017

Yeah, agree. The alet macro should be fixed.

@niwinz niwinz self-assigned this Jul 20, 2017
@niwinz niwinz added the bug label Jul 20, 2017
@niwinz niwinz closed this as completed in d673894 Aug 1, 2017
@niwinz
Copy link
Member

niwinz commented Aug 1, 2017

Fixed ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants