Don't allow two equals for the same key
This commit is contained in:
@@ -192,6 +192,10 @@ func lexRvalue(l *lexer) stateFn {
|
||||
for {
|
||||
next := l.peek()
|
||||
switch next {
|
||||
case '.':
|
||||
return l.errorf("cannot start float with a dot")
|
||||
case '=':
|
||||
return l.errorf("cannot have multiple equals for the same key")
|
||||
case '[':
|
||||
l.depth += 1
|
||||
return lexLeftBracket
|
||||
@@ -234,10 +238,6 @@ func lexRvalue(l *lexer) stateFn {
|
||||
return lexNumber
|
||||
}
|
||||
|
||||
if next == '.' {
|
||||
return l.errorf("cannot start float with a dot")
|
||||
}
|
||||
|
||||
if isSpace(next) {
|
||||
l.ignore()
|
||||
}
|
||||
|
||||
@@ -284,6 +284,14 @@ func TestFloatWithTwoDots(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestDoubleEqualKey(t *testing.T) {
|
||||
testFlow(t, "foo= = 2", []token{
|
||||
token{tokenKey, "foo"},
|
||||
token{tokenEqual, "="},
|
||||
token{tokenError, "cannot have multiple equals for the same key"},
|
||||
})
|
||||
}
|
||||
|
||||
func TestKeyEqualNumber(t *testing.T) {
|
||||
testFlow(t, "foo = 42", []token{
|
||||
token{tokenKey, "foo"},
|
||||
|
||||
Reference in New Issue
Block a user