From 781ea22d57c3fdd953f89bea74558dfa5fc021fc Mon Sep 17 00:00:00 2001 From: Andreas Lubbe Date: Sat, 6 Sep 2014 17:12:25 +0200 Subject: [PATCH] always wrap 'yield' in () to allow composability with all other operators --- lib/coffee-script/nodes.js | 4 ++-- src/nodes.coffee | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/coffee-script/nodes.js b/lib/coffee-script/nodes.js index 5f115d72..c61159a1 100644 --- a/lib/coffee-script/nodes.js +++ b/lib/coffee-script/nodes.js @@ -2472,9 +2472,9 @@ parts.push(this.first.expression.compileToFragments(o, LEVEL_OP)); } } else { - parts.push([this.makeCode(op)]); - parts.push([this.makeCode(' ')]); + parts.push([this.makeCode("(" + op + " ")]); parts.push(this.first.compileToFragments(o, LEVEL_OP)); + parts.push([this.makeCode(")")]); } return this.joinFragmentArrays(parts, ''); }; diff --git a/src/nodes.coffee b/src/nodes.coffee index dc01e364..72162242 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -1760,9 +1760,9 @@ exports.Op = class Op extends Base if 'expression' in Object.keys @first parts.push @first.expression.compileToFragments o, LEVEL_OP if @first.expression? else - parts.push [@makeCode op] - parts.push [@makeCode(' ')] + parts.push [@makeCode "(#{op} "] parts.push @first.compileToFragments o, LEVEL_OP + parts.push [@makeCode ")"] @joinFragmentArrays parts, '' compilePower: (o) ->