Fix integer keys in inline tables (#239)

Fixes #224
This commit is contained in:
xiehuc
2018-09-23 02:02:51 +08:00
committed by Thomas Pelletier
parent 90d6f96e9e
commit 78b76feda6
2 changed files with 12 additions and 1 deletions
+1 -1
View File
@@ -338,7 +338,7 @@ Loop:
case tokenRightCurlyBrace:
p.getToken()
break Loop
case tokenKey:
case tokenKey, tokenInteger, tokenString:
if !tokenIsComma(previous) && previous != nil {
p.raiseError(follow, "comma expected between fields in inline table")
}
+11
View File
@@ -897,3 +897,14 @@ func TestInvalidFloatParsing(t *testing.T) {
t.Error("Bad error message:", err.Error())
}
}
func TestMapKeyIsNum(t *testing.T) {
_, err := Load("table={2018=1,2019=2}")
if err != nil {
t.Error("should be passed")
}
_, err = Load(`table={"2018"=1,"2019"=2}`)
if err != nil {
t.Error("should be passed")
}
}