mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
Minor cleanup
This commit is contained in:
@@ -225,11 +225,10 @@ grammar =
|
||||
]
|
||||
|
||||
# The **Code** node is the function literal. It's defined by an indented block
|
||||
# of **Block** preceded by a function arrow, with an optional parameter
|
||||
# list.
|
||||
# of **Block** preceded by a function arrow, with an optional parameter list.
|
||||
Code: [
|
||||
o 'PARAM_START ParamList PARAM_END FuncGlyph Block', -> new Code $2, $5, $4
|
||||
o 'FuncGlyph Block', -> new Code [], $2, $1
|
||||
o 'FuncGlyph Block', -> new Code [], $2, $1
|
||||
]
|
||||
|
||||
# CoffeeScript has two different symbols for functions. `->` is for ordinary
|
||||
|
||||
@@ -1661,8 +1661,8 @@ exports.Code = class Code extends Base
|
||||
params[i] = p.compileToFragments o
|
||||
o.scope.parameter fragmentsToText params[i]
|
||||
uniqs = []
|
||||
@eachParamName (name, node) ->
|
||||
node.error "multiple parameters named #{name}" if name in uniqs
|
||||
@eachParamName (name, node) =>
|
||||
node.error "multiple parameters named '#{name}'" if name in uniqs
|
||||
uniqs.push name
|
||||
@body.makeReturn() unless wasEmpty or @noReturn
|
||||
code = 'function'
|
||||
@@ -1729,7 +1729,7 @@ exports.Param = class Param extends Base
|
||||
# The `iterator` function will be called as `iterator(name, node)` where
|
||||
# `name` is the name of the parameter and `node` is the AST node corresponding
|
||||
# to that name.
|
||||
eachName: (iterator, name = @name)->
|
||||
eachName: (iterator, name = @name) ->
|
||||
atParam = (obj) -> iterator "@#{obj.properties[0].name.value}", obj
|
||||
# * simple literals `foo`
|
||||
return iterator name.value, name if name instanceof Literal
|
||||
|
||||
@@ -642,14 +642,14 @@ test "duplicate function arguments", ->
|
||||
assertErrorFormat '''
|
||||
(foo, bar, foo) ->
|
||||
''', '''
|
||||
[stdin]:1:12: error: multiple parameters named foo
|
||||
[stdin]:1:12: error: multiple parameters named 'foo'
|
||||
(foo, bar, foo) ->
|
||||
^^^
|
||||
'''
|
||||
assertErrorFormat '''
|
||||
(@foo, bar, @foo) ->
|
||||
''', '''
|
||||
[stdin]:1:13: error: multiple parameters named @foo
|
||||
[stdin]:1:13: error: multiple parameters named '@foo'
|
||||
(@foo, bar, @foo) ->
|
||||
^^^^
|
||||
'''
|
||||
|
||||
Reference in New Issue
Block a user