[
https://issues.apache.org/jira/browse/COUCHDB-1397?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13199668#comment-13199668
]
Paul Joseph Davis commented on COUCHDB-1397:
--------------------------------------------
@Jason
Of course I'd look at a patch if you have one. Though as I've mentioned before,
anything that relies on parsing JavaScript or other source-to-source transforms
is going to be heavily discouraged. Also, while I understand that this will
change things from the old method, I'm not overly swayed by the relaxing
arguments here. Fact of the matter is that this is invalid JavaScript, so
regardless of what we do, it should at least be valid JavaScript. (And jslint
and other command line tools would finally start working as well).
@Jason, @Max, @James
I tried doing some hacky shortcuts to account for this. Specifically, "(" +
map_source + ")" because the "error" is literally "anonymous function at top
level scope" or some such and the parens make it kosher. But this ends up
breaking all of the code that looks like "var f = 1; function(doc)
{emit(doc._id, f);};" which is a noticeable amount of JavaScript.
@Jason, @Max, @James
I did just think of an alternative solution which would be to make the new
version use scripts instead of functions. The resulting syntax would be
something like:
"var doc = next_doc(); emit(doc._id, null)"
Which would then just be executed once for every doc. Though going this route,
we'd need some sort of context for the functions so people could precompile
their CommonJS libs and the like.
> Function expressions, evals in SpiderMonkey
> -------------------------------------------
>
> Key: COUCHDB-1397
> URL: https://issues.apache.org/jira/browse/COUCHDB-1397
> Project: CouchDB
> Issue Type: Bug
> Components: JavaScript View Server
> Affects Versions: 1.2.1
> Environment: All
> Reporter: Jason Smith
>
> New SpiderMonkey releases do not eval() a sole anonymous function expression.
> That is not a valid JavaScript statement, and so it is not a valid JavaScript
> script.
> COUCHDB-1302 addressed this for 1.1 and the 1.1.x branch. This ticket is for
> 1.2. (Sorry to spam COUCHDB-1302. I saw "Unassigned" and read "Unresolved.")
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira