Skip to content

Commit ca275c2

Browse files
helixbassGeoffreyBooth
authored andcommitted
Fix #5128: parens around default param (#5167)
* compile params at LEVEL_PAREN * test
1 parent 63ffe0a commit ca275c2

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

lib/coffeescript/nodes.js

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

src/nodes.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2744,7 +2744,7 @@ exports.Code = class Code extends Base
27442744
# (e.g. `ref`), shift those into the parent scope since we can’t put a
27452745
# `var` line inside a function parameter list.
27462746
scopeVariablesCount = o.scope.variables.length
2747-
signature.push param.compileToFragments(o)...
2747+
signature.push param.compileToFragments(o, LEVEL_PAREN)...
27482748
if scopeVariablesCount isnt o.scope.variables.length
27492749
generatedVariables = o.scope.variables.splice scopeVariablesCount
27502750
o.scope.parent.variables.push generatedVariables...

test/functions.coffee

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,3 +493,7 @@ test "#4657: destructured array parameters", ->
493493
result = f [1, 2, 3, 4]
494494
arrayEq result.a, [1, 2, 3]
495495
eq result.b, 4
496+
497+
test "#5128: default parameters of function in binary operation", ->
498+
foo = yes or (a, b = {}) -> null
499+
eq foo, yes

0 commit comments

Comments
 (0)