ClojureScript

js-obj emits invalid js when keys are expressions

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    CLJS 1934

Description

ClojureScript REPL:

> (js-obj (identity "a") 1)
"Error evaluating:" (js-obj (identity "a") 1) :as "{cljs.core.identity.call(null,\"a\"):1}"

But this is ok:

> (def object js-obj)
> (object (identity "a") 1)
#<[object Object]>
> (js->clj *1)
{"a" 1}

Activity

Hide
Travis Thieman added a comment -

Patch: 20131110

Rebased to 0e427a0.

Show
Travis Thieman added a comment - Patch: 20131110 Rebased to 0e427a0.
Hide
David Nolen added a comment -

Need another rebase sorry.

Show
David Nolen added a comment - Need another rebase sorry.
Hide
Travis Thieman added a comment -

Patch: 20131108

Rebased to 8d1d315.

Show
Travis Thieman added a comment - Patch: 20131108 Rebased to 8d1d315.
Hide
David Nolen added a comment -

path needs to be rebased on master thanks.

Show
David Nolen added a comment - path needs to be rebased on master thanks.
Hide
Travis Thieman added a comment -

Revised: 20131106

JS objects are now constructed in three parts. Key-value pairs with string literals are used to construct the object. Pairs with symbol keys are set directly using the implicit evaluation of the symbol. Remaining pairs have their keys let-bound to gensyms, then the pair is set on the object using the evaluation of the gensym for the key.

Show
Travis Thieman added a comment - Revised: 20131106 JS objects are now constructed in three parts. Key-value pairs with string literals are used to construct the object. Pairs with symbol keys are set directly using the implicit evaluation of the symbol. Remaining pairs have their keys let-bound to gensyms, then the pair is set on the object using the evaluation of the gensym for the key.
Hide
Travis Thieman added a comment -

Revised: 20131106

Only key-value pairs with string literals as the keys are used for the original creation of the JS object. All other pairs, including those with symbols are keys, have their keys evaluated before updating the object.

Show
Travis Thieman added a comment - Revised: 20131106 Only key-value pairs with string literals as the keys are used for the original creation of the JS object. All other pairs, including those with symbols are keys, have their keys evaluated before updating the object.
Hide
David Nolen added a comment -

I messed up the patch, we should only check for strings not symbols.

Show
David Nolen added a comment - I messed up the patch, we should only check for strings not symbols.
Hide
Travis Thieman added a comment -

Patch: 20131106

JS objects are now created in two stages. First, an object is instantiated with all key-value pairs having a string or symbol as the key. Then, all other keys are evaluated, and the evaluated key is set to the value on the new object.

Show
Travis Thieman added a comment - Patch: 20131106 JS objects are now created in two stages. First, an object is instantiated with all key-value pairs having a string or symbol as the key. Then, all other keys are evaluated, and the evaluated key is set to the value on the new object.

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: