disallow inline chained call after func glyph (#4590)
This commit is contained in:
parent
b1d2061cbc
commit
58c608620e
|
@ -441,7 +441,7 @@
|
||||||
return this.tokens.splice((this.tag(i - 1) === ',' ? i - 1 : i), 0, outdent);
|
return this.tokens.splice((this.tag(i - 1) === ',' ? i - 1 : i), 0, outdent);
|
||||||
};
|
};
|
||||||
return this.scanTokens(function(token, i, tokens) {
|
return this.scanTokens(function(token, i, tokens) {
|
||||||
var j, k, ref, ref1, ref2, tag;
|
var j, k, ref, ref1, tag;
|
||||||
[tag] = token;
|
[tag] = token;
|
||||||
if (tag === 'TERMINATOR') {
|
if (tag === 'TERMINATOR') {
|
||||||
if (this.tag(i + 1) === 'ELSE' && this.tag(i - 1) !== 'OUTDENT') {
|
if (this.tag(i + 1) === 'ELSE' && this.tag(i - 1) !== 'OUTDENT') {
|
||||||
|
@ -462,7 +462,7 @@
|
||||||
return 2 + j;
|
return 2 + j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((tag === '->' || tag === '=>') && ((ref2 = this.tag(i + 1)) === ',' || ref2 === '.')) {
|
if ((tag === '->' || tag === '=>') && (this.tag(i + 1) === ',' || this.tag(i + 1) === '.' && token.newLine)) {
|
||||||
[indent, outdent] = this.indentation(tokens[i]);
|
[indent, outdent] = this.indentation(tokens[i]);
|
||||||
tokens.splice(i + 1, 0, indent, outdent);
|
tokens.splice(i + 1, 0, indent, outdent);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -434,7 +434,7 @@ exports.Rewriter = class Rewriter
|
||||||
for j in [1..2] when @tag(i + j) in ['OUTDENT', 'TERMINATOR', 'FINALLY']
|
for j in [1..2] when @tag(i + j) in ['OUTDENT', 'TERMINATOR', 'FINALLY']
|
||||||
tokens.splice i + j, 0, @indentation()...
|
tokens.splice i + j, 0, @indentation()...
|
||||||
return 2 + j
|
return 2 + j
|
||||||
if tag in ['->', '=>'] and @tag(i + 1) in [',', '.']
|
if tag in ['->', '=>'] and (@tag(i + 1) is ',' or @tag(i + 1) is '.' and token.newLine)
|
||||||
[indent, outdent] = @indentation tokens[i]
|
[indent, outdent] = @indentation tokens[i]
|
||||||
tokens.splice i + 1, 0, indent, outdent
|
tokens.splice i + 1, 0, indent, outdent
|
||||||
return 1
|
return 1
|
||||||
|
|
|
@ -1601,6 +1601,16 @@ test 'Bound method called as callback before binding throws runtime error', ->
|
||||||
ok no
|
ok no
|
||||||
d = new Derived
|
d = new Derived
|
||||||
|
|
||||||
|
test "#3845/#3446: chain after function glyph (but not inline)", ->
|
||||||
|
assertErrorFormat '''
|
||||||
|
a -> .b
|
||||||
|
''',
|
||||||
|
'''
|
||||||
|
[stdin]:1:6: error: unexpected .
|
||||||
|
a -> .b
|
||||||
|
^
|
||||||
|
'''
|
||||||
|
|
||||||
test "#3906: error for unusual indentation", ->
|
test "#3906: error for unusual indentation", ->
|
||||||
assertErrorFormat '''
|
assertErrorFormat '''
|
||||||
a
|
a
|
||||||
|
|
Loading…
Reference in New Issue