<< Back to previous view

[CLJS-890] Incorrect behaviour of (str obj) when obj has valueOf method Created: 24/Nov/14  Updated: 24/Nov/14

Status: Open
Project: ClojureScript
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Nikita Beloglazov Assignee: Unassigned
Resolution: Unresolved Votes: 1
Labels: None


 Description   

Example

(str #js {"toString" (fn [] "hello") "valueOf" (fn [] 42)}) ; => "42"

The problem in the fact that ClojureScript uses concatenation to convert values to strings and that doesn't work well with objects which have valueOf() method overriden.

Example in js:

var obj = {
    toString: function() { return 'hello'; },
    valueOf: function() { return 42; }
};
console.log(String(obj)); => 'hello'
console.log(obj.toString()); => 'hello'
console.log('' + obj); => '42'

Potential solution might be to use String() function. Using toString() won't work as described in this issue: http://dev.clojure.org/jira/browse/CLJS-847



 Comments   
Comment by Kevin Neaton [ 24/Nov/14 10:34 AM ]

Is there a valid use case where toString and valueOf are not in sync? E.g.

(not= (.toString x) (js/String (.valueOf x))

If not, is it "incorrect" for the two methods to be out of sync?

Comment by Nikita Beloglazov [ 24/Nov/14 10:40 AM ]

Here is an example of such use case: https://github.com/processing-js/processing-js/blob/master/src/Objects/Char.js
That's how I found this bug.





[CLJS-889] 2 characters not supported in re-pattern: \u2028 \u2029 Created: 18/Nov/14  Updated: 18/Nov/14

Status: Open
Project: ClojureScript
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect Priority: Trivial
Reporter: Dave Sann Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Environment:

[org.clojure/clojurescript "0.0-2371"]
ubuntu



 Description   

The following 2 patterns

(re-pattern "[\u2028]")
(re-pattern "[\u2029]")

Cause:

SyntaxError: Invalid regular expression: missing terminating ] for character class

They are probably somewhat rare characters in practice.

http://www.fileformat.info/info/unicode/char/2028/index.htm
http://www.fileformat.info/info/unicode/char/2029/index.htm






[CLJS-888] Make better use of newlines in emitted javascript Created: 17/Nov/14  Updated: 20/Nov/14  Resolved: 20/Nov/14

Status: Closed
Project: ClojureScript
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Herwig Hochleitner Assignee: Unassigned
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File 0001-CLJS-888-Better-placement-of-newlines-in-emitter.patch     Text File 0002-CLJS-888-Omit-redundant-around-emitted-recur.patch    

 Description   

Problem Statement

Javascript debuggers are pretty line-oriented and so it's often very difficult to follow control flow without source maps. Even with source maps it's often not feasible to properly work with breakpoints in emitted Javascript.

Proposal

Emit more newlines and do so in places that would make sense when hand-coding javascript. The attached patch came from experience in debugging on IE and makes the emitter break up lines pretty neatly, with the exception of deeply nested literals.



 Comments   
Comment by Herwig Hochleitner [ 17/Nov/14 4:11 PM ]

Patch 0002 is not strictly in scope of the ticket title, but fits within an emitter cleanup, so I think it could be reviewed as part of this ticket.

Comment by David Nolen [ 20/Nov/14 11:24 AM ]

fixed
https://github.com/clojure/clojurescript/commit/124998c05dea844e892cd28b40f89eecdd442e1a
https://github.com/clojure/clojurescript/commit/bf2d2413dcb46b2cec9a00e37af407006634c804





[CLJS-887] cljs.repl.browser does not serve css by default Created: 17/Nov/14  Updated: 17/Nov/14

Status: Open
Project: ClojureScript
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect Priority: Trivial
Reporter: Christopher Shea Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: repl
Environment:

*


Attachments: File cljs-browser-repl-serve-css.diff    
Patch: Code

 Description   

A browser repl's server serves js, cljs, map, and html files by default, but not css.






Generated at Mon Nov 24 10:45:33 CST 2014 using JIRA 4.4#649-r158309.