Skip to content

Commit ee8f022

Browse files
committed
Merge branch 'master' of github.com:jashkenas/coffeescript into 1.12.4
# Conflicts: # Cakefile
2 parents 94023d8 + 98c1a3a commit ee8f022

File tree

14 files changed

+144
-28
lines changed

14 files changed

+144
-28
lines changed

Cakefile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,7 @@ watchAndBuildAndTest = (harmony = no) ->
100100
if eventType is 'change'
101101
log "src/#{filename} changed, rebuilding..."
102102
buildAndTest (filename is 'grammar.coffee'), harmony
103-
fs.watch 'test/',
104-
interval: 200
105-
recursive: yes
106-
, (eventType, filename) ->
103+
fs.watch 'test/', {interval: 200, recursive: yes}, (eventType, filename) ->
107104
if eventType is 'change'
108105
log "test/#{filename} changed, rebuilding..."
109106
buildAndTest no, harmony

lib/coffee-script/coffee-script.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/coffee-script/lexer.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/coffee-script/nodes.js

Lines changed: 18 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/coffee-script/scope.js

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/coffee-script.coffee

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ getSourceMap = (filename) ->
366366
answer = compile sources[filename],
367367
filename: filename
368368
sourceMap: yes
369+
literate: helpers.isLiterate filename
369370
answer.sourceMap
370371
else
371372
null

src/lexer.coffee

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -343,10 +343,10 @@ exports.Lexer = class Lexer
343343
@token 'CALL_START', '(', 0, 0
344344
@mergeInterpolationTokens tokens, {delimiter: '"', double: yes}, @formatHeregex
345345
if flags
346-
@token ',', ',', index, 0
347-
@token 'STRING', '"' + flags + '"', index, flags.length
348-
@token ')', ')', end, 0
349-
@token 'REGEX_END', ')', end, 0
346+
@token ',', ',', index - 1, 0
347+
@token 'STRING', '"' + flags + '"', index - 1, flags.length
348+
@token ')', ')', end - 1, 0
349+
@token 'REGEX_END', ')', end - 1, 0
350350

351351
end
352352

src/nodes.coffee

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,13 +633,29 @@ exports.Call = class Call extends Base
633633

634634
children: ['variable', 'args']
635635

636+
# When setting the location, we sometimes need to update the start location to
637+
# account for a newly-discovered `new` operator to the left of us. This
638+
# expands the range on the left, but not the right.
639+
updateLocationDataIfMissing: (locationData) ->
640+
if @locationData and @needsUpdatedStartLocation
641+
@locationData.first_line = locationData.first_line
642+
@locationData.first_column = locationData.first_column
643+
base = @variable?.base or @variable
644+
if base.needsUpdatedStartLocation
645+
@variable.locationData.first_line = locationData.first_line
646+
@variable.locationData.first_column = locationData.first_column
647+
base.updateLocationDataIfMissing locationData
648+
delete @needsUpdatedStartLocation
649+
super
650+
636651
# Tag this invocation as creating a new instance.
637652
newInstance: ->
638653
base = @variable?.base or @variable
639654
if base instanceof Call and not base.isNew
640655
base.newInstance()
641656
else
642657
@isNew = true
658+
@needsUpdatedStartLocation = true
643659
this
644660

645661
# Soaked chained invocations unfold into if/else ternary structures.
@@ -1352,7 +1368,7 @@ exports.ModuleSpecifier = class ModuleSpecifier extends Base
13521368
children: ['original', 'alias']
13531369

13541370
compileNode: (o) ->
1355-
o.scope.add @identifier, @moduleDeclarationType
1371+
o.scope.find @identifier, @moduleDeclarationType
13561372
code = []
13571373
code.push @makeCode @original.value
13581374
code.push @makeCode " as #{@alias.value}" if @alias?

src/scope.litcoffee

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ function object that has a name filled in, or bottoms out.
4444
Look up a variable name in lexical scope, and declare it if it does not
4545
already exist.
4646

47-
find: (name) ->
47+
find: (name, type = 'var') ->
4848
return yes if @check name
49-
@add name, 'var'
49+
@add name, type
5050
no
5151
5252
Reserve a variable name as originating from a function parameter for this
@@ -116,4 +116,3 @@ of this scope.
116116

117117
assignedVariables: ->
118118
"#{v.name} = #{v.type.value}" for v in @variables when v.type.assigned
119-

test/error_messages.coffee

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,21 @@ if require?
7171

7272
test "#2849: compilation error in a require()d file", ->
7373
# Create a temporary file to require().
74-
ok not fs.existsSync 'test/syntax-error.coffee'
75-
fs.writeFileSync 'test/syntax-error.coffee', 'foo in bar or in baz'
74+
tempFile = path.join os.tmpdir(), 'syntax-error.coffee'
75+
ok not fs.existsSync tempFile
76+
fs.writeFileSync tempFile, 'foo in bar or in baz'
7677

7778
try
78-
assertErrorFormat '''
79-
require './test/syntax-error'
80-
''',
79+
assertErrorFormat """
80+
require '#{tempFile}'
81+
""",
8182
"""
82-
#{path.join __dirname, 'syntax-error.coffee'}:1:15: error: unexpected in
83+
#{fs.realpathSync tempFile}:1:15: error: unexpected in
8384
foo in bar or in baz
8485
^^
8586
"""
8687
finally
87-
fs.unlinkSync 'test/syntax-error.coffee'
88+
fs.unlinkSync tempFile
8889

8990
test "#3890 Error.prepareStackTrace doesn't throw an error if a compiled file is deleted", ->
9091
# Adapted from https://github.com/atom/coffee-cash/blob/master/spec/coffee-cash-spec.coffee

0 commit comments

Comments
 (0)