mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
leading then
is now valid
This commit is contained in:
parent
b2be475f93
commit
426d71cb4f
4 changed files with 12 additions and 3 deletions
|
@ -228,6 +228,10 @@
|
|||
return this.scanTokens(function(token, i, tokens) {
|
||||
var _ref, _ref2, action, condition, indent, outdent, starter, tag;
|
||||
tag = token[0];
|
||||
if (tag === 'TERMINATOR' && this.tag(i + 1) === 'THEN') {
|
||||
tokens.splice(i, 1);
|
||||
return 0;
|
||||
}
|
||||
if (tag === 'ELSE' && this.tag(i - 1) !== 'OUTDENT') {
|
||||
tokens.splice.apply(tokens, [i, 0].concat(this.indentation(token)));
|
||||
return 2;
|
||||
|
|
|
@ -715,9 +715,8 @@ exports.Class = class Class extends Base
|
|||
ctor.body.unshift new Literal "this.#{pname} = function() { #{ret} }"
|
||||
if pvar
|
||||
access = if prop.context is 'this'
|
||||
pvar.properties[0]
|
||||
else
|
||||
new Accessor pvar, 'proto'
|
||||
then pvar.properties[0]
|
||||
else new Accessor pvar, 'proto'
|
||||
val = new Value variable, [access]
|
||||
prop = new Assign val, func
|
||||
props.push prop
|
||||
|
|
|
@ -194,6 +194,9 @@ class exports.Rewriter
|
|||
addImplicitIndentation: ->
|
||||
@scanTokens (token, i, tokens) ->
|
||||
[tag] = token
|
||||
if tag is 'TERMINATOR' and @tag(i + 1) is 'THEN'
|
||||
tokens.splice i, 1
|
||||
return 0
|
||||
if tag is 'ELSE' and @tag(i - 1) isnt 'OUTDENT'
|
||||
tokens.splice i, 0, @indentation(token)...
|
||||
return 2
|
||||
|
|
|
@ -131,6 +131,9 @@ result =
|
|||
|
||||
ok result is 70
|
||||
|
||||
if 'tight formatting with leading `then` is allowed'
|
||||
then ok 'yay'
|
||||
else throw 'boo'
|
||||
|
||||
# Issue #738
|
||||
func = if true then -> 1
|
||||
|
|
Loading…
Add table
Reference in a new issue