<< Back to previous view

[CLJS-177] js->clj should convert JavaScript null to Clojure nil Created: 10/Apr/12  Updated: 27/Jul/13  Resolved: 10/Apr/12

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

Type: Defect Priority: Minor
Reporter: Jason Rudolph Assignee: Unassigned
Resolution: Completed Votes: 0
Labels: patch,

Attachments: File js-null-to-clj-nil.diff    
Patch: Code and Test

 Description   

Prior to commit ebf45f5 [A], js->clj converted JavaScript null to Clojure nil without any errors.

As of commit ebf45f5 (related to CLJS-175), js->clj throws a TypeError when it encounters JavaScript null:

TypeError: Cannot read property 'constructor' of null
b===c}function q(b,c){return gb.call(e,b,c)}function pb(b){return b.construct
^
TypeError: Cannot read property 'constructor' of null

The attached patch [B] adds a test to demonstrate the issue and provides a suggested fix.

Note: CLJS-175 intentionally limited the types of objects it would attempt to convert to Clojure code. For example, CLJS-175 notes that conversion "doesn't make sense for something like Date or RegExp." I agree for those types of objects, but "null" seems straightforward enough that it should be converted.

[A] https://github.com/clojure/clojurescript/commit/ebf45f5
[B] Also viewable here: https://github.com/jasonrudolph/clojurescript/compare/master...js-null-to-clj-nil



 Comments   
Comment by David Nolen [ 10/Apr/12 7:38 PM ]

Fixed, http://github.com/clojure/clojurescript/commit/9319579acfc4fc9dbcf6e79f611afad707f97579

Generated at Fri Dec 19 21:04:37 CST 2014 using JIRA 4.4#649-r158309.