Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion extras/coffee-script.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions lib/coffee-script/browser.js

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

1 change: 1 addition & 0 deletions lib/coffee-script/cake.js

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

12 changes: 9 additions & 3 deletions lib/coffee-script/coffee-script.js

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

1 change: 1 addition & 0 deletions lib/coffee-script/command.js

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

1 change: 1 addition & 0 deletions lib/coffee-script/grammar.js

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

1 change: 1 addition & 0 deletions lib/coffee-script/helpers.js

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

1 change: 1 addition & 0 deletions lib/coffee-script/index.js

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

1 change: 1 addition & 0 deletions lib/coffee-script/lexer.js

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

3 changes: 2 additions & 1 deletion lib/coffee-script/nodes.js

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

1 change: 1 addition & 0 deletions lib/coffee-script/optparse.js

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

1 change: 1 addition & 0 deletions lib/coffee-script/repl.js

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

1 change: 1 addition & 0 deletions lib/coffee-script/rewriter.js

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

1 change: 1 addition & 0 deletions lib/coffee-script/scope.js

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

5 changes: 4 additions & 1 deletion src/coffee-script.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ exports.eval = (code, options = {}) ->
sandbox.module = _module = new Module(options.modulename || 'eval')
sandbox.require = _require = (path) -> Module._load path, _module, true
_module.filename = sandbox.__filename
_require[r] = require[r] for r in Object.getOwnPropertyNames require when r isnt 'paths'
for r in Object.getOwnPropertyNames require when r isnt 'paths'
descriptor = Object.getOwnPropertyDescriptor require, r
continue unless descriptor.writable
_require[r] = require[r]
# use the same hack node currently uses for their own REPL
_require.paths = _module.paths = Module._nodeModulePaths process.cwd()
_require.resolve = (request) -> Module._resolveFilename request, _module
Expand Down
2 changes: 1 addition & 1 deletion src/nodes.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ exports.Block = class Block extends Base
@expressions = rest
code = @compileWithDeclarations o
return code if o.bare
"#{prelude}(function() {\n#{code}\n}).call(this);\n"
"#{prelude}(function() {\n#{TAB}'use strict';\n#{code}\n}).call(this);\n"

# Compile the expressions body for the contents of a function, with
# declarations of all inner variables pushed up to the top.
Expand Down
10 changes: 8 additions & 2 deletions test/function_invocation.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,16 @@ test "Prefix unary assignment operators are allowed in parenless calls.", ->
ok (func --val) is 5

test "#855: execution context for `func arr...` should be `null`", ->
contextTest = -> eq @, if window? then window else global
contextTest = ->
if this is undefined
eq this, undefined
else if this is null
eq this, null
else
eq this, window ? global
array = []
contextTest array
contextTest.apply null, array
contextTest.apply undefined, array
contextTest array...

test "#904: Destructuring function arguments with same-named variables in scope", ->
Expand Down