ClojureScript

Printed JS code on REPL stack trace inconsistent with what got evaluated

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Trivial Trivial
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

This issue arose from http://dev.clojure.org/jira/browse/CLJS-397

The REPL uses a statement context to compile the code printed out as part of a stack trace. The code that runs, however, actually gets compiled in an :expr context, in a wrapper form.

Several ops (fn, constant, var) don't get emitted in a statement context. Thus a form a form like

(if (> 0.5 (Math/random))
(throw "")
:value)

gets compiled to

if (Math.random() > 0.5) { throw ""; }else{
}

according to the stack trace, while still returning :value half of the time.

Activity

Hide
Herwig Hochleitner added a comment -

Attached patch updates REPL to analyze in an expression context.

Show
Herwig Hochleitner added a comment - Attached patch updates REPL to analyze in an expression context.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: