kriskowal/q — pull request #517 by Yogu (2014-04-19 10:37:19+00:00)
Title: Q.async() no longer unwraps returned promises

#499 fixed a bug, but introduced another one:

var Q = require('q');
var test = Q.async(function*() {
return Q(123);
});
test().then(console.log);

prints `123`, but should print `{ state: "fulfilled", value: 123 }`.

**Why should it print the promise?**

`async` should not guess on the return value, but instead provide a static, reliable semantic that chains all `yield`ed promises, and finally resolves in the returned value - no matter what the returned value is.

I stumbled upon this bug because I have a class `Task` that derives from `Promise`, and I needed to return the task (and not wait until the task itself is fulfilled).

**Where is the bug located?**

`async` calls [`Q()`](https://github.com/kriskowal/q/blob/v1/q.js#L449), wich does some magic typeguessing with the parameter, i.e. if the parameter is a promise, it does not wrap it in a promise as it does with other values.

It would be awesome if you could deploy a bugfix release after this.