ClojureScript

(object? nil) throws TypeError exception

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    r2127
  • Patch:
    Code and Test

Description

Some primitive types and host objects throw an exception on property access. I know null does this, but I see reports that window.location on Firefox does this too, possibly other objects.

This is a problem because the implementation of object? is

o.constructor === Object{/code}, which causes
(object? nil)

to throw a TypeError exception. Suggested patch attached.

The patch guards the constructor test with a try-except clause. I don't know what the performance implications of this are, but object? is only used once in cljs core (in pr-writer, in a giant cond, where it could be moved further down), so it probably doesn't matter much.

(Note: I don't have a CA yet--it's in the mail.)

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: