Don’t allow mixing different types of whitespace for indentation, per line.

This commit is contained in:
Eelco Lempsink
2016-09-20 23:32:41 +02:00
parent 98068611b1
commit bb40b1188c
4 changed files with 32 additions and 37 deletions

View File

@@ -349,6 +349,10 @@ exports.Lexer = class Lexer
noNewlines = @unfinished()
newIndentLiteral = if size > 0 then indent[-size..] else ''
unless /^(.?)\1*$/.exec newIndentLiteral
@error 'mixed indentation', offset: indent.length
return indent.length
minLiteralLength = Math.min newIndentLiteral.length, @indentLiteral.length
if newIndentLiteral[...minLiteralLength] isnt @indentLiteral[...minLiteralLength]
@error 'indentation mismatch', offset: indent.length