Skip to content

Commit

Permalink
More accurately emulating node's REPL behaviour with regard to _
Browse files Browse the repository at this point in the history
assignment. Also addresses `i for i in [1..3]` regression introduced by
fff4c9c and noticed by @satyr
  • Loading branch information
michaelficarra committed Jul 6, 2011
1 parent 60e51a2 commit b9c3e0e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
11 changes: 6 additions & 5 deletions lib/coffee-script.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions src/coffee-script.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,11 @@ exports.eval = (code, options = {}) ->
o = {}
o[k] = v for own k, v of options
o.bare = on # ensure return value
js = compile "(#{code}\n)", o
_ = Script.runInContext js, sandbox
sandbox._ = _ if _?
_
js = compile "_=(#{code}\n)", o
_ = sandbox._
returnValue = Script.runInContext js, sandbox
sandbox._ = _ if returnValue is undefined

This comment has been minimized.

Copy link
@satyr

satyr Jul 6, 2011

Collaborator

isnt

This comment has been minimized.

Copy link
@satyr

satyr Jul 6, 2011

Collaborator

Uh wait, you're writing it back. Seems ok unless user does _ = undefined.

returnValue

# Instantiate a Lexer for our use here.
lexer = new Lexer
Expand Down

0 comments on commit b9c3e0e

Please sign in to comment.